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 GetNVMEDeviceInfo(self): """Get the NVME disk device info, by querying the VM.""" self.InstallPackages('nvme-cli') version_str, _ = self.RemoteCommand('sudo nvme --version') version_num = version_str.split()[2] # TODO(arushigaur): Version check can be removed and we can just parse # the raw ...
Get the NVME disk device info, by querying the VM.
GetNVMEDeviceInfo
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def GenerateAndCaptureLogs(self) -> list[str]: """Generates and/or captures logs for this VM and returns the paths. Currently supports syslog and journalctl, and/or sos reports depending on what the VM supports. Returns: A list of paths where the logs are stored on the caller's machine. """...
Generates and/or captures logs for this VM and returns the paths. Currently supports syslog and journalctl, and/or sos reports depending on what the VM supports. Returns: A list of paths where the logs are stored on the caller's machine.
GenerateAndCaptureLogs
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def GenerateAndCaptureSosReport(self, local_path: str) -> bool: """Generates an sos report for the remote VM and captures it. Following the instructions at: https://cloud.google.com/container-optimized-os/docs/how-to/sosreport Args: local_path: The path to store the sos report on the caller's ...
Generates an sos report for the remote VM and captures it. Following the instructions at: https://cloud.google.com/container-optimized-os/docs/how-to/sosreport Args: local_path: The path to store the sos report on the caller's machine. Returns: True if the sos report was successfully ge...
GenerateAndCaptureSosReport
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def GenerateAndCaptureSerialPortOutput(self, local_path: str) -> bool: """Generates and captures the serial port output for the remote VM. Implemented per-provider Args: local_path: The path to store the serial port output on the caller's machine. Returns: True if the serial port ...
Generates and captures the serial port output for the remote VM. Implemented per-provider Args: local_path: The path to store the serial port output on the caller's machine. Returns: True if the serial port output was successfully generated and captured; False otherwise.
GenerateAndCaptureSerialPortOutput
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def CopyLogs(self, log_dir: str): """Copies logs from the given directory on the VM to the scratch directory. Log paths are converted to snake_case and .log extension is added if it is missing. And VM name is prepended to the file name to distinguish between multiple VMs. Example: VM: pkb-1234...
Copies logs from the given directory on the VM to the scratch directory. Log paths are converted to snake_case and .log extension is added if it is missing. And VM name is prepended to the file name to distinguish between multiple VMs. Example: VM: pkb-123456-0 Log path: /var/log/syslog C...
CopyLogs
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def _IncrementStackLevel(**kwargs: Any) -> Any: """Increments the stack_level variable stored in kwargs.""" if 'stack_level' in kwargs: kwargs['stack_level'] += 1 else: # Default to 2 - one for helper function this is called from, & one for # RemoteHostCommandWithReturnCode. kwargs['stack_level'] ...
Increments the stack_level variable stored in kwargs.
_IncrementStackLevel
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def OnStartup(self): """Eliminates the need to have a tty to run sudo commands.""" super().OnStartup() self.RemoteHostCommand('sudo swupd autoupdate --disable') self.RemoteHostCommand('sudo mkdir -p /etc/sudoers.d') self.RemoteHostCommand( "echo 'Defaults:{} !requiretty' | sudo tee /etc/sudo...
Eliminates the need to have a tty to run sudo commands.
OnStartup
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def PackageCleanup(self): """Cleans up all installed packages. Performs the normal package cleanup, then deletes the file added to the /etc/sudoers.d directory during startup. """ super().PackageCleanup() self.RemoteCommand('sudo rm /etc/sudoers.d/pkb')
Cleans up all installed packages. Performs the normal package cleanup, then deletes the file added to the /etc/sudoers.d directory during startup.
PackageCleanup
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def HasPackage(self, package): """Returns True iff the package is available for installation.""" return self.TryRemoteCommand( 'sudo swupd bundle-list --all | grep {}'.format(package) )
Returns True iff the package is available for installation.
HasPackage
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def Install(self, package_name): """Installs a PerfKit package on the VM.""" if not self.install_packages: return if package_name not in self._installed_packages: package = linux_packages.PACKAGES[package_name] if hasattr(package, 'SwupdInstall'): package.SwupdInstall(self) e...
Installs a PerfKit package on the VM.
Install
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def Uninstall(self, package_name): """Uninstalls a PerfKit package on the VM.""" package = linux_packages.PACKAGES[package_name] if hasattr(package, 'SwupdUninstall'): package.SwupdUninstall(self) elif hasattr(package, 'Uninstall'): package.Uninstall(self)
Uninstalls a PerfKit package on the VM.
Uninstall
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def RemoteCommand(self, command, **kwargs): """Runs a command inside the container. Args: command: Arguments passed directly to RemoteHostCommandWithReturnCode. **kwargs: Keyword arguments passed directly to RemoteHostCommandWithReturnCode. Returns: A tuple of stdout and stderr f...
Runs a command inside the container. Args: command: Arguments passed directly to RemoteHostCommandWithReturnCode. **kwargs: Keyword arguments passed directly to RemoteHostCommandWithReturnCode. Returns: A tuple of stdout and stderr from running the command.
RemoteCommand
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def SnapshotPackages(self): """Grabs a snapshot of the currently installed packages.""" self.RemoteCommand( 'rpm -qa > %s/rpm_package_list' % linux_packages.INSTALL_DIR )
Grabs a snapshot of the currently installed packages.
SnapshotPackages
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def RestorePackages(self): """Restores the currently installed packages to those snapshotted.""" self.RemoteCommand( 'rpm -qa | grep --fixed-strings --line-regexp --invert-match --file ' '%s/rpm_package_list | xargs --no-run-if-empty sudo rpm -e' % linux_packages.INSTALL_DIR, ign...
Restores the currently installed packages to those snapshotted.
RestorePackages
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def InstallPackages(self, packages): """Installs packages using the yum or dnf package managers.""" cmd = f'sudo {self.PACKAGE_MANAGER} install -y {packages}' if self.PACKAGE_MANAGER == DNF: cmd += ' --allowerasing' self.RemoteCommand(cmd)
Installs packages using the yum or dnf package managers.
InstallPackages
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def InstallPackageGroup(self, package_group): """Installs a 'package group' using the yum package manager.""" cmd = f'sudo {self.PACKAGE_MANAGER} groupinstall -y "{package_group}"' if self.PACKAGE_MANAGER == DNF: cmd += ' --allowerasing' self.RemoteCommand(cmd)
Installs a 'package group' using the yum package manager.
InstallPackageGroup
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def AppendKernelCommandLine(self, command_line, reboot=True): """Appends the provided command-line to the VM and reboots by default.""" self.RemoteCommand( r'echo GRUB_CMDLINE_LINUX_DEFAULT=\"\${GRUB_CMDLINE_LINUX_DEFAULT} %s\"' ' | sudo tee -a /etc/default/grub' % command_line ) self.Re...
Appends the provided command-line to the VM and reboots by default.
AppendKernelCommandLine
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def AptUpdate(self): """Updates the package lists on VMs using apt.""" try: # setting the timeout on the apt-get to 10 minutes because # it is known to get stuck. In a normal update this # takes less than 30 seconds, but far flung regions can be slower. self.RemoteCommand('sudo apt-get ...
Updates the package lists on VMs using apt.
AptUpdate
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def InstallPackages(self, packages): """Installs packages using the apt package manager.""" if not self.install_packages: return if not self._apt_updated: self.AptUpdate() self._apt_updated = True try: install_command = ( "sudo DEBIAN_FRONTEND='noninteractive' /usr/bin...
Installs packages using the apt package manager.
InstallPackages
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def IncreaseSSHConnection(self, target): """Increase maximum number of ssh connections on vm. Args: target: int. The max number of ssh connection. """ self.RemoteCommand( r'sudo sed -i -e "s/.*MaxStartups.*/MaxStartups {}/" ' '/etc/ssh/sshd_config'.format(target) ) self.Re...
Increase maximum number of ssh connections on vm. Args: target: int. The max number of ssh connection.
IncreaseSSHConnection
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def UpdateEnvironmentPath(self): """Add /snap/bin to default search path for Ubuntu2004. See https://bugs.launchpad.net/snappy/+bug/1659719. """ # Ensure ~/.bashrc exists. self.RemoteCommand( r'touch ~/.bashrc && sed -i "1 i\export PATH=$PATH:/snap/bin" ~/.bashrc' ) self.RemoteComma...
Add /snap/bin to default search path for Ubuntu2004. See https://bugs.launchpad.net/snappy/+bug/1659719.
UpdateEnvironmentPath
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def _CheckDockerExists(self): """Returns whether docker is installed or not.""" resp, _ = self.RemoteHostCommand('command -v docker', ignore_failure=True) if resp.rstrip() == '': return False return True
Returns whether docker is installed or not.
_CheckDockerExists
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def PrepareVMEnvironment(self): """Initializes docker before proceeding with preparation.""" if not self._CheckDockerExists(): self.Install('docker') # We need to explicitly create VM_TMP_DIR in the host because # otherwise it will be implicitly created by Docker in InitDocker() # (because of ...
Initializes docker before proceeding with preparation.
PrepareVMEnvironment
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def RemoteCommand(self, command, **kwargs): """Runs a command inside the container. Args: command: A valid bash command. **kwargs: Keyword arguments passed directly to RemoteHostCommand. Returns: A tuple of stdout and stderr from running the command. """ # Escapes bash sequences ...
Runs a command inside the container. Args: command: A valid bash command. **kwargs: Keyword arguments passed directly to RemoteHostCommand. Returns: A tuple of stdout and stderr from running the command.
RemoteCommand
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def ContainerCopy(self, file_name, container_path='', copy_to=True): """Copies a file to or from container_path to the host's vm_util.VM_TMP_DIR. Args: file_name: Name of the file in the host's vm_util.VM_TMP_DIR. container_path: Optional path of where to copy file on container. copy_to: True...
Copies a file to or from container_path to the host's vm_util.VM_TMP_DIR. Args: file_name: Name of the file in the host's vm_util.VM_TMP_DIR. container_path: Optional path of where to copy file on container. copy_to: True to copy to container, False to copy from container. Raises: Remo...
ContainerCopy
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def RemoteCopy(self, file_path, remote_path='', copy_to=True): """Copies a file to or from the container in the remote VM. Args: file_path: Local path to file. remote_path: Optional path of where to copy file inside the container. copy_to: True to copy to VM, False to copy from VM. """ ...
Copies a file to or from the container in the remote VM. Args: file_path: Local path to file. remote_path: Optional path of where to copy file inside the container. copy_to: True to copy to VM, False to copy from VM.
RemoteCopy
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def MoveFile(self, target, source_path, remote_path=''): """Copies a file from one VM to a target VM. Copies a file from a container in the source VM to a container in the target VM. Args: target: The target ContainerizedVirtualMachine object. source_path: The location of the file on the R...
Copies a file from one VM to a target VM. Copies a file from a container in the source VM to a container in the target VM. Args: target: The target ContainerizedVirtualMachine object. source_path: The location of the file on the REMOTE machine. remote_path: The destination of the file on...
MoveFile
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def PackageCleanup(self): """Cleans up all installed packages. Stop the docker container launched with --rm. """ if self.docker_id: self.RemoteHostCommand('docker stop %s' % self.docker_id)
Cleans up all installed packages. Stop the docker container launched with --rm.
PackageCleanup
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def _ParseTextProperties(text, key_value_regex=_COLON_SEPARATED_RE): """Parses raw text that has lines in "key:value" form. When comes across an empty line will return a dict of the current values. Args: text: Text of lines in "key:value" form. key_value_regex: Regex to use to parse key and value from e...
Parses raw text that has lines in "key:value" form. When comes across an empty line will return a dict of the current values. Args: text: Text of lines in "key:value" form. key_value_regex: Regex to use to parse key and value from each line of text. Yields: Dict of [key,value] values for a section....
_ParseTextProperties
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def CreateLscpuSamples(vms): """Creates samples from linux VMs of lscpu output.""" samples = [] for vm in vms: if vm.OS_TYPE in os_types.LINUX_OS_TYPES: metadata = {'node_name': vm.name} metadata.update(vm.CheckLsCpu().data) samples.append(sample.Sample('lscpu', 0, '', metadata)) return sa...
Creates samples from linux VMs of lscpu output.
CreateLscpuSamples
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def __init__(self, lscpu): """LsCpuResults Constructor. The lscpu command on Ubuntu 16.04 does *not* have the "--json" option for json output, so keep on using the text format. Args: lscpu: A string in the format of "lscpu" command Raises: ValueError: if the format of lscpu isn't what...
LsCpuResults Constructor. The lscpu command on Ubuntu 16.04 does *not* have the "--json" option for json output, so keep on using the text format. Args: lscpu: A string in the format of "lscpu" command Raises: ValueError: if the format of lscpu isn't what was expected for parsing Exa...
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def GetValues(self): """Dict of cpuinfo keys to its values. Multiple values are joined by semicolons. Returns: Dict of [cpuinfo key:value string] """ cpuinfo = { key: ';'.join(sorted(values)) for key, values in self.attributes.items() } cpuinfo['proccpu'] = ','.join(sorted(se...
Dict of cpuinfo keys to its values. Multiple values are joined by semicolons. Returns: Dict of [cpuinfo key:value string]
GetValues
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def _ParseStanza(self, stanza): """Parses the cpuinfo section for an individual CPU. Args: stanza: Dict of the /proc/cpuinfo results for an individual CPU. Returns: Tuple of (processor_id, dict of values that are known to change with each CPU, dict of other cpuinfo results). """ ...
Parses the cpuinfo section for an individual CPU. Args: stanza: Dict of the /proc/cpuinfo results for an individual CPU. Returns: Tuple of (processor_id, dict of values that are known to change with each CPU, dict of other cpuinfo results).
_ParseStanza
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def JujuAddMachine(self, unit): """Adds a manually-created virtual machine to Juju. Args: unit: An object representing the unit's BaseVirtualMachine. """ resp, _ = self.RemoteHostCommand( 'juju add-machine ssh:%s' % unit.internal_ip ) # We don't know what the machine's going to b...
Adds a manually-created virtual machine to Juju. Args: unit: An object representing the unit's BaseVirtualMachine.
JujuAddMachine
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def JujuSet(self, service, params=[]): """Set the configuration options on a deployed service. Args: service: The name of the service. params: A list of key=values pairs. """ output, _ = self.RemoteHostCommand( 'juju set %s %s' % (service, ' '.join(params)) ) return output.s...
Set the configuration options on a deployed service. Args: service: The name of the service. params: A list of key=values pairs.
JujuSet
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def JujuWait(self): """Wait for all deployed services to be installed, configured, and idle.""" status = yaml.safe_load(self.JujuStatus()) for service in status['services']: ss = status['services'][service]['service-status']['current'] # Accept blocked because the service may be waiting on rela...
Wait for all deployed services to be installed, configured, and idle.
JujuWait
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def JujuDeploy(self, charm, vm_group): """Deploy (and scale) this service to the machines in its vm group. Args: charm: The charm to deploy, i.e., cs:trusty/ubuntu. vm_group: The name of vm_group the unit(s) should be deployed to. """ # Find the already-deployed machines belonging to this ...
Deploy (and scale) this service to the machines in its vm group. Args: charm: The charm to deploy, i.e., cs:trusty/ubuntu. vm_group: The name of vm_group the unit(s) should be deployed to.
JujuDeploy
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def JujuRelate(self, service1, service2): """Create a relation between two services. Args: service1: The first service to relate. service2: The second service to relate. """ resp, _ = self.RemoteHostCommand( 'juju add-relation %s %s' % (service1, service2) )
Create a relation between two services. Args: service1: The first service to relate. service2: The second service to relate.
JujuRelate
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def __init__(self, thread_log_context=None): """Constructs a ThreadLogContext by copying a previous ThreadLogContext. Args: thread_log_context: A ThreadLogContext for an existing thread whose state will be copied to initialize a ThreadLogContext for a new thread. """ if thread_log_context...
Constructs a ThreadLogContext by copying a previous ThreadLogContext. Args: thread_log_context: A ThreadLogContext for an existing thread whose state will be copied to initialize a ThreadLogContext for a new thread.
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/log_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/log_util.py
Apache-2.0
def _RecalculateLabel(self): """Recalculate the string label used to to prepend log messages. The label is the concatenation of all non-empty strings in the _label_list. """ non_empty_string_list = [s for s in self._label_list if s] if len(non_empty_string_list): self._label = ' '.join(non_em...
Recalculate the string label used to to prepend log messages. The label is the concatenation of all non-empty strings in the _label_list.
_RecalculateLabel
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/log_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/log_util.py
Apache-2.0
def ExtendLabel(self, label_extension): """Extends the string label used to prepend log messages. Args: label_extension: A string appended to the end of the current label. """ self._label_list.append(label_extension) self._RecalculateLabel() yield self._label_list.pop() self._Reca...
Extends the string label used to prepend log messages. Args: label_extension: A string appended to the end of the current label.
ExtendLabel
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/log_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/log_util.py
Apache-2.0
def CollectPKBLogs(run_uri: str) -> None: """Move PKB log files over to a GCS bucket (`pkb_log_bucket` flag). Args: run_uri: The run URI of the benchmark run. """ if PKB_LOG_BUCKET.value: # Generate the log path to the cloud bucket based on the invocation date of # this function. gcs_log_path =...
Move PKB log files over to a GCS bucket (`pkb_log_bucket` flag). Args: run_uri: The run URI of the benchmark run.
CollectPKBLogs
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/log_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/log_util.py
Apache-2.0
def CollectVMLogs(run_uri: str, source_path: str) -> None: """Move VM log files over to a GCS bucket (`vm_log_bucket` flag). Args: run_uri: The run URI of the benchmark run. source_path: The path to the log file. """ if VM_LOG_BUCKET.value: source_filename = source_path.split('/')[-1] gcs_direc...
Move VM log files over to a GCS bucket (`vm_log_bucket` flag). Args: run_uri: The run URI of the benchmark run. source_path: The path to the log file.
CollectVMLogs
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/log_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/log_util.py
Apache-2.0
def GetLogCloudPath(log_bucket: str, path_suffix: str) -> str: """Returns the GCS path, to where the logs should be saved. Args: log_bucket: The GCS bucket to save the logs to. path_suffix: The suffix to append to the GCS path. Returns: The GCS path to where the logs should be saved. """ run_dat...
Returns the GCS path, to where the logs should be saved. Args: log_bucket: The GCS bucket to save the logs to. path_suffix: The suffix to append to the GCS path. Returns: The GCS path to where the logs should be saved.
GetLogCloudPath
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/log_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/log_util.py
Apache-2.0
def _GetGcsPathPrefix(bucket: str) -> str: """Returns the GCS path prefix, to where the logs should be saved. Args: bucket: The GCS bucket to save the logs to. Returns: The GCS path prefix, to where the logs should be saved. If `relative_gcs_log_path` is specified, the prefix will be gs://<bucke...
Returns the GCS path prefix, to where the logs should be saved. Args: bucket: The GCS bucket to save the logs to. Returns: The GCS path prefix, to where the logs should be saved. If `relative_gcs_log_path` is specified, the prefix will be gs://<bucket>/<relative_gcs_log_path>. Otherwise, it will b...
_GetGcsPathPrefix
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/log_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/log_util.py
Apache-2.0
def GetManagedMemoryStoreClass( cloud: str, service_type: str, memory_store: str ) -> type['BaseManagedMemoryStore']: """Gets the cloud managed memory store class corresponding to 'cloud'. Args: cloud: String. Name of cloud to get the class for. service_type: String. Service type of the managed memory ...
Gets the cloud managed memory store class corresponding to 'cloud'. Args: cloud: String. Name of cloud to get the class for. service_type: String. Service type of the managed memory store. e.g. elasticache. memory_store: String. Type of memory store to get the class for. Returns: Implementat...
GetManagedMemoryStoreClass
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/managed_memory_store.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/managed_memory_store.py
Apache-2.0
def __init__(self, spec): """Initialize the cloud managed memory store object. Args: spec: spec of the managed memory store. """ super().__init__() self.name: str = 'pkb-%s' % FLAGS.run_uri self._ip: str = None self._port: int = None self._password: str = None self.failover_s...
Initialize the cloud managed memory store object. Args: spec: spec of the managed memory store.
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/managed_memory_store.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/managed_memory_store.py
Apache-2.0
def _GetNodeCount(self) -> int: """Returns the number of nodes in the cluster.""" if self.clustered: return self.shard_count * (1 + self.replicas_per_shard) if self.failover_style == Failover.FAILOVER_NONE: return 1 return 2
Returns the number of nodes in the cluster.
_GetNodeCount
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/managed_memory_store.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/managed_memory_store.py
Apache-2.0
def GetMemoryStoreIp(self) -> str: """Returns the Ip address of the managed memory store.""" if not self._ip: self._PopulateEndpoint() return self._ip
Returns the Ip address of the managed memory store.
GetMemoryStoreIp
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/managed_memory_store.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/managed_memory_store.py
Apache-2.0
def GetMemoryStorePort(self) -> int: """Returns the port number of the managed memory store.""" if not self._port: self._PopulateEndpoint() return self._port
Returns the port number of the managed memory store.
GetMemoryStorePort
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/managed_memory_store.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/managed_memory_store.py
Apache-2.0
def GetShardEndpoints( self, client: virtual_machine.BaseVirtualMachine ) -> list[RedisShard]: """Returns shard endpoints for the cluster. The format of the `cluster shards` command can be found here: https://redis.io/commands/cluster-shards/. Args: client: VM that has access to the redi...
Returns shard endpoints for the cluster. The format of the `cluster shards` command can be found here: https://redis.io/commands/cluster-shards/. Args: client: VM that has access to the redis cluster. Returns: A list of redis shards.
GetShardEndpoints
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/managed_memory_store.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/managed_memory_store.py
Apache-2.0
def SetVms(self, vm_groups) -> None: """Sets the VMs for the managed memory store.""" self._client_vms = vm_groups[ 'clients' if 'clients' in vm_groups else 'default' ]
Sets the VMs for the managed memory store.
SetVms
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/managed_memory_store.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/managed_memory_store.py
Apache-2.0
def GetReadableVersion(self) -> str: """Parses Redis major and minor version number. Used for Azure and AWS versions. Returns: Parsed version """ if self.version.count('.') < 1: logging.info( ( 'Could not parse version string correctly,' 'full Redi...
Parses Redis major and minor version number. Used for Azure and AWS versions. Returns: Parsed version
GetReadableVersion
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/managed_memory_store.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/managed_memory_store.py
Apache-2.0
def GetMessagingServiceClass(cloud, delivery): """Gets the underlying Messaging Service class.""" return resource.GetResourceClass( BaseMessagingService, CLOUD=cloud, DELIVERY=delivery )
Gets the underlying Messaging Service class.
GetMessagingServiceClass
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/messaging_service.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/messaging_service.py
Apache-2.0
def _InstallCommonClientPackages(self): """Installs common software for running benchmarks on the client VM.""" # Install commom packages self.client_vm.Install('python') self.client_vm.Install('pip') self.client_vm.RemoteCommand('sudo pip3 install absl-py numpy') # Upload common scripts se...
Installs common software for running benchmarks on the client VM.
_InstallCommonClientPackages
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/messaging_service.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/messaging_service.py
Apache-2.0
def Run( self, benchmark_scenario: str, number_of_messages: int, message_size: int, warmup_messages: int, streaming_pull: bool = False, ) -> Dict[str, Any]: """Runs remote commands on client VM - benchmark's run phase. Runs a benchmark that consists of first publishing mes...
Runs remote commands on client VM - benchmark's run phase. Runs a benchmark that consists of first publishing messages and then pulling messages from messaging service, based on the configuration specified through the FLAGS: benchmark_scenario, number_of_messages, and message_size. Specific implementat...
Run
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/messaging_service.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/messaging_service.py
Apache-2.0
def _IsReadyUnmanaged(self): """Return true if the underlying resource is ready. Returns: True if MySQL was installed successfully, False if not. Raises: Exception: If this method is called when the database is a managed one. Shouldn't happen. """ if ( self.spec.engine_...
Return true if the underlying resource is ready. Returns: True if MySQL was installed successfully, False if not. Raises: Exception: If this method is called when the database is a managed one. Shouldn't happen.
_IsReadyUnmanaged
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/mysql_iaas_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/mysql_iaas_relational_db.py
Apache-2.0
def _SetupLinuxUnmanagedDatabase(self): """Installs MySQL Server on the server vm. https://d0.awsstatic.com/whitepapers/Database/optimizing-mysql-running-on-amazon-ec2-using-amazon-ebs.pdf for minimal tuning parameters. Raises: Exception: If the requested engine version is unsupported, or if this...
Installs MySQL Server on the server vm. https://d0.awsstatic.com/whitepapers/Database/optimizing-mysql-running-on-amazon-ec2-using-amazon-ebs.pdf for minimal tuning parameters. Raises: Exception: If the requested engine version is unsupported, or if this method is called when the database is ...
_SetupLinuxUnmanagedDatabase
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/mysql_iaas_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/mysql_iaas_relational_db.py
Apache-2.0
def PrintUnmanagedDbStats(self): """Print server logs on unmanaged db.""" self.server_vm.RemoteCommand('sudo cat /var/log/mysql/error.log') self.server_vm_query_tools.IssueSqlCommand( "SHOW GLOBAL STATUS LIKE 'Aborted_connects';", superuser=True ) self.server_vm_query_tools.IssueSqlCommand( ...
Print server logs on unmanaged db.
PrintUnmanagedDbStats
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/mysql_iaas_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/mysql_iaas_relational_db.py
Apache-2.0
def _TuneForSQL(vm): """Set TuneD settings specific to SQL Server on RedHat.""" tune_settings = ( '# A TuneD configuration for SQL Server on Linux \n' '[main] \n' 'summary=Optimize for Microsoft SQL Server \n' 'include=throughput-performance \n\n' '[cpu] \n' 'force_latency=5\n\n'...
Set TuneD settings specific to SQL Server on RedHat.
_TuneForSQL
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/mysql_iaas_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/mysql_iaas_relational_db.py
Apache-2.0
def _SetupLinuxUnmanagedDatabase(self): """Installs MariaDB on the server vm. https://mariadb.com/kb/en/getting-installing-and-upgrading-mariadb/ Raises: Exception: If the requested engine version is unsupported, or if this method is called when the database is a managed one. The latter ...
Installs MariaDB on the server vm. https://mariadb.com/kb/en/getting-installing-and-upgrading-mariadb/ Raises: Exception: If the requested engine version is unsupported, or if this method is called when the database is a managed one. The latter shouldn't happen.
_SetupLinuxUnmanagedDatabase
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/mysql_iaas_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/mysql_iaas_relational_db.py
Apache-2.0
def ConfigureSQLServerLinux(vm, username: str, password: str): """Update the username and password on a SQL Server.""" vm.RemoteCommand( f'/opt/mssql-tools/bin/sqlcmd -Q "ALTER LOGIN {username} ENABLE;"' ) vm.RemoteCommand( '/opt/mssql-tools/bin/sqlcmd -Q ' f'"ALTER LOGIN sa WITH PASSWORD = \'...
Update the username and password on a SQL Server.
ConfigureSQLServerLinux
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/mysql_iaas_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/mysql_iaas_relational_db.py
Apache-2.0
def GetFirewall(cls): """Returns a BaseFirewall. This method is used instead of directly calling the class's constructor. It creates BaseFirewall instances and registers them. If a BaseFirewall object has already been registered, that object will be returned rather than creating a new one. This ena...
Returns a BaseFirewall. This method is used instead of directly calling the class's constructor. It creates BaseFirewall instances and registers them. If a BaseFirewall object has already been registered, that object will be returned rather than creating a new one. This enables multiple VMs to call...
GetFirewall
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/network.py
Apache-2.0
def AllowPort( self, vm, 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 first local port in a range of ports to open. ...
Opens a port on the firewall. Args: vm: The BaseVirtualMachine object to open the port for. start_port: The first local port in a range of ports to open. end_port: The last port in a range of ports to open. If None, only start_port will be opened. source_range: List of source CIDRs ...
AllowPort
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/network.py
Apache-2.0
def AllowIcmp(self, vm): """Logs a warning rather than opening ICMP.""" logging.warning( 'Benchmark tried to modify the firewalls of existing network %s to ' 'allow ICMP. This will be ignored, but may cause connection issues. ' 'Either allow PKB to provision a network/VPC or open ICMP ma...
Logs a warning rather than opening ICMP.
AllowIcmp
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/network.py
Apache-2.0
def AllowPort( self, vm, start_port: int, end_port: int | None = None, source_range: list[str] | None = None): """Logs a warning rather than opening ports.""" logging.warning( 'Benchmark tried to modify the firewalls of existing network %s to ' 'allow TCP connection...
Logs a warning rather than opening ports.
AllowPort
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/network.py
Apache-2.0
def __init__(self, zone=None, cidr=None, machine_type=None): """Initializes the BaseNetworkSpec. Args: zone: The zone in which to create the network. cidr: The subnet this network belongs to in CIDR notation machine_type: The vm machine_type to determine placement policy """ self.zone...
Initializes the BaseNetworkSpec. Args: zone: The zone in which to create the network. cidr: The subnet this network belongs to in CIDR notation machine_type: The vm machine_type to determine placement policy
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/network.py
Apache-2.0
def __init__(self, zone=None, cidr=None): """Initializes the BaseVpnGateway. Args: zone: The zone in which to create the VpnGateway. cidr: The cidr for the VpnGateway. """ self.zone = zone self.cidr: str = cidr # Set to True if we need target Gateway up front (AWS) self.require_...
Initializes the BaseVpnGateway. Args: zone: The zone in which to create the VpnGateway. cidr: The cidr for the VpnGateway.
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/network.py
Apache-2.0
def _GetNetworkSpecFromVm(vm): """Returns a BaseNetworkSpec created from VM attributes.""" return BaseNetworkSpec( zone=vm.zone, cidr=vm.cidr, machine_type=vm.machine_type )
Returns a BaseNetworkSpec created from VM attributes.
_GetNetworkSpecFromVm
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/network.py
Apache-2.0
def _GetKeyFromNetworkSpec(cls, spec): """Returns a key used to register Network instances.""" if cls.CLOUD is None: raise errors.Error('Networks should have CLOUD attributes.') return (cls.CLOUD, spec.zone)
Returns a key used to register Network instances.
_GetKeyFromNetworkSpec
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/network.py
Apache-2.0
def FormatCidrString(cidr_raw): """Format CIDR string for use in resource name. Removes or replaces illegal characters from CIDR. eg '10.128.0.0/9' -> '10-128-0-0-9' Args: cidr_raw: The unformatted CIDR string. Returns: A CIDR string suitable for use in resource names. Raises: ...
Format CIDR string for use in resource name. Removes or replaces illegal characters from CIDR. eg '10.128.0.0/9' -> '10-128-0-0-9' Args: cidr_raw: The unformatted CIDR string. Returns: A CIDR string suitable for use in resource names. Raises: Error: Invalid CIDR format
FormatCidrString
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/network.py
Apache-2.0
def GetNetworkFromNetworkSpec(cls, spec): """Returns a BaseNetwork. This method is used instead of directly calling the class's constructor. It creates BaseNetwork instances and registers them. If a BaseNetwork object has already been registered with the same key, that object will be returned rathe...
Returns a BaseNetwork. This method is used instead of directly calling the class's constructor. It creates BaseNetwork instances and registers them. If a BaseNetwork object has already been registered with the same key, that object will be returned rather than creating a new one. This enables multiple ...
GetNetworkFromNetworkSpec
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/network.py
Apache-2.0
def __init__(self, network_a=None, network_b=None): """Initializes BaseVPCPeeringSpec. Args: network_a: BaseNetwork. The network initiating the peering. network_b: BaseNetwork. The network to be peered to. """ self.network_a = network_a self.network_b = network_b
Initializes BaseVPCPeeringSpec. Args: network_a: BaseNetwork. The network initiating the peering. network_b: BaseNetwork. The network to be peered to.
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/network.py
Apache-2.0
def __init__(self, vpc_peering_spec): """Initialize BaseVPCPeering class. Args: vpc_peering_spec: BaseVPCPeeringSpec. Spec for VPC peering object. """ super().__init__() self.network_a = vpc_peering_spec.network_a self.network_b = vpc_peering_spec.network_b
Initialize BaseVPCPeering class. Args: vpc_peering_spec: BaseVPCPeeringSpec. Spec for VPC peering object.
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/network.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/network.py
Apache-2.0
def _ExportNfsDir(self, export_dir_path): """Export a directory on the NFS server to be shared with NFS clients. Args: export_dir_path: Path to the directory to export. """ if self.server_vm.TryRemoteCommand( f'grep "^{export_dir_path} " /etc/exports' ): logging.info('Already NF...
Export a directory on the NFS server to be shared with NFS clients. Args: export_dir_path: Path to the directory to export.
_ExportNfsDir
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/nfs_service.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/nfs_service.py
Apache-2.0
def NfsMount(server_ip, client_vm, client_path, server_path=None) -> None: """NFS mounts the server's path on the client. Args: server_ip: IP address of the NFS server. client_vm: The VM that will mount the NFS server's exported directory. client_path: The mount point on the client. server_path: Th...
NFS mounts the server's path on the client. Args: server_ip: IP address of the NFS server. client_vm: The VM that will mount the NFS server's exported directory. client_path: The mount point on the client. server_path: The NFS exported directory on the server. Defaults to the same as the clien...
NfsMount
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/nfs_service.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/nfs_service.py
Apache-2.0
def NfsExportAndMount(vms, client_path, server_path=None) -> None: """NFS exports from the first VM to the others. Args: vms: List of VMs. First is the NFS server, the others will mount it. client_path: The path on the client to mount the NFS export. server_path: The path on the server to export. Def...
NFS exports from the first VM to the others. Args: vms: List of VMs. First is the NFS server, the others will mount it. client_path: The path on the client to mount the NFS export. server_path: The path on the server to export. Default is the same as the client_path
NfsExportAndMount
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/nfs_service.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/nfs_service.py
Apache-2.0
def _GetOptionDecoderConstructions(cls): """Gets decoder classes and constructor args for each configurable option. Returns: dict. Maps option name string to a (ConfigOptionDecoder class, dict) pair. The pair specifies a decoder class and its __init__() keyword arguments to construct in order...
Gets decoder classes and constructor args for each configurable option. Returns: dict. Maps option name string to a (ConfigOptionDecoder class, dict) pair. The pair specifies a decoder class and its __init__() keyword arguments to construct in order to decode the named option.
_GetOptionDecoderConstructions
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/non_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/non_relational_db.py
Apache-2.0
def GetNonRelationalDbSpecClass( service_type: str, ) -> type[BaseNonRelationalDbSpec]: """Gets the non-relational db spec class corresponding to 'service_type'.""" return spec.GetSpecClass(BaseNonRelationalDbSpec, SERVICE_TYPE=service_type)
Gets the non-relational db spec class corresponding to 'service_type'.
GetNonRelationalDbSpecClass
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/non_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/non_relational_db.py
Apache-2.0
def GetNonRelationalDbClass(service_type: str) -> type[BaseNonRelationalDb]: """Gets the non-relational database class corresponding to 'service_type'.""" return resource.GetResourceClass( BaseNonRelationalDb, SERVICE_TYPE=service_type )
Gets the non-relational database class corresponding to 'service_type'.
GetNonRelationalDbClass
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/non_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/non_relational_db.py
Apache-2.0
def GetDownloadUrl( self, bucket: str, object_name: str, use_https=True ) -> str: """Get the URL to download objects over HTTP(S). Args: bucket: name of bucket object_name: name of object use_https: whether to use HTTPS or else HTTP Returns: The URL to download objects over...
Get the URL to download objects over HTTP(S). Args: bucket: name of bucket object_name: name of object use_https: whether to use HTTPS or else HTTP Returns: The URL to download objects over.
GetDownloadUrl
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/object_storage_service.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/object_storage_service.py
Apache-2.0
def FindCredentialFile(default_location): """Return the path to the credential file.""" credential_file = FLAGS.object_storage_credential_file or default_location credential_file = os.path.expanduser(credential_file) if not (os.path.isfile(credential_file) or os.path.isdir(credential_file)): raise errors.B...
Return the path to the credential file.
FindCredentialFile
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/object_storage_service.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/object_storage_service.py
Apache-2.0
def FindBotoFile() -> str: """Return the path to the boto file.""" paths_to_check = [ FLAGS.boto_file_location, DEFAULT_BOTO_LOCATION_USER, DEFAULT_BOTO_LOCATION_MACHINE, ] for path in paths_to_check: if not path: continue path = pathlib.Path(path).expanduser() if path.exist...
Return the path to the boto file.
FindBotoFile
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/object_storage_service.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/object_storage_service.py
Apache-2.0
def __init__(self, relational_db_spec): """Initialize the Postgres IAAS relational database object. Args: relational_db_spec: spec of the managed database. Raises: UnsupportedError: if high availability is requested for an unmanaged db. """ super().__init__(relational_db_spec) if s...
Initialize the Postgres IAAS relational database object. Args: relational_db_spec: spec of the managed database. Raises: UnsupportedError: if high availability is requested for an unmanaged db.
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/omni_postgres_iaas_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/omni_postgres_iaas_relational_db.py
Apache-2.0
def _IsReadyUnmanaged(self): """Return true if the underlying resource is ready. Returns: True if Omni was installed successfully, False if not. Raises: Exception: If this method is called when the database is a managed one. Shouldn't happen. """ stdout, _ = self.server_vm.Remo...
Return true if the underlying resource is ready. Returns: True if Omni was installed successfully, False if not. Raises: Exception: If this method is called when the database is a managed one. Shouldn't happen.
_IsReadyUnmanaged
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/omni_postgres_iaas_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/omni_postgres_iaas_relational_db.py
Apache-2.0
def RunCommand( self, command: str | list[str], ignore_failure: bool = False, should_pre_log: bool = True, stack_level: int = 1, timeout: float | None = None, **kwargs: Any, ) -> tuple[str, str, int]: """Runs a command. Additional args can be supplied & are passed to...
Runs a command. Additional args can be supplied & are passed to lower level functions but aren't required. Args: command: A valid bash command in string form. ignore_failure: Ignore any failure if set to true. should_pre_log: Whether to print the command being run or not. stack_lev...
RunCommand
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/os_mixin.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/os_mixin.py
Apache-2.0
def RemoteCommandWithReturnCode( self, *args, **kwargs ) -> Tuple[str, str, int]: """Runs a command on the VM & returns error code. Args: *args: Generic arguments, lining up with RemoteCommand. **kwargs: Additional arguments, including anything additional from child implementations....
Runs a command on the VM & returns error code. Args: *args: Generic arguments, lining up with RemoteCommand. **kwargs: Additional arguments, including anything additional from child implementations. Returns: A tuple of stdout, stderr, return_code from running the command. Raises...
RemoteCommandWithReturnCode
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/os_mixin.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/os_mixin.py
Apache-2.0
def Reboot(self): """Reboots the VM. Returns: The duration in seconds from the time the reboot command was issued to the time we could SSH into the VM and verify that the timestamp changed. Raises: Exception: If trying to reboot a VM that isn't rebootable (e.g. Kubernetes). "...
Reboots the VM. Returns: The duration in seconds from the time the reboot command was issued to the time we could SSH into the VM and verify that the timestamp changed. Raises: Exception: If trying to reboot a VM that isn't rebootable (e.g. Kubernetes).
Reboot
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/os_mixin.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/os_mixin.py
Apache-2.0
def Suspend(self) -> float: """Suspends the vm. Future plans and edge cases: checking if a vm is suspendable. Accidentally suspending a VM that is already suspending. Trying to resume a VM that is not already suspended. Returns: The amount of time it takes to Suspend a VM that is suspe...
Suspends the vm. Future plans and edge cases: checking if a vm is suspendable. Accidentally suspending a VM that is already suspending. Trying to resume a VM that is not already suspended. Returns: The amount of time it takes to Suspend a VM that is suspendable.
Suspend
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/os_mixin.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/os_mixin.py
Apache-2.0
def Resume(self) -> float: """Resumes the vm. Returns: The amount of time it takes to resume a VM that is suspendable. """ before_resume_timestamp = time.time() self._Resume() # WaitForSSH tries to ssh into the VM,ensuring resume was successful self._WaitForSSH() return time.tim...
Resumes the vm. Returns: The amount of time it takes to resume a VM that is suspendable.
Resume
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/os_mixin.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/os_mixin.py
Apache-2.0
def Start(self) -> float: """Starts the VM. Returns: The duration in seconds from the time the start command was issued to the time we could SSH into the VM and verify that the timestamp changed. """ before_start_timestamp = time.time() self._Start() self._PostStart() self._Wai...
Starts the VM. Returns: The duration in seconds from the time the start command was issued to the time we could SSH into the VM and verify that the timestamp changed.
Start
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/os_mixin.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/os_mixin.py
Apache-2.0
def Stop(self) -> float: """Stop the VM. Returns: The duration in seconds from the time the start command was issued to after the API call """ before_stop_timestamp = time.time() self._Stop() self._PostStop() stop_duration_sec = time.time() - before_stop_timestamp return st...
Stop the VM. Returns: The duration in seconds from the time the start command was issued to after the API call
Stop
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/os_mixin.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/os_mixin.py
Apache-2.0
def OnStartup(self): """Performs any necessary setup on the VM specific to the OS. This will be called once immediately after the VM has booted. """ events.on_vm_startup.send(vm=self) # Resets the cached SMT enabled status and number cpus value. self._is_smt_enabled = None self.num_cpus = N...
Performs any necessary setup on the VM specific to the OS. This will be called once immediately after the VM has booted.
OnStartup
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/os_mixin.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/os_mixin.py
Apache-2.0
def RecordAdditionalMetadata(self): """After the VM has been prepared, store VM metadata.""" # Skip metadata capture if the VM lacks a boot time, indicating that prior # VM connection attempts failed. if not self.bootable_time: return if self.num_cpus is None: self.num_cpus = self._GetNu...
After the VM has been prepared, store VM metadata.
RecordAdditionalMetadata
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/os_mixin.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/os_mixin.py
Apache-2.0
def PrepareVMEnvironment(self): """Performs any necessary setup on the VM specific to the OS. This will be called once after setting up scratch disks. """ if self.disable_interrupt_moderation: self.DisableInterruptModeration() if self.disable_rss: self.DisableRSS()
Performs any necessary setup on the VM specific to the OS. This will be called once after setting up scratch disks.
PrepareVMEnvironment
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/os_mixin.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/os_mixin.py
Apache-2.0
def PushDataFile(self, data_file, remote_path='', should_double_copy=None): """Upload a file in perfkitbenchmarker.data directory to the VM. Args: data_file: The filename of the file to upload. remote_path: The destination for 'data_file' on the VM. If not specified, the file will be placed...
Upload a file in perfkitbenchmarker.data directory to the VM. Args: data_file: The filename of the file to upload. remote_path: The destination for 'data_file' on the VM. If not specified, the file will be placed in the user's home directory. should_double_copy: Indicates whether to first...
PushDataFile
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/os_mixin.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/os_mixin.py
Apache-2.0
def RenderTemplate(self, template_path, remote_path, context): """Renders a local Jinja2 template and copies it to the remote host. The template will be provided variables defined in 'context', as well as a variable named 'vm' referencing this object. Args: template_path: string. Local path to j...
Renders a local Jinja2 template and copies it to the remote host. The template will be provided variables defined in 'context', as well as a variable named 'vm' referencing this object. Args: template_path: string. Local path to jinja2 template. remote_path: string. Remote path for rendered fi...
RenderTemplate
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/os_mixin.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/os_mixin.py
Apache-2.0
def _CreateScratchDiskFromDisks(self, disk_spec, disks): """Helper method to create scratch data disks. Given a list of BaseDisk objects, create and attach scratch disk to VM. Multiple BaseDisk objects are striped and combined into one 'logical' data disk and treated as a single disk from a benchmarks ...
Helper method to create scratch data disks. Given a list of BaseDisk objects, create and attach scratch disk to VM. Multiple BaseDisk objects are striped and combined into one 'logical' data disk and treated as a single disk from a benchmarks perspective. Args: disk_spec: The BaseDiskSpec object...
_CreateScratchDiskFromDisks
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/os_mixin.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/os_mixin.py
Apache-2.0
def _SetNumCpus(self): """Sets the number of CPUs on the VM. Returns: The number of CPUs on the VM. """ if self.num_cpus is None: self.num_cpus = self._GetNumCpus() return self.num_cpus
Sets the number of CPUs on the VM. Returns: The number of CPUs on the VM.
_SetNumCpus
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/os_mixin.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/os_mixin.py
Apache-2.0
def NumCpusForBenchmark(self, report_only_physical_cpus=False): """Gets the number of CPUs for benchmark configuration purposes. Many benchmarks scale their configurations based off of the number of CPUs available on the system (e.g. determine the number of threads). Benchmarks should use this property...
Gets the number of CPUs for benchmark configuration purposes. Many benchmarks scale their configurations based off of the number of CPUs available on the system (e.g. determine the number of threads). Benchmarks should use this property rather than num_cpus so that users can override that behavior with...
NumCpusForBenchmark
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/os_mixin.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/os_mixin.py
Apache-2.0