def test_from_dictionnary_missing_keys(self): d = { "resources": { "machines": [], "networks": [] } } with self.assertRaises(jsonschema.exceptions.ValidationError) as _: Configuration.from_dictionnary(d)
def init(self, conf, force_deploy=False): logging.info("Openstack provider") enoslib_conf = self.build_config(conf) _conf = Configuration.from_dictionnary(enoslib_conf) openstack = Enos_Openstack(_conf) roles, networks = openstack.init(force_deploy=force_deploy) return roles, networks
def test_from_dictionnary_minimal(self): d = { "key_name": "test_key", "user": "******", "image": "test_image", "resources": {"machines": [], "networks": []}, } conf = Configuration.from_dictionnary(d) self.assertEqual(constants.DEFAULT_ALLOCATION_POOL, conf.allocation_pool) self.assertEqual(constants.DEFAULT_CONFIGURE_NETWORK, conf.configure_network)
def test_from_dictionnary(self): d = { "key_name": "test_key", "user": "******", "image": "test_image", "resources": { "machines": [{"roles": ["r1"], "flavour": "m1.tiny", "number": 1}], "networks": ["api"] } } conf = Configuration.from_dictionnary(d) self.assertEqual("test_key", conf.key_name) self.assertEqual("test_image", conf.image)
"prefix": "plop", "resources": { "machines": [{ "roles": ["control"], "flavour": "m1.medium", "number": 1, }, { "roles": ["compute"], "flavour": "m1.medium", "number": 5, }], "networks": ["network_interface"] } } tc = { "enable": True, "default_delay": "20ms", "default_rate": "1gbit", } inventory = os.path.join(os.getcwd(), "hosts") conf = Configuration.from_dictionnary(provider_conf) provider = Openstack(conf) provider.destroy() roles, networks = provider.init() generate_inventory(roles, networks, inventory) wait_ssh(inventory) generate_inventory(roles, networks, inventory, check_networks=True) emulate_network(roles, inventory, tc) validate_network(roles, inventory)