예제 #1
0
 def test_main_default(self, mock_logger_debug, mock_logger_info,
                       mock_creds, mock_nova, mock_neutron, mock_keystone,
                       mock_cinder):
     with mock.patch('functest.utils.openstack_snapshot.get_instances',
                     return_value=self.update_list), \
         mock.patch('functest.utils.openstack_snapshot.get_images',
                    return_value=self.update_list), \
         mock.patch('functest.utils.openstack_snapshot.get_images',
                    return_value=self.update_list), \
         mock.patch('functest.utils.openstack_snapshot.get_volumes',
                    return_value=self.update_list), \
         mock.patch('functest.utils.openstack_snapshot.get_networks',
                    return_value=self.update_list), \
         mock.patch('functest.utils.openstack_snapshot.get_routers',
                    return_value=self.update_list), \
         mock.patch('functest.utils.openstack_snapshot.get_security_groups',
                    return_value=self.update_list), \
         mock.patch('functest.utils.openstack_snapshot.get_floatinips',
                    return_value=self.update_floatingips), \
         mock.patch('functest.utils.openstack_snapshot.get_users',
                    return_value=self.update_list), \
         mock.patch('functest.utils.openstack_snapshot.get_tenants',
                    return_value=self.update_list), \
             mock.patch('__builtin__.open', mock.mock_open()) as m:
         openstack_snapshot.main()
         mock_logger_info.assert_called_once_with("Generating OpenStack "
                                                  "snapshot...")
         m.assert_called_once_with(openstack_snapshot.OS_SNAPSHOT_FILE,
                                   'w+')
         mock_logger_debug.assert_any_call("NOTE: These objects will "
                                           "NOT be deleted after " +
                                           "running the test.")
예제 #2
0
    def snapshot_create(self):
        self.ping_endpoint()
        if os.path.isfile(self.snapshot_file):
            answer = raw_input("It seems there is already an OpenStack "
                               "snapshot. Do you want to overwrite it with "
                               "the current OpenStack status? [y|n]\n")
            while True:
                if answer.lower() in ["y", "yes"]:
                    break
                elif answer.lower() in ["n", "no"]:
                    return
                else:
                    answer = raw_input("Invalid answer. Please type [y|n]\n")

        click.echo("Generating Openstack snapshot...")
        os_snapshot.main()
예제 #3
0
    def snapshot_create(self):
        self.ping_endpoint()
        if os.path.isfile(OS_SNAPSHOT_FILE):
            answer = raw_input("It seems there is already an OpenStack "
                               "snapshot. Do you want to overwrite it with "
                               "the current OpenStack status? [y|n]\n")
            while True:
                if answer.lower() in ["y", "yes"]:
                    break
                elif answer.lower() in ["n", "no"]:
                    return
                else:
                    answer = raw_input("Invalid answer. Please type [y|n]\n")

        click.echo("Generating Openstack snapshot...")
        os_snapshot.main()
예제 #4
0
    def create_snapshot(self):
        """Create a snapshot listing the OpenStack resources.

        Returns:
            TestCase.EX_OK if os_snapshot.main() returns 0.
            TestCase.EX_RUN_ERROR otherwise.
        """
        try:
            assert os_snapshot.main() == 0
            self.__logger.info("OpenStack resources snapshot created")
            return TestCase.EX_OK
        except Exception:  # pylint: disable=broad-except
            self.__logger.exception("Cannot create the snapshot")
            return TestCase.EX_RUN_ERROR
예제 #5
0
def generate_os_snapshot():
    os_snapshot.main()
예제 #6
0
def generate_os_snapshot():
    logger.debug("Generating OpenStack snapshot...")
    os_snapshot.main()