def ListImagesFilters(): """ @summary: Generates a dataset list of filters for the list images request @return: Dataset_list @rtype: DatasetList """ auto_disk_config = 'False' checksum = random_string() container_format = ImageContainerFormat.AMI created_at = datetime.now() disk_format = ImageDiskFormat.RAW id_ = str(uuid.uuid1()) image_type = ImageType.IMPORT min_disk = images.config.min_disk min_ram = images.config.min_ram name = rand_name('image') os_type = ImageOSType.LINUX owner = random_int(0, 999999) protected = False size = random_int(0, 9999999) status = ImageStatus.ACTIVE updated_at = datetime.now() user_id = random_string() visibility = ImageVisibility.PUBLIC data_dict = {'passing_auto_disk_config': {'auto_disk_config': auto_disk_config}, 'passing_checksum': {'checksum': checksum}, 'passing_container_format': {'container_format': container_format}, 'passing_created_at': {'created_at': created_at}, 'passing_disk_format': {'disk_format': disk_format}, 'passing_id': {'id_': id_}, 'passing_image_type': {'image_type': image_type}, 'passing_min_disk': {'min_disk': min_disk}, 'passing_min_ram': {'min_ram': min_ram}, 'passing_multiple_filters': {'container_format': container_format, 'disk_format': disk_format}, 'passing_name': {'name': name}, 'passing_os_type': {'os_type': os_type}, 'passing_owner': {'owner': owner}, 'passing_protected': {'protected': protected}, 'passing_size': {'size': size}, 'passing_status': {'status': status}, 'passing_updated_at': {'updated_at': updated_at}, 'passing_user_id': {'user_id': user_id}, 'passing_visibility': {'visibility': visibility}} return build_basic_dataset(data_dict, 'params')
def ListImagesFilters(): """ @summary: Generates a dataset list of filters for the list images request @return: Dataset_list @rtype: DatasetList """ auto_disk_config = 'False' checksum = random_string() container_format = ImageContainerFormat.AMI created_at = datetime.now() disk_format = ImageDiskFormat.RAW id_ = '00000000-0000-0000-0000-000000000000' image_type = ImageType.IMPORT min_disk = images.config.min_disk min_ram = images.config.min_ram name = rand_name('image') os_type = ImageOSType.LINUX owner = random_int(0, 999999) protected = False size = random_int(0, 9999999) status = ImageStatus.ACTIVE updated_at = datetime.now() user_id = random_string() visibility = ImageVisibility.PUBLIC data_dict = {'passing_auto_disk_config': {'auto_disk_config': auto_disk_config}, 'passing_checksum': {'checksum': checksum}, 'passing_container_format': {'container_format': container_format}, 'passing_created_at': {'created_at': created_at}, 'passing_disk_format': {'disk_format': disk_format}, 'passing_id': {'id_': id_}, 'passing_image_type': {'image_type': image_type}, 'passing_min_disk': {'min_disk': min_disk}, 'passing_min_ram': {'min_ram': min_ram}, 'passing_multiple_filters': {'container_format': container_format, 'disk_format': disk_format}, 'passing_name': {'name': name}, 'passing_os_type': {'os_type': os_type}, 'passing_owner': {'owner': owner}, 'passing_protected': {'protected': protected}, 'passing_size': {'size': size}, 'passing_status': {'status': status}, 'passing_updated_at': {'updated_at': updated_at}, 'passing_user_id': {'user_id': user_id}, 'passing_visibility': {'visibility': visibility}} return build_basic_dataset(data_dict, 'params')
def UpdateAddRemoveImageRestricted(): """ @summary: Generates a dataset list of properties that are restricted for the update image requests to add and remove properties @return: Dataset_list @rtype: DatasetList """ image_id = str(uuid.uuid1()) # Properties that are read-only checksum = random_string() created_at = str(datetime.now()) file_ = '/v2/images/{0}/file'.format(image_id) id_ = str(uuid.uuid1()) schema = Schemas.IMAGE_MEMBER_SCHEMA self_ = '/v2/images/{0}'.format(image_id) size = random_int(0, 9999999) status = ImageStatus.ACTIVE updated_at = str(datetime.now()) # Properties that are reserved image_type = ImageType.IMPORT location = '/v2/images/{0}/file'.format(image_id) os_type = ImageOSType.LINUX owner = str(random_int(0, 999999)) user_id = random_string() # Properties that unauthorized visibility = ImageVisibility.PRIVATE data_dict = { 'passing_id': {'id': id_}, 'passing_checksum': {'checksum': checksum}, 'passing_created_at': {'created_at': created_at}, 'passing_file': {'file': file_}, 'passing_schema': {'schema': schema}, 'passing_self': {'self': self_}, 'passing_size': {'size': size}, 'passing_status': {'status': status}, 'passing_updated_at': {'updated_at': updated_at}, 'passing_image_type': {'image_type': image_type}, 'passing_location': {'location': location}, 'passing_os_type': {'os_type': os_type}, 'passing_owner': {'owner': owner}, 'passing_user_id': {'user_id': user_id}, 'passing_visibility': {'visibility': visibility}} return build_basic_dataset(data_dict, 'prop')
def RegisterImageRestricted(): """ @summary: Generates a dataset list of properties that are restricted for the register image request @return: Dataset_list @rtype: DatasetList """ image_id = str(uuid.uuid1()) # Properties that are read-only checksum = random_string() created_at = str(datetime.now()) file_ = '/v2/images/{0}/file'.format(image_id) schema = Schemas.IMAGE_MEMBER_SCHEMA self_ = '/v2/images/{0}'.format(image_id) size = random_int(0, 9999999) status = ImageStatus.ACTIVE updated_at = str(datetime.now()) # Properties that are reserved owner = str(random_int(0, 999999)) data_dict = { 'passing_checksum': {'checksum': checksum}, 'passing_created_at': {'created_at': created_at}, 'passing_file': {'file': file_}, 'passing_schema': {'schema': schema}, 'passing_self': {'self': self_}, 'passing_size': {'size': size}, 'passing_status': {'status': status}, 'passing_updated_at': {'updated_at': updated_at}, 'passing_owner': {'owner': owner}} return build_basic_dataset(data_dict, 'prop')
def ddtest_verify_data_on_custom_snapshot_after_copy_to_volume( self, image, flavor, volume_type=BlockstorageDatasets.default_volume_type_model()): """This test currently only works for Linux images""" # Create a server original_server = self.new_server( name=self.random_server_name(), image=image.id, flavor=flavor.id, add_cleanup=False) # Connect to server original_server_connection = self.connect_to_instance( original_server) # Write data to the root disk file_name = random_string("original_data") file_content = "a" * 1024 self.create_remote_file( original_server_connection, '/', file_name, file_content) original_server_connection.filesystem_sync() # Get hash of remote file original_hash = self.get_remote_file_md5_hash( original_server_connection, '/', file_name) # Create a snapshot of the server server_snapshot = self.make_server_snapshot(original_server) # Create a bootable volume from the server snapshot bootable_volume = self.create_volume_from_image_test( volume_type, server_snapshot) # Create block device mapping bdm = self.compute.servers.behaviors.create_block_device_mapping_v1( bootable_volume.id_, True, 'vda', bootable_volume.size, volume_type.id_) # Boot a server from the volume new_bfv_server = self.servers.behaviors.create_active_server( name=self.random_server_name(), flavor_ref=flavor.id, block_device_mapping=bdm).entity assert new_bfv_server is not None, ( "Unable to build a server from volume '{volume}' and flavor " "'{flavor}' with block device mapping: {bdm}".format( volume=bootable_volume.id_, flavor=flavor.id, bdm=bdm)) # Setup remote instance client new_bfv_server_conn = self.connect_to_instance( new_bfv_server, os_type='linux') # Get hash of remote file restored_hash = self.get_remote_file_md5_hash( new_bfv_server_conn, '/', file_name) assert original_hash == restored_hash, ( 'Restored data hash "{0}" did not match original data hash "{1}"' .format(restored_hash, original_hash))
def UpdateRegisterImageRestricted(): """ @summary: Generates a dataset list of properties that are restricted for the update and register image requests @return: Dataset_list @rtype: DatasetList """ # Properties that are read-only id_ = '00000000-0000-0000-0000-000000000000' checksum = random_string() created_at = str(datetime.now()) file_ = '/v2/images/00000000-0000-0000-0000-000000000000/file' schema = Schemas.IMAGE_MEMBER_SCHEMA self_ = '/v2/images/00000000-0000-0000-0000-000000000000' size = random_int(0, 9999999) status = ImageStatus.ACTIVE updated_at = str(datetime.now()) # Properties that are reserved image_type = ImageType.IMPORT os_type = ImageOSType.LINUX owner = random_int(0, 999999) user_id = random_string() # Properties that unauthorized visibility = ImageVisibility.PUBLIC data_dict = { 'passing_id': {'id': id_}, 'passing_checksum': {'checksum': checksum}, 'passing_created_at': {'created_at': created_at}, 'passing_file': {'file': file_}, 'passing_schema': {'schema': schema}, 'passing_self': {'self': self_}, 'passing_size': {'size': size}, 'passing_status': {'status': status}, 'passing_updated_at': {'updated_at': updated_at}, 'passing_image_type': {'image_type': image_type}, 'passing_os_type': {'os_type': os_type}, 'passing_owner': {'owner': owner}, 'passing_user_id': {'user_id': user_id}, 'passing_visibility': {'visibility': visibility}} return build_basic_dataset(data_dict, 'prop')
def create_available_volume(self, name=None, type_=None, size=None): name = random_string(prefix="Volume_", size=10) size = size or self.api_config.min_volume_size type_ = type_ or self.api_config.default_volume_type resp = self.client.create_volume( size=size, volume_type=type_, display_name=name) self.raise_on_error(resp, "Cinder CLI Volume Create call failed.") volume = resp.entity self.wait_for_volume_status(volume.id_, statuses.Volume.AVAILABLE) return volume
def generate_mountpoint(self, prefix=None): """ Generates a string to use as a path for mounting drives on the remote linux os @param prefix: Optional string to prepend to the mountpoint name default prefix is 'mountpoint' @type source_path: string """ return "/{0}".format( datagen.random_string(prefix=prefix or "mountpoint_"))
def test_get_all_producers(self): result = self.producer_behaviors.create_producer() id_1 = result['producer_id'] result = self.producer_behaviors.create_producer(name=random_string()) id_2 = result['producer_id'] resp = self.producer_client.get_all_producers() producers = resp.entity self.assertEqual(resp.status_code, 200) self.assertEqual(len(producers), 2) self.assertIn(True, [producer.id == id_1 for producer in producers]) self.assertIn(True, [producer.id == id_2 for producer in producers])
def create_available_volume(self, name=None, type_=None, size=None): name = random_string(prefix="Volume_", size=10) size = size or self.api_config.min_volume_size type_ = type_ or self.api_config.default_volume_type resp = self.client.create_volume(size=size, volume_type=type_, display_name=name) self.raise_on_error(resp, "Cinder CLI Volume Create call failed.") volume = resp.entity self.wait_for_volume_status(volume.id_, statuses.Volume.AVAILABLE) return volume
def test_update_producer(self): result = self.producer_behaviors.create_producer() producer_id = result['producer_id'] update_name = random_string() resp = self.producer_client.update_producer(producer_id=producer_id, name=update_name) self.assertEqual(resp.status_code, 200) resp = self.producer_client.get_producer(producer_id) producer = resp.entity self.assertEqual(producer.name, update_name)
def test_update_producer(self): result = self.producer_behaviors.create_producer() producer_id = result['producer_id'] update_name = random_string() resp = self.producer_client.update_producer( producer_id=producer_id, name=update_name) self.assertEqual(resp.status_code, 200) resp = self.producer_client.get_producer(producer_id) producer = resp.entity self.assertEqual(producer.name, update_name)
def make_server_snapshot(self, server, add_cleanup=True): server_snapshot_name = random_string( prefix="cbs_qe_image_of_{0}_".format(server.name), size=10) create_img_resp = self.servers.client.create_image( server.id, name=server_snapshot_name) assert create_img_resp.ok, ( "Create-Server-Image call failed with a {0}".format( create_img_resp.status_code)) self.images.behaviors.verify_server_snapshotting_progression(server.id) # Poll for list of all snapshots and find the one that belongs to our # server. list_imgs_resp = self.images.client.list_images() assert list_imgs_resp.ok, ( "list-images call failed with a {0}".format( list_imgs_resp.status_code)) assert list_imgs_resp.entity is not None, ( "Unable to deserialize list-images response".format( list_imgs_resp.status_code)) image_list = list_imgs_resp.entity server_snapshot = None for img in image_list: if img.name == server_snapshot_name: server_snapshot = img break assert server_snapshot is not None, "Could not locate image by name." if add_cleanup is True: self.addCleanup( self.images.client.delete_image, server_snapshot.id) # Wait for the image to become active just in case self.images.behaviors.wait_for_image_status( server_snapshot.id, 'ACTIVE', 10, 600) # get the model for the snapshot in question resp = self.images.client.get_image(server_snapshot.id) assert resp.ok, ("Could not get updated snapshot info after create") assert resp.entity is not None, ( "Could not deserialize snapshot infor response") return resp.entity
def make_server_snapshot(self, server, add_cleanup=True): server_snapshot_name = random_string( prefix="cbs_qe_image_of_{0}_".format(server.name), size=10) create_img_resp = self.servers.client.create_image( server.id, name=server_snapshot_name) assert create_img_resp.ok, ( "Create-Server-Image call failed with a {0}".format( create_img_resp.status_code)) self.images.behaviors.verify_server_snapshotting_progression(server.id) # Poll for list of all snapshots and find the one that belongs to our # server. list_imgs_resp = self.images.client.list_images() assert list_imgs_resp.ok, ("list-images call failed with a {0}".format( list_imgs_resp.status_code)) assert list_imgs_resp.entity is not None, ( "Unable to deserialize list-images response".format( list_imgs_resp.status_code)) image_list = list_imgs_resp.entity server_snapshot = None for img in image_list: if img.name == server_snapshot_name: server_snapshot = img break assert server_snapshot is not None, "Could not locate image by name." if add_cleanup is True: self.addCleanup(self.images.client.delete_image, server_snapshot.id) # Wait for the image to become active just in case self.images.behaviors.wait_for_image_status(server_snapshot.id, 'ACTIVE', 10, 600) # get the model for the snapshot in question resp = self.images.client.get_image(server_snapshot.id) assert resp.ok, ("Could not get updated snapshot info after create") assert resp.entity is not None, ( "Could not deserialize snapshot infor response") return resp.entity
def random_string(prefix='NovaClientTestServer_', suffix=None, size=8): return random_string(prefix=prefix, suffix=suffix, size=size)
def random_server_name(cls): return random_string(prefix="Server_", size=10)
def test_register_image_passing_all_allowed_properties(self): """ @summary: Register image passing all allowed properties 1) Register image passing all allowed properties 2) Verify that the response code is 201 3) Add the image to the resource pool for deletion 4) Verify that the response contains values for all allowed properties as expected """ errors = [] id_regex = re.compile(ImageProperties.ID_REGEX) auto_disk_config = 'False' container_format = ImageContainerFormat.AKI disk_format = ImageDiskFormat.ISO id_ = str(uuid.uuid1()) image_type = ImageType.IMPORT min_disk = images.config.min_disk min_ram = images.config.min_ram name = rand_name('register_image') os_type = ImageOSType.LINUX protected = False tags = [rand_name('tag1')] user_id = random_string() additional_properties = {self.images.config.additional_property: self.images.config.additional_property_value} resp = self.images.client.register_image( auto_disk_config=auto_disk_config, container_format=container_format, disk_format=disk_format, id_=id_, image_type=image_type, min_disk=min_disk, min_ram=min_ram, name=name, os_type=os_type, protected=protected, tags=tags, user_id=user_id, additional_properties=additional_properties) self.assertEqual( resp.status_code, 201, Messages.STATUS_CODE_MSG.format(201, resp.status_code)) reg_image = resp.entity self.resources.add( reg_image.id_, self.images.client.delete_image) if reg_image.auto_disk_config != auto_disk_config: errors.append(Messages.PROPERTY_MSG.format( 'auto_disk_config', auto_disk_config, reg_image.auto_disk_config)) if reg_image.container_format != container_format: errors.append(Messages.PROPERTY_MSG.format( 'container_format', container_format, reg_image.container_format)) if reg_image.disk_format != disk_format: errors.append(Messages.PROPERTY_MSG.format( 'disk_format', disk_format, reg_image.disk_format)) if id_regex.match(reg_image.id_) is None: errors.append(Messages.PROPERTY_MSG.format( 'id_', 'not None', id_regex)) if reg_image.image_type is None: errors.append(Messages.PROPERTY_MSG.format( 'image_type', 'not None', reg_image.image_type)) if reg_image.min_disk != min_disk: errors.append(Messages.PROPERTY_MSG.format( 'min_disk', min_disk, reg_image.min_disk)) if reg_image.min_ram != min_ram: errors.append(Messages.PROPERTY_MSG.format( 'min_ram', min_ram, reg_image.min_ram)) if reg_image.name != name: errors.append(Messages.PROPERTY_MSG.format( 'name', name, reg_image.name)) if reg_image.os_type is None: errors.append(Messages.PROPERTY_MSG.format( 'os_type', 'not None', reg_image.os_type)) if reg_image.protected != protected: errors.append(Messages.PROPERTY_MSG.format( 'protected', protected, reg_image.protected)) if reg_image.tags != tags: errors.append(Messages.PROPERTY_MSG.format( 'tags', tags, reg_image.tags)) if reg_image.user_id is None: errors.append(Messages.PROPERTY_MSG.format( 'user_id', 'not None', reg_image.user_id)) if reg_image.additional_properties != additional_properties: errors.append(Messages.PROPERTY_MSG.format( 'additional_properties', additional_properties, reg_image.additional_properties)) self.assertEqual( errors, [], msg=('Unexpected error received. Expected: No errors ' 'Received: {0}').format(errors))
def test_register_image_passing_all_allowed_properties(self): """ @summary: Register image passing all allowed properties 1) Register image passing all allowed properties 2) Verify that the response code is 201 3) Add the image to the resource pool for deletion 4) Verify that the response contains values for all allowed properties as expected """ errors = [] id_regex = re.compile(ImageProperties.ID_REGEX) auto_disk_config = 'False' container_format = ImageContainerFormat.AKI disk_format = ImageDiskFormat.ISO id_ = '00000000-0000-0000-0000-000000000000' image_type = ImageType.IMPORT min_disk = images.config.min_disk min_ram = images.config.min_ram name = rand_name('register_image') os_type = ImageOSType.LINUX protected = False tags = [rand_name('tag1')] user_id = random_string() additional_properties = { self.images.config.additional_property: self.images.config.additional_property_value } resp = self.images.client.register_image( auto_disk_config=auto_disk_config, container_format=container_format, disk_format=disk_format, id_=id_, image_type=image_type, min_disk=min_disk, min_ram=min_ram, name=name, os_type=os_type, protected=protected, tags=tags, user_id=user_id, additional_properties=additional_properties) self.assertEqual( resp.status_code, 201, Messages.STATUS_CODE_MSG.format(201, resp.status_code)) reg_image = resp.entity self.resources.add(reg_image.id_, self.images.client.delete_image) if reg_image.auto_disk_config != auto_disk_config: errors.append( Messages.PROPERTY_MSG.format('auto_disk_config', auto_disk_config, reg_image.auto_disk_config)) if reg_image.container_format != container_format: errors.append( Messages.PROPERTY_MSG.format('container_format', container_format, reg_image.container_format)) if reg_image.disk_format != disk_format: errors.append( Messages.PROPERTY_MSG.format('disk_format', disk_format, reg_image.disk_format)) if id_regex.match(reg_image.id_) is None: errors.append( Messages.PROPERTY_MSG.format('id_', 'not None', id_regex)) if reg_image.image_type is not None: errors.append( Messages.PROPERTY_MSG.format('image_type', 'None', reg_image.image_type)) if reg_image.min_disk != min_disk: errors.append( Messages.PROPERTY_MSG.format('min_disk', min_disk, reg_image.min_disk)) if reg_image.min_ram != min_ram: errors.append( Messages.PROPERTY_MSG.format('min_ram', min_ram, reg_image.min_ram)) if reg_image.name != name: errors.append( Messages.PROPERTY_MSG.format('name', name, reg_image.name)) if reg_image.os_type is not None: errors.append( Messages.PROPERTY_MSG.format('os_type', 'None', reg_image.os_type)) if reg_image.protected != protected: errors.append( Messages.PROPERTY_MSG.format('protected', protected, reg_image.protected)) if reg_image.tags != tags: errors.append( Messages.PROPERTY_MSG.format('tags', tags, reg_image.tags)) if reg_image.user_id is not None: errors.append( Messages.PROPERTY_MSG.format('user_id', 'None', reg_image.user_id)) if reg_image.additional_properties != additional_properties: errors.append( Messages.PROPERTY_MSG.format('additional_properties', additional_properties, reg_image.additional_properties)) self.assertEqual(errors, [], msg=('Unexpected error received. Expected: No errors ' 'Received: {0}').format(errors))
def random_server_name(): return random_string(prefix="NovaClientTestServer_", size=10)
def ListImagesSmoke(): """ @summary: Generates a dataset list of parameters for the list images request for smoke tests @return: Dataset_list @rtype: DatasetList """ additional_property = images.config.additional_property additional_property_value = images.config.additional_property_value auto_disk_config = 'False' checksum = random_string() container_format = ImageContainerFormat.AMI created_at = datetime.now() disk_format = ImageDiskFormat.RAW id_ = str(uuid.uuid1()) image_type = ImageType.IMPORT limit = 10 marker = None member_status = ImageMemberStatus.ACCEPTED min_disk = images.config.min_disk min_ram = images.config.min_ram name = rand_name('image') os_type = ImageOSType.LINUX owner = random_int(0, 999999) protected = False size = random_int(0, 9999999) size_max = images.config.size_max size_min = images.config.size_min status = ImageStatus.ACTIVE sort_dir = SortDirection.ASCENDING sort_key = 'name' tag = [rand_name('tag')] updated_at = datetime.now() user_id = random_string() visibility = ImageVisibility.SHARED data_dict = {'passing_additional_property': {additional_property: additional_property_value}, 'passing_auto_disk_config': {'auto_disk_config': auto_disk_config}, 'passing_checksum': {'checksum': checksum}, 'passing_container_format': {'container_format': container_format}, 'passing_created_at': {'created_at': created_at}, 'passing_disk_format': {'disk_format': disk_format}, 'passing_id': {'id_': id_}, 'passing_image_type': {'image_type': image_type}, 'passing_limit': {'limit': limit}, 'passing_marker': {'marker': marker}, 'passing_member_status': {'member_status': member_status, 'visibility': visibility}, 'passing_min_disk': {'min_disk': min_disk}, 'passing_min_ram': {'min_ram': min_ram}, 'passing_name': {'name': name}, 'passing_no_parameters': {}, 'passing_os_type': {'os_type': os_type}, 'passing_owner': {'owner': owner}, 'passing_protected': {'protected': protected}, 'passing_size': {'size': size}, 'passing_size_max': {'size_max': size_max}, 'passing_size_min': {'size_min': size_min}, 'passing_sort_dir': {'sort_dir': sort_dir}, 'passing_sort_key': {'sort_key': sort_key}, 'passing_status': {'status': status}, 'passing_tag': {'tag': tag}, 'passing_updated_at': {'updated_at': updated_at}, 'passing_user_id': {'user_id': user_id}, 'passing_visibility': {'visibility': visibility}} return build_basic_dataset(data_dict, 'params')
def random_volume_name(): return random_string(prefix="Volume_", size=10)
def random_snapshot_name(): return random_string(prefix="Snapshot_", size=10)
def ListImagesSmoke(): """ @summary: Generates a dataset list of parameters for the list images request for smoke tests @return: Dataset_list @rtype: DatasetList """ additional_property = images.config.additional_property additional_property_value = images.config.additional_property_value auto_disk_config = 'False' checksum = random_string() container_format = ImageContainerFormat.AMI created_at = datetime.now() disk_format = ImageDiskFormat.RAW id_ = '00000000-0000-0000-0000-000000000000' image_type = ImageType.IMPORT limit = 10 marker = None member_status = ImageMemberStatus.ACCEPTED min_disk = images.config.min_disk min_ram = images.config.min_ram name = rand_name('image') os_type = ImageOSType.LINUX owner = random_int(0, 999999) protected = False size = random_int(0, 9999999) size_max = images.config.size_max size_min = images.config.size_min status = ImageStatus.ACTIVE sort_dir = SortDirection.ASCENDING sort_key = 'name' tag = [rand_name('tag')] updated_at = datetime.now() user_id = random_string() visibility = ImageVisibility.SHARED data_dict = {'passing_additional_property': {additional_property: additional_property_value}, 'passing_auto_disk_config': {'auto_disk_config': auto_disk_config}, 'passing_checksum': {'checksum': checksum}, 'passing_container_format': {'container_format': container_format}, 'passing_created_at': {'created_at': created_at}, 'passing_disk_format': {'disk_format': disk_format}, 'passing_id': {'id_': id_}, 'passing_image_type': {'image_type': image_type}, 'passing_limit': {'limit': limit}, 'passing_marker': {'marker': marker}, 'passing_member_status': {'member_status': member_status, 'visibility': visibility}, 'passing_min_disk': {'min_disk': min_disk}, 'passing_min_ram': {'min_ram': min_ram}, 'passing_name': {'name': name}, 'passing_no_parameters': {}, 'passing_os_type': {'os_type': os_type}, 'passing_owner': {'owner': owner}, 'passing_protected': {'protected': protected}, 'passing_size': {'size': size}, 'passing_size_max': {'size_max': size_max}, 'passing_size_min': {'size_min': size_min}, 'passing_sort_dir': {'sort_dir': sort_dir}, 'passing_sort_key': {'sort_key': sort_key}, 'passing_status': {'status': status}, 'passing_tag': {'tag': tag}, 'passing_updated_at': {'updated_at': updated_at}, 'passing_user_id': {'user_id': user_id}, 'passing_visibility': {'visibility': visibility}} return build_basic_dataset(data_dict, 'params')
def create_available_server( self, name, flavor=None, image=None, no_service_net=None, no_public=None, disk_config=None, image_with=None, boot_volume=None, snapshot=None, num_instances=None, meta=None, file_=None, key_name=None, user_data=None, availability_zone=None, security_groups=None, block_device_mapping=None, block_device=None, swap=None, ephemeral=None, hint=None, nic=None, config_drive=None, ): """ Expected input for non-string parameters disk_config: 'auto' or 'manual' image-with: {key: value} meta: {key: value, [key2=value2, ...] } file_: {dst-path: src-path} block_device_mapping: {dev-name: mapping} block_device: {key=value, [key2=value2, ...] } ephemeral: {'size': size, ['format': format]} hint: {key: value} nic: {'net-id'=net-uuid, 'port-id'=port-uuid, ['v4-fixed-ip'=ip-addr]} """ name = name or random_string("NovaCLI") image = image or self.images_api_config.primary_image flavor = flavor or self.flavors_api_config.primary_flavor failures = [] attempts = self.servers_api_config.resource_build_attempts for attempt in range(attempts): self._log.debug( "Attempt {attempt} of {attempts} to create server with the " "NovaCLI.".format(attempt=attempt + 1, attempts=attempts) ) resp = self.nova_cli_client.create_server( name=name, flavor=flavor, image=image, no_service_net=no_service_net, no_public=no_public, disk_config=disk_config, image_with=image_with, boot_volume=boot_volume, snapshot=snapshot, num_instances=num_instances, meta=meta, file_=file_, key_name=key_name, user_data=user_data, availability_zone=availability_zone, security_groups=security_groups, block_device_mapping=block_device_mapping, block_device=block_device, swap=swap, ephemeral=ephemeral, hint=hint, nic=nic, config_drive=config_drive, ) server = resp.entity if server is None: raise self._default_error("Unable to parse nova boot response") try: resp = self.wait_for_server_status(server.id_, ServerStates.ACTIVE) # Add the password from the create request # into the final response resp.entity.admin_pass = server.admin_pass return resp except (TimeoutException, BuildErrorException) as ex: msg = "Failed to build server {server_id}".format(server_id=server.id_) self._log.exception(msg) failures.append(ex.message) self.nova_cli_client.delete_server(server.id_) raise RequiredResourceException( "Failed to successfully build a server after " "{attempts} attempts: {failures}".format(attempts=attempts, failures=failures) )
def create_available_server(self, name, flavor=None, image=None, no_service_net=None, no_public=None, disk_config=None, image_with=None, boot_volume=None, snapshot=None, num_instances=None, meta=None, file_=None, key_name=None, user_data=None, availability_zone=None, security_groups=None, block_device_mapping=None, block_device=None, swap=None, ephemeral=None, hint=None, nic=None, config_drive=None): """ Expected input for non-string parameters disk_config: 'auto' or 'manual' image-with: {key: value} meta: {key: value, [key2=value2, ...] } file_: {dst-path: src-path} block_device_mapping: {dev-name: mapping} block_device: {key=value, [key2=value2, ...] } ephemeral: {'size': size, ['format': format]} hint: {key: value} nic: {'net-id'=net-uuid, 'port-id'=port-uuid, ['v4-fixed-ip'=ip-addr]} """ name = name or random_string('NovaCLI') image = image or self.images_api_config.primary_image flavor = flavor or self.flavors_api_config.primary_flavor failures = [] attempts = self.servers_api_config.resource_build_attempts for attempt in range(attempts): self._log.debug( 'Attempt {attempt} of {attempts} to create server with the ' 'NovaCLI.'.format(attempt=attempt + 1, attempts=attempts)) resp = self.nova_cli_client.create_server( name=name, flavor=flavor, image=image, no_service_net=no_service_net, no_public=no_public, disk_config=disk_config, image_with=image_with, boot_volume=boot_volume, snapshot=snapshot, num_instances=num_instances, meta=meta, file_=file_, key_name=key_name, user_data=user_data, availability_zone=availability_zone, security_groups=security_groups, block_device_mapping=block_device_mapping, block_device=block_device, swap=swap, ephemeral=ephemeral, hint=hint, nic=nic, config_drive=config_drive) server = resp.entity if server is None: raise self._default_error("Unable to parse nova boot response") try: resp = self.wait_for_server_status(server.id_, ServerStates.ACTIVE) # Add the password from the create request # into the final response resp.entity.admin_pass = server.admin_pass return resp except (TimeoutException, BuildErrorException) as ex: msg = 'Failed to build server {server_id}'.format( server_id=server.id_) self._log.exception(msg) failures.append(ex.message) self.nova_cli_client.delete_server(server.id_) raise RequiredResourceException( 'Failed to successfully build a server after ' '{attempts} attempts: {failures}'.format(attempts=attempts, failures=failures))