def test_set_memory(self, mock_modify_vm, mock_host_info):
        mock_host_info.side_effect = [
            {constants.HOST_MEMORY_AVAILABLE: self._FAKE_MEMORY + 1024},
            {constants.HOST_MEMORY_AVAILABLE: self._FAKE_MEMORY - 1024}
        ]
        vmutils.set_memory(self._instance)

        self.assertEqual(1, mock_modify_vm.call_count)
        mock_modify_vm.assert_called_with(self._instance,
                                          constants.FIELD_MEMORY,
                                          self._FAKE_MEMORY)
        self.assertRaises(exception.InsufficientFreeMemory,
                          vmutils.set_memory, self._instance)
예제 #2
0
    def create_instance(self, instance, image_meta, network_info,
                        overwrite=True):
        image_properties = image_meta.get("properties", {})
        action = constants.PATH_DELETE if overwrite else None

        basepath = pathutils.instance_basepath(instance, action=action)
        self._vbox_manage.create_vm(
            instance.name, basefolder=os.path.dirname(basepath),
            register=True)

        vmutils.set_os_type(instance, image_properties.get('os_type', None))
        vmutils.set_memory(instance)
        vmutils.set_cpus(instance)
        self._network_setup(instance, network_info)
예제 #3
0
    def test_set_memory(self, mock_modify_vm, mock_host_info):
        mock_host_info.side_effect = [{
            constants.HOST_MEMORY_AVAILABLE:
            self._FAKE_MEMORY + 1024
        }, {
            constants.HOST_MEMORY_AVAILABLE:
            self._FAKE_MEMORY - 1024
        }]
        vmutils.set_memory(self._instance)

        self.assertEqual(1, mock_modify_vm.call_count)
        mock_modify_vm.assert_called_with(self._instance,
                                          constants.FIELD_MEMORY,
                                          self._FAKE_MEMORY)
        self.assertRaises(exception.InsufficientFreeMemory, vmutils.set_memory,
                          self._instance)
예제 #4
0
    def create_instance(self,
                        instance,
                        image_meta,
                        network_info,
                        overwrite=True):
        image_properties = image_meta.get("properties", {})
        action = constants.PATH_DELETE if overwrite else None

        basepath = pathutils.instance_basepath(instance, action=action)
        self._vbox_manage.create_vm(instance.name,
                                    basefolder=os.path.dirname(basepath),
                                    register=True)

        vmutils.set_os_type(instance, image_properties.get('os_type', None))
        vmutils.set_memory(instance)
        vmutils.set_cpus(instance)
        self._network_setup(instance, network_info)