Beispiel #1
0
 def test_ensure_vnet_lxc_environment_calls_create_vnet_storage_pool_if_does_not_exist(
         self):
     self.check_if_lxc_storage_pool_exists.return_value = False
     ensure_vnet_lxc_environment(self.config)
     self.create_lxc_storage_pool.assert_called_once_with(
         name=settings.LXC_STORAGE_POOL_NAME,
         driver=settings.LXC_STORAGE_POOL_DRIVER)
Beispiel #2
0
 def test_ensure_vnet_lxc_environment_does_not_call_create_vnet_profile_if_it_exists(
         self):
     self.check_if_lxc_profile_exists.return_value = True
     ensure_vnet_lxc_environment(self.config)
     self.assertFalse(self.create_vnet_lxc_profile.called)
     self.logger.debug.has_calls(
         call("VNet profile {} found".format(settings.LXC_VNET_PROFILE)))
Beispiel #3
0
 def test_ensure_vnet_lxc_environment_does_nothing_if_no_lxc_machines_in_config(
         self):
     self.config["machines"] = {}
     ensure_vnet_lxc_environment(self.config)
     self.logger.debug.assert_called_once_with(
         "Skipping LXC environment creation, no LXC machines in config")
     self.assertFalse(self.create_lxc_storage_pool.called)
Beispiel #4
0
 def test_ensure_vnet_lxc_environment_does_not_call_create_vnet_storage_pool_if_it_exists(
         self):
     self.check_if_lxc_storage_pool_exists.return_value = True
     ensure_vnet_lxc_environment(self.config)
     self.assertFalse(self.create_lxc_storage_pool.called)
     self.logger.debug.has_calls(
         call("VNet LXC storage pool {} found".format(
             settings.LXC_STORAGE_POOL_NAME)))
Beispiel #5
0
 def test_ensure_vnet_lxc_environment_throws_runtime_error_when_check_for_installed_packages_fails(
         self):
     self.check_for_installed_packages.return_value = False
     with self.assertRaises(RuntimeError):
         ensure_vnet_lxc_environment(self.config)
     self.logger.critical.assert_called_once_with(
         "Not all required host packages seem to be installed, please fix this before proceeding"
     )
Beispiel #6
0
 def test_ensure_vnet_lxc_environment_throws_runtime_error_when_running_on_unsupported_os(
         self):
     self.check_for_supported_os.return_value = False
     with self.assertRaises(RuntimeError):
         ensure_vnet_lxc_environment(self.config)
     self.logger.critical.assert_called_once_with(
         "Unable to create LXC environment on your machine, OS not supported"
     )
Beispiel #7
0
 def test_ensure_vnet_lxc_environment_does_not_call_base_image_creation_functions_when_it_exists(
         self):
     self.check_if_lxc_image_exists.return_value = True
     ensure_vnet_lxc_environment(self.config)
     self.assertFalse(self.create_lxc_base_image_container.called)
     self.assertFalse(self.change_lxc_machine_status.called)
     self.assertFalse(self.configure_lxc_base_machine.called)
     self.assertFalse(self.create_lxc_image_from_container.called)
     self.assertFalse(self.destroy_lxc_machine.called)
     self.logger.debug.has_calls(
         call("Base image {} found".format(settings.LXC_BASE_IMAGE_ALIAS)))
Beispiel #8
0
 def preform_create_action(self):
     # Make sure the provider environments are correct
     ensure_vnet_lxc_environment(self.config)
     # Make the machines
     create_machines(self.config, machines=self._machines)
     # Put user requested file on the machines
     put_files_on_machine(self.config)
     if not self.no_hosts:
         # Put /etc/hosts on the machines
         generate_vnet_hosts_file(self.config)
         place_vnet_hosts_file_on_machines(self.config)
     # Configure type specific stuff
     enable_type_specific_machine_configuration(self.config)
Beispiel #9
0
 def test_ensure_vnet_lxc_environment_calls_base_image_creation_funtions_when_it_does_not_exist(
         self):
     self.check_if_lxc_image_exists.return_value = False
     ensure_vnet_lxc_environment(self.config)
     self.create_lxc_base_image_container.assert_called_once_with(
         self.config)
     self.change_lxc_machine_status.assert_called_once_with(
         settings.LXC_BASE_IMAGE_MACHINE_NAME, status="start")
     self.configure_lxc_base_machine.assert_called_once_with(self.config)
     self.create_lxc_image_from_container.assert_called_once_with(
         settings.LXC_BASE_IMAGE_MACHINE_NAME,
         alias=settings.LXC_BASE_IMAGE_ALIAS)
     self.destroy_lxc_machine.assert_called_once_with(
         settings.LXC_BASE_IMAGE_MACHINE_NAME, wait=False)
Beispiel #10
0
 def test_ensure_vnet_lxc_environment_calls_create_vnet_lxc_profile_if_it_does_not_exist(
         self):
     self.check_if_lxc_profile_exists.return_value = False
     ensure_vnet_lxc_environment(self.config)
     self.create_vnet_lxc_profile.assert_called_once_with(
         settings.LXC_VNET_PROFILE)