示例#1
0
def g5k(env=None, broker=BROKER, force=False, **kwargs):
    with open("confs/g5k-%s.yaml" % broker) as f:
        g5k_config = yaml.load(f)
        provider = G5k(g5k_config)
        roles, networks = provider.init(force_deploy=force)
        env["roles"] = roles
        env["networks"] = networks
示例#2
0
def g5k(config, force, env=None, **kwargs):
    conf = G5kConf.from_dictionnary(config["g5k"])
    provider = G5k(conf)
    roles, networks = provider.init(force_deploy=force)
    env["config"] = config
    env["roles"] = roles
    env["networks"] = networks
    env["context"] = "g5k"
示例#3
0
def g5k_deploy(g5k_config, env=None, force_deploy=False, **kwargs):
    provider = G5k(g5k_config)
    roles, networks = provider.init(force_deploy=force_deploy)
    env['roles'] = roles
    env['networks'] = networks
    logging.info('Wait 30 seconds for iface to be ready...')
    time.sleep(30)
    return env
示例#4
0
文件: juice.py 项目: chardetm/juice
def g5k(env=None, force=False, config=None, **kwargs):
    "Claim resources on Grid'5000 (from a frontend)"

    provider = G5k(config["g5k"])
    roles, networks = provider.init(force_deploy=force)
    env["config"] = config
    env["roles"] = roles
    env["networks"] = networks
    env["tasks_ran"] = ['g5k']
    env["latency"] = "0ms"
    env["db"] = config.get('database', 'cockroachdb')
示例#5
0
def g5k(env=None, force=False, config=None, **kwargs):
    """
usage: juice g5k

Claim resources on Grid'5000 (from a frontend)
    """
    provider = G5k(config["g5k"])
    roles, networks = provider.init(force_deploy=force)
    env["config"] = config
    env["roles"] = roles
    env["networks"] = networks
    env["tasks_ran"] = ['g5k']
    env["latency"] = "0ms"
示例#6
0
def main(test):
    # Claim the resources
    infra = G5k(make_conf(testing=test))
    roles, networks = infra.init(force_deploy=False)

    # Provision machines
    provision(roles)

    # Display subnet
    subnet = [
        n for n in networks if "neutron_external_interface" in n["roles"]
    ]
    print(subnet)

    # Assign machines
    print("Lab machine assignations:")
    addrs = map(get_ip_addr, roles["OpenStack"])
    for (usr, addr) in zip_longest(TEAMS, addrs):
        print(f"- {addr} ({usr}): ")
            "role": "my_network",
            "site": "rennes",
        }, {
            "id": "not_linked_to_any_machine",
            "type": "slash_22",
            "role": "my_subnet",
            "site": "rennes",
        }]
    }
}

# path to the inventory
inventory = os.path.join(os.getcwd(), "hosts")

# claim the resources
provider = G5k(provider_conf)
roles, networks = provider.init()

# generate an inventory compatible with ansible
generate_inventory(roles, networks, inventory, check_networks=True)

subnet = [n for n in networks if "my_subnet" in n["roles"]][0]
mac_start = subnet["mac_start"]
mac_end = subnet["mac_end"]

vms = []

# Distribute mac addresses to vms
for idx, (mac, ip) in enumerate(range_mac(mac_start, mac_end)):
    if len(vms) >= VMS:
        break
SEED = 5
NB_QUERY = 1500
FAIRNESS = 0.2
EXPORT_TRACES_FILE = Path(f'../../results/result_fairness_1b_s{SEED}.json')

boxes = Boxes(depth=3, arity=2, kind=BoxesType.WORST)
boxes.print()
longestTimeOfLongest = boxes.getMaxTime()
logging.debug(f"Longest possible task takes {longestTimeOfLongest}ms.")

seed(SEED)



provider = G5k(conf)
roles, networks = provider.init()
roles = discover_networks(roles, networks)



priors = [__python3__, __default_python3__, __docker__]
with play_on(pattern_hosts='all', roles=roles, priors=priors) as p:
    p.pip(display_name='Installing python-docker…', name='docker')

## #A deploy jaeger, for now, we set up with all in one
with play_on(pattern_hosts='collector', roles=roles) as p:
    p.docker_container(
        display_name=f'Installing jaeger…',
        name='jaeger',
        image='jaegertracing/all-in-one:1.17',
示例#9
0
    nodes = get_nodes(roles)
    cmd   = lambda cmd: api.exec_command_on_nodes(nodes, cmd, cmd)

    # Install the bare necessities
    packages = [ 'silversearcher-ag', 'curl', 'htop', 'python', 'tcpdump', 'vim']
    cmd('apt update')
    cmd("apt install -y --force-yes %s" % ' '.join(packages))

    # Setup ssh for root w/ password
    cmd('echo "root:os-imt" | chpasswd')
    cmd('echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config')
    cmd('echo "PermitRootLogin yes"        >> /etc/ssh/sshd_config')
    cmd('systemctl restart ssh')

    # Put /snap/bin in PATH
    cmd('echo "export PATH=/snap/bin:${PATH}" >> /root/.bashrc')

    # Disable ip forwarding (for pedagogical purpose)
    cmd('sudo sysctl -w net.ipv4.ip_forward=0')

    return nodes

# Claim the resources and do the scaffolding
roles, networks = G5k(make_conf(testing=False)).init(force_deploy=False)
nodes = bootstrap(roles)
addrs = map(socket.gethostbyname, nodes)

print("Lab machine assignations:")
for (team, addr) in zip(TEAMS, addrs):
    print("- %s :: ~%s~" % (', '.join(p for p in team), addr))
示例#10
0
def g5k(env=None, broker=BROKER, force=False, config=None, **kwargs):
    provider = G5k(config["g5k"])
    roles, networks = provider.init(force_deploy=force)
    env["config"] = config
    env["roles"] = roles
    env["networks"] = networks
示例#11
0
        ])

        # Setup ssh for root w/ password
        p.raw('echo "root:os-imt" | chpasswd')
        p.blockinfile(path='/etc/ssh/sshd_config',
                      block='''
                      PasswordAuthentication yes
                      PermitRootLogin yes
                      ''')
        p.systemd(name='ssh', state='restarted')

        # Put /snap/bin in PATH
        p.lineinfile(path='/root/.bashrc',
                     line='export PATH=/snap/bin:${PATH}')


# Claim the resources
infra = G5k(make_conf(testing=True))
roles, networks = infra.init(force_deploy=False)

# Do the scaffolding and assign machines
bootstrap(roles)
addrs = map(get_addr, roles["OpenStack"])

print("Lab machine assignations:")
for (team, addr) in zip(TEAMS, addrs):
    team_members_str = ', '.join(m for m in team)
    print(f"- {team_members_str} :: ~{addr}~")

# infra.destroy()  # Destroy
示例#12
0
def g5k(config, **kwargs):
    return G5k(config["g5k"])