Esempio n. 1
0
 def preform_destroy_action(self):
     if self.base_image:
         request_confirmation(
             prompt=
             "Are you sure you want to delete the VNet base images (y/n)? ")
         destroy_lxc_image(settings.LXC_BASE_IMAGE_ALIAS, by_alias=True)
     else:
         destroy_machines(self.config, machines=self._machines)
         # If specific machines are specified, we don't want to mess with the interfaces
         if self._machines:
             logger.warning(
                 "Not deleting VNet interfaces as we are only destroying specific machines, this may leave lingering sniffers"
             )
         else:
             delete_vnet_interfaces(self.config)
Esempio n. 2
0
 def test_destroy_lxc_image_does_nothing_when_image_does_not_exist(self):
     self.check_if_image_exists.return_value = False
     destroy_lxc_image("test")
     self.assertFalse(self.get_lxd.called)
     self.assertFalse(self.image.delete.called)
Esempio n. 3
0
 def test_destroy_lxc_image_calls_image_delete_method(self):
     destroy_lxc_image("test")
     self.image.delete.assert_called_once_with()
Esempio n. 4
0
 def test_destroy_lxc_image_calls_images_get_when_not_by_alias(self):
     destroy_lxc_image("test", by_alias=False)
     self.client.images.get.assert_called_once_with("test")
     self.assertFalse(self.client.images.get_by_alias.called)
Esempio n. 5
0
 def test_destroy_lxc_image_calls_images_get_by_alias_by_default(self):
     destroy_lxc_image("test")
     self.client.images.get_by_alias.assert_called_once_with("test")
     self.assertFalse(self.client.images.get.called)
Esempio n. 6
0
 def test_destroy_lxc_image_calls_get_lxd_client(self):
     destroy_lxc_image("test")
     self.get_lxd.assert_called_once_with()
Esempio n. 7
0
 def test_destroy_lxc_image_check_if_image_exists_without_alias(self):
     destroy_lxc_image("test", by_alias=False)
     self.check_if_image_exists.assert_called_once_with("test", by_alias=False)
Esempio n. 8
0
 def test_destroy_lxc_image_checks_if_image_exists(self):
     destroy_lxc_image("test")
     self.check_if_image_exists.assert_called_once_with("test", by_alias=True)