def vmong5k(config, force, env=None, **kwargs): conf = VMonG5kConf.from_dictionnary(config["vmong5k"]) provider = VMonG5k(conf) roles, networks = provider.init(force_deploy=force) env["config"] = config env["roles"] = roles env["networks"] = networks env["context"] = "vmong5k"
def test_from_dictionnary_custom_backend(self): d = { "job_name": "test-job", "walltime": "12:34:56", "resources": { "machines": [], "networks": [] } } conf = Configuration.from_dictionnary(d) self.assertEqual("test-job", conf.job_name) self.assertEqual("12:34:56", conf.walltime)
def test_programmatic(self): conf = Configuration() conf.add_machine_conf( MachineConfiguration(roles=["r1"], flavour=constants.FLAVOURS["large"], number=10, cluster="test-cluster")) conf.finalize() self.assertEqual(1, len(conf.machines)) # default networks self.assertEqual(constants.DEFAULT_NETWORKS, conf.networks)
def test_do_build_g5k_conf(self, mock_find_node_number): conf = Configuration() conf.add_machine(roles=["r1"], cluster="cluster1", number=10, flavour="tiny") conf.finalize() g5k_conf = _do_build_g5k_conf(conf, "rennes") # it's valid g5k_conf.finalize() # machines self.assertEqual(1, len(g5k_conf.machines)) machine = g5k_conf.machines[0] self.assertEqual("cluster1", machine.cluster) self.assertEqual(2, machine.nodes) # role have been expanded with the unique cookie self.assertEqual(2, len(machine.roles)) # networks self.assertEqual(2, len(g5k_conf.networks)) self.assertTrue(g5k_conf.networks[0].type in ["prod", "slash_22"]) self.assertTrue(g5k_conf.networks[1].type in ["prod", "slash_22"])
from enoslib.api import discover_networks from enoslib.infra.enos_vmong5k.provider import VMonG5k from enoslib.infra.enos_vmong5k.configuration import Configuration import logging import os logging.basicConfig(level=logging.DEBUG) # path to the inventory inventory = os.path.join(os.getcwd(), "hosts") # claim the resources conf = Configuration.from_settings(job_name="tuto-vmong5k", image="/grid5000/virt-images/debian9-x64-nfs-2019040916.qcow2")\ .add_machine(roles=["compute"], cluster="grisou", number=100, flavour="tiny")\ .add_machine(roles=["controller"], cluster="grisou", number=3, flavour="tiny")\ .finalize() provider = VMonG5k(conf) roles, networks = provider.init() print(roles) print(networks)
def test_from_dictionnary_minimal(self): d = {"resources": {"machines": [], "networks": []}} conf = Configuration.from_dictionnary(d) self.assertEqual(constants.DEFAULT_JOB_NAME, conf.job_name) self.assertEqual([], conf.machines) self.assertEqual([], conf.machines)
def test_programmatic_missing_keys(self): conf = Configuration() conf.add_machine_conf(MachineConfiguration()) with self.assertRaises(jsonschema.exceptions.ValidationError) as _: conf.finalize()
from enoslib.infra.enos_vmong5k.provider import VMonG5k from enoslib.infra.enos_vmong5k.configuration import Configuration import logging import os logging.basicConfig(level=logging.DEBUG) # path to the inventory inventory = os.path.join(os.getcwd(), "hosts") # claim the resources conf = Configuration.from_settings(job_name="tuto-vmong5k")\ .add_machine(roles=["compute"], cluster="grisou", number=100, flavour="tiny")\ .add_machine(roles=["controller"], cluster="grisou", number=100, flavour="tiny")\ .finalize() provider = VMonG5k(conf) roles, networks = provider.init() print(roles) print(networks)
from enoslib.api import discover_networks, play_on from enoslib.infra.enos_vmong5k.provider import VMonG5k from enoslib.infra.enos_vmong5k.configuration import Configuration import logging logging.basicConfig(level=logging.DEBUG) conf = Configuration.from_settings(job_name="flent_on", image="/grid5000/virt-images/debian9-x64-std-2019040916.qcow2", gateway="access.grid5000.fr", gateway_user="******")\ .add_machine(roles=["server"], cluster="grisou", number=1)\ .add_machine(roles=["client"], cluster="grisou", number=1)\ .finalize() provider = VMonG5k(conf) roles, networks = provider.init() discover_networks(roles, networks) with play_on("all", roles=roles) as p: # flent requires python3, so we default python to python3 p.shell( "update-alternatives --install /usr/bin/python python /usr/bin/python3 1" ) p.apt_repository( repo="deb http://deb.debian.org/debian stretch main contrib non-free",
"paris": { "paris": 0.3, "strasbourg": 12, "edimburgh": 13 }, "strasbourg": { "strasbourg": 0.3, "edimburgh": 30 }, "edimburgh": { "edimburgh": 0.3 } } # Building the configuration conf = Configuration.from_settings(job_name="tuto-vmong5k-netem", image="/grid5000/virt-images/debian9-x64-base-2019040916.qcow2") cities = list(CITIES.keys()) for city in cities: conf.add_machine(roles=[city], cluster="paravance", number=1, flavour="tiny") conf.finalize() # Starting the machnes provider = VMonG5k(conf) roles, networks = provider.init() # Building the network constraints emulation_conf = { "enable": True,
def _get_provider_instance(configuration): enoslib_configuration = _build_enoslib_configuration(configuration) _configuration = Configuration.from_dictionnary(enoslib_configuration) return VMonG5K(_configuration)
from enoslib.infra.enos_vmong5k.provider import VMonG5k from enoslib.infra.enos_vmong5k.configuration import Configuration import logging import os logging.basicConfig(level=logging.INFO) # path to the inventory inventory = os.path.join(os.getcwd(), "hosts") # claim the resources conf = Configuration.from_settings(job_name="tuto-vmong5k")\ .add_machine(roles=["control"], cluster="parapluie", number=3, flavour="large")\ .add_machine(roles=["compute"], cluster="parapluie", number=100, flavour="tiny")\ .finalize() provider = VMonG5k(conf) roles, networks = provider.init() print(roles) print(networks)
master_nodes = [] duration = "04:00:00" for i in range(0, len(clusters)): name_job = name + clusters[i] + str(i) role_name = "cluster" + str(clusters[i]) conf = Configuration.from_settings(job_name=name_job, walltime=duration, image="/grid5000/virt-images/debian9-x64-base.qcow2")\ .add_machine(roles=[role_name], cluster=clusters[i], flavour_desc={"core": 2, "mem": 4096}, number=6)\ .finalize() provider = VMonG5k(conf) roles, networks = provider.init() roles = discover_networks(roles, networks) inventory_file = "kubefed_inventory_cluster" + str(i) + ".ini" inventory = generate_inventory(roles, networks, inventory_file) master_nodes.append(roles[role_name][0].address) # Make sure k8s is not already running
"strasbourg": 12, "edimburgh": 13 }, "strasbourg": { "strasbourg": 0.3, "edimburgh": 30 }, "edimburgh": { "edimburgh": 0.3 } } # Building the configuration conf = Configuration.from_settings( job_name="tuto-vmong5k-netem", image="/grid5000/virt-images/debian9-x64-base-2019040916.qcow2", gateway="access.grid5000.fr", gateway_user="******") cities = list(CITIES.keys()) for city in cities: conf.add_machine(roles=[city], cluster="parasilo", number=1, flavour="tiny") conf.finalize() # Starting the machnes provider = VMonG5k(conf) roles, networks = provider.init() # Building the network constraints