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.")
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()
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()
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
def generate_os_snapshot(): os_snapshot.main()
def generate_os_snapshot(): logger.debug("Generating OpenStack snapshot...") os_snapshot.main()