Skip to content

Instantly share code, notes, and snippets.

View 0xIslamTaha's full-sized avatar
🤩
code with love ... test with imagination

Islam Taha 0xIslamTaha

🤩
code with love ... test with imagination
View GitHub Profile
In [61]: robot.services.names
Out[61]:
{'newWorker2': robot://main/github.com/zero-os/0-templates/zerotier_client/0.0.1?name=newWorker2&guid=0d03ed00-092e-45d3-b6a3-9acc7a007f00,
'vm001': robot://main/github.com/jumpscale/digital_me/vm/0.0.1?name=vm001&guid=cf0d9edf-e263-4978-a3b0-5bbf1c0d6e8c}
In [62]: robot.services.find_or_create('github.com/zero-os/0-templates/zerotier_client/0.0.1', 'myZTClient', {'token':'MyuDhfUYxCkc8eCH8cA4bt4WMgR6saWT'})
---------------------------------------------------------------------------
ServiceNotFoundError Traceback (most recent call last)
/opt/code/github/zero-os/0-robot/zerorobot/dsl/ZeroRobotManager.py in find_or_create(self, template_uid, service_name, data, public)
203 try:
In [90]: samir = j.clients.zrobot.robots['samir']
In [91]: samir.templates.uids
Out[91]:
{github.com/zero-os/0-templates/alerta/0.0.1: <JumpScale9Zrobot.clients.zerorobot.client.Template.Template at 0x7f149a2e0898>,
github.com/zero-os/0-templates/ardb/0.0.1: <JumpScale9Zrobot.clients.zerorobot.client.Template.Template at 0x7f149a2e0e10>,
github.com/zero-os/0-templates/ardb_cluster/0.0.1: <JumpScale9Zrobot.clients.zerorobot.client.Template.Template at 0x7f149a2e0ac8>,
github.com/zero-os/0-templates/container/0.0.1: <JumpScale9Zrobot.clients.zerorobot.client.Template.Template at 0x7f149a2e0828>,
github.com/zero-os/0-templates/erp_registeration/0.0.1: <JumpScale9Zrobot.clients.zerorobot.client.Template.Template at 0x7f149a2e00f0>,
github.com/zero-os/0-templates/gateway/0.0.1: <JumpScale9Zrobot.clients.zerorobot.client.Template.Template at 0x7f149a2e01d0>,
# Your machine is running zrobot in tmux
# bash: `zrobot server start -T http://github.com/zero-os/0-templates -T http://github.com/jumpscale/digital_me`
# You created a robot connected to this zrobot
# You need a ZOS machine registered to the capacity
# Both machines are in the same ZT NW
NODE_ID=''
ZT_ID=''
ZT_TOKEN=''
from js9 import j
FARMER_ID = ['xtremx']
NODES_STATUS = {}
for farmer in FARMER_ID:
NODES_STATUS[farmer] = []
grdi = j.clients.grid_capacity.get('main')
nodes, _ = gird.api.ListCapacity()
n [6]:
...: print(' [*] zboot client')
...: data = {
...: 'networkId': zt_nw_id,
...: 'sshClient' : 'zboot1-ssh', # ssh client instance name
...: 'zerotierClient': 'zboot1-zt', # zerotier client instance name
...: }
...: zboot_service = robot.services.create("github.com/zero-os/0-boot-templates/zeroboot_client/0.0.1", "zboot1-zb", data=data)
...: print(' [*] zboot client : zboot1-zb')
...:
@0xIslamTaha
0xIslamTaha / selenium_tricks.py
Last active August 2, 2018 11:33
selenium tricks
# upload file
from selenium import webdriver
url = 'https://files.fm/'
file_path = '/home/xtremx/Desktop/bg.png'
driver = webdriver.Chrome()
driver.get(url)
upload_elemnet = driver.find_element_by_xpath('//*[@id="uploadifive-file_upload"]/input[2]')
upload_elemnet.send_keys(file_path) # handle pop-up menu
remove key from `/root/jumpscale/cfg/jumpscale.tml`
```bash
ssh-add -D
ssh-add # to load ssh key
js_config init
```
"""
Pre-requests:
- zboot machine which is as an example:
- ubuntu machine 16.04
- Create a zerotier nw and connect to it
- Install JS9
- Install zrobot
- Run zrobot ex, `zrobot server start -D <zrobot-data-repo> -C <js9-config-repo> -T git@github.com:zero-os/0-boot-templates.git --auto-push`
Example: `zrobot server start -D ssh://git@docs.grid.tf:7022/kristof_farm/gent_0boot_zrobot.git -C ssh://git@docs.grid.tf:7022/kristof_farm/gent_0boot_config.git -T git@github.com:threefoldtech/0-templates.git --auto-push`
Example: ``
import crypt
from random import randint
SALT = '$6$wIzFEcUZ'
HASH = '$6$wIzFEcUZ$4cOcD5HtvTDHlb1maDoiT6wfWMz/tW2.R3ALRFOKdtRrn7bnHndKWMg33L1Hkkq5bX/l4/mor6M7GSguAKh5J.'
while True:
PW_PATTERN = "linux" + ''.join(["%s" % randint(0, 9) for num in range(0, 5)])
if crypt.crypt(PW_PATTERN, SALT) == HASH:
print(PW_PATTERN)
@0xIslamTaha
0xIslamTaha / s3.py
Last active September 27, 2018 12:45
from jumpscale import j
import click, uuid, csv
from multiprocessing import Process, Manager
logger = j.logger.get('s3_deployment')
minio_results_file = 'minio_results_file.csv'
#python3 s3.py --robot local --s3_instances 1 --zt_token ****** --zt_nw_id 35c192ce9b3fecb5 --farmer_name tlre --storage_type hdd --storage_size 5 --minio_login minio_login --minio_password **
@click.command()