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
from jumpscale import j
from termcolor import colored
from random import randint
import click, uuid
# Templates
zerotier_template = "github.com/threefoldtech/0-templates/zerotier_client/0.0.1"
dm_vm_template = "github.com/threefoldtech/0-templates/dm_vm/0.0.1"
#python3 dm.py -r local -t ******* -i 35c192ce9ba98299 -n ac1f6b456b98 -im ubuntu -dt hdd -ds 5 -m 2048 -c 1 -s "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCjPfKUsaFuaGJsnHvF3k0PbqQTr3GL2pNuddn/xQjsroF35ELJVEovAsd9IlsFWOmDWlL6B+JYFgj8g5IykklHCDfmTu6LcGXjdfAYVp+eXARmgoCJKxVyenSVHu6No9O1e+QKFvMJTiJXdl08fZD1Fd2kRetDRKAijCZ76pmB4/KwVFiJKCVVdsDW/0R+td0gNVJyCQyRTcWEPmBfGMW/JrvRCSHfxlLdqsD3txLOm9pHlQ/LmEwOP3bqEEpQU1jP32JbdAdreuD6BYB+YRp02yyU33gd1QbqIEgftcN+6TuZJOU3j2VRSiUQX8h5SjtWV1UXE15ELlIlhcFJYH6L root@islamtaha-TT"
import requests, time, random
mykey = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCjPfKUsaFuaGJsnHvF3k0PbqQTr3GL2pNuddn/xQjsroF35ELJVEovAsd9IlsFWOmDWlL6B+JYFgj8g5IykklHCDfmTu6LcGXjdfAYVp+eXARmgoCJKxVyenSVHu6No9O1e+QKFvMJTiJXdl08fZD1Fd2kRetDRKAijCZ76pmB4/KwVFiJKCVVdsDW/0R+td0gNVJyCQyRTcWEPmBfGMW/JrvRCSHfxlLdqsD3txLOm9pHlQ/LmEwOP3bqEEpQU1jP32JbdAdreuD6BYB+YRp02yyU33gd1QbqIEgftcN+6TuZJOU3j2VRSiUQX8h5SjtWV1UXE15ELlIlhcFJYH6L root@islamtaha-TT'
client_id = ''
client_secret = ''
packet_auth_token = ''
zt_token = ''
#ipxe = 'http://unsecure.bootstrap.gig.tech/ipxe/v1.2.2/9f77fc393e097c6e/console=ttyS1,115200%20development'
# ipxe_url = 'ipxe: http://unsecure.bootstrap.gig.tech/ipxe/v1.2.2/{}/console=ttyS1,115200%20development'
import math
import time
import requests
import gevent
import netaddr
from jumpscale import j
from zerorobot.service_collection import ServiceNotFoundError
from zerorobot.template.base import TemplateBase
In [13]: j.builder.web.caddy.build(reset=True)
Sun07 17:13 uilderBaseClass.py - 185 - buildercaddy:buildercaddy : build profile path in:/tmp/builders/caddy/env.sh
Sun07 17:13 uilderBaseClass.py - 185 - buildergolang:buildergolang : build profile path in:/tmp/builders/go/env.sh
Sun07 17:13 uilderBaseClass.py - 220 - buildergolang:buildergolang : sandbox profile path in:/sandbox/env.sh
Sun07 17:13 BuilderTools.py - 176 - j.builder.tools:buildertools : curl -L 'https://dl.google.com/go/go1.12.linux-amd64.tar.gz' -o '/tmp/jumpscale/go1.12.linux-amd64.tar.gz' --connect-timeout 30 --retry 3 --retry-max-time 0
Sun07 17:13 BuilderTools.py - 692 - j.builder.tools:buildertools : curl -L 'https://dl.google.com/go/go1.12.linux-amd64.tar.gz' -o '/tmp/jumpscale/go1.12.linux-amd64.tar.gz' --connect-timeout 30 --retry 3 --retry-m
# python3 check_nodes_version.py -f 'kristof-farm' -c 'cb52b076df76c4da6be41999f65f87a047437f30'
from jumpscale import j
logger = j.logger.get('check_node_commit')
import click
@click.command()
@click.option("-f", "--farm_name", help="farm name to update its zrobot", required=True)
@click.option("-c", "--commit_id", help="match with this commit id", default='')
import collections
from subprocess import Popen, PIPE
def execute_cmd(cmd):
sub = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
out, err = sub.communicate()
return out, err
out, err = execute_cmd('ip n')
ip_n_data = str(out)
from jumpscale import j
import click
@click.command()
@click.option("-f", "--farm_name", help="farm name to update its zrobot", required=True)
def main(farm_name):
capacity = j.clients.threefold_directory.get(interactive=False)
resp = capacity.api.ListCapacity(query_params={'farmer': farm_name})[1]
nodes = resp.json() #nodes
for node in nodes:

0-db level:

data 0-db temporary unavailable

    def test001_upload_stop_parity_zdb_download(self):
        """
        - upload 2M, should succeed.
        - Download file, should succeed
        - Deleted the downloaded file
        - assert md5 checksum is matching
        - Stop n zdb, n <= parity
```python
JSX> tft_client = j.clients.tfchain.new(name='tft_client', network_type='TEST')
Mon 24 10:45:50 BCDB.py - 465 - bcdb:bcdb : load model:jumpscale.tfchain.client
JSX> wallet = tft_client.wallets.new('wallet001', seed='slam table target hand drift aim brief fit dizzy flash engine attend oil steel manage oblige mercy duck razor steak crash essay coin stone')
Mon 24 10:45:56 BCDB.py - 465 - bcdb:bcdb : load model:jumpscale.tfchain.wallet
JSX> wallet.balance
wallet balance on height 304409 at 2019/06/24 10:45:24
3457.95 TFT available and 0 TFT locked
JSX> wallet.capacity.reserve_zos_vm(email="tft.testing.
```python
s3 = demo.s3['s3_demo_5']
tlog = s3.service.data['data']['tlog']
robot = j.clients.zrobot.robots[tlog['node']]
robot._try_god_token()
ns = robot.services.get(name=tlog['name'])
print(ns.name)
zdb = robot.services.get(name=ns.data['data']['zerodb'])