Commit 640865c4 authored by Maverick Chardet's avatar Maverick Chardet
Browse files

Trying to use Ansible to install requirements on remote Concerto host.

parent 989006ce
......@@ -3,15 +3,18 @@ import yaml
class G5kReservation:
def _g5k_deploy(self, g5k_config, force_deploy=False):
def _g5k_deploy(self, g5k_config, force_deploy=False, discover=True):
from enoslib.api import discover_networks
from enoslib.infra.enos_g5k.provider import G5k
from enoslib.infra.enos_g5k.configuration import Configuration
self._g5k_job = G5k(Configuration.from_dictionnary(g5k_config))
self._roles, self._networks = self._g5k_job.init(force_deploy=force_deploy)
if discover:
discover_networks(self._roles, self._networks)
# logging.info('Wait 30 seconds for iface to be ready...')
# time.sleep(30)
def _allocate(self, conf, force_deployment=False):
def _allocate(self, conf, force_deployment=False, discover_networks=True):
if isinstance(conf, str):
with open(conf) as f:
config = yaml.load(f)
......@@ -26,7 +29,7 @@ class G5kReservation:
# Claim resources on Grid'5000
if 'g5k' not in config:
raise Exception("'g5k' key missing in configuration!")
self._g5k_deploy(config['g5k'], force_deploy=force_deployment)
self._g5k_deploy(config['g5k'], force_deploy=force_deployment, discover=discover_networks)
@staticmethod
def _get_ip(g5k_address):
......@@ -38,13 +41,13 @@ class G5kReservation:
def _get_host_dict(g5k_address):
return {"address": g5k_address, "ip": G5kReservation._get_ip(g5k_address)}
def __init__(self, conf, force_deployment=True, destroy=False):
def __init__(self, conf, force_deployment=True, destroy=False, discover_networks=True):
self._config = None
self._g5k_job = None
self._roles = None
self._networks = None
self._destroy = destroy
self._allocate(conf, force_deployment)
self._allocate(conf, force_deployment, discover_networks)
self._alive = True
def get_roles(self):
......@@ -64,6 +67,15 @@ class G5kReservation:
self._g5k_job.destroy()
self._alive = False
def ansible_to(self, pattern_hosts="all"):
"""
Args:
pattern_hosts (str): pattern to describe ansible hosts to target.
see https://docs.ansible.com/ansible/latest/intro_patterns.html
"""
from enoslib.api import play_on
return play_on(roles=self._roles, pattern_hosts=pattern_hosts)
def __enter__(self):
return self
......
......@@ -4,7 +4,8 @@ g5k:
walltime: "01:00:00"
dhcp: true
job_name: concerto_ssh_scalability
env_name: debian9-x64-nfs-madpp
env_name: debian10-x64-base
# env_name: debian9-x64-nfs-madpp
resources:
machines:
- roles:
......
......@@ -34,6 +34,10 @@ def run_experiment(list_nb_remote_ssh, nb_repeats, conf, working_directory=DEFAU
with open(working_directory + "/concerto_config.json", "w") as concerto_config_file:
dump(concerto_config, concerto_config_file)
with g5k.ansible_to("concerto") as ansible_to_concerto:
ansible_to_concerto.apt(name=["python3"], state="present")
ansible_to_concerto.pip(name=["enoslib"], executable="pip3")
with RemoteHost(concerto_machine["address"], remote_user="root") as concerto_host:
run_cmd = "mkdir -p %s;" % ROOT_DIR + \
"cd %s;" % ROOT_DIR + \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment