code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def GetConfigFromMachineType(self, machine_type): """Returns a tuple of (edition, family, vcore) from Azure machine type. Args: machine_type (string): Azure machine type i.e GP_Gen5_4 Returns: (string, string, string): edition, family, vcore Raises: UnsupportedError: if the machine ty...
Returns a tuple of (edition, family, vcore) from Azure machine type. Args: machine_type (string): Azure machine type i.e GP_Gen5_4 Returns: (string, string, string): edition, family, vcore Raises: UnsupportedError: if the machine type is not supported.
GetConfigFromMachineType
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_relational_db.py
Apache-2.0
def _CreateMySqlOrPostgresInstance(self): """Creates a managed MySql or Postgres instance.""" if not self.spec.high_availability: raise KeyError( 'Azure databases can only be used in high ' 'availability. Please rerurn with flag ' '--db_high_availability=True' ) # ...
Creates a managed MySql or Postgres instance.
_CreateMySqlOrPostgresInstance
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_relational_db.py
Apache-2.0
def _CreateAzureManagedSqlInstance(self): """Creates an Azure Sql Instance from a managed service.""" if self.engine_type == sql_engine_utils.POSTGRES: self._CreateMySqlOrPostgresInstance() elif self.engine_type == sql_engine_utils.MYSQL: self._CreateMySqlOrPostgresInstance() elif self.engin...
Creates an Azure Sql Instance from a managed service.
_CreateAzureManagedSqlInstance
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_relational_db.py
Apache-2.0
def _AzServerShow(self): """Runs the azure command az server show. Returns: json object representing holding the of the show command on success. None for a non 0 retcode. A non 0 retcode can occur if queried before the database has finished being created. """ cmd = [ azure.AZ...
Runs the azure command az server show. Returns: json object representing holding the of the show command on success. None for a non 0 retcode. A non 0 retcode can occur if queried before the database has finished being created.
_AzServerShow
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_relational_db.py
Apache-2.0
def _SetEndpoint(self): """Assigns the ports and endpoints from the instance_id to self. These will be used to communicate with the database. Called during _PostCreate(). """ server_show_json = self._AzServerShow() self.endpoint = server_show_json['fullyQualifiedDomainName']
Assigns the ports and endpoints from the instance_id to self. These will be used to communicate with the database. Called during _PostCreate().
_SetEndpoint
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_relational_db.py
Apache-2.0
def _IsDeleting(self): """Overrides BaseResource._IsDeleting. Used internally while deleting to check if the deletion is still in progress. Returns: A bool. True if the resource is not yet deleted, else False. """ return ( self._NamespaceExists() or self._TopicExists() ...
Overrides BaseResource._IsDeleting. Used internally while deleting to check if the deletion is still in progress. Returns: A bool. True if the resource is not yet deleted, else False.
_IsDeleting
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_service_bus.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_service_bus.py
Apache-2.0
def _TopicExists(self) -> bool: """Checks whether Service Bus topic already exists.""" cmd = [ azure.AZURE_PATH, 'servicebus', 'topic', 'show', '--name', self.topic_name, '--namespace-name', self.namespace_name, ] + self.resource_group.args ...
Checks whether Service Bus topic already exists.
_TopicExists
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_service_bus.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_service_bus.py
Apache-2.0
def _SubscriptionExists(self) -> bool: """Checks whether Service Bus subscription already exists.""" cmd = [ azure.AZURE_PATH, 'servicebus', 'topic', 'subscription', 'show', '--name', self.subscription_name, '--topic-name', self.topic_name,...
Checks whether Service Bus subscription already exists.
_SubscriptionExists
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_service_bus.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_service_bus.py
Apache-2.0
def _CreateNamespace(self): """Creates an Azure Service Bus Namespace.""" cmd = [ azure.AZURE_PATH, 'servicebus', 'namespace', 'create', '--name', self.namespace_name, '--location', self.location, ] + self.resource_group.args vm_util.IssueC...
Creates an Azure Service Bus Namespace.
_CreateNamespace
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_service_bus.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_service_bus.py
Apache-2.0
def _NamespaceExists(self) -> bool: """Checks if our Service Bus Namespace exists.""" cmd = [ azure.AZURE_PATH, 'servicebus', 'namespace', 'show', '--name', self.namespace_name, ] + self.resource_group.args _, _, retcode = vm_util.IssueCommand(cmd, raise_o...
Checks if our Service Bus Namespace exists.
_NamespaceExists
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_service_bus.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_service_bus.py
Apache-2.0
def _DeleteNamespace(self): """Deletes the Azure Service Bus namespace.""" cmd = [ azure.AZURE_PATH, 'servicebus', 'namespace', 'delete', '--name', self.namespace_name, ] + self.resource_group.args vm_util.IssueCommand(cmd, raise_on_failure=False)
Deletes the Azure Service Bus namespace.
_DeleteNamespace
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_service_bus.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_service_bus.py
Apache-2.0
def _GetPrimaryConnectionString(self): """Gets Azure Service Bus Namespace connection string.""" cmd = [ azure.AZURE_PATH, 'servicebus', 'namespace', 'authorization-rule', 'keys', 'list', '--name=RootManageSharedAccessKey', '--namespace-name', ...
Gets Azure Service Bus Namespace connection string.
_GetPrimaryConnectionString
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_service_bus.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_service_bus.py
Apache-2.0
def _Create(self): """Creates an Azure Files share. For Standard Files, see https://docs.microsoft.com/en-us/azure/storage/files/storage-how-to-create-file-share#create-file-share-through-command-line-interface-cli and for Premium Files, see https://docs.microsoft.com/en-us/azure/storage/files/stor...
Creates an Azure Files share. For Standard Files, see https://docs.microsoft.com/en-us/azure/storage/files/storage-how-to-create-file-share#create-file-share-through-command-line-interface-cli and for Premium Files, see https://docs.microsoft.com/en-us/azure/storage/files/storage-how-to-create-premium-...
_Create
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_smb_service.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_smb_service.py
Apache-2.0
def GetSqlDataWarehouseClientInterface( server_name: str, database: str, user: str, password: str, resource_group: str, ) -> edw_service.EdwClientInterface: """Builds and Returns the requested SqlDataWarehouse client Interface. Args: server_name: Name of the SqlDataWarehouse server to use. ...
Builds and Returns the requested SqlDataWarehouse client Interface. Args: server_name: Name of the SqlDataWarehouse server to use. database: Name of the database to run queries against. user: SqlDataWarehouse username for authentication. password: SqlDataWarehouse password for authentication. res...
GetSqlDataWarehouseClientInterface
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_sql_data_warehouse.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_sql_data_warehouse.py
Apache-2.0
def Prepare(self, package_name: str) -> None: """Prepares the client vm to execute query. Installs the sql server tool dependencies. Args: package_name: String name of the package defining the preprovisioned data (certificates, etc.) to extract and use during client vm preparation. """ ...
Prepares the client vm to execute query. Installs the sql server tool dependencies. Args: package_name: String name of the package defining the preprovisioned data (certificates, etc.) to extract and use during client vm preparation.
Prepare
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_sql_data_warehouse.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_sql_data_warehouse.py
Apache-2.0
def WhitelistIPAddress(self, ip_address): """To whitelist the IP address on the cluster.""" self.whitelist_ip = ip_address cmd = [ azure.AZURE_PATH, 'sql', 'server', 'firewall-rule', 'create', '--name', self.whitelist_ip, '--resource-group', ...
To whitelist the IP address on the cluster.
WhitelistIPAddress
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_sql_data_warehouse.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_sql_data_warehouse.py
Apache-2.0
def _Exists(self): """Method to validate the existence of cluster. Returns: Boolean value indicating the existence of a cluster. """ stdout, _, _ = self.__DescribeCluster() if not stdout or (json.loads(stdout)['status'] not in VALID_EXIST_STATUSES): return False else: return T...
Method to validate the existence of cluster. Returns: Boolean value indicating the existence of a cluster.
_Exists
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_sql_data_warehouse.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_sql_data_warehouse.py
Apache-2.0
def _IsDeleting(self): """Method to check if the cluster is pausing.""" stdout, _, _ = self.__DescribeCluster() if not stdout: return False else: return json.loads(stdout)['status'] in PAUSING_STATUSES
Method to check if the cluster is pausing.
_IsDeleting
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_sql_data_warehouse.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_sql_data_warehouse.py
Apache-2.0
def _GetSkuType(machine_type): """Returns the host SKU type derived from the VM machine type.""" # TODO(user): add support for FSv2 machine types when no longer in preview # https://docs.microsoft.com/en-us/azure/virtual-machines/windows/dedicated-hosts sku = '' assert isinstance(machine_type, str) if re.ma...
Returns the host SKU type derived from the VM machine type.
_GetSkuType
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_virtual_machine.py
Apache-2.0
def _GetArmArch(machine_type) -> str | None: """Get the ARM architecture for the machine type.""" if _MachineTypeIsArm(machine_type): generation = util.GetMachineSeriesNumber(machine_type) if generation == 5: return 'neoverse-n1' elif generation == 6: return 'neoverse-n2' else: rai...
Get the ARM architecture for the machine type.
_GetArmArch
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_virtual_machine.py
Apache-2.0
def __init__(self, vm_spec): """Initialize an Azure virtual machine. Args: vm_spec: virtual_machine.BaseVmSpec object of the vm. """ super().__init__(vm_spec) # PKB zone can be either a region or a region with an availability zone. # Format for Azure availability zone support is "region-...
Initialize an Azure virtual machine. Args: vm_spec: virtual_machine.BaseVmSpec object of the vm.
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_virtual_machine.py
Apache-2.0
def _Exists(self): """Returns True if the VM exists.""" if self._deleted: return False show_cmd = [ azure.AZURE_PATH, 'vm', 'show', '--output', 'json', '--name', self.name, ] + self.resource_group.args stdout, _, _ = vm_util.IssueCommand(...
Returns True if the VM exists.
_Exists
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_virtual_machine.py
Apache-2.0
def DownloadPreprovisionedData( self, install_path, module_name, filename, timeout=virtual_machine.PREPROVISIONED_DATA_TIMEOUT, ): """Downloads a data file from Azure blob storage with pre-provisioned data. Use --azure_preprovisioned_data_account to specify the name of the accou...
Downloads a data file from Azure blob storage with pre-provisioned data. Use --azure_preprovisioned_data_account to specify the name of the account. Note: Azure blob storage does not allow underscores in the container name, so this method replaces any underscores in module_name with dashes. Make sure ...
DownloadPreprovisionedData
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/azure_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/azure_virtual_machine.py
Apache-2.0
def _Exists(self): """Returns True if the service principal exists.""" # Use show rather than list, because list requires admin privileges. cmd = [azure.AZURE_PATH, 'ad', 'sp', 'show', '--id', self.app_id] try: vm_util.IssueCommand(cmd, raise_on_failure=True) return True except errors.Vm...
Returns True if the service principal exists.
_Exists
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/service_principal.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/service_principal.py
Apache-2.0
def GetZonesInRegion(region: str) -> Set[str]: """Returns a set of zones in the region.""" # As of 2021 all Azure AZs are numbered 1-3 for eligible regions. return {f'{region}-{i}' for i in range(1, 4)}
Returns a set of zones in the region.
GetZonesInRegion
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/util.py
Apache-2.0
def ShouldKeepZoneFromCLI(zone: str) -> bool: """Filter out zones that we can't access.""" if 'EUAP' in zone: return False return True
Filter out zones that we can't access.
ShouldKeepZoneFromCLI
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/util.py
Apache-2.0
def GetZonesFromMachineType(machine_type: str) -> Set[str]: """Returns a set of zones for a machine type.""" stdout, _ = vm_util.IssueRetryableCommand( [AZURE_PATH, 'vm', 'list-skus', '--size', machine_type] ) zones = set() for item in json.loads(stdout): for location_info in item['locationInfo']: ...
Returns a set of zones for a machine type.
GetZonesFromMachineType
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/util.py
Apache-2.0
def GetGeoFromRegion(region: str) -> str: """Gets valid geo from the region, i.e. region westus2 returns US.""" stdout, _ = vm_util.IssueRetryableCommand([ AZURE_PATH, 'account', 'list-locations', '--output', 'json', '--query', f"[?name == '{region}'].metadata.geographyGrou...
Gets valid geo from the region, i.e. region westus2 returns US.
GetGeoFromRegion
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/util.py
Apache-2.0
def GetRegionsInGeo(geo: str) -> Set[str]: """Gets valid regions in the geo.""" stdout, _ = vm_util.IssueRetryableCommand([ AZURE_PATH, 'account', 'list-locations', '--output', 'json', '--query', f"[?metadata.geographyGroup == '{geo}']", ]) return { item['name'] f...
Gets valid regions in the geo.
GetRegionsInGeo
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/util.py
Apache-2.0
def GetAvailabilityZoneFromZone(zone_or_region): """Returns the Availability Zone from a zone.""" if IsZone(zone_or_region): return zone_or_region[-1] if _IsRegion(zone_or_region): return None raise ValueError('%s is not a valid Azure zone' % zone_or_region)
Returns the Availability Zone from a zone.
GetAvailabilityZoneFromZone
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/util.py
Apache-2.0
def GetMachineFamily(machine_type): """Returns the machine family of a machine type. The family is the machine type with the number of vCPUs removed, hence all machines from the same series shows up as having the same family. See testGetMachineFamily in azure_util_test.py for examples. Args: machine_typ...
Returns the machine family of a machine type. The family is the machine type with the number of vCPUs removed, hence all machines from the same series shows up as having the same family. See testGetMachineFamily in azure_util_test.py for examples. Args: machine_type: Azure machine type
GetMachineFamily
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/util.py
Apache-2.0
def GetMachineSeriesNumber(machine_type: str) -> int: """Returns the series numberof a machine type. Not to be confused with the boot architecture generation number. https://learn.microsoft.com/en-us/azure/virtual-machines/generation-2 Args: machine_type: Azure machine type """ match = re.search(r'_v(...
Returns the series numberof a machine type. Not to be confused with the boot architecture generation number. https://learn.microsoft.com/en-us/azure/virtual-machines/generation-2 Args: machine_type: Azure machine type
GetMachineSeriesNumber
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/azure/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/azure/util.py
Apache-2.0
def Attach(self, vm): """Attaches the disk to a VM. Args: vm: The CloudStackVirtualMachine instance to which the disk will be attached. """ res = self.cs.attach_volume(self.volume_id, vm.id) assert res, 'Unable to attach volume' self.device_id = res['deviceid'] self.device_...
Attaches the disk to a VM. Args: vm: The CloudStackVirtualMachine instance to which the disk will be attached.
Attach
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/cloudstack/cloudstack_disk.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/cloudstack/cloudstack_disk.py
Apache-2.0
def _GetBestOfferingId(self, disk_size): """Given a disk_size (in GB), try to find a disk offering that is atleast as big as the requested one. """ disk_offerings = self.cs.list_disk_offerings() sorted_do = sorted(disk_offerings, key=lambda x: x['disksize']) for do in sorted_do: if ...
Given a disk_size (in GB), try to find a disk offering that is atleast as big as the requested one.
_GetBestOfferingId
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/cloudstack/cloudstack_disk.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/cloudstack/cloudstack_disk.py
Apache-2.0
def __init__(self, vm_spec): """Initialize a CloudStack virtual machine. Args: vm_spec: virtual_machine.BaseVirtualMachineSpec object of the vm. """ super().__init__(vm_spec) self.network = cloudstack_network.CloudStackNetwork.GetNetwork(self) self.cs = util.CsClient( FLAGS.CS_AP...
Initialize a CloudStack virtual machine. Args: vm_spec: virtual_machine.BaseVirtualMachineSpec object of the vm.
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/cloudstack/cloudstack_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/cloudstack/cloudstack_virtual_machine.py
Apache-2.0
def __init__(self, vm_spec): """Initialize a DigitalOcean virtual machine. Args: vm_spec: virtual_machine.BaseVirtualMachineSpec object of the vm. """ super().__init__(vm_spec) self.droplet_id = None self.max_local_disks = 1 self.local_disk_counter = 0 self.image = self.image or s...
Initialize a DigitalOcean virtual machine. Args: vm_spec: virtual_machine.BaseVirtualMachineSpec object of the vm.
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/digitalocean/digitalocean_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/digitalocean/digitalocean_virtual_machine.py
Apache-2.0
def DoctlAndParse(arg_list): """Run a doctl command and parse the output. Args: arg_list: a list of arguments for doctl. Will be formated with str() before being sent to the process. Returns: A tuple of - doctl's JSON output, pre-parsed, or None if output is empty. - doctl's return cod...
Run a doctl command and parse the output. Args: arg_list: a list of arguments for doctl. Will be formated with str() before being sent to the process. Returns: A tuple of - doctl's JSON output, pre-parsed, or None if output is empty. - doctl's return code Raises: errors.VmUtil.Cal...
DoctlAndParse
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/digitalocean/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/digitalocean/util.py
Apache-2.0
def _FormatCreateCommand(self): """Formats the command for Docker based on vm_spec and flags.""" create_command = ['docker', 'run', '-d', '--name', self.name] # format scratch disks for vol in self.scratch_disks: vol_string = vol.volume_name + ':' + vol.mount_point create_command.append('-...
Formats the command for Docker based on vm_spec and flags.
_FormatCreateCommand
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/docker/docker_container_instance.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/docker/docker_container_instance.py
Apache-2.0
def _PostCreate(self): """Prepares running container. Gets the IP address, copies public keys, and configures the proxy if one is specified """ self._GetIpAddresses() # Copy ssh key to container to enable ssh login copy_ssh_command = [ 'docker', 'cp', self.ssh_publi...
Prepares running container. Gets the IP address, copies public keys, and configures the proxy if one is specified
_PostCreate
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/docker/docker_container_instance.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/docker/docker_container_instance.py
Apache-2.0
def _Exists(self): """Returns whether the container is up and running.""" info, return_code = self._GetContainerInfo() logging.info('Checking if Docker Container Exists') if info and return_code == 0: status = info[0]['State']['Running'] if status: logging.info('Docker Container %s...
Returns whether the container is up and running.
_Exists
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/docker/docker_container_instance.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/docker/docker_container_instance.py
Apache-2.0
def _GetIpAddresses(self): """Sets the internal and external IP address for the Container.""" info, return_code = self._GetContainerInfo() ip = False if info and return_code == 0: ip = info[0]['NetworkSettings']['IPAddress'].encode('ascii') logging.info('IP: %s', ip) self.ip_address =...
Sets the internal and external IP address for the Container.
_GetIpAddresses
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/docker/docker_container_instance.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/docker/docker_container_instance.py
Apache-2.0
def _GetContainerInfo(self): """Returns information about a container. Gets Container information from Docker Inspect. Returns the information, if there is any and a return code. 0 """ logging.info('Checking Container Information') inspect_cmd = ['docker', 'inspect', self.name] info, _, ret...
Returns information about a container. Gets Container information from Docker Inspect. Returns the information, if there is any and a return code. 0
_GetContainerInfo
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/docker/docker_container_instance.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/docker/docker_container_instance.py
Apache-2.0
def _ConfigureProxy(self): """Configure network proxy for Docker Container. In Docker containers environment variables from /etc/environment are not sourced - this results in connection problems when running behind proxy. Prepending proxy environment variables to bashrc solves the problem. Note: AP...
Configure network proxy for Docker Container. In Docker containers environment variables from /etc/environment are not sourced - this results in connection problems when running behind proxy. Prepending proxy environment variables to bashrc solves the problem. Note: APPENDING to bashrc will not work be...
_ConfigureProxy
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/docker/docker_container_instance.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/docker/docker_container_instance.py
Apache-2.0
def _BuildVolumesBody(self): """Construct volumes-related part of create command for Docker Container.""" volumes = [] for scratch_disk in self.scratch_disks: vol_string = scratch_disk.volume_name + ':' + scratch_disk.mount_point volumes.append('-v') volumes.append(vol_string) return...
Construct volumes-related part of create command for Docker Container.
_BuildVolumesBody
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/docker/docker_container_instance.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/docker/docker_container_instance.py
Apache-2.0
def _LocalImageExists(self, docker_image_name): """Returns whether a Docker image exists locally.""" inspect_cmd = ['docker', 'image', 'inspect', docker_image_name] info, _, return_code = vm_util.IssueCommand( inspect_cmd, raise_on_failure=False ) info = json.loads(info) logging.info('Ch...
Returns whether a Docker image exists locally.
_LocalImageExists
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/docker/docker_container_instance.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/docker/docker_container_instance.py
Apache-2.0
def _BuildImageLocally(self): """Build Container Image Locally. Dockerfiles located at PerfKitBenchmarker/data/docker/pkb/<containerImage>/Dockerfile """ directory = os.path.dirname( data.ResourcePath( os.path.join( DOCKERFILE_DIRECTORY, self.container_image, 'Do...
Build Container Image Locally. Dockerfiles located at PerfKitBenchmarker/data/docker/pkb/<containerImage>/Dockerfile
_BuildImageLocally
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/docker/docker_container_instance.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/docker/docker_container_instance.py
Apache-2.0
def ApplySysctlPersistent(self, sysctl_params): """Override ApplySysctlPeristent function for Docker provider. Parent function causes errors with Docker because it shutdowns container Args: sysctl_params: dict - the keys and values to write """ logging.warn( 'sysctl flags are applied ...
Override ApplySysctlPeristent function for Docker provider. Parent function causes errors with Docker because it shutdowns container Args: sysctl_params: dict - the keys and values to write
ApplySysctlPersistent
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/docker/docker_container_instance.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/docker/docker_container_instance.py
Apache-2.0
def GetBigQueryClientInterface( project_id: str, dataset_id: str ) -> GenericClientInterface: """Builds and Returns the requested BigQuery client Interface. Args: project_id: String name of the BigQuery project to benchmark dataset_id: String name of the BigQuery dataset to benchmark Returns: A ...
Builds and Returns the requested BigQuery client Interface. Args: project_id: String name of the BigQuery project to benchmark dataset_id: String name of the BigQuery dataset to benchmark Returns: A concrete Client Interface object (subclass of GenericClientInterface) Raises: RuntimeError: if a...
GetBigQueryClientInterface
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/bigquery.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/bigquery.py
Apache-2.0
def Prepare(self, package_name: str) -> None: """Prepares the client vm to execute query. Installs the bq tool dependencies and authenticates using a service account. Args: package_name: String name of the package defining the preprovisioned data (certificates, etc.) to extract and use durin...
Prepares the client vm to execute query. Installs the bq tool dependencies and authenticates using a service account. Args: package_name: String name of the package defining the preprovisioned data (certificates, etc.) to extract and use during client vm preparation.
Prepare
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/bigquery.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/bigquery.py
Apache-2.0
def Prepare(self, package_name: str) -> None: """Prepares the client vm to execute query. Installs a) Java Execution Environment, b) BigQuery Authnetication Credentials, c) JDBC Application to execute a query and gather execution details, d) Simba JDBC BigQuery client code dependencencies, and ...
Prepares the client vm to execute query. Installs a) Java Execution Environment, b) BigQuery Authnetication Credentials, c) JDBC Application to execute a query and gather execution details, d) Simba JDBC BigQuery client code dependencencies, and e) The Simba JDBC interface jar Args: ...
Prepare
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/bigquery.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/bigquery.py
Apache-2.0
def Prepare(self, package_name: str) -> None: """Prepares the client vm to execute query. Installs the Java Execution Environment and a uber jar with a) BigQuery Java client libraries, b) An application to execute a query and gather execution details, and c) their dependencies. Args: pac...
Prepares the client vm to execute query. Installs the Java Execution Environment and a uber jar with a) BigQuery Java client libraries, b) An application to execute a query and gather execution details, and c) their dependencies. Args: package_name: String name of the package defining the pr...
Prepare
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/bigquery.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/bigquery.py
Apache-2.0
def Prepare(self, package_name: str) -> None: """Prepares the client vm to execute query.""" # Push the service account file to the working directory on client vm if '/' in FLAGS.gcp_service_account_key_file: self.client_vm.PushFile(FLAGS.gcp_service_account_key_file) else: self.client_vm.In...
Prepares the client vm to execute query.
Prepare
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/bigquery.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/bigquery.py
Apache-2.0
def ExecuteQuery( self, query_name: str, print_results: bool = False ) -> tuple[float, dict[str, Any]]: """Executes a query and returns performance details.""" cmd = ( f'.venv/bin/python {BQ_PYTHON_CLIENT_FILE} single --project' f' {self.project_id} --credentials_file {self.key_file_name...
Executes a query and returns performance details.
ExecuteQuery
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/bigquery.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/bigquery.py
Apache-2.0
def ExecuteThroughput( self, concurrency_streams: list[list[str]], labels: dict[str, str] | None = None, ) -> str: """Executes queries simultaneously on client and return performance details.""" cmd = ( f'.venv/bin/python {BQ_PYTHON_CLIENT_FILE} throughput --project' f' {self...
Executes queries simultaneously on client and return performance details.
ExecuteThroughput
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/bigquery.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/bigquery.py
Apache-2.0
def RunQueryWithResults(self, query_name: str) -> str: """Executes a query and returns performance details and query output.""" cmd = ( f'.venv/bin/python {BQ_PYTHON_CLIENT_FILE} single --project' f' {self.project_id} --credentials_file {self.key_file_name} --dataset' f' {self.dataset_id...
Executes a query and returns performance details and query output.
RunQueryWithResults
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/bigquery.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/bigquery.py
Apache-2.0
def GetMetadata(self): """Return a dictionary of the metadata for the BigQuery cluster.""" basic_data = super().GetMetadata() basic_data.update(self.client_interface.GetMetadata()) return basic_data
Return a dictionary of the metadata for the BigQuery cluster.
GetMetadata
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/bigquery.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/bigquery.py
Apache-2.0
def FormatProjectAndDatasetForCommand(self, dataset=None): """Returns the project and dataset in the format needed for bq commands. E.g., project:dataset. Args: dataset: The dataset to run commands against. If None, extracts the dataset from the cluster identifier whose format is "project.da...
Returns the project and dataset in the format needed for bq commands. E.g., project:dataset. Args: dataset: The dataset to run commands against. If None, extracts the dataset from the cluster identifier whose format is "project.dataset").
FormatProjectAndDatasetForCommand
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/bigquery.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/bigquery.py
Apache-2.0
def GetDatasetLastUpdatedTime(self, dataset=None): """Get the formatted last modified timestamp of the dataset.""" cmd = [ 'bq', 'show', '--format=prettyjson', self.FormatProjectAndDatasetForCommand(dataset), ] dataset_metadata, _, _ = vm_util.IssueCommand(cmd) metada...
Get the formatted last modified timestamp of the dataset.
GetDatasetLastUpdatedTime
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/bigquery.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/bigquery.py
Apache-2.0
def GetAllTablesInDataset(self, dataset=None): """Returns a list of the IDs of all the tables in the dataset.""" cmd = [ 'bq', 'ls', '--format=prettyjson', self.FormatProjectAndDatasetForCommand(dataset), ] tables_list, _, _ = vm_util.IssueCommand(cmd) all_tables = []...
Returns a list of the IDs of all the tables in the dataset.
GetAllTablesInDataset
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/bigquery.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/bigquery.py
Apache-2.0
def ExtractDataset( self, dest_bucket, dataset=None, tables=None, dest_format='CSV' ): """Extract all tables in a dataset to a GCS bucket. Args: dest_bucket: Name of the bucket to extract the data to. Should already exist. dataset: Optional name of the dataset. If none, will be extr...
Extract all tables in a dataset to a GCS bucket. Args: dest_bucket: Name of the bucket to extract the data to. Should already exist. dataset: Optional name of the dataset. If none, will be extracted from the cluster_identifier. tables: Optional list of table names to extract. If n...
ExtractDataset
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/bigquery.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/bigquery.py
Apache-2.0
def RemoveDataset(self, dataset=None): """Removes a dataset. See https://cloud.google.com/bigquery/docs/managing-tables#deleting_tables Args: dataset: Optional name of the dataset. If none, will be extracted from the cluster_identifier. """ project_dataset = self.FormatProjectAndData...
Removes a dataset. See https://cloud.google.com/bigquery/docs/managing-tables#deleting_tables Args: dataset: Optional name of the dataset. If none, will be extracted from the cluster_identifier.
RemoveDataset
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/bigquery.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/bigquery.py
Apache-2.0
def CreateDataset(self, dataset=None, description=None): """Creates a new dataset. See https://cloud.google.com/bigquery/docs/tables Args: dataset: Optional name of the dataset. If none, will be extracted from the cluster_identifier. description: Optional description of the dataset. Es...
Creates a new dataset. See https://cloud.google.com/bigquery/docs/tables Args: dataset: Optional name of the dataset. If none, will be extracted from the cluster_identifier. description: Optional description of the dataset. Escape double quotes.
CreateDataset
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/bigquery.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/bigquery.py
Apache-2.0
def GetDatasetRegion(self, dataset=None): """Get the region that a dataset resides in.""" cmd = [ 'bq', 'show', '--format=prettyjson', self.FormatProjectAndDatasetForCommand(dataset), ] dataset_metadata, _, _ = vm_util.IssueCommand(cmd) metadata_json = json.loads(str(...
Get the region that a dataset resides in.
GetDatasetRegion
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/bigquery.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/bigquery.py
Apache-2.0
def GetMetadata(self) -> dict[str, str]: """Return a dictionary of the metadata for the BigQuery Endor service. Returns: A dictionary set to Endor service details. """ basic_data = super().GetMetadata() basic_data['edw_service_type'] = 'endor' basic_data.update(self.client_interface.GetMe...
Return a dictionary of the metadata for the BigQuery Endor service. Returns: A dictionary set to Endor service details.
GetMetadata
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/bigquery.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/bigquery.py
Apache-2.0
def GetDataDetails(self) -> dict[str, str]: """Returns a dictionary with underlying data details. cluster_identifier = <project_id>.<dataset_id> Data details are extracted from the dataset_id that follows the format: <dataset>_<format>_<compression>_<partitioning>_<location> eg. tpch100_parquet...
Returns a dictionary with underlying data details. cluster_identifier = <project_id>.<dataset_id> Data details are extracted from the dataset_id that follows the format: <dataset>_<format>_<compression>_<partitioning>_<location> eg. tpch100_parquet_uncompressed_unpartitoned_s3 Returns: A...
GetDataDetails
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/bigquery.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/bigquery.py
Apache-2.0
def GetMetadata(self) -> dict[str, str]: """Return a dictionary of the metadata for the BigQuery Endor Azure service. Returns: A dictionary set to Endor Azure service details. """ basic_data = super().GetMetadata() basic_data['edw_service_type'] = 'endorazure' return basic_data
Return a dictionary of the metadata for the BigQuery Endor Azure service. Returns: A dictionary set to Endor Azure service details.
GetMetadata
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/bigquery.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/bigquery.py
Apache-2.0
def GetMetadata(self) -> dict[str, str]: """Return a dictionary of the metadata for the BigQuery Federated service. Returns: A dictionary set to Federated service details. """ basic_data = super().GetMetadata() basic_data['edw_service_type'] = self.SERVICE_TYPE basic_data.update(self.clie...
Return a dictionary of the metadata for the BigQuery Federated service. Returns: A dictionary set to Federated service details.
GetMetadata
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/bigquery.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/bigquery.py
Apache-2.0
def GetDataDetails(self) -> dict[str, str]: """Returns a dictionary with underlying data details. cluster_identifier = <project_id>.<dataset_id> Data details are extracted from the dataset_id which follows one of these three formats: <dataset>_<format>_<compression>_<partitioning>_<location> o...
Returns a dictionary with underlying data details. cluster_identifier = <project_id>.<dataset_id> Data details are extracted from the dataset_id which follows one of these three formats: <dataset>_<format>_<compression>_<partitioning>_<location> or <dataset>_<format>_<compression>_<partitionin...
GetDataDetails
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/bigquery.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/bigquery.py
Apache-2.0
def _Exists(self) -> bool: """Method to validate the existence of a Bigquery cluster. Returns: Boolean value indicating the existence of a cluster. """ if self.compute_resource_identifier is None: return False cmd = [ 'bq', 'ls', '--format=prettyjson', '-...
Method to validate the existence of a Bigquery cluster. Returns: Boolean value indicating the existence of a cluster.
_Exists
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/bigquery_slot_resource.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/bigquery_slot_resource.py
Apache-2.0
def _GetDefaultLocation(self) -> str: """Gets the config that corresponds the region used for the test.""" return ( util.GetRegionFromZone(FLAGS.zone[0]) if FLAGS.zone else _DEFAULT_LOCATION )
Gets the config that corresponds the region used for the test.
_GetDefaultLocation
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/firestore.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/firestore.py
Apache-2.0
def _Exists(self) -> bool: """Returns true if the database exists.""" database = self._DescribeDatabase() if not database: return False return 'createTime' in database
Returns true if the database exists.
_Exists
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/firestore.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/firestore.py
Apache-2.0
def PdDriveIsNvme(vm): """Check if the machine uses NVMe for PD.""" machine_type = vm.machine_type family = machine_type.split('-')[0].lower() if family in NVME_PD_MACHINE_FAMILIES: return True # In other cases, only a sub-category of a family uses nvme, # such as confidential VMs on Milan. # this is ...
Check if the machine uses NVMe for PD.
PdDriveIsNvme
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_disk.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_disk.py
Apache-2.0
def AddLabels(gcp_resource: resource.BaseResource, disk_name: str): """Add labels to a disk created by a service that fails to label a disk. Disks created by PKB (and most services) are labeled at create time. Args: gcp_resource: a resource with the project and zone of the disk. disk_name: the name of t...
Add labels to a disk created by a service that fails to label a disk. Disks created by PKB (and most services) are labeled at create time. Args: gcp_resource: a resource with the project and zone of the disk. disk_name: the name of the disk
AddLabels
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_disk.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_disk.py
Apache-2.0
def _Describe(self): """Returns json describing the disk or None on failure.""" cmd = util.GcloudCommand(self, 'compute', 'disks', 'describe', self.name) if self.replica_zones: cmd.flags['region'] = self.region del cmd.flags['zone'] stdout, _, _ = cmd.Issue(raise_on_failure=False) try:...
Returns json describing the disk or None on failure.
_Describe
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_disk.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_disk.py
Apache-2.0
def _IsReady(self): """Returns true if the disk is ready.""" result = self._Describe() if not result: return False return result.get('status') == 'READY'
Returns true if the disk is ready.
_IsReady
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_disk.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_disk.py
Apache-2.0
def _Attach(self, vm): """Attaches the disk to a VM. Args: vm: The GceVirtualMachine instance to which the disk will be attached. Raises: GceServiceUnavailableError: when the service is not available """ self.attached_vm_name = vm.name cmd = util.GcloudCommand( self, 'compu...
Attaches the disk to a VM. Args: vm: The GceVirtualMachine instance to which the disk will be attached. Raises: GceServiceUnavailableError: when the service is not available
_Attach
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_disk.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_disk.py
Apache-2.0
def DiskCreatedOnVMCreation(self) -> bool: """Returns whether the disk is created on VM creation.""" if self.disk_spec.replica_zones or self.disk_spec.multi_writer_mode: # GCE regional disks cannot use create-on-create. return False return self.disk_spec.create_with_vm
Returns whether the disk is created on VM creation.
DiskCreatedOnVMCreation
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_disk_strategies.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_disk_strategies.py
Apache-2.0
def FindRemoteNVMEDevices(self, nvme_devices): """Find the paths for all remote NVME devices inside the VM.""" remote_nvme_devices = [ device['DevicePath'] for device in nvme_devices if device['ModelNumber'] == 'nvme_card-pd' ] return sorted(remote_nvme_devices)
Find the paths for all remote NVME devices inside the VM.
FindRemoteNVMEDevices
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_disk_strategies.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_disk_strategies.py
Apache-2.0
def UpdateDevicePath(self, scratch_disk, remote_nvme_devices): """Updates the paths for all remote NVME devices inside the VM.""" if isinstance(scratch_disk, disk.StripedDisk): disks = scratch_disk.disks else: disks = [scratch_disk] # round robin assignment since we cannot tell the disks ap...
Updates the paths for all remote NVME devices inside the VM.
UpdateDevicePath
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_disk_strategies.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_disk_strategies.py
Apache-2.0
def _GenerateDiskNamePrefix( vm: 'virtual_machine. BaseVirtualMachine', group_name: str, disk_spec_id: int, is_multiwriter: bool, index: int, ) -> str: """Generates a deterministic disk name given disk_spec_id and index.""" if is_multiwriter: # if group_name is not specified, use the vm_grou...
Generates a deterministic disk name given disk_spec_id and index.
_GenerateDiskNamePrefix
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_disk_strategies.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_disk_strategies.py
Apache-2.0
def ConfigureTunnel(self, tunnel_config: vpn_service.TunnelConfig): """Updates tunnel config with new information. Args: tunnel_config: The tunnel configuration for this VPN. """ logging.debug('Configuring Tunnel with params:') logging.debug(tunnel_config) # update tunnel_config if neede...
Updates tunnel config with new information. Args: tunnel_config: The tunnel configuration for this VPN.
ConfigureTunnel
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py
Apache-2.0
def _SetupTunnel(self, tunnel_config: vpn_service.TunnelConfig): """Register a new GCE VPN tunnel for this endpoint. Args: tunnel_config: VPN tunnel configuration. """ target_endpoint = [ k for k in tunnel_config.endpoints.keys() if k not in self.name ][0] project = tunnel_config....
Register a new GCE VPN tunnel for this endpoint. Args: tunnel_config: VPN tunnel configuration.
_SetupTunnel
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py
Apache-2.0
def _SetupForwarding(self, tunnel_config: vpn_service.TunnelConfig): """Create IPSec forwarding rules. Forwards ESP protocol, and UDP 500/4500 for tunnel setup. Args: tunnel_config: The tunnel configuration for this VPN. """ if len(self.forwarding_rules) == 3: return # backout if alre...
Create IPSec forwarding rules. Forwards ESP protocol, and UDP 500/4500 for tunnel setup. Args: tunnel_config: The tunnel configuration for this VPN.
_SetupForwarding
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py
Apache-2.0
def _SetupRouting(self, suffix: str, next_hop_tun: str, dest_cidr: str): """Create IPSec routing rules between the source and target gateways.""" route_name = 'route-' + self.name + '-' + suffix if route_name not in self.routes: self.routes[route_name] = GceRoute( route_name, dest...
Create IPSec routing rules between the source and target gateways.
_SetupRouting
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py
Apache-2.0
def _Create(self): """Allocates a public IP for the VPN gateway.""" cmd = util.GcloudCommand(self, 'compute', 'addresses', 'create', self.name) cmd.flags['region'] = self.region if self.subnet is not None: cmd.flags['subnet'] = self.subnet cmd.Issue()
Allocates a public IP for the VPN gateway.
_Create
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py
Apache-2.0
def _Delete(self): """Deletes a public IP for the VPN gateway.""" cmd = util.GcloudCommand(self, 'compute', 'addresses', 'delete', self.name) cmd.flags['region'] = self.region cmd.Issue(raise_on_failure=False)
Deletes a public IP for the VPN gateway.
_Delete
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py
Apache-2.0
def _Exists(self) -> bool: """Returns True if the IP address exists.""" cmd = util.GcloudCommand( self, 'compute', 'addresses', 'describe', self.name ) cmd.flags['region'] = self.region _, _, retcode = cmd.Issue(raise_on_failure=False) return not retcode
Returns True if the IP address exists.
_Exists
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py
Apache-2.0
def _IsReady(self) -> bool: """Returns True if the IP address is reserved.""" cmd = util.GcloudCommand( self, 'compute', 'addresses', 'describe', self.name ) cmd.flags['region'] = self.region cmd.flags['format'] = 'value(status)' stdout, _, _ = cmd.Issue() return stdout.rstrip() == '...
Returns True if the IP address is reserved.
_IsReady
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py
Apache-2.0
def _Exists(self) -> bool: """Returns True if the tunnel exists.""" cmd = util.GcloudCommand( self, 'compute', 'vpn-tunnels', 'describe', self.name ) cmd.flags['region'] = self.region _, _, retcode = cmd.Issue(raise_on_failure=False) return not retcode
Returns True if the tunnel exists.
_Exists
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py
Apache-2.0
def _Exists(self) -> bool: """Returns True if the Route exists.""" cmd = util.GcloudCommand(self, 'compute', 'routes', 'describe', self.name) _, _, retcode = cmd.Issue(raise_on_failure=False) return not retcode
Returns True if the Route exists.
_Exists
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py
Apache-2.0
def __eq__(self, other: 'GceForwardingRule') -> bool: """Defines equality to make comparison easy.""" return ( self.name == other.name and self.protocol == other.protocol and self.port == other.port and self.target_name == other.target_name and self.target_ip == other.tar...
Defines equality to make comparison easy.
__eq__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py
Apache-2.0
def _Exists(self) -> bool: """Returns True if the Forwarding Rule exists.""" cmd = util.GcloudCommand( self, 'compute', 'forwarding-rules', 'describe', self.name ) cmd.flags['region'] = self.src_region _, _, retcode = cmd.Issue(raise_on_failure=False) return not retcode
Returns True if the Forwarding Rule exists.
_Exists
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py
Apache-2.0
def _Exists(self) -> bool: """Returns True if the Firewall Rule exists.""" cmd = util.GcloudCommand( self, 'compute', 'firewall-rules', 'describe', self.name ) _, _, retcode = cmd.Issue(raise_on_failure=False) return not retcode
Returns True if the Firewall Rule exists.
_Exists
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py
Apache-2.0
def GetFirewall(cls): """Decide whether to create a new firewall rule.""" if gcp_flags.GCE_NETWORK_NAMES.value: # It's fine if different callers get different instances. return network.ExistingNetworkFirewall( gcp_flags.GCE_NETWORK_NAMES.value[0] ) return super().GetFirewall()
Decide whether to create a new firewall rule.
GetFirewall
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py
Apache-2.0
def AllowPort( self, vm, # gce_virtual_machine.GceVirtualMachine start_port: int, end_port: int | None = None, source_range: list[str] | None = None, ): """Opens a port on the firewall. Args: vm: The BaseVirtualMachine object to open the port for. start_port: The fi...
Opens a port on the firewall. Args: vm: The BaseVirtualMachine object to open the port for. start_port: The first local port to open in a range. end_port: The last local port to open in a range. If None, only start_port will be opened. source_range: List of source CIDRs to allow for...
AllowPort
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py
Apache-2.0
def DisallowAllPorts(self): """Closes all ports on the firewall.""" for firewall_rule in self.firewall_rules.values(): firewall_rule.Delete() for firewall_rule in self.firewall_icmp_rules.values(): firewall_rule.Delete()
Closes all ports on the firewall.
DisallowAllPorts
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py
Apache-2.0
def __init__( self, project: str | None = None, zone: str | None = None, cidr: str | None = None, mtu: int | None = None, machine_type: str | None = None, subnet_names: List[str] | None = None, **kwargs, ): """Initializes the GceNetworkSpec. Args: project...
Initializes the GceNetworkSpec. Args: project: The project for which the Network should be created. zone: The zone for which the subnet and/or network should be created. cidr: The CIDR to use for the network. mtu: The MTU (max transmission unit) to use, if any. machine_type: The machi...
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py
Apache-2.0
def _Exists(self) -> bool: """Returns True if the Network resource exists.""" cmd = util.GcloudCommand(self, 'compute', 'networks', 'describe', self.name) _, _, retcode = cmd.Issue(raise_on_failure=False) return not retcode
Returns True if the Network resource exists.
_Exists
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py
Apache-2.0
def _GetAllFirewallRules(self) -> List[GceFirewallRule]: """Returns all the firewall rules that use the network.""" cmd = util.GcloudCommand(self, 'compute', 'firewall-rules', 'list') cmd.flags['filter'] = 'network=%s' % self.name stdout, _, _ = cmd.Issue() result = json.loads(stdout) return [ ...
Returns all the firewall rules that use the network.
_GetAllFirewallRules
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py
Apache-2.0
def UpdateProperties(self) -> None: """Updates the properties of the subnet resource.""" cmd = util.GcloudCommand( self, 'compute', 'networks', 'subnets', 'describe', self.name ) cmd.flags['region'] = self.region stdout, _, _ = cmd.Issue() json_details = json.loads(stdout) self.netwo...
Updates the properties of the subnet resource.
UpdateProperties
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gce_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py
Apache-2.0