log_errors=False, retryable_exceptions=errors.Resource.RetryableCreationError) def WaitForVolumeCreation(resource, volume_id): """Waits until volume is available""" vol_cmd = os_utils.OpenStackCLICommand(resource, 'volume', 'show', volume_id) stdout, stderr, _ = vol_cmd.Issue() if stderr: raise errors.Error(stderr) resp = json.loads(stdout) if resp['status'] != 'available': msg = 'Volume is not ready. Retrying to check status.' raise errors.Resource.RetryableCreationError(msg) disk.RegisterDiskTypeMap(providers.OPENSTACK, DISK_TYPE) class OpenStackDiskSpec(disk.BaseDiskSpec): """Object holding the information needed to create an OpenStackDisk. Attributes: disk_size: None or int. Size of the disk in GB. volume_type: None or string. Volume type to be used to create a block storage volume. """ CLOUD = providers.OPENSTACK @classmethod
disk.REPLICATION: disk.ZONE, }, PD_SSD: { disk.MEDIA: disk.SSD, disk.REPLICATION: disk.ZONE, }, disk.LOCAL: { disk.MEDIA: disk.SSD, disk.REPLICATION: disk.NONE, } } SCSI = 'SCSI' NVME = 'NVME' disk.RegisterDiskTypeMap(GCP, DISK_TYPE) class GceDisk(disk.BaseDisk): """Object representing an GCE Disk.""" def __init__(self, disk_spec, name, zone, project, image=None, image_project=None): super(GceDisk, self).__init__(disk_spec) self.attached_vm_name = None self.image = image self.image_project = image_project
disk.MEDIA: disk.SSD, disk.REPLICATION: disk.NONE, disk.LEGACY_DISK_TYPE: disk.LOCAL } BLOCK_STORAGE_METADATA = { disk.MEDIA: disk.SSD, disk.REPLICATION: disk.ZONE, disk.LEGACY_DISK_TYPE: disk.REMOTE_SSD } # Map legacy disk types to DigitalOcean disk types. DISK_TYPE_MAP = { disk.REMOTE_SSD: BLOCK_STORAGE } disk.RegisterDiskTypeMap(providers.DIGITALOCEAN, DISK_TYPE_MAP) class DigitalOceanLocalDisk(disk.BaseDisk): """Dummy Object representing a DigitalOcean Disk.""" def __init__(self, disk_spec): super(DigitalOceanLocalDisk, self).__init__(disk_spec) self.metadata = LOCAL_DISK_METADATA def Attach(self, vm): pass def Detach(self): pass
disk.REPLICATION: RAID10, DURABILITY: EPHEMERAL }, CBS_SSD: { disk.REPLICATION: disk.REGION, DURABILITY: PERSISTENT, disk.MEDIA: disk.SSD }, CBS_SATA: { disk.REPLICATION: disk.REGION, DURABILITY: PERSISTENT, disk.MEDIA: disk.HDD } } disk.RegisterDiskTypeMap(providers.RACKSPACE, DISK_TYPE) class RackspaceDiskSpec(disk.BaseDiskSpec): """Object containing the information needed to create a RackspaceDisk. Attributes: rackspace_region: None or string. Rackspace region to build VM resources. rack_profile: None or string. Rack CLI profile configuration. """ CLOUD = providers.RACKSPACE @classmethod def _ApplyFlags(cls, config_values, flag_values): super(RackspaceDiskSpec, cls)._ApplyFlags(config_values, flag_values)
return machine_type[:2].lower() in LOCAL_HDD_PREFIXES def LocalDriveIsNvme(machine_type): """Check if the machine type uses NVMe driver.""" return machine_type[:2].lower() in LOCAL_NVME_TYPES def EbsDriveIsNvme(machine_type): """Check if the machine type uses NVMe driver.""" return machine_type[:2].lower() in EBS_NVME_TYPES AWS = 'AWS' disk.RegisterDiskTypeMap(AWS, DISK_TYPE) class AwsDiskSpec(disk.BaseDiskSpec): """Object holding the information needed to create an AwsDisk. Attributes: iops: None or int. IOPS for Provisioned IOPS (SSD) volumes in AWS. """ CLOUD = providers.AWS @classmethod def _ApplyFlags(cls, config_values, flag_values): """Modifies config options based on runtime flag values.
from perfkitbenchmarker.providers.azure import azure_network from perfkitbenchmarker.providers.azure import flags as azure_flags FLAGS = flags.FLAGS DRIVE_START_LETTER = 'c' PREMIUM_STORAGE = 'Premium_LRS' STANDARD_DISK = 'Standard_LRS' DISK_TYPE = {disk.STANDARD: STANDARD_DISK, disk.REMOTE_SSD: PREMIUM_STORAGE} HOST_CACHING = 'host_caching' AZURE = 'Azure' disk.RegisterDiskTypeMap(AZURE, DISK_TYPE) AZURE_REPLICATION_MAP = { azure_flags.LRS: disk.ZONE, azure_flags.ZRS: disk.REGION, # Deliberately omitting PLRS, because that is set explicty in __init__, # and (RA)GRS, because those are asynchronously replicated. } LOCAL_SSD_PREFIXES = {'Standard_D', 'Standard_G'} def LocalDiskIsSSD(machine_type): """Check whether the local disk is an SSD drive.""" return any(
LOCAL = 'local' DISK_TYPE = { disk.LOCAL: LOCAL, } DISK_METADATA = { LOCAL: { disk.MEDIA: disk.HDD, disk.REPLICATION: disk.ZONE, disk.LEGACY_DISK_TYPE: disk.STANDARD } } SoftLayer = 'SoftLayer' disk.RegisterDiskTypeMap(SoftLayer, DISK_TYPE) class SoftLayerDiskSpec(disk.BaseDiskSpec): """Object holding the information needed to create a SoftLayerDisk.""" CLOUD = providers.SOFTLAYER @classmethod def _ApplyFlags(cls, config_values, flag_values): """Modifies config options based on runtime flag values. Can be overridden by derived classes to add support for specific flags. Args: config_values: dict mapping config option names to provided values. May
disk.REPLICATION: disk.ZONE, }, PD_EXTREME: { disk.MEDIA: disk.SSD, disk.REPLICATION: disk.ZONE, }, disk.LOCAL: { disk.MEDIA: disk.SSD, disk.REPLICATION: disk.NONE, }, } SCSI = 'SCSI' NVME = 'NVME' disk.RegisterDiskTypeMap(providers.GCP, DISK_TYPE) class GceDisk(disk.BaseDisk): """Object representing an GCE Disk.""" def __init__(self, disk_spec, name, zone, project, image=None, image_project=None, replica_zones=None): super(GceDisk, self).__init__(disk_spec) self.attached_vm_name = None