Example #1
0
def startDocker(G, net):
    bar = IncrementalBar('Starting Containers', max=numberOfNodes)
    for node in G.nodes():
        time.sleep(1)
        rew.rewriteConfig(net.get(node).name)
        set.restartExited()
        rew.agent_param(net.get(node).name)
        rew.herd_param(net.get(node).name)
        subprocess.call(
            ['docker cp ./tmp/. mn.%s:etc/kraken/.' % net.get(node).name],
            shell=True)
        if net.get(node).name in set.seeder:
            net.get(node).cmdPrint(
                'docker run --restart=unless-stopped --name registry -d -p 5001:5000 172.17.0.1:5000/registry'
            )
        if net.get(node).name in set.servers:
            net.get(node).cmdPrint(
                'source /etc/kraken/agent_param.sh && export AGENT_REGISTRY_PORT AGENT_PEER_PORT AGENT_SERVER_PORT && export IP=%s && docker-compose -f stack_server.yml up -d'
                % net.get(node).IP())
        else:
            net.get(node).cmdPrint(
                'source /etc/kraken/agent_param.sh && export AGENT_REGISTRY_PORT AGENT_PEER_PORT AGENT_SERVER_PORT && export IP=%s && docker-compose -f stack_client.yml up -d'
                % net.get(node).IP())
        bar.next()
    bar.finish()
Example #2
0
def startDocker(G, net):
    bar = IncrementalBar('Starting Containers', max=numberOfNodes)
    for node in G.nodes():
        set.restartExited()
        subprocess.call([
            'docker cp dfget.yml mn.%s:etc/dragonfly/dfget.yml' %
            net.get(node).name
        ],
                        shell=True)
        #if not net.get(node).name in set.seeder:
        set.dfdaemon(str(net.get(node).IP()))
        subprocess.call([
            'docker cp dfdaemon.yml mn.%s:etc/dragonfly/dfdaemon.yml' %
            net.get(node).name
        ],
                        shell=True)
        if net.get(node).name in set.servers:
            set.supernode(str(net.get(node).IP()))
            subprocess.call([
                'docker cp supernode.yml mn.%s:etc/dragonfly/supernode.yml' %
                net.get(node).name
            ],
                            shell=True)
            net.get(node).cmdPrint(
                'export IP=%s && docker-compose -f stack_server.yml up -d' %
                net.get(node).IP())
            #net.get(node).cmdPrint('docker run -d --network host --privileged --name supernode --restart=unless-stopped -p 8001:8001 -p 8002:8002 -v /home/admin/supernode:/home/admin/supernode 172.17.0.1:5000/supernode --download-port=8001')
        else:
            net.get(node).cmdPrint(
                'export IP=%s && docker-compose -f stack_client.yml up -d' %
                net.get(node).IP())
            #net.get(node).cmdPrint('docker run -d --network host --privileged --name dfclient --restart=always -p 65001:65001 -v /etc/dragonfly:/etc/dragonfly -v $HOME/.small-dragonfly:/root/.small-dragonfly 172.17.0.1:5000/dfclient --registry https://index.docker.io')
        #net.get(node).cmdPrint('docker run -d --network host --privileged --name dfclient --restart=unless-stopped -p 65001:65001 -v /etc/dragonfly:/etc/dragonfly -v $HOME/.small-dragonfly:/root/.small-dragonfly 172.17.0.1:5000/dfclient --registry https://index.docker.io') # --registry https://index.docker.io --bind ' + c.IP())
        bar.next()
    bar.finish()
Example #3
0
def startDocker(G, net):
    bar = IncrementalBar('Starting Containers', max=numberOfNodes)
    for node in G.nodes():
        set.restartExited()
        if net.get(node).name in set.servers:
            net.get(node).cmdPrint(
                "sh -c 'export IP=%s && docker-compose -f stack_server.yml up -d'"
                % net.get(node).IP())
        else:
            net.get(node).cmdPrint(
                "sh -c 'export IP=%s && docker-compose -f stack_client.yml up -d'"
                % net.get(node).IP())
        net.get(node).cmdPrint(
            'transmission-daemon --log-debug --logfile /var/log/transmission/transmission.log --download-dir /downloads/'
        )
        bar.next()
    bar.finish()
Example #4
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
# test.py

from progress.bar import Bar, IncrementalBar
from progress.spinner import Spinner
import time
import settings as set

spinner = Spinner('Restarting stopped hosts ')
while True:
    time.sleep(5)
    set.restartExited()
    spinner.next()
Example #5
0
def graph2Network(G, net):

    nextip = 738197504  #44.0.0.0

    for (u, v, c) in G.edges.data():

        left_ip = nextip
        nextip += 1
        right_ip = nextip
        nextip += 1

        left_ip_isset = False
        right_ip_isset = False

        set.restartExited()
        time.sleep(1)
        if u not in net:
            try:
                net.addDocker(u,
                              ip='%s/31' %
                              socket.inet_ntoa(struct.pack('!I', left_ip)),
                              dimage="transmission_dind",
                              dcmd="dockerd-entrypoint.sh",
                              prefixLen=31)
            except:
                subprocess.call(['docker rm mn.%s' % u], shell=True)
                net.addDocker(u,
                              ip='%s/31' %
                              socket.inet_ntoa(struct.pack('!I', left_ip)),
                              dimage="transmission_dind",
                              dcmd="dockerd-entrypoint.sh",
                              prefixLen=31)

            left_ip_isset = True

            h = net.get(u)
            h.cmd("sysctl -w net.ipv6.conf.all.disable_ipv6=0")
            h.cmd("sysctl -w net.ipv6.conf.default.disable_ipv6=0")
            h.cmd("sysctl -w net.ipv6.conf.lo.disable_ipv6=0")
        if v not in net:
            try:
                net.addDocker(v,
                              ip='%s/31' %
                              socket.inet_ntoa(struct.pack('!I', right_ip)),
                              dimage="transmission_dind",
                              dcmd="dockerd-entrypoint.sh",
                              prefixLen=31)
            except:
                subprocess.call(['docker rm mn.%s' % v], shell=True)
                net.addDocker(v,
                              ip='%s/31' %
                              socket.inet_ntoa(struct.pack('!I', right_ip)),
                              dimage="transmission_dind",
                              dcmd="dockerd-entrypoint.sh",
                              prefixLen=31)

            right_ip_isset = True

            h = net.get(v)
            h.cmd("sysctl -w net.ipv6.conf.all.disable_ipv6=0")
            h.cmd("sysctl -w net.ipv6.conf.default.disable_ipv6=0")
            h.cmd("sysctl -w net.ipv6.conf.lo.disable_ipv6=0")

        if1 = (u + '-' + v)[-15:]
        if2 = (v + '-' + u)[-15:]

        net.addLink(net.get(u), net.get(v), intfName1=if1, intfName2=if2)

        if not left_ip_isset:
            print("set on host %s interface %s" % (u, if1))
            net.get(u).setIP(socket.inet_ntoa(struct.pack('!I', left_ip)),
                             prefixLen=31,
                             intf=if1)
        if not right_ip_isset:
            print("set on host %s interface %s" % (v, if2))
            net.get(v).setIP(socket.inet_ntoa(struct.pack('!I', right_ip)),
                             prefixLen=31,
                             intf=if2)
    return
Example #6
0
def graph2Network(G, net):

    nextip = 738197504  #44.0.0.0

    for (u, v, c) in G.edges.data():
        set.restartExited()

        left_ip = nextip
        nextip += 1
        right_ip = nextip
        nextip += 1

        left_ip_isset = False
        right_ip_isset = False

        if u not in net:
            net.addDocker(u,
                          ip='%s/31' %
                          socket.inet_ntoa(struct.pack('!I', left_ip)),
                          dimage="kraken_dind",
                          dcmd="dockerd-entrypoint.sh",
                          prefixLen=31)
            left_ip_isset = True

            h = net.get(u)
            h.cmd("sysctl -w net.ipv6.conf.all.disable_ipv6=0")
            h.cmd("sysctl -w net.ipv6.conf.default.disable_ipv6=0")
            h.cmd("sysctl -w net.ipv6.conf.lo.disable_ipv6=0")
        if v not in net:
            net.addDocker(v,
                          ip='%s/31' %
                          socket.inet_ntoa(struct.pack('!I', right_ip)),
                          dimage="kraken_dind",
                          dcmd="dockerd-entrypoint.sh",
                          prefixLen=31)
            right_ip_isset = True

            h = net.get(v)
            h.cmd("sysctl -w net.ipv6.conf.all.disable_ipv6=0")
            h.cmd("sysctl -w net.ipv6.conf.default.disable_ipv6=0")
            h.cmd("sysctl -w net.ipv6.conf.lo.disable_ipv6=0")

        if1 = (u + '-' + v)[-15:]
        if2 = (v + '-' + u)[-15:]

        try:
            net.addLink(net.get(u), net.get(v), intfName1=if1, intfName2=if2)
        except:
            print("Unexpected error:", sys.exc_info()[0], u, v, c)

        if not left_ip_isset:
            print("set on host %s interface %s" % (u, if1))
            net.get(u).setIP(socket.inet_ntoa(struct.pack('!I', left_ip)),
                             prefixLen=31,
                             intf=if1)
        if not right_ip_isset:
            print("set on host %s interface %s" % (v, if2))
            net.get(v).setIP(socket.inet_ntoa(struct.pack('!I', right_ip)),
                             prefixLen=31,
                             intf=if2)
        time.sleep(1)