Mentions légales du service

Skip to content
Snippets Groups Projects
Commit b6a08527 authored by SIMONIN Matthieu's avatar SIMONIN Matthieu
Browse files

Merge branch 'distem' into 'distem'

pnodes init avec api

See merge request discovery/enoslib!24
parents 622986dc 7a9bd504
Branches distem
No related tags found
No related merge requests found
...@@ -10,7 +10,7 @@ import os ...@@ -10,7 +10,7 @@ import os
import distem as d import distem as d
from netaddr import EUI, mac_unix_expanded from netaddr import EUI, mac_unix_expanded
from enoslib.api import run_ansible, play_on from enoslib.api import run_ansible, play_on, run_command
from enoslib.host import Host from enoslib.host import Host
import enoslib.infra.enos_g5k.configuration as g5kconf import enoslib.infra.enos_g5k.configuration as g5kconf
import enoslib.infra.enos_g5k.provider as g5kprovider import enoslib.infra.enos_g5k.provider as g5kprovider
...@@ -51,11 +51,12 @@ def start_containers(g5k_roles, provider_conf, g5k_subnets): ...@@ -51,11 +51,12 @@ def start_containers(g5k_roles, provider_conf, g5k_subnets):
# Voir pour l'emplacement de l'image # Voir pour l'emplacement de l'image
# Voir pour les clefs - Créer de nouvelles ? # Voir pour les clefs - Créer de nouvelles ?
# Voir pour la valeur de retour de start_containers # Voir pour la valeur de retour de start_containers
# Non utilisation de _distribute (voir pour répartir tous les vnodes # Non utilisation de _distribute
coordinator = distem_bootstrap(g5k_roles) distem = d.Distem()
coordinator = distem_bootstrap(g5k_roles, distem)
# For now we only consider a single subnet # For now we only consider a single subnet
distem_roles = _start_containers(coordinator, provider_conf, g5k_subnets[0]) distem_roles = _start_containers(coordinator, provider_conf, g5k_subnets[0], distem)
return distem_roles, g5k_subnets return distem_roles, g5k_subnets
...@@ -118,12 +119,10 @@ def _build_g5k_conf(distemong5k_conf): ...@@ -118,12 +119,10 @@ def _build_g5k_conf(distemong5k_conf):
return _do_build_g5k_conf(distemong5k_conf, site) return _do_build_g5k_conf(distemong5k_conf, site)
def _start_containers(coordinator, provider_conf, g5k_subnet): def _start_containers(coordinator, provider_conf, g5k_subnet, distem):
roles = defaultdict(list) roles = defaultdict(list)
distem = d.Distem() # distem = d.Distem(serveraddr=coordinator)
import ipdb; ipdb.set_trace() FSIMG = "file:///home/rolivo/public/distem-fs-jessie.tar.gz"
# distem = d.Distem(serveraddr=coordinator.address)
FSIMG = "file:///home/msimonin/public/distem-fs-jessie.tar.gz"
PRIV_KEY = os.path.join(os.environ["HOME"], ".ssh", "id_rsa") PRIV_KEY = os.path.join(os.environ["HOME"], ".ssh", "id_rsa")
PUB_KEY = "%s.pub" % PRIV_KEY PUB_KEY = "%s.pub" % PRIV_KEY
...@@ -139,7 +138,8 @@ def _start_containers(coordinator, provider_conf, g5k_subnet): ...@@ -139,7 +138,8 @@ def _start_containers(coordinator, provider_conf, g5k_subnet):
# Currently we need to jump through the coordinator # Currently we need to jump through the coordinator
# NOTE(msimonin): is there a way in distem to make the vnode reachable from # NOTE(msimonin): is there a way in distem to make the vnode reachable from
# outside directly ? extra = {} # outside directly ? extra = {}
extra.update(gateway=coordinator.address) extra = {}
extra.update(gateway=coordinator)
extra.update(gateway_user="root") extra.update(gateway_user="root")
distem.vnetwork_create(SUBNET_NAME, g5k_subnet["cidr"]) distem.vnetwork_create(SUBNET_NAME, g5k_subnet["cidr"])
...@@ -170,20 +170,23 @@ def _start_containers(coordinator, provider_conf, g5k_subnet): ...@@ -170,20 +170,23 @@ def _start_containers(coordinator, provider_conf, g5k_subnet):
return dict(roles) return dict(roles)
def _get_controller(roles): def _get_all_hosts(roles):
all_hosts = [] all_hosts = set([])
for _, machines in roles.items(): for _, machines in roles.items():
for machine in machines: for machine in machines:
all_hosts.append(machine) all_hosts.add(machine.address)
return(sorted(all_hosts, key=lambda n: n.address)[0]) return(sorted(all_hosts, key=lambda n: n))
def distem_bootstrap(roles): def distem_bootstrap(roles, distem):
_user = g5k_api_utils.get_api_username() _user = g5k_api_utils.get_api_username()
# TODO: generate keys on the fly # TODO: generate keys on the fly
keys_path = os.path.join(PROVIDER_PATH, "keys") keys_path = os.path.join(PROVIDER_PATH, "keys")
private = os.path.join(keys_path, "id_rsa") private = os.path.join(keys_path, "id_rsa")
public = os.path.join(keys_path, "id_rsa.pub") public = os.path.join(keys_path, "id_rsa.pub")
coordinator = _get_all_hosts(roles)[0]
with play_on(roles=roles) as p: with play_on(roles=roles) as p:
p.copy(dest="/root/.ssh/id_rsa", src=private) p.copy(dest="/root/.ssh/id_rsa", src=private)
p.copy(dest="/root/.ssh/id_rsa.pub", src=public) p.copy(dest="/root/.ssh/id_rsa.pub", src=public)
...@@ -197,18 +200,18 @@ def distem_bootstrap(roles): ...@@ -197,18 +200,18 @@ def distem_bootstrap(roles):
state="present", state="present",
allow_unauthenticated="yes", allow_unauthenticated="yes",
force="yes", force="yes",
force_apt_get="yes" ) force_apt_get="yes")
# see below # see below
p.apt(name="tmux", state="present") p.apt(name="tmux", state="present")
coordinator = _get_controller(roles)
# kill coordinator on any nodes # kill coordinator on any nodes
with play_on(roles=roles) as p: with play_on(roles=roles) as p:
p.shell("kill -9 `ps aux|grep \"distemd\"|grep -v grep|sed \"s/ \{1,\}/ /g\"|cut -f 2 -d\" \"` || true") p.shell("kill -9 `ps aux|grep \"distemd\"|grep -v grep|sed \"s/ \{1,\}/ /g\"|cut -f 2 -d\" \"` || true")
p.wait_for(state="stopped", port=4567) p.wait_for(state="stopped", port=4567)
p.wait_for(state="stopped", port=4568) p.wait_for(state="stopped", port=4568)
with play_on(pattern_hosts=coordinator.alias, roles=roles) as p: # Echec du run command ici
with play_on(pattern_hosts=coordinator, roles=roles) as p:
p.file(state="directory", dest=PATH_DISTEMD_LOGS) p.file(state="directory", dest=PATH_DISTEMD_LOGS)
# nohup starts distem but 4568 is unreachable (and init-pnodes returns # nohup starts distem but 4568 is unreachable (and init-pnodes returns
# nil) The only thing I found is to start distem in a tmux session... # nil) The only thing I found is to start distem in a tmux session...
...@@ -217,8 +220,9 @@ def distem_bootstrap(roles): ...@@ -217,8 +220,9 @@ def distem_bootstrap(roles):
p.shell("tmux new-session -d \"exec distemd --verbose -d\"") p.shell("tmux new-session -d \"exec distemd --verbose -d\"")
p.wait_for(state="started", port=4567, timeout=10) p.wait_for(state="started", port=4567, timeout=10)
p.wait_for(state="started", port=4568, timeout=10) p.wait_for(state="started", port=4568, timeout=10)
with play_on(roles=roles) as p:
p.shell("distem --coordinator host=%s --init-pnode {{ inventory_hostname }}" %(coordinator.address))
distem.pnode_init(_get_all_hosts(roles))
return coordinator return coordinator
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment