示例#1
0
 def clean(self):
     self.ping_endpoint()
     if not os.path.isfile(OS_SNAPSHOT_FILE):
         click.echo("Not possible to clean OpenStack without a snapshot. "
                    "This could cause problems. "
                    "Run first the command 'os-create-shapshot'.")
         return
     os_clean.main()
示例#2
0
 def clean(self):
     self.ping_endpoint()
     if not os.path.isfile(self.snapshot_file):
         click.echo("Not possible to clean OpenStack without a snapshot. "
                    "This could cause problems. "
                    "Run first the command "
                    "'functest openstack snapshot-create'")
         return
     os_clean.main()
示例#3
0
 def clean(self):
     """Clean the OpenStack resources."""
     try:
         assert os_clean.main() == 0
         self.__logger.info("OpenStack resources cleaned")
     except Exception:  # pylint: disable=broad-except
         self.__logger.exception("Cannot clean the OpenStack resources")
    def test_main_default(self, mock_logger_debug, mock_logger_info,
                          mock_creds, mock_nova, mock_neutron, mock_keystone,
                          mock_cinder, mock_glance):

        with mock.patch('functest.utils.openstack_clean.remove_instances') \
            as mock_remove_instances, \
            mock.patch('functest.utils.openstack_clean.remove_images') \
            as mock_remove_images, \
            mock.patch('functest.utils.openstack_clean.remove_volumes') \
            as mock_remove_volumes, \
            mock.patch('functest.utils.openstack_clean.remove_floatingips') \
            as mock_remove_floatingips, \
            mock.patch('functest.utils.openstack_clean.remove_networks') \
            as mock_remove_networks, \
            mock.patch('functest.utils.openstack_clean.'
                       'remove_security_groups') \
            as mock_remove_security_groups, \
            mock.patch('functest.utils.openstack_clean.remove_users') \
            as mock_remove_users, \
            mock.patch('functest.utils.openstack_clean.remove_tenants') \
            as mock_remove_tenants, \
            mock.patch('functest.utils.openstack_clean.yaml.safe_load',
                       return_value=mock.Mock()), \
                mock.patch('__builtin__.open', mock.mock_open()) as m:
            openstack_clean.main()
            self.assertTrue(mock_remove_instances)
            self.assertTrue(mock_remove_images)
            self.assertTrue(mock_remove_volumes)
            self.assertTrue(mock_remove_floatingips)
            self.assertTrue(mock_remove_networks)
            self.assertTrue(mock_remove_security_groups)
            self.assertTrue(mock_remove_users)
            self.assertTrue(mock_remove_tenants)
            m.assert_called_once_with(openstack_clean.OS_SNAPSHOT_FILE)
            mock_logger_info.assert_called_once_with("Cleaning OpenStack "
                                                     "resources...")
示例#5
0
def cleanup():
    os_clean.main()
示例#6
0
def cleanup():
    os_clean.main()