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 CreateRule( self, sg, direction, ip_version, cidr_block, protocol, port, port_min=None, port_max=None, ) -> Dict[str, Any]: """Send a security group rule create request. Args: sg: security group. direction: in or outbound. ip_vers...
Send a security group rule create request. Args: sg: security group. direction: in or outbound. ip_version: ipv4 or 6. cidr_block: cidr_block. protocol: tcp or udp. port: port. port_min: port min. port_max: port max. Returns: returns request respon...
CreateRule
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def DeleteRule(self, sg, ruleid): """Send a security group rule delete request.""" sg_uri = self.GetUris(sg) + '/rules/' + ruleid return self._g.Request('DELETE', '%s' % sg_uri)
Send a security group rule delete request.
DeleteRule
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def Create(self, resource_group, vpcid, zone, **kwargs) -> Dict[str, Any]: # pytype: disable=signature-mismatch # overriding-parameter-count-checks """Construct and send a vm create request. Args: resource_group: optional. vpcid: vpc id. zone: zone name. **kwargs: name - name of the v...
Construct and send a vm create request. Args: resource_group: optional. vpcid: vpc id. zone: zone name. **kwargs: name - name of the vm. floating_ip - optional, floating ip id. Returns: returns created public gateways.
Create
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def Create(self, key, key_type, **kwargs) -> Dict[str, Any]: # pytype: disable=signature-mismatch # overriding-parameter-count-checks """Construct and send a ssh key create request. Args: key: public key string. key_type: rsa. **kwargs: name - name of the key: resource_group - optional. ...
Construct and send a ssh key create request. Args: key: public key string. key_type: rsa. **kwargs: name - name of the key: resource_group - optional. Returns: returns created key.
Create
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def Create(self, subnet, vpcid, **kwargs) -> Dict[str, Any]: # pytype: disable=signature-mismatch # overriding-parameter-count-checks """Construct and send a vm create request. Args: subnet: subnet vpcid: vpc id. **kwargs: name - name of the subnet. zone - zone name. ip_version - ipv4 ...
Construct and send a vm create request. Args: subnet: subnet vpcid: vpc id. **kwargs: name - name of the subnet. zone - zone name. ip_version - ipv4 or 6. ipv4_cidr_block - cidr for subnet. Returns: created subnet.
Create
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def ShowPg(self, subnet) -> Dict[str, Any]: """Send a subnet public gateway get request.""" uri = self.GetUri(subnet) + '/public_gateway' return self._g.Request('GET', uri)
Send a subnet public gateway get request.
ShowPg
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def AttachPg(self, subnet, pgid) -> Dict[str, Any]: """Send a subnet public gateway attach request.""" uri = self.GetUri(subnet) + '/public_gateway' req_data = {'id': pgid} return self._g.Request('PUT', uri, req_data)
Send a subnet public gateway attach request.
AttachPg
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def DeletePg(self, subnet): """Send a subnet public gateway delete request.""" uri = self.GetUri(subnet) + '/public_gateway' return self._g.Request('DELETE', uri)
Send a subnet public gateway delete request.
DeletePg
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def Create(self, href, osname, name=None) -> Dict[str, Any]: # pytype: disable=signature-mismatch # overriding-parameter-count-checks """Construct and send a vm create request. Args: href: href to the image. osname: os name. name: name of the image. Returns: created image. ...
Construct and send a vm create request. Args: href: href to the image. osname: os name. name: name of the image. Returns: created image.
Create
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def Create(self, resource_group, target, **kwargs) -> Dict[str, Any]: # pytype: disable=signature-mismatch # overriding-parameter-count-checks """Construct and send a vm create request. Args: resource_group: optional. target: id of the vm network interface. **kwargs: name - name of the f...
Construct and send a vm create request. Args: resource_group: optional. target: id of the vm network interface. **kwargs: name - name of the fip. zone - zone name. Returns: returns floating IP addresses.
Create
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def GetSubnetIndex(ipv4_cidr_block: str) -> int: """Finds the index for the given cidr. Args: ipv4_cidr_block: cidr to find. Returns: The index number of the found cidr as in the predefined list. -1 is returned if the cidr is not known and not found in the predefined list of subnets """ for ...
Finds the index for the given cidr. Args: ipv4_cidr_block: cidr to find. Returns: The index number of the found cidr as in the predefined list. -1 is returned if the cidr is not known and not found in the predefined list of subnets
GetSubnetIndex
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_network.py
Apache-2.0
def GetRouteCommands(data: str, index: int, target_index: int) -> List[str]: """Creates a list of ip route commands in text format to run on vm. List of IPs not used on normal perfkit runs. Args: data: output from route command on vm. index: subnet index. target_index: target subnet index. Return...
Creates a list of ip route commands in text format to run on vm. List of IPs not used on normal perfkit runs. Args: data: output from route command on vm. index: subnet index. target_index: target subnet index. Returns: The index number of the found cidr as in the predefined list
GetRouteCommands
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_network.py
Apache-2.0
def _Create(self): """Creates a IBM Cloud VPC with address prefixes for all zones.""" cmd = ibm.IbmAPICommand(self) cmd.flags['name'] = self.name logging.info('Creating vpc: %s', cmd.flags) self.vpcid = cmd.CreateVpc() if self.vpcid: for zone in FLAGS.zone: cmd.flags.update({'vpcid...
Creates a IBM Cloud VPC with address prefixes for all zones.
_Create
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_network.py
Apache-2.0
def CreateSubnet(self, vpcid: str): """Creates a IBM Cloud subnet on the given vpc.""" self.vpcid = vpcid subnet_index = int(self.zone[len(self.zone) - 1]) # get the ending -1 cmd = ibm.IbmAPICommand(self) cmd.flags.update({ 'vpcid': self.vpcid, 'zone': self.zone, 'name': ( ...
Creates a IBM Cloud subnet on the given vpc.
CreateSubnet
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_network.py
Apache-2.0
def CreateFip(self, name: str, vmid: str): """Creates a VNIC in a IBM Cloud VM instance.""" cmd = ibm.IbmAPICommand(self) cmd.flags['instanceid'] = vmid vnicid = cmd.InstanceGetPrimaryVnic() cmd.flags['name'] = name cmd.flags['target'] = vnicid logging.info('Creating FIP for instanceid: %s',...
Creates a VNIC in a IBM Cloud VM instance.
CreateFip
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_network.py
Apache-2.0
def DeleteFip(self, vmid: str, fip_address: str, fipid: str): """Deletes fip in a IBM Cloud VM instance.""" logging.info( 'Deleting FIP, instanceid: %s, fip address: %s, fip id: %s', vmid, fip_address, fipid, ) cmd = ibm.IbmAPICommand(self) cmd.flags['fipid'] = fipid ...
Deletes fip in a IBM Cloud VM instance.
DeleteFip
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_network.py
Apache-2.0
def __init__(self, vm_spec: virtual_machine.BaseVmSpec): """Initialize a IBM Cloud virtual machine. Args: vm_spec: virtual_machine.BaseVirtualMachineSpec object of the vm. """ super().__init__(vm_spec) self.user_name = FLAGS.ibmcloud_image_username self.boot_volume_size = FLAGS.ibmcloud_b...
Initialize a IBM Cloud virtual machine. Args: vm_spec: virtual_machine.BaseVirtualMachineSpec object of the vm.
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_virtual_machine.py
Apache-2.0
def _CreateRiasKey(self): """Creates a ibmcloud key from the generated ssh key.""" logging.info('Creating rias key') with open(vm_util.GetPublicKeyPath()) as keyfile: pubkey = keyfile.read() logging.info( 'ssh private key file: %s, public key file: %s', vm_util.GetPrivateKeyPath(),...
Creates a ibmcloud key from the generated ssh key.
_CreateRiasKey
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_virtual_machine.py
Apache-2.0
def _CheckImage(self): """Verifies we have an imageid to use.""" cmd = ibm.IbmAPICommand(self) cmd.flags['image_name'] = self.image or self._GetDefaultImageName() logging.info('Looking up image: %s', cmd.flags['image_name']) self.imageid = cmd.GetImageId() if self.imageid is None: logging....
Verifies we have an imageid to use.
_CheckImage
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_virtual_machine.py
Apache-2.0
def _SetupResources(self): """Looks up the resources needed, if not found, creates new.""" logging.info('Checking resources') cmd = ibm.IbmAPICommand(self) cmd.flags.update( {'prefix': self.prefix, 'zone': self.zone, 'items': 'vpcs'} ) self.vpcid = cmd.GetResource() logging.info('Vpc...
Looks up the resources needed, if not found, creates new.
_SetupResources
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_virtual_machine.py
Apache-2.0
def _Create(self): """Creates and starts a IBM Cloud VM instance.""" self._CreateInstance() if self.subnet: # this is for the primary vnic and fip self.fip_address, self.fip_id = self.network.CreateFip( self.name + 'fip', self.vmid ) self.ip_address = self.fip_address self...
Creates and starts a IBM Cloud VM instance.
_Create
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_virtual_machine.py
Apache-2.0
def _Delete(self): """Delete all the resources that were created.""" if self.vm_deleted: return self._StopInstance() if self.fip_address: self.network.DeleteFip(self.vmid, self.fip_address, self.fip_id) time.sleep(10) self._DeleteInstance() if not FLAGS.ibmcloud_resources_keep: ...
Delete all the resources that were created.
_Delete
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_virtual_machine.py
Apache-2.0
def _CheckPrerequisites(self): """Checks prerequisites are met otherwise aborts execution.""" with self._lock: logging.info('Validating prerequisites.') logging.info('zones: %s', FLAGS.zone) if len(FLAGS.zones) > 1: for zone in FLAGS.zone: if zone not in IbmCloudVirtualMachin...
Checks prerequisites are met otherwise aborts execution.
_CheckPrerequisites
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_virtual_machine.py
Apache-2.0
def _WaitForIPAssignment(self, networkid: str): """Finds the IP address assigned to the vm.""" ip_v4_address = '0.0.0.0' count = 0 while ( ip_v4_address == '0.0.0.0' and count * FLAGS.ibmcloud_polling_delay < 240 ): time.sleep(FLAGS.ibmcloud_polling_delay) count += 1 ...
Finds the IP address assigned to the vm.
_WaitForIPAssignment
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_virtual_machine.py
Apache-2.0
def __init__(self, *args, **kwargs): """Initializes a IbmAPICommand with the provided args and flags. Args: *args: sequence of strings. Positional args to pass to rest api calls, typically specifying an operation to perform (e.g. ['image', 'list'] to list available images). **kwargs...
Initializes a IbmAPICommand with the provided args and flags. Args: *args: sequence of strings. Positional args to pass to rest api calls, typically specifying an operation to perform (e.g. ['image', 'list'] to list available images). **kwargs: resource - A IBM Cloud resource of type Ba...
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def _CheckEnvironment(self): """Get the information needed to authenticate on IBM Cloud. Check for the config if env variables for apikey is not set. """ if not os.environ.get('IBMCLOUD_ENDPOINT'): raise errors.Config.InvalidValue( 'PerfKit Benchmarker on IBM Cloud requires that the ' ...
Get the information needed to authenticate on IBM Cloud. Check for the config if env variables for apikey is not set.
_CheckEnvironment
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def CreateSgRules(self): """Creates default security group rules needed for vms to communicate.""" self.gen_sgmgr.CreateRule( self.sg_id, 'inbound', 'ipv4', '0.0.0.0/0', 'icmp', None ) self.gen_sgmgr.CreateRule( self.sg_id, 'inbound', 'ipv4', '0.0.0.0/0', 'tcp', 22 ) self.gen_sgm...
Creates default security group rules needed for vms to communicate.
CreateSgRules
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def CreatePrefix(self): """Creates address prefix on vpc needed to attach subnets. Flags: vpcid: ibm cloud vpc id. zone: name of the zone within ibm network. cidr: ip range that this prefix will cover. name: name of this prefix. Returns: The json representation of the created...
Creates address prefix on vpc needed to attach subnets. Flags: vpcid: ibm cloud vpc id. zone: name of the zone within ibm network. cidr: ip range that this prefix will cover. name: name of this prefix. Returns: The json representation of the created address prefix.
CreatePrefix
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def CreateSubnet(self): """Creates a subnet on the vpc. Flags: vpcid: ibm cloud vpc id. zone: name of the zone within ibm network. cidr: ip range for the subnet. name: name of this subnet. Returns: The json representation of the created subnet. """ kwargs = {} kwa...
Creates a subnet on the vpc. Flags: vpcid: ibm cloud vpc id. zone: name of the zone within ibm network. cidr: ip range for the subnet. name: name of this subnet. Returns: The json representation of the created subnet.
CreateSubnet
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def DeleteResource(self): """Deletes a resource based on items set in the flags. Flags: items: type of resource to delete. id: matching id to delete. """ data_mgr = self.gen_subnetmgr if self.items == 'vpcs': data_mgr = self.gen_vpcmgr elif self.items == 'keys': data_mgr...
Deletes a resource based on items set in the flags. Flags: items: type of resource to delete. id: matching id to delete.
DeleteResource
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def GetResource(self): """Returns id of the found resource matching the resource type and prefix. Flags: items: type of resource. zone: name of the zone within ibm network, for subnets. preifx: a label matching the resource name. Returns: The id of the first matching resource. ...
Returns id of the found resource matching the resource type and prefix. Flags: items: type of resource. zone: name of the zone within ibm network, for subnets. preifx: a label matching the resource name. Returns: The id of the first matching resource.
GetResource
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def ListSubnetsExtra(self): """Returns a list of extra subnets, this is not used for regular runs. Flags: zone: name of the zone within ibm network, for subnets. preifx: a label matching the resource name. Returns: List of ids of the additional subnets matching the prefix and zone. "...
Returns a list of extra subnets, this is not used for regular runs. Flags: zone: name of the zone within ibm network, for subnets. preifx: a label matching the resource name. Returns: List of ids of the additional subnets matching the prefix and zone.
ListSubnetsExtra
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def CreateVolume(self): """Creates an external disk volume. Flags: name: name of the new volume. capacity: size of the volume in GB. iops: desired iops on the volume. profile: profile name of the volume, usually custom for large volumes encryption_key: optional, encrytion key ...
Creates an external disk volume. Flags: name: name of the new volume. capacity: size of the volume in GB. iops: desired iops on the volume. profile: profile name of the volume, usually custom for large volumes encryption_key: optional, encrytion key resource_group: optional, res...
CreateVolume
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def CreateVpc(self): """Creates a vpc. Flags: name: name of the vpc to create. Returns: The id of the created vpc. """ vpcid = None resp = self.gen_vpcmgr.Create(self.name) if resp: vpcid = resp.get('id') sgid = resp.get('default_security_group')['id'] logging...
Creates a vpc. Flags: name: name of the vpc to create. Returns: The id of the created vpc.
CreateVpc
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def CreateKey(self): """Creates a ssh key in ibm cloud. Flags: name: name of the key to create. pubkey: public key to use. Returns: The id of the created ssh key. """ kwargs = {} kwargs['name'] = self.flags['name'] resp = self.gen_keymgr.Create(self.pubkey, 'rsa', **kwarg...
Creates a ssh key in ibm cloud. Flags: name: name of the key to create. pubkey: public key to use. Returns: The id of the created ssh key.
CreateKey
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def CreateInstance(self): """Creates a vm. Flags: name: name of the vm. imageid: id of the image to use. profile: machine type for the vm. vpcid: id of the vpc. user_data: this is set if windows optional: optional args added to kwargs. Returns: The json representa...
Creates a vm. Flags: name: name of the vm. imageid: id of the image to use. profile: machine type for the vm. vpcid: id of the vpc. user_data: this is set if windows optional: optional args added to kwargs. Returns: The json representation of the created vm.
CreateInstance
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def InstanceGetPrimaryVnic(self): """Finds the primary network vnic on vm. Flags: instanceid: id of the vm. Returns: The found vnic id. """ resp = self.gen_instmgr.Show(self.instance_id) if ( 'primary_network_interface' in resp and 'href' in resp['primary_network_in...
Finds the primary network vnic on vm. Flags: instanceid: id of the vm. Returns: The found vnic id.
InstanceGetPrimaryVnic
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def InstanceFipCreate(self): """Creates a FIP on vm. Flags: name: name of the fip. Returns: json represenation of the created fip. """ kwargs = {} kwargs['name'] = self.name return json.dumps(self.gen_fipmgr.Create(None, self.target, **kwargs))
Creates a FIP on vm. Flags: name: name of the fip. Returns: json represenation of the created fip.
InstanceFipCreate
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def _GetStatus(self, resp): """Returns instance status in the given resp.""" status = None if not resp: logging.error('http response is None') return status if 'status' in resp: status = resp['status'] else: logging.error('No status found in resp: %s', resp) return status
Returns instance status in the given resp.
_GetStatus
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def InstanceStatus(self): """Returns instance status matching the instance id.""" resp = self.gen_instmgr.Show(self.instance_id) status = self._GetStatus(resp) logging.info('Instance status: %s, %s', self.instance_id, status) if status != States.RUNNING: endtime = time.time() + FLAGS.ibmcloud_...
Returns instance status matching the instance id.
InstanceStatus
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def InstanceStart(self): """Starts the instance matching instance id and returns final status.""" resp = self.gen_instmgr.Start(self.flags['instanceid']) status = self._GetStatus(resp) logging.info( 'Instance start issued: %s, %s', self.flags['instanceid'], status ) if status != States.R...
Starts the instance matching instance id and returns final status.
InstanceStart
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def InstanceStop(self): """Stops instance matching the instance id and returns final status.""" resp = self.gen_instmgr.Stop(self.instance_id, force=False) logging.info('Instance stop issued: %s', self.instance_id) # force stop again resp = self.gen_instmgr.Stop(self.instance_id, force=True) sta...
Stops instance matching the instance id and returns final status.
InstanceStop
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def InstanceVnicCreate(self): """Creates a vnic on the instance. Flags: instanceid: id of the vm. name: name of the vnic. subnet: subnet id. Returns: id of the created vnic and assigned private ip address. """ ip_addr = None resp = self.gen_instmgr.CreateVnic(self.insta...
Creates a vnic on the instance. Flags: instanceid: id of the vm. name: name of the vnic. subnet: subnet id. Returns: id of the created vnic and assigned private ip address.
InstanceVnicCreate
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def InstanceVnicShow(self): """GETs instance vnic. Flags: instanceid: id of the vm. vnicid: id of the vnic. Returns: json representation of the found vnic. """ return json.dumps( self.gen_instmgr.ShowVnic(self.instance_id, self.vnic_id), indent=2 )
GETs instance vnic. Flags: instanceid: id of the vm. vnicid: id of the vnic. Returns: json representation of the found vnic.
InstanceVnicShow
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def InstanceCreateVolume(self): """Attaches a volume to instance. Flags: instanceid: id of the vm. name: name of the volume on the vm. volume: id of the volume to attach to the vm. True: always true, delete the volume when instance is deleted. Returns: json representation of ...
Attaches a volume to instance. Flags: instanceid: id of the vm. name: name of the volume on the vm. volume: id of the volume to attach to the vm. True: always true, delete the volume when instance is deleted. Returns: json representation of the attached volume on the instance. ...
InstanceCreateVolume
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def InstanceDeleteVolume(self): """Deletes the volume on the vm matching instanceid and volume.""" return json.dumps( self.gen_instmgr.DeleteVolume(self.instance_id, self.volume), indent=2 )
Deletes the volume on the vm matching instanceid and volume.
InstanceDeleteVolume
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def InstanceShowVolume(self): """Returns json representation of the volume matching instanceid.""" for item in self.gen_instmgr.ListVolumes(self.instance_id)[ 'volume_attachments' ]: if item['volume'].get('id') == self.volume: return json.dumps( self.gen_instmgr.ShowVolume(...
Returns json representation of the volume matching instanceid.
InstanceShowVolume
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def GetImageId(self): """Returns image id that matches the image name.""" resp = self.gen_imgmgr.List()['images'] if resp is not None: for image in resp: if ( image['name'].startswith(self.image_name) and image['status'] == States.AVAILABLE ): return i...
Returns image id that matches the image name.
GetImageId
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibm_api.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibm_api.py
Apache-2.0
def ReadConfig(config: str) -> Dict[Any, Any]: """Reads in config yml. Args: config: config file name. Returns: The json representation of the config file. """ try: with open(config) as stream: return yaml.safe_load(stream) except Exception as ex: raise errors.Error(('Failed to load ...
Reads in config yml. Args: config: config file name. Returns: The json representation of the config file.
ReadConfig
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/util.py
Apache-2.0
def GetBaseOs(osdata: Dict[str, str]): """Finds the base os name to use. Args: osdata: json representation of os information of an image. Returns: Short name of the os name """ if 'name' in osdata and osdata['name'] is not None: osname = osdata['name'].lower() if 'window' in osname: re...
Finds the base os name to use. Args: osdata: json representation of os information of an image. Returns: Short name of the os name
GetBaseOs
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/util.py
Apache-2.0
def GetImageId(account: Account, imgname: str): """Returns image id matching the image name.""" data_mgr = ibmcloud_manager.ImageManager(GetGen(account)) resp = data_mgr.List()['images'] if resp is not None: for image in resp: if image['name'] == imgname: return image['id'] return None
Returns image id matching the image name.
GetImageId
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/util.py
Apache-2.0
def GetOsInfo(image: Dict[Any, Any]) -> Dict[str, Any]: """Returns os information in json format. Args: image: json representation of os information of an image. Returns: OS details of the image in json format """ data = {} custom = False if image and 'operating_system' in image: data = imag...
Returns os information in json format. Args: image: json representation of os information of an image. Returns: OS details of the image in json format
GetOsInfo
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/util.py
Apache-2.0
def _CheckPrerequisites(self): """Exits if any of the prerequisites is not met.""" if self.disk_specs and self.disk_specs[0].disk_type == disk.STANDARD: raise Exception( 'Currently only local disks are supported. Please ' 're-run the benchmark with "--data_disk_type=local".' ) ...
Exits if any of the prerequisites is not met.
_CheckPrerequisites
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/mesos/mesos_docker_instance.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/mesos/mesos_docker_instance.py
Apache-2.0
def _WaitForBootCompletion(self): """Periodically asks Marathon if the instance is already running.""" logging.info( 'Waiting for App %s to get up and running. It may take a while' ' if a Docker image is being downloaded for the first time.' % self.name ) output = requests.get(se...
Periodically asks Marathon if the instance is already running.
_WaitForBootCompletion
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/mesos/mesos_docker_instance.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/mesos/mesos_docker_instance.py
Apache-2.0
def _SetupSSH(self): """Setup SSH connection details for each instance: - IP address of the instance is the address of a host which instance is running on, - SSH port is drawn by Marathon and is unique for each instance. """ output = requests.get(self.app_url, auth=self.auth) output = json....
Setup SSH connection details for each instance: - IP address of the instance is the address of a host which instance is running on, - SSH port is drawn by Marathon and is unique for each instance.
_SetupSSH
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/mesos/mesos_docker_instance.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/mesos/mesos_docker_instance.py
Apache-2.0
def _ConfigureProxy(self): """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 because the sc...
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 because the script exits when it is NOT executed...
_ConfigureProxy
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/mesos/mesos_docker_instance.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/mesos/mesos_docker_instance.py
Apache-2.0
def _BuildAppBody(self): """Builds JSON which will be passed as a body of POST request to Marathon API in order to create App. """ cat_cmd = ['cat', vm_util.GetPublicKeyPath()] key_file, _ = vm_util.IssueRetryableCommand(cat_cmd) cmd = ( "/bin/mkdir /root/.ssh; echo '%s' >> /root/.ssh/a...
Builds JSON which will be passed as a body of POST request to Marathon API in order to create App.
_BuildAppBody
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/mesos/mesos_docker_instance.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/mesos/mesos_docker_instance.py
Apache-2.0
def CreateBootVolume(resource, name, image): """Creates a remote (Cinder) block volume with a boot image.""" vol_cmd = os_utils.OpenStackCLICommand(resource, 'volume', 'create', name) vol_cmd.flags['availability-zone'] = resource.zone vol_cmd.flags['image'] = image vol_cmd.flags['size'] = resource.disk_size o...
Creates a remote (Cinder) block volume with a boot image.
CreateBootVolume
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/openstack/os_disk.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/openstack/os_disk.py
Apache-2.0
def GetImageMinDiskSize(resource, image): """Returns minimum disk size required by the image.""" image_cmd = os_utils.OpenStackCLICommand(resource, 'image', 'show', image) stdout, _, _ = image_cmd.Issue() image_resp = json.loads(stdout) volume_size = max(( int(image_resp['min_disk']), resource.dis...
Returns minimum disk size required by the image.
GetImageMinDiskSize
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/openstack/os_disk.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/openstack/os_disk.py
Apache-2.0
def AllowICMP(self, vm, icmp_type=-1, icmp_code=-1, source_range=None): """Creates a Security Group Rule on the Firewall to allow/disallow ICMP traffic. Args: vm: The BaseVirtualMachine object to allow ICMP traffic to. icmp_type: ICMP type to allow. If none given then allows all types. i...
Creates a Security Group Rule on the Firewall to allow/disallow ICMP traffic. Args: vm: The BaseVirtualMachine object to allow ICMP traffic to. icmp_type: ICMP type to allow. If none given then allows all types. icmp_code: ICMP code to allow. If none given then allows all codes. source...
AllowICMP
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/openstack/os_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/openstack/os_network.py
Apache-2.0
def AllowPort(self, vm, start_port, end_port=None, source_range=None): """Creates a Security Group Rule on the Firewall to allow for both TCP and UDP network traffic on given port, or port range. Args: vm: The BaseVirtualMachine object to open the port for. start_port: The first local port to ...
Creates a Security Group Rule on the Firewall to allow for both TCP and UDP network traffic on given port, or port range. 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 No...
AllowPort
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/openstack/os_network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/openstack/os_network.py
Apache-2.0
def __init__(self, vm_spec): """Initialize an OpenStack virtual machine. Args: vm_spec: virtual_machine.BaseVirtualMachineSpec object of the vm. """ super().__init__(vm_spec) self.key_name = 'perfkit_key_%s' % FLAGS.run_uri self.user_name = FLAGS.openstack_image_username self.image = ...
Initialize an OpenStack virtual machine. Args: vm_spec: virtual_machine.BaseVirtualMachineSpec object of the vm.
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/openstack/os_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/openstack/os_virtual_machine.py
Apache-2.0
def _CreateDependencies(self): """Validate and Create dependencies prior creating the VM.""" self._CheckPrerequisites() self.firewall = os_network.OpenStackFirewall.GetFirewall() self.public_network = os_network.OpenStackFloatingIPPool( OpenStackVirtualMachine.floating_network_id ) self....
Validate and Create dependencies prior creating the VM.
_CreateDependencies
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/openstack/os_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/openstack/os_virtual_machine.py
Apache-2.0
def _Create(self): """Creates an OpenStack VM instance and waits until it is ACTIVE.""" if FLAGS.openstack_boot_from_volume: vol_name = '%s_volume' % self.name disk_resp = os_disk.CreateBootVolume(self, vol_name, self.image) self.boot_volume_id = disk_resp['id'] os_disk.WaitForVolumeCrea...
Creates an OpenStack VM instance and waits until it is ACTIVE.
_Create
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/openstack/os_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/openstack/os_virtual_machine.py
Apache-2.0
def _CheckImage(self): """Tries to get image, if found continues execution otherwise aborts.""" cmd = os_utils.OpenStackCLICommand(self, 'image', 'show', self.image) err_msg = VALIDATION_ERROR_MESSAGE.format('Image', self.image) self._IssueCommandCheck(cmd, err_msg)
Tries to get image, if found continues execution otherwise aborts.
_CheckImage
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/openstack/os_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/openstack/os_virtual_machine.py
Apache-2.0
def _CheckFlavor(self): """Tries to get flavor, if found continues execution otherwise aborts.""" cmd = os_utils.OpenStackCLICommand( self, 'flavor', 'show', self.machine_type ) err_msg = VALIDATION_ERROR_MESSAGE.format('Machine type', self.machine_type) self._IssueCommandCheck(cmd, err_msg)
Tries to get flavor, if found continues execution otherwise aborts.
_CheckFlavor
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/openstack/os_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/openstack/os_virtual_machine.py
Apache-2.0
def _CheckNetworks(self): """Tries to get network, if found continues execution otherwise aborts.""" if not self.network_name: if self.floating_ip_pool_name: msg = ( 'Cannot associate floating-ip address from pool %s without ' 'an internally routable network. Make sure ' ...
Tries to get network, if found continues execution otherwise aborts.
_CheckNetworks
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/openstack/os_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/openstack/os_virtual_machine.py
Apache-2.0
def _IssueCommandCheck(self, cmd, err_msg=None): """Issues command and, if stderr is non-empty, raises an error message Args: cmd: The command to be issued. err_msg: string. Error message if command fails. """ if err_msg is None: err_msg = '' stdout, stderr, _ = cmd.Issue() ...
Issues command and, if stderr is non-empty, raises an error message Args: cmd: The command to be issued. err_msg: string. Error message if command fails.
_IssueCommandCheck
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/openstack/os_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/openstack/os_virtual_machine.py
Apache-2.0
def _UploadSSHPublicKey(self): """Uploads SSH public key to the VM's region.""" with self._lock: if self.zone in self.uploaded_keypair_set: return cmd = os_utils.OpenStackCLICommand( self, 'keypair', 'create', self.key_name ) cmd.flags['public-key'] = self.ssh_public_ke...
Uploads SSH public key to the VM's region.
_UploadSSHPublicKey
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/openstack/os_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/openstack/os_virtual_machine.py
Apache-2.0
def _DeleteSSHPublicKey(self): """Deletes SSH public key used for the VM.""" with self._lock: if self.zone in self.deleted_keypair_set: return cmd = os_utils.OpenStackCLICommand( self, 'keypair', 'delete', self.key_name ) del cmd.flags['format'] # keypair delete does n...
Deletes SSH public key used for the VM.
_DeleteSSHPublicKey
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/openstack/os_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/openstack/os_virtual_machine.py
Apache-2.0
def _CreateInstance(self): """Execute command for creating an OpenStack VM instance.""" create_cmd = self._GetCreateCommand() stdout, stderr, _ = create_cmd.Issue() if stderr: raise errors.Error(stderr) resp = json.loads(stdout) self.id = resp['id']
Execute command for creating an OpenStack VM instance.
_CreateInstance
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/openstack/os_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/openstack/os_virtual_machine.py
Apache-2.0
def _GetInternalNetworkCIDR(self): """Returns IP addresses source range of internal network.""" net_cmd = os_utils.OpenStackCLICommand( self, 'network', 'show', self.network_name ) net_stdout, _, _ = net_cmd.Issue() network = json.loads(net_stdout) if isinstance(network['subnets'], list...
Returns IP addresses source range of internal network.
_GetInternalNetworkCIDR
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/openstack/os_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/openstack/os_virtual_machine.py
Apache-2.0
def __init__(self, resource, *args): """Initializes an OpenStackCLICommand with the provided args and common flags. Args: resource: An OpenStack resource of type BaseResource. *args: sequence of strings. Positional args to pass to openstack cli, typically specifying an operation to per...
Initializes an OpenStackCLICommand with the provided args and common flags. Args: resource: An OpenStack resource of type BaseResource. *args: sequence of strings. Positional args to pass to openstack cli, typically specifying an operation to perform (e.g. ['image', 'list'] to list...
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/openstack/utils.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/openstack/utils.py
Apache-2.0
def _GetCommand(self): """Generates the openstack cli command. Returns: list of strings. When joined by spaces, forms the openstack cli command. """ cmd = [FLAGS.openstack_cli_path] cmd.extend(self.args) for flag_name, values in self.flags.items(): flag_name_str = '--%s' % flag_name...
Generates the openstack cli command. Returns: list of strings. When joined by spaces, forms the openstack cli command.
_GetCommand
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/openstack/utils.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/openstack/utils.py
Apache-2.0
def Issue(self, **kwargs): """Tries running the openstack cli command once. Args: **kwargs: Keyword arguments to forward to vm_util.IssueCommand when issuing the openstack cli command. Returns: A tuple of stdout, stderr, and retcode from running the openstack command. """ if 'r...
Tries running the openstack cli command once. Args: **kwargs: Keyword arguments to forward to vm_util.IssueCommand when issuing the openstack cli command. Returns: A tuple of stdout, stderr, and retcode from running the openstack command.
Issue
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/openstack/utils.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/openstack/utils.py
Apache-2.0
def _AddCommonFlags(self, resource): """Adds common flags to the command. Adds common openstack flags derived from the PKB flags and provided resource. Args: resource: An OpenStack resource of type BaseResource. """ self.flags['format'] = 'json' self.additional_flags.extend(FLAGS.op...
Adds common flags to the command. Adds common openstack flags derived from the PKB flags and provided resource. Args: resource: An OpenStack resource of type BaseResource.
_AddCommonFlags
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/openstack/utils.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/openstack/utils.py
Apache-2.0
def Decode(self, value, component_full_name, flag_values): """Decodes the machine_type option of a ProfitBricks VM config. Args: value: Either a string name of a PB machine type or a dict containing 'cores' and 'ram' keys describing a custom VM. component_full_name: string. Fully qualified ...
Decodes the machine_type option of a ProfitBricks VM config. Args: value: Either a string name of a PB machine type or a dict containing 'cores' and 'ram' keys describing a custom VM. component_full_name: string. Fully qualified name of the configurable component containing the config o...
Decode
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/profitbricks/profitbricks_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/profitbricks/profitbricks_virtual_machine.py
Apache-2.0
def __init__(self, vm_spec): """Initialize a ProfitBricks virtual machine. Args: vm_spec: virtual_machine.BaseVirtualMachineSpec object of the vm. """ super().__init__(vm_spec) # Get user authentication credentials user_config_path = os.path.expanduser(FLAGS.profitbricks_config) with...
Initialize a ProfitBricks virtual machine. Args: vm_spec: virtual_machine.BaseVirtualMachineSpec object of the vm.
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/profitbricks/profitbricks_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/profitbricks/profitbricks_virtual_machine.py
Apache-2.0
def _PostCreate(self): """Get the instance's public IP address.""" # Build URL url = '%s/datacenters/%s/servers/%s?depth=5' % ( PROFITBRICKS_API, self.dc_id, self.server_id, ) # Perform Request r = util.PerformRequest('get', url, self.header) response = r.json() ...
Get the instance's public IP address.
_PostCreate
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/profitbricks/profitbricks_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/profitbricks/profitbricks_virtual_machine.py
Apache-2.0
def _CreateDependencies(self): """Create a data center and LAN prior to creating VM.""" # Create data center self.dc_id, self.dc_status = util.CreateDatacenter( self.header, self.location ) if not self._WaitUntilReady(self.dc_status): raise errors.Error('Data center creation failed, s...
Create a data center and LAN prior to creating VM.
_CreateDependencies
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/profitbricks/profitbricks_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/profitbricks/profitbricks_virtual_machine.py
Apache-2.0
def _WaitUntilReady(self, status_url): """Returns true if the ProfitBricks resource is ready.""" # Poll resource for status update logging.info('Polling ProfitBricks resource.') r = util.PerformRequest('get', status_url, self.header) response = r.json() status = response['metadata']['status'] ...
Returns true if the ProfitBricks resource is ready.
_WaitUntilReady
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/profitbricks/profitbricks_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/profitbricks/profitbricks_virtual_machine.py
Apache-2.0
def PerformRequest(action, url, header, json=None): """Makes an HTTP request to the ProfitBricks REST API.""" # Make HTTP call if action == 'get': r = requests.get(url, headers=header) elif action == 'post': r = requests.post(url, headers=header, json=json) elif action == 'delete': r = requests.d...
Makes an HTTP request to the ProfitBricks REST API.
PerformRequest
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/profitbricks/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/profitbricks/util.py
Apache-2.0
def ReturnImage(header, location): """Returns Ubuntu image based on zone location.""" # Retrieve list of provider images url = '%s/images?depth=5' % PROFITBRICKS_API r = PerformRequest('get', url, header) response = r.json() logging.info('Fetching image for new VM.') # Search for Ubuntu image in preferr...
Returns Ubuntu image based on zone location.
ReturnImage
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/profitbricks/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/profitbricks/util.py
Apache-2.0
def ReturnFlavor(machine_type): """Returns RAM and Core values based on machine_type selection.""" logging.info('Fetching flavor specs for new VM.') for flavor in FLAVORS: if machine_type == flavor['name']: return flavor['ram'], flavor['cores']
Returns RAM and Core values based on machine_type selection.
ReturnFlavor
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/profitbricks/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/profitbricks/util.py
Apache-2.0
def CreateLan(header, datacenter): """Creates a LAN with public IP address.""" # Build new LAN body new_lan = { 'properties': { 'name': 'lan1', 'public': True, }, } # Make call logging.info('Creating LAN') url = '%s/datacenters/%s/lans' % (PROFITBRICKS_API, datacenter) ...
Creates a LAN with public IP address.
CreateLan
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/profitbricks/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/profitbricks/util.py
Apache-2.0
def RenderBlockDeviceTemplate(image, volume_size): """Renders template used for the block-device flag in RackCLI. Args: image: string. Image ID of the source image. volume_size: string. Size in GB of desired volume size. Returns: string value for block-device parameter used when creating a VM. """...
Renders template used for the block-device flag in RackCLI. Args: image: string. Image ID of the source image. volume_size: string. Size in GB of desired volume size. Returns: string value for block-device parameter used when creating a VM.
RenderBlockDeviceTemplate
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
Apache-2.0
def __init__(self, vm_spec): """Initialize a Rackspace Virtual Machine Args: vm_spec: virtual_machine.BaseVirtualMachineSpec object of the VM. """ super().__init__(vm_spec) self.boot_metadata = {} self.boot_device = None self.boot_disk_allocated = False self.allocated_disks = set(...
Initialize a Rackspace Virtual Machine Args: vm_spec: virtual_machine.BaseVirtualMachineSpec object of the VM.
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
Apache-2.0
def _Exists(self): """Returns true if the VM exists otherwise returns false.""" if self.id is None: return False get_cmd = util.RackCLICommand(self, 'servers', 'instance', 'get') get_cmd.flags['id'] = self.id stdout, _, _ = get_cmd.Issue() try: resp = json.loads(stdout) except Va...
Returns true if the VM exists otherwise returns false.
_Exists
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
Apache-2.0
def _Delete(self): """Deletes a Rackspace VM instance and waits until API returns 404.""" if self.id is None: return self._DeleteInstance() self._WaitForInstanceUntilDeleted()
Deletes a Rackspace VM instance and waits until API returns 404.
_Delete
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
Apache-2.0
def _UploadSSHPublicKey(self): """Uploads SSH public key to the VM's region. 1 key per VM per Region.""" cmd = util.RackCLICommand(self, 'servers', 'keypair', 'upload') cmd.flags = OrderedDict( [('name', self.name), ('file', self.ssh_public_key)] ) cmd.Issue()
Uploads SSH public key to the VM's region. 1 key per VM per Region.
_UploadSSHPublicKey
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
Apache-2.0
def _DeleteSSHPublicKey(self): """Deletes SSH public key used for a VM.""" cmd = util.RackCLICommand(self, 'servers', 'keypair', 'delete') cmd.flags['name'] = self.name cmd.Issue()
Deletes SSH public key used for a VM.
_DeleteSSHPublicKey
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
Apache-2.0
def _CreateInstance(self): """Generates and execute command for creating a Rackspace VM.""" with tempfile.NamedTemporaryFile( dir=vm_util.GetTempDir(), prefix='user-data' ) as tf: with open(self.ssh_public_key) as f: public_key = f.read().rstrip('\n') tf.write(CLOUD_CONFIG_TEMPLA...
Generates and execute command for creating a Rackspace VM.
_CreateInstance
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
Apache-2.0
def _GetCreateCommand(self, tf): """Generates RackCLI command for creating a Rackspace VM. Args: tf: file object containing cloud-config script. Returns: RackCLICommand containing RackCLI arguments to build a Rackspace VM. """ create_cmd = util.RackCLICommand(self, 'servers', 'instance...
Generates RackCLI command for creating a Rackspace VM. Args: tf: file object containing cloud-config script. Returns: RackCLICommand containing RackCLI arguments to build a Rackspace VM.
_GetCreateCommand
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
Apache-2.0
def _WaitForInstanceUntilActive(self): """Waits until instance achieves non-transient state.""" get_cmd = util.RackCLICommand(self, 'servers', 'instance', 'get') get_cmd.flags['id'] = self.id stdout, stderr, _ = get_cmd.Issue() if stdout: instance = json.loads(stdout) if instance['Status...
Waits until instance achieves non-transient state.
_WaitForInstanceUntilActive
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
Apache-2.0
def _DeleteInstance(self): """Executes delete command for removing a Rackspace VM.""" cmd = util.RackCLICommand(self, 'servers', 'instance', 'delete') cmd.flags['id'] = self.id stdout, _, _ = cmd.Issue() resp = json.loads(stdout) if 'result' not in resp or 'Deleting' not in resp['result']: ...
Executes delete command for removing a Rackspace VM.
_DeleteInstance
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
Apache-2.0
def _WaitForInstanceUntilDeleted(self): """Waits until instance has been fully removed, or deleted.""" get_cmd = util.RackCLICommand(self, 'servers', 'instance', 'get') get_cmd.flags['id'] = self.id stdout, stderr, _ = get_cmd.Issue() if stderr: resp = json.loads(stderr) if 'error' in re...
Waits until instance has been fully removed, or deleted.
_WaitForInstanceUntilDeleted
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
Apache-2.0
def AddMetadata(self, **kwargs): """Adds metadata to the VM via RackCLI update-metadata command.""" if not kwargs: return cmd = util.RackCLICommand(self, 'servers', 'instance', 'update-metadata') cmd.flags['id'] = self.id cmd.flags['metadata'] = ','.join( '{}={}'.format(key, value) for...
Adds metadata to the VM via RackCLI update-metadata command.
AddMetadata
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
Apache-2.0
def OnStartup(self): """Executes commands on the VM immediately after it has booted.""" super().OnStartup() self.boot_device = self._GetBootDevice()
Executes commands on the VM immediately after it has booted.
OnStartup
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
Apache-2.0
def CreateScratchDisk(self, _, disk_spec): """Creates a VM's scratch disk that will be used for a benchmark. Given a data_disk_type it will either create a corresponding Disk object, or raise an error that such data disk type is not supported. Args: disk_spec: virtual_machine.BaseDiskSpec object...
Creates a VM's scratch disk that will be used for a benchmark. Given a data_disk_type it will either create a corresponding Disk object, or raise an error that such data disk type is not supported. Args: disk_spec: virtual_machine.BaseDiskSpec object of the disk. Raises: errors.Error indi...
CreateScratchDisk
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
Apache-2.0
def _AllocateBootDisk(self, disk_spec): """Allocate the VM's boot, or system, disk as the scratch disk. Boot disk can only be allocated once. If multiple data disks are required it will raise an error. Args: disk_spec: virtual_machine.BaseDiskSpec object of the disk. Raises: errors.Er...
Allocate the VM's boot, or system, disk as the scratch disk. Boot disk can only be allocated once. If multiple data disks are required it will raise an error. Args: disk_spec: virtual_machine.BaseDiskSpec object of the disk. Raises: errors.Error when boot disk has already been allocated a...
_AllocateBootDisk
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py
Apache-2.0