Exemple #1
0
    def test_distribute_2_vms_2_hosts(self):
        machine = MachineConfiguration(roles=["r1"],
                                       flavour="tiny",
                                       cluster="paravance",
                                       number=2)
        machines = [machine]
        host0 = Host("paravance-1")
        host1 = Host("paravance-2")

        g5k_roles = {"r1": [host0, host1], machine.cookie: [host0, host1]}

        g5k_subnet = {
            "mac_start": EUI("00:16:3E:9E:44:00"),
            "mac_end": EUI("00:16:3E:9E:47:FE")
        }

        vmong5k_roles = _distribute(machines, g5k_roles, g5k_subnet)
        self.assertEqual(2, len(vmong5k_roles["r1"]))
        vm = vmong5k_roles["r1"][0]
        # we skip the first mac
        self.assertEqual(EUI(int(g5k_subnet['mac_start']) + 1), vm.eui)
        self.assertEqual(host0, vm.pm)

        vm = vmong5k_roles["r1"][1]
        self.assertEqual(EUI(int(g5k_subnet['mac_start']) + 2), vm.eui)
        self.assertEqual(host1, vm.pm)
 def test_from_dictionnary(self):
     d = {
         "roles": ["r1"],
         "flavour": "large",
         "number": 2,
         "cluster": "test-cluster"
     }
     conf = MachineConfiguration.from_dictionnary(d)
     self.assertEqual(constants.FLAVOURS["large"], conf.flavour)
     self.assertEqual(2, conf.number)
 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)
Exemple #4
0
 def test_from_dictionnary_flavour_desc(self):
     flavour_desc = {"core": 42, "mem": 42}
     d = {
         "roles": ["r1"],
         "flavour_desc": flavour_desc,
         "number": 2,
         "cluster": "test-cluster"
     }
     conf = MachineConfiguration.from_dictionnary(d)
     self.assertEqual(flavour_desc, conf.flavour_desc)
     self.assertEqual(2, conf.number)
Exemple #5
0
    def test_distribute_minimal(self):

        host = Host("paravance-1")
        machine = MachineConfiguration(
            roles=["r1"], flavour="tiny", undercloud=[host], number=1
        )
        machines = [machine]

        g5k_subnet = {"mac_start": "00:16:3E:9E:44:00", "mac_end": "00:16:3E:9E:47:FE"}

        vmong5k_roles = _distribute(machines, [g5k_subnet])
        self.assertEqual(1, len(vmong5k_roles["r1"]))
        vm = vmong5k_roles["r1"][0]
        # we skip the first mac
        self.assertEqual(EUI(int(EUI(g5k_subnet["mac_start"])) + 1), vm.eui)
        self.assertEqual(host, vm.pm)
Exemple #6
0
    def test_distribute_minimal(self):
        machine = MachineConfiguration(roles=["r1"],
                                       flavour="tiny",
                                       cluster="paravance",
                                       number=1)
        machines = [machine]
        host = Host("paravance-1")

        g5k_roles = {"r1": [host], machine.cookie: [host]}

        g5k_subnet = {
            "mac_start": "00:16:3E:9E:44:00",
            "mac_end": "00:16:3E:9E:47:FE"
        }

        vmong5k_roles = _distribute(machines, g5k_roles, g5k_subnet)
        self.assertEqual(1, len(vmong5k_roles["r1"]))
        vm = vmong5k_roles["r1"][0]
        # we skip the first mac
        self.assertEqual(EUI(int(EUI(g5k_subnet['mac_start'])) + 1), vm.eui)
        self.assertEqual(host, vm.pm)
Exemple #7
0
    def test_distribute_2_vms_2_hosts(self):
        host0 = Host("paravance-1")
        host1 = Host("paravance-2")
        machine = MachineConfiguration(
            roles=["r1"], flavour="tiny", undercloud=[host0, host1], number=2
        )
        machines = [machine]

        g5k_subnet = {
            "mac_start": EUI("00:16:3E:9E:44:00"),
            "mac_end": EUI("00:16:3E:9E:47:FE"),
        }

        vmong5k_roles = _distribute(machines, [g5k_subnet])
        self.assertEqual(2, len(vmong5k_roles["r1"]))
        vm = vmong5k_roles["r1"][0]
        # we skip the first mac
        self.assertEqual(EUI(int(g5k_subnet["mac_start"]) + 1), vm.eui)
        self.assertEqual(host0, vm.pm)

        vm = vmong5k_roles["r1"][1]
        self.assertEqual(EUI(int(g5k_subnet["mac_start"]) + 2), vm.eui)
        self.assertEqual(host1, vm.pm)
 def test_from_dictionnary_minimal(self):
     d = {"roles": ["r1"], "cluster": "test-cluster"}
     conf = MachineConfiguration.from_dictionnary(d)
     self.assertEqual(constants.DEFAULT_FLAVOUR, conf.flavour)
 def test_programmatic_missing_keys(self):
     conf = Configuration()
     conf.add_machine_conf(MachineConfiguration())
     with self.assertRaises(jsonschema.exceptions.ValidationError) as _:
         conf.finalize()