Пример #1
0
    def test_storage(self):
        """Test using Machine's storage.
        """
        src_machine = Machine(uuid=self.uuid_1,
                              provider_id=self.provider.provider_id,
                              av_zone=self.av_zone)
        Machine.add(src_machine)
        dst_machine = Machine.fetch(self.uuid_1)
        self.assertEqual(src_machine, dst_machine)
        self.assertNotEqual(id(src_machine), id(dst_machine))

        Machine.remove(src_machine)
        dst_machine = Machine.fetch(self.uuid_1)
        self.assertEqual(None, dst_machine)
Пример #2
0
def _create_machine(provider_id, parameters, machine_group_uuid, skip_store,
                    wait_spawning):
    """Create a machine.
    """
    manager = _retrieve_machine_manager(provider_id)

    _preprocess_parameters(parameters, machine_group_uuid, manager.provider)
    machines = manager.create(parameters, wait_spawning)

    _LOGGER.debug("Created machine(s) (%s).", machines)

    if not skip_store:
        for machine in machines:
            Machine.add(machine)

    return [machine.as_dict() for machine in machines]
Пример #3
0
def _create_machine(provider_id, parameters, machine_group_uuid,
                    skip_store, wait_spawning):
    """Create a machine.
    """
    manager = _retrieve_machine_manager(provider_id)

    _preprocess_parameters(parameters, machine_group_uuid, manager.provider)
    machines = manager.create(parameters, wait_spawning)

    _LOGGER.debug("Created machine(s) (%s).", machines)

    if not skip_store:
        for machine in machines:
            Machine.add(machine)

    return [machine.as_dict() for machine in machines]
Пример #4
0
    def test_machines(self):
        """Check machines created within a provider.
        """
        machine_1 = Machine(uuid=self.uuid_1,
                            provider_id=self.provider.provider_id,
                            av_zone=self.av_zone)
        Machine.add(machine_1)

        machine_2 = Machine(uuid=self.uuid_2,
                            provider_id=self.provider.provider_id,
                            av_zone=self.av_zone)
        Machine.add(machine_2)

        ret = [ isinstance(machine, Machine) for machine in \
            Machine.machines(self.provider.provider_id)
        ]
        self.assertEqual(len(ret), 2)
        self.assertTrue(all(ret))