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 GetSQLServerVersion(
self,
vm: virtual_machine.VirtualMachine
) -> str:
"""Fetch SQL Server Version of the vm.
Args:
vm: vm
Returns:
SQL Server Version
"""
return_value: str = None
sql_srv_version_prefix = "sqlserver_"
sql_srv_supported_versions = [
"... | Fetch SQL Server Version of the vm.
Args:
vm: vm
Returns:
SQL Server Version
| GetSQLServerVersion | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/sqlserver_iaas_relational_db.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/sqlserver_iaas_relational_db.py | Apache-2.0 |
def SamplesFromQueriesAfterRunningExplain(
self,
database_name: str,
queries: Dict[str, str],
metadata: Dict[str, Any],
) -> List[sample.Sample]:
"""Run queryset once to prewarm, then run the queryset again for timing."""
results = []
for query in queries:
execution_plan, _, ... | Run queryset once to prewarm, then run the queryset again for timing. | SamplesFromQueriesAfterRunningExplain | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/sql_engine_utils.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/sql_engine_utils.py | Apache-2.0 |
def RunSqlScript(
self, file_path: str, database_name: str = ''
) -> Tuple[str, str]:
"""Run a sql command through a file.
The file could have multiple commands. RunSqlScript runs the sql file
from the file_path using the database_name. Failure in one command might
cause failure in subsequent c... | Run a sql command through a file.
The file could have multiple commands. RunSqlScript runs the sql file
from the file_path using the database_name. Failure in one command might
cause failure in subsequent commands.
Args:
file_path: The local path from the machine.
database_name: Name of th... | RunSqlScript | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/sql_engine_utils.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/sql_engine_utils.py | Apache-2.0 |
def Connect(
self, sessions: int | None = None, database_name: str = ''
) -> None:
"""Connects to the DB using PGAdapter.
See https://cloud.google.com/spanner/docs/sessions for a description
of how session count affects performance.
Args:
sessions: The number of Spanner minSessions to se... | Connects to the DB using PGAdapter.
See https://cloud.google.com/spanner/docs/sessions for a description
of how session count affects performance.
Args:
sessions: The number of Spanner minSessions to set for the client.
database_name: Database to connect
| Connect | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/sql_engine_utils.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/sql_engine_utils.py | Apache-2.0 |
def InstallPackages(self):
"""Installs packages required for making queries."""
if (
self.connection_properties.engine_version == '5.6'
or self.connection_properties.engine_version.startswith('5.6.')
):
mysql_name = 'mysqlclient56'
elif (
self.connection_properties.engine_v... | Installs packages required for making queries. | InstallPackages | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/sql_engine_utils.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/sql_engine_utils.py | Apache-2.0 |
def RunSqlScript(
self, file_path: str, database_name: str = ''
) -> Tuple[str, str]:
"""Runs Sql script from sqlcmd.
This method execute command in a sql file using sqlcmd with the -i option
enabled.
Args:
file_path: The local path from the machine.
database_name: Name of the datab... | Runs Sql script from sqlcmd.
This method execute command in a sql file using sqlcmd with the -i option
enabled.
Args:
file_path: The local path from the machine.
database_name: Name of the database.
Returns:
A tuple of stdout and stderr from running the command.
| RunSqlScript | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/sql_engine_utils.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/sql_engine_utils.py | Apache-2.0 |
def GetDbEngineType(db_engine: str) -> str:
"""Converts the engine type from db_engine.
The same engine type can have multiple names because of differences
in cloud provider or versions.
Args:
db_engine: db_engine defined in the spec
Returns:
Engine type in string.
"""
# AWS uses sqlserver-se ... | Converts the engine type from db_engine.
The same engine type can have multiple names because of differences
in cloud provider or versions.
Args:
db_engine: db_engine defined in the spec
Returns:
Engine type in string.
| GetDbEngineType | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/sql_engine_utils.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/sql_engine_utils.py | Apache-2.0 |
def GetQueryToolsByEngine(vm, connection_properties):
"""Returns the query tools to use for the engine."""
engine_type = GetDbEngineType(connection_properties.engine)
if engine_type == MYSQL:
return MysqlCliQueryTools(vm, connection_properties)
elif engine_type == MARIADB:
return MysqlCliQueryTools(vm, ... | Returns the query tools to use for the engine. | GetQueryToolsByEngine | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/sql_engine_utils.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/sql_engine_utils.py | Apache-2.0 |
def parse(self, argument):
"""Parses a list of stages.
Args:
argument: string or list of strings.
Returns:
list of strings whose elements are chosen from STAGES.
Raises:
ValueError: If argument does not conform to the guidelines explained in
syntactic_help.
"""
sta... | Parses a list of stages.
Args:
argument: string or list of strings.
Returns:
list of strings whose elements are chosen from STAGES.
Raises:
ValueError: If argument does not conform to the guidelines explained in
syntactic_help.
| parse | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/stages.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/stages.py | Apache-2.0 |
def __init__(
self,
component_full_name,
ip_address=None,
user_name=None,
ssh_private_key=None,
internal_ip=None,
ssh_port=22,
password=None,
disk_specs=None,
os_type=None,
tag=None,
zone=None,
**kwargs
):
"""Initialize the StaticVmSpec... | Initialize the StaticVmSpec object.
Args:
component_full_name: string. Fully qualified name of the configurable
component containing the config options.
ip_address: The public ip address of the VM.
user_name: The username of the VM that the keyfile corresponds to.
ssh_private_key: T... | __init__ | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/static_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/static_virtual_machine.py | Apache-2.0 |
def __init__(self, vm_spec):
"""Initialize a static virtual machine.
Args:
vm_spec: A StaticVmSpec object containing arguments.
"""
super().__init__(vm_spec)
self.ip_address = vm_spec.ip_address
self.user_name = vm_spec.user_name
self.ssh_private_key = vm_spec.ssh_private_key
self... | Initialize a static virtual machine.
Args:
vm_spec: A StaticVmSpec object containing arguments.
| __init__ | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/static_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/static_virtual_machine.py | Apache-2.0 |
def _Delete(self):
"""Returns the virtual machine to the pool."""
if self.from_pool:
with self.vm_pool_lock:
self.vm_pool.appendleft(self) | Returns the virtual machine to the pool. | _Delete | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/static_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/static_virtual_machine.py | Apache-2.0 |
def ReadStaticVirtualMachineFile(cls, file_obj):
"""Read a file describing the static VMs to use.
This function will read the static VM information from the provided file,
instantiate VMs corresponding to the info, and add the VMs to the static
VM pool. The provided file should contain a single array i... | Read a file describing the static VMs to use.
This function will read the static VM information from the provided file,
instantiate VMs corresponding to the info, and add the VMs to the static
VM pool. The provided file should contain a single array in JSON-format.
Each element in the array must be an ... | ReadStaticVirtualMachineFile | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/static_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/static_virtual_machine.py | Apache-2.0 |
def VerifyItemFormat(item):
"""Verify that the decoded JSON object matches the required schema."""
item_keys = frozenset(item)
extra_keys = sorted(item_keys - allowed_keys)
missing_keys = required_keys - item_keys
if extra_keys:
raise ValueError('Unexpected keys: {}'.format(', '.jo... | Verify that the decoded JSON object matches the required schema. | VerifyItemFormat | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/static_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/static_virtual_machine.py | Apache-2.0 |
def GetStaticVirtualMachine(cls):
"""Pull a Static VM from the pool of static VMs.
If there are no VMs left in the pool, the method will return None.
Returns:
A static VM from the pool, or None if there are no static VMs left.
"""
with cls.vm_pool_lock:
if cls.vm_pool:
vm = c... | Pull a Static VM from the pool of static VMs.
If there are no VMs left in the pool, the method will return None.
Returns:
A static VM from the pool, or None if there are no static VMs left.
| GetStaticVirtualMachine | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/static_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/static_virtual_machine.py | Apache-2.0 |
def GetStaticVmClass(os_type) -> type[virtual_machine.BaseVirtualMachine]:
"""Returns the static VM class that corresponds to the os_type."""
if not os_type:
os_type = os_types.DEFAULT
logging.warning('Could not find os type for VM. Defaulting to %s.', os_type)
return virtual_machine.GetVmClass(
Sta... | Returns the static VM class that corresponds to the os_type. | GetStaticVmClass | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/static_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/static_virtual_machine.py | Apache-2.0 |
def _GetPlatformDependentTempDir():
"""Gets temporary directory based on platform."""
if platform.system() == 'Darwin':
# MacOS by default has extremely long temp directory path,
# resulting failure during ssh due to "too long for Unix domain socket".
return '/tmp'
else:
return tempfile.gettempdir... | Gets temporary directory based on platform. | _GetPlatformDependentTempDir | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/temp_dir.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/temp_dir.py | Apache-2.0 |
def CreateTemporaryDirectories():
"""Creates the temporary sub-directories needed by the current run."""
for path in (GetRunDirPath(), GetVersionDirPath(), GetSshConnectionsDir()):
try:
os.makedirs(path)
except OSError:
if not os.path.isdir(path):
raise | Creates the temporary sub-directories needed by the current run. | CreateTemporaryDirectories | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/temp_dir.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/temp_dir.py | Apache-2.0 |
def assertSamplesEqualUpToTimestamp(self, a, b, msg=None):
"""Assert that two samples are equal, ignoring timestamp differences."""
self.assertEqual(
a.metric,
b.metric,
msg or 'Samples %s and %s have different metrics' % (a, b),
)
if isinstance(a.value, float) and isinstance(b.v... | Assert that two samples are equal, ignoring timestamp differences. | assertSamplesEqualUpToTimestamp | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/test_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/test_util.py | Apache-2.0 |
def assertSampleListsEqualUpToTimestamp(self, a, b, msg=None):
"""Compare two lists of samples.
Sadly, the builtin assertListsEqual will only use Python's
built-in equality predicate for testing the equality of elements
in a list. Since we compare lists of samples a lot, we need a
custom test for t... | Compare two lists of samples.
Sadly, the builtin assertListsEqual will only use Python's
built-in equality predicate for testing the equality of elements
in a list. Since we compare lists of samples a lot, we need a
custom test for that.
| assertSampleListsEqualUpToTimestamp | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/test_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/test_util.py | Apache-2.0 |
def assertSampleInList(self, a, b, msg=None): # pylint:disable=invalid-name
"""Assert that sample a is in list b (up to timestamp)."""
found = False
for s in b:
try:
self.assertSamplesEqualUpToTimestamp(a, s, msg=msg)
except self.failureException:
continue
found = True
... | Assert that sample a is in list b (up to timestamp). | assertSampleInList | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/test_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/test_util.py | Apache-2.0 |
def assertDiskMounts(benchmark_config, mount_point):
"""Test whether a disk mounts in a given configuration.
Sets up a virtual machine following benchmark_config and then tests
whether the path mount_point contains a working disk by trying to
create a file there. Returns nothing if file creation works;
other... | Test whether a disk mounts in a given configuration.
Sets up a virtual machine following benchmark_config and then tests
whether the path mount_point contains a working disk by trying to
create a file there. Returns nothing if file creation works;
otherwise raises an exception.
Args:
benchmark_config: a... | assertDiskMounts | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/test_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/test_util.py | Apache-2.0 |
def _IsReadyUnmanaged(self):
"""Return true if the underlying resource is ready.
Returns:
True if TimescaleDB 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_... | Return true if the underlying resource is ready.
Returns:
True if TimescaleDB 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/timescaledb_iaas_relational_db.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/timescaledb_iaas_relational_db.py | Apache-2.0 |
def EndToEndRuntimeMeasurementEnabled():
"""Returns whether end-to-end runtime measurement is globally enabled."""
return (
MEASUREMENTS_END_TO_END_RUNTIME in flags.FLAGS.timing_measurements
or RuntimeMeasurementsEnabled()
) | Returns whether end-to-end runtime measurement is globally enabled. | EndToEndRuntimeMeasurementEnabled | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/timing_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/timing_util.py | Apache-2.0 |
def ValidateMeasurementsFlag(options_list):
"""Verifies correct usage of the measurements configuration flag.
The user of the flag must provide at least one option. All provided options
must be valid. The NONE option cannot be combined with other options.
Args:
options_list: A list of strings parsed from ... | Verifies correct usage of the measurements configuration flag.
The user of the flag must provide at least one option. All provided options
must be valid. The NONE option cannot be combined with other options.
Args:
options_list: A list of strings parsed from the provided value for the flag.
Returns:
... | ValidateMeasurementsFlag | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/timing_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/timing_util.py | Apache-2.0 |
def _GenerateIntervalSamples(interval, include_timestamps):
"""Generates Samples for a single interval timed by IntervalTimer.Measure.
Args:
interval: A (name, start_time, stop_time) tuple from a call to
IntervalTimer.Measure.
include_timestamps: A Boolean that controls whether Samples containing the... | Generates Samples for a single interval timed by IntervalTimer.Measure.
Args:
interval: A (name, start_time, stop_time) tuple from a call to
IntervalTimer.Measure.
include_timestamps: A Boolean that controls whether Samples containing the
start and stop timestamps are added to the generated list.... | _GenerateIntervalSamples | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/timing_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/timing_util.py | Apache-2.0 |
def Measure(self, name):
"""Records the start and stop times of the enclosed interval.
Args:
name: A string that names the interval.
"""
start_time = time.time()
yield
stop_time = time.time()
self.intervals.append((name, start_time, stop_time)) | Records the start and stop times of the enclosed interval.
Args:
name: A string that names the interval.
| Measure | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/timing_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/timing_util.py | Apache-2.0 |
def GenerateSamples(self):
"""Generates Samples based on the times recorded in all calls to Measure.
Returns:
A list of Samples. The list contains Samples for each interval that was
wrapped by a call to Measure, with per-interval Samples generated as
specified by the args in the order of runt... | Generates Samples based on the times recorded in all calls to Measure.
Returns:
A list of Samples. The list contains Samples for each interval that was
wrapped by a call to Measure, with per-interval Samples generated as
specified by the args in the order of runtime, start timestamp, stop
t... | GenerateSamples | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/timing_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/timing_util.py | Apache-2.0 |
def _GetVersion():
"""Gets the version from git or the static version file."""
# Try to pull the version from git.
root_dir = os.path.dirname(os.path.dirname(__file__))
git_dir = os.path.join(root_dir, '.git')
try:
version = subprocess.check_output(
['git', '--git-dir', git_dir, 'describe', '--alw... | Gets the version from git or the static version file. | _GetVersion | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/version.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/version.py | Apache-2.0 |
def ValidateVmMetadataFlag(options_list):
"""Verifies correct usage of the vm metadata flag.
All provided options must be in the form of key:value.
Args:
options_list: A list of strings parsed from the provided value for the flag.
Returns:
True if the list of options provided as the value for the fla... | Verifies correct usage of the vm metadata flag.
All provided options must be in the form of key:value.
Args:
options_list: A list of strings parsed from the provided value for the flag.
Returns:
True if the list of options provided as the value for the flag meets
requirements.
Raises:
flags.... | ValidateVmMetadataFlag | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/virtual_machine.py | Apache-2.0 |
def GetVmSpecClass(cloud: str, platform: str | None = None):
"""Returns the VmSpec class with corresponding attributes.
Args:
cloud: The cloud being used.
platform: The vm platform being used (see enum above). If not provided,
defaults to flag value.
Returns:
A child of BaseVmSpec with the cor... | Returns the VmSpec class with corresponding attributes.
Args:
cloud: The cloud being used.
platform: The vm platform being used (see enum above). If not provided,
defaults to flag value.
Returns:
A child of BaseVmSpec with the corresponding attributes.
| GetVmSpecClass | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/virtual_machine.py | Apache-2.0 |
def GetVmClass(cloud: str, os_type: str, platform: str | None = None):
"""Returns the VM class with corresponding attributes.
Args:
cloud: The cloud being used.
os_type: The os type of the VM.
platform: The vm platform being used (see enum above). If not provided,
defaults to flag value.
Retur... | Returns the VM class with corresponding attributes.
Args:
cloud: The cloud being used.
os_type: The os type of the VM.
platform: The vm platform being used (see enum above). If not provided,
defaults to flag value.
Returns:
A child of BaseVirtualMachine with the corresponding attributes.
| GetVmClass | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/virtual_machine.py | Apache-2.0 |
def __init__(self, vm_spec: BaseVmSpec):
"""Initialize BaseVirtualMachine class.
Args:
vm_spec: virtual_machine.BaseVmSpec object of the vm.
"""
super().__init__()
with self._instance_counter_lock:
self.instance_number = self._instance_counter
name_prefix = (
_VM_NAME_PR... | Initialize BaseVirtualMachine class.
Args:
vm_spec: virtual_machine.BaseVmSpec object of the vm.
| __init__ | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/virtual_machine.py | Apache-2.0 |
def GetConnectionIp(self):
"""Gets the IP to use for connecting to the VM."""
if not self.created:
raise errors.VirtualMachine.VirtualMachineError(
'VM was not properly created, but PKB is attempting to connect to '
'it anyways. Caller should guard against VM not being created.'
... | Gets the IP to use for connecting to the VM. | GetConnectionIp | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/virtual_machine.py | Apache-2.0 |
def GetInternalIPs(self):
"""Gets the Internal IP's for the VM."""
if self.internal_ips:
return self.internal_ips
elif self.internal_ip:
return [self.internal_ip]
return [] | Gets the Internal IP's for the VM. | GetInternalIPs | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/virtual_machine.py | Apache-2.0 |
def SetDiskSpec(self, disk_spec, disk_count):
"""Set Disk Specs of the current VM."""
# This method will be depreciate soon.
if disk_spec.disk_type == disk.LOCAL and disk_count is None:
disk_count = self.max_local_disks
self.disk_specs = [copy.copy(disk_spec) for _ in range(disk_count)]
# In t... | Set Disk Specs of the current VM. | SetDiskSpec | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/virtual_machine.py | Apache-2.0 |
def SetupAllScratchDisks(self):
"""Set up all scratch disks of the current VM."""
# This method will be depreciate soon.
# Prepare vm scratch disks:
if any(spec.disk_type == disk.RAM for spec in self.disk_specs):
disk_strategies.SetUpRamDiskStrategy(self, self.disk_specs[0]).SetUpDisk()
retu... | Set up all scratch disks of the current VM. | SetupAllScratchDisks | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/virtual_machine.py | Apache-2.0 |
def GetScratchDir(self, disk_num=0):
"""Gets the path to the scratch directory.
Args:
disk_num: The number of the disk to mount.
Returns:
The mounted disk directory.
"""
if disk_num >= len(self.scratch_disks):
raise errors.Error(
'GetScratchDir(disk_num=%s) is invalid, ... | Gets the path to the scratch directory.
Args:
disk_num: The number of the disk to mount.
Returns:
The mounted disk directory.
| GetScratchDir | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/virtual_machine.py | Apache-2.0 |
def CreateAndBoot(self):
"""Creates a single VM and waits for boot to complete.
This is done repeatedly to get --required_cpu_version if it is set.
"""
def CreateAndBootOnce():
self.Create()
logging.info('VM: %s (%s)', self.ip_address, self.internal_ip)
logging.info('Waiting for boot... | Creates a single VM and waits for boot to complete.
This is done repeatedly to get --required_cpu_version if it is set.
| CreateAndBoot | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/virtual_machine.py | Apache-2.0 |
def PrepareAfterBoot(self):
"""Prepares a VM after it has booted.
This function will prepare a scratch disk if required.
Raises:
Exception: If --vm_metadata is malformed.
"""
self.AddMetadata()
self.OnStartup()
self.SetupAllScratchDisks()
self.PrepareVMEnvironment()
self.Re... | Prepares a VM after it has booted.
This function will prepare a scratch disk if required.
Raises:
Exception: If --vm_metadata is malformed.
| PrepareAfterBoot | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/virtual_machine.py | Apache-2.0 |
def AllowPort(self, start_port, end_port=None, source_range=None):
"""Opens the port on the firewall corresponding to the VM if one exists.
Args:
start_port: The first local port to open in a range.
end_port: The last local port to open in a range. If None, only start_port
will be opened.
... | Opens the port on the firewall corresponding to the VM if one exists.
Args:
start_port: The first local port to open in a range.
end_port: The last local port to open in a range. If None, only start_port
will be opened.
source_range: list of CIDRs. If none, all sources are allowed.
| AllowPort | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/virtual_machine.py | Apache-2.0 |
def GetResourceMetadata(self):
"""Returns a dict containing VM metadata.
Returns:
dict mapping string property key to value.
"""
if not self.created:
return {}
result = self.metadata.copy()
result.update({
'image': self.image,
'cloud': self.CLOUD,
'os_type': ... | Returns a dict containing VM metadata.
Returns:
dict mapping string property key to value.
| GetResourceMetadata | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/virtual_machine.py | Apache-2.0 |
def _InstallData(
self,
preprovisioned_data: Dict[str, str],
module_name: str,
filenames: List[str],
install_path: str,
fallback_url: Dict[str, str],
timeout=PREPROVISIONED_DATA_TIMEOUT,
):
"""Installs preprovisioned_data on this VM.
Args:
preprovisioned_data: ... | Installs preprovisioned_data on this VM.
Args:
preprovisioned_data: The dict mapping filenames to sha256sum hashes.
module_name: The name of the module defining the preprovisioned data.
filenames: An iterable of preprovisioned data filenames for a particular
module.
install_path: Th... | _InstallData | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/virtual_machine.py | Apache-2.0 |
def InstallPreprovisionedBenchmarkData(
self,
benchmark_name,
filenames,
install_path,
timeout=PREPROVISIONED_DATA_TIMEOUT,
):
"""Installs preprovisioned benchmark data on this VM.
Some benchmarks require importing many bytes of data into the virtual
machine. This data can b... | Installs preprovisioned benchmark data on this VM.
Some benchmarks require importing many bytes of data into the virtual
machine. This data can be staged in a particular cloud and the virtual
machine implementation can override how the preprovisioned data is
installed in the VM by overriding DownloadPr... | InstallPreprovisionedBenchmarkData | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/virtual_machine.py | Apache-2.0 |
def InstallPreprovisionedPackageData(
self,
package_name,
filenames,
install_path,
timeout=PREPROVISIONED_DATA_TIMEOUT,
):
"""Installs preprovisioned Package data on this VM.
Some benchmarks require importing many bytes of data into the virtual
machine. This data can be stag... | Installs preprovisioned Package data on this VM.
Some benchmarks require importing many bytes of data into the virtual
machine. This data can be staged in a particular cloud and the virtual
machine implementation can override how the preprovisioned data is
installed in the VM by overriding DownloadPrep... | InstallPreprovisionedPackageData | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/virtual_machine.py | Apache-2.0 |
def DownloadPreprovisionedData(
self,
install_path: str,
module_name: str,
filename: str,
timeout: int = PREPROVISIONED_DATA_TIMEOUT,
):
"""Downloads preprovisioned benchmark data.
This function should be overridden by each cloud provider VM. The file
should be downloaded in... | Downloads preprovisioned benchmark data.
This function should be overridden by each cloud provider VM. The file
should be downloaded into the install path within a subdirectory with the
benchmark name.
The downloaded file's parent directory will be created if it does not
exist.
Args:
in... | DownloadPreprovisionedData | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/virtual_machine.py | Apache-2.0 |
def UpdateInterruptibleVmStatus(self, use_api=False):
"""Updates the status of the discounted vm.
Args:
use_api: boolean, If use_api is false, method will attempt to query
metadata service to check vm preemption. If use_api is true, method will
attempt to use API to detect vm preemption q... | Updates the status of the discounted vm.
Args:
use_api: boolean, If use_api is false, method will attempt to query
metadata service to check vm preemption. If use_api is true, method will
attempt to use API to detect vm preemption query if metadata service
detecting fails.
| UpdateInterruptibleVmStatus | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/virtual_machine.py | Apache-2.0 |
def SSHKeyGen():
"""Use provided SSH keys or create PerfKitBenchmarker SSH keys in the tmp dir of the current run."""
if UseProvidedSSHKeys():
return
if not os.path.isdir(GetTempDir()):
GenTempDir()
if not os.path.isfile(GetPrivateKeyPath()):
create_cmd = [
'ssh-keygen',
'-t',
... | Use provided SSH keys or create PerfKitBenchmarker SSH keys in the tmp dir of the current run. | SSHKeyGen | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vm_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vm_util.py | Apache-2.0 |
def GetSshOptions(ssh_key_filename, connect_timeout=None):
"""Return common set of SSH and SCP options."""
# pyformat: disable
options = [
'-2',
'-o', 'UserKnownHostsFile=/dev/null',
'-o', 'StrictHostKeyChecking=no',
'-o', 'IdentitiesOnly=yes',
'-o', 'PreferredAuthentications=publick... | Return common set of SSH and SCP options. | GetSshOptions | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vm_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vm_util.py | Apache-2.0 |
def Wrap(f):
"""Wraps the supplied function with retry logic."""
def WrappedFunction(*args, **kwargs):
"""Holds the retry logic."""
local_timeout = FLAGS.default_timeout if timeout is None else timeout
if local_timeout >= 0:
deadline = time.time() + local_timeout
else:
... | Wraps the supplied function with retry logic. | Wrap | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vm_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vm_util.py | Apache-2.0 |
def _ReadIssueCommandOutput(tf_out, tf_err):
"""Reads IssueCommand Output from stdout and stderr."""
tf_out.seek(0)
stdout = tf_out.read().decode('ascii', 'ignore')
tf_err.seek(0)
stderr = tf_err.read().decode('ascii', 'ignore')
return stdout, stderr | Reads IssueCommand Output from stdout and stderr. | _ReadIssueCommandOutput | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vm_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vm_util.py | Apache-2.0 |
def IssueCommand(
cmd: Iterable[str],
env: Dict[str, str] | None = None,
timeout: int | None = DEFAULT_TIMEOUT,
cwd: str | None = None,
should_pre_log: bool = True,
raise_on_failure: bool = True,
suppress_failure: Callable[[str, str, int], bool] | None = None,
suppress_logging: bool = Fa... | Tries running the provided command once.
Args:
cmd: A list of strings such as is given to the subprocess.Popen()
constructor.
env: A dict of key/value strings, such as is given to the subprocess.Popen()
constructor, that contains environment variables to be injected.
timeout: Timeout for the ... | IssueCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vm_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vm_util.py | Apache-2.0 |
def IssueBackgroundCommand(cmd, stdout_path, stderr_path, env=None):
"""Run the provided command once in the background.
Args:
cmd: Command to be run, as expected by subprocess.Popen.
stdout_path: Redirect stdout here. Overwritten.
stderr_path: Redirect stderr here. Overwritten.
env: A dict of key/... | Run the provided command once in the background.
Args:
cmd: Command to be run, as expected by subprocess.Popen.
stdout_path: Redirect stdout here. Overwritten.
stderr_path: Redirect stderr here. Overwritten.
env: A dict of key/value strings, such as is given to the subprocess.Popen()
constructo... | IssueBackgroundCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vm_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vm_util.py | Apache-2.0 |
def IssueRetryableCommand(cmd, env=None, **kwargs):
"""Tries running the provided command until it succeeds or times out.
Args:
cmd: A list of strings such as is given to the subprocess.Popen()
constructor.
env: An alternate environment to pass to the Popen command.
**kwargs: additional arguments... | Tries running the provided command until it succeeds or times out.
Args:
cmd: A list of strings such as is given to the subprocess.Popen()
constructor.
env: An alternate environment to pass to the Popen command.
**kwargs: additional arguments for the command
Returns:
A tuple of stdout and st... | IssueRetryableCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vm_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vm_util.py | Apache-2.0 |
def ParseTimeCommandResult(command_result):
"""Parse command result and get time elapsed.
Note this parses the output of bash's time builtin, not /usr/bin/time or other
implementations. You may need to run something like bash -c "time ./command"
to produce parseable output.
Args:
command_result: The re... | Parse command result and get time elapsed.
Note this parses the output of bash's time builtin, not /usr/bin/time or other
implementations. You may need to run something like bash -c "time ./command"
to produce parseable output.
Args:
command_result: The result after executing a remote time command.
Re... | ParseTimeCommandResult | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vm_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vm_util.py | Apache-2.0 |
def ShouldRunOnExternalIpAddress(ip_type=None):
"""Returns whether a test should be run on an instance's external IP."""
ip_type_to_check = ip_type or FLAGS.ip_addresses
return ip_type_to_check in (
IpAddressSubset.EXTERNAL,
IpAddressSubset.BOTH,
IpAddressSubset.REACHABLE,
) | Returns whether a test should be run on an instance's external IP. | ShouldRunOnExternalIpAddress | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vm_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vm_util.py | Apache-2.0 |
def ShouldRunOnInternalIpAddress(sending_vm, receiving_vm, ip_type=None):
"""Returns whether a test should be run on an instance's internal IP.
Based on the command line flag --ip_addresses. Internal IP addresses are used
when:
* --ip_addresses=BOTH or --ip-addresses=INTERNAL
* --ip_addresses=REACHABLE and ... | Returns whether a test should be run on an instance's internal IP.
Based on the command line flag --ip_addresses. Internal IP addresses are used
when:
* --ip_addresses=BOTH or --ip-addresses=INTERNAL
* --ip_addresses=REACHABLE and 'sending_vm' can ping 'receiving_vm' on its
internal IP.
Args:
sendi... | ShouldRunOnInternalIpAddress | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vm_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vm_util.py | Apache-2.0 |
def GetLastRunUri():
"""Returns the last run_uri used (or None if it can't be determined)."""
runs_dir_path = temp_dir.GetAllRunsDirPath()
try:
dir_names = next(os.walk(runs_dir_path))[1]
except StopIteration:
# The runs directory was not found.
return None
if not dir_names:
# No run subdirec... | Returns the last run_uri used (or None if it can't be determined). | GetLastRunUri | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vm_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vm_util.py | Apache-2.0 |
def NamedTemporaryFile(
mode='w+b', prefix='tmp', suffix='', dir=None, delete=True
):
"""Behaves like tempfile.NamedTemporaryFile.
The existing tempfile.NamedTemporaryFile has the annoying property on
Windows that it cannot be opened a second time while it is already open.
This makes it impossible to use i... | Behaves like tempfile.NamedTemporaryFile.
The existing tempfile.NamedTemporaryFile has the annoying property on
Windows that it cannot be opened a second time while it is already open.
This makes it impossible to use it with a "with" statement in a cross platform
compatible way. This serves a similar role, but... | NamedTemporaryFile | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vm_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vm_util.py | Apache-2.0 |
def GenerateSSHConfig(vms, vm_groups):
"""Generates an SSH config file to simplify connecting to the specified VMs.
Writes a file to GetTempDir()/ssh_config with an SSH configuration for each VM
provided in the arguments. Users can then SSH with any of the following:
ssh -F <ssh_config_path> <vm_name>
... | Generates an SSH config file to simplify connecting to the specified VMs.
Writes a file to GetTempDir()/ssh_config with an SSH configuration for each VM
provided in the arguments. Users can then SSH with any of the following:
ssh -F <ssh_config_path> <vm_name>
ssh -F <ssh_config_path> vm<vm_index>
... | GenerateSSHConfig | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vm_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vm_util.py | Apache-2.0 |
def ExecutableOnPath(executable_name):
"""Return True if the given executable can be found on the path."""
cmd = ['where'] if RunningOnWindows() else ['which']
cmd.append(executable_name)
shell_value = RunningOnWindows()
process = subprocess.Popen(
cmd, shell=shell_value, stdout=subprocess.PIPE, stderr... | Return True if the given executable can be found on the path. | ExecutableOnPath | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vm_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vm_util.py | Apache-2.0 |
def GenerateRandomWindowsPassword(
password_length=PASSWORD_LENGTH, special_chars='*!@#$+'
):
"""Generates a password that meets Windows complexity requirements."""
# The special characters have to be recognized by the Azure CLI as
# special characters. This greatly limits the set of characters
# that we ca... | Generates a password that meets Windows complexity requirements. | GenerateRandomWindowsPassword | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vm_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vm_util.py | Apache-2.0 |
def CopyFileBetweenVms(filename, src_vm, src_path, dest_vm, dest_path):
"""Copies a file from the src_vm to the dest_vm."""
with tempfile.NamedTemporaryFile() as tf:
temp_path = tf.name
src_vm.RemoteCopy(
temp_path, os.path.join(src_path, filename), copy_to=False
)
dest_vm.RemoteCopy(
... | Copies a file from the src_vm to the dest_vm. | CopyFileBetweenVms | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vm_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vm_util.py | Apache-2.0 |
def DictionaryToEnvString(dictionary, joiner=' '):
"""Convert a dictionary to a space sperated 'key=value' string.
Args:
dictionary: the key-value dictionary to be convert
joiner: string to separate the entries in the returned value.
Returns:
a string representing the dictionary
"""
return joine... | Convert a dictionary to a space sperated 'key=value' string.
Args:
dictionary: the key-value dictionary to be convert
joiner: string to separate the entries in the returned value.
Returns:
a string representing the dictionary
| DictionaryToEnvString | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vm_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vm_util.py | Apache-2.0 |
def CreateRemoteFile(vm, file_contents, file_path):
"""Creates a file on the remote server."""
with NamedTemporaryFile(mode='w') as tf:
tf.write(file_contents)
tf.close()
parent_dir = posixpath.dirname(file_path)
vm.RemoteCommand(f'[ -d {parent_dir} ] || mkdir -p {parent_dir}')
vm.PushFile(tf.na... | Creates a file on the remote server. | CreateRemoteFile | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vm_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vm_util.py | Apache-2.0 |
def getKeyFromGatewayPair(self, gateway_pair, suffix=''):
"""Return the VPN key for a pair of endpoints.
Args:
gateway_pair: A tuple of 2 VPN gateways which define the VPN tunnel.
suffix: A unique suffix if multiple tunnels b/t this gateway pair exist.
Returns:
string. The VPN key.
"... | Return the VPN key for a pair of endpoints.
Args:
gateway_pair: A tuple of 2 VPN gateways which define the VPN tunnel.
suffix: A unique suffix if multiple tunnels b/t this gateway pair exist.
Returns:
string. The VPN key.
| getKeyFromGatewayPair | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vpn_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vpn_service.py | Apache-2.0 |
def GetVPN(self, gateway_pair, suffix=''):
"""Gets a VPN object for the gateway_pair or creates one if none exists.
Args:
gateway_pair: a tuple of two VpnGateways
"""
benchmark_spec = context.GetThreadBenchmarkSpec()
if benchmark_spec is None:
raise errors.Error('GetVPN called in a thre... | Gets a VPN object for the gateway_pair or creates one if none exists.
Args:
gateway_pair: a tuple of two VpnGateways
| GetVPN | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vpn_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vpn_service.py | Apache-2.0 |
def isTunnelConfigured(self):
"""Returns True if the tunnel configuration is complete.
Returns:
boolean.
"""
is_tunnel_configured = False
if len(self.tunnel_config.endpoints) == 2:
if (
self.tunnel_config.endpoints[self.gateway_pair[0]]['is_configured']
and self.tunn... | Returns True if the tunnel configuration is complete.
Returns:
boolean.
| isTunnelConfigured | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vpn_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vpn_service.py | Apache-2.0 |
def isTunnelReady(self):
"""Returns True if the tunnel is up.
Returns:
boolean.
"""
benchmark_spec = context.GetThreadBenchmarkSpec()
logging.debug('Tunnel endpoints configured. Waiting for tunnel...')
ready = benchmark_spec.vpn_gateways[self.gateway_pair[0]].IsTunnelReady(
self.t... | Returns True if the tunnel is up.
Returns:
boolean.
| isTunnelReady | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vpn_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vpn_service.py | Apache-2.0 |
def __init__(self, spec):
"""Initialize the VPN Service object.
Args:
vpn_service_spec: spec of the vpn service.
"""
super().__init__()
self.name = spec.name
self.tunnel_count = spec.tunnel_count
self.gateway_count = FLAGS.vpn_service_gateway_count
self.routing = spec.routing_type... | Initialize the VPN Service object.
Args:
vpn_service_spec: spec of the vpn service.
| __init__ | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vpn_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vpn_service.py | Apache-2.0 |
def GetResourceMetadata(self):
"""Returns a dictionary of metadata about the resource."""
if not self.created:
return {}
result = self.metadata.copy()
if self.routing is not None:
result['vpn_service_routing_type'] = self.routing
if self.ike_version is not None:
result['vpn_servic... | Returns a dictionary of metadata about the resource. | GetResourceMetadata | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vpn_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vpn_service.py | Apache-2.0 |
def _Create(self):
"""Creates VPN objects for VpnGateway pairs."""
benchmark_spec = context.GetThreadBenchmarkSpec()
if benchmark_spec is None:
raise errors.Error(
'CreateVPN Service. called in a thread without a BenchmarkSpec.'
)
self.vpn_gateway_pairs = self.GetVpnGatewayPairs(... | Creates VPN objects for VpnGateway pairs. | _Create | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vpn_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vpn_service.py | Apache-2.0 |
def GetMetadata(self):
"""Return a dictionary of the metadata for VPNs created."""
basic_data = {
'vpn_service_name': self.name,
'vpn_service_routing_type': self.routing,
'vpn_service_ike_version': self.ike_version,
'vpn_service_tunnel_count': self.tunnel_count,
'vpn_serv... | Return a dictionary of the metadata for VPNs created. | GetMetadata | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vpn_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vpn_service.py | Apache-2.0 |
def GetVpnGatewayPairs(
self, vpn_gateways
) -> List[Tuple[network.BaseVpnGateway, network.BaseVpnGateway]]:
"""Returns pairs of gateways to create VPNs between.
Currently creates a pair between all non-matching region endpoints (mesh).
--vpn_service_gateway_count flag dictates how many gateways ar... | Returns pairs of gateways to create VPNs between.
Currently creates a pair between all non-matching region endpoints (mesh).
--vpn_service_gateway_count flag dictates how many gateways are created in
each vm_group(region).
--vpn_service_tunnel_count flag dictates how many VPN tunnels to create for
... | GetVpnGatewayPairs | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/vpn_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/vpn_service.py | Apache-2.0 |
def winrm_retry(func):
"""A decorator that applies vm_util.Retry with WinRM-specific flag settings.
This decorator is a "decorator factory" that, when applied to a method,
returns a vm_util.Retry decorator configured with the *runtime* values
of absl flags.
Args:
func: The function to decorate vm_util.R... | A decorator that applies vm_util.Retry with WinRM-specific flag settings.
This decorator is a "decorator factory" that, when applied to a method,
returns a vm_util.Retry decorator configured with the *runtime* values
of absl flags.
Args:
func: The function to decorate vm_util.Retry.
Returns:
A func... | winrm_retry | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/windows_virtual_machine.py | Apache-2.0 |
def RobustRemoteCommand(
self,
command: str,
ignore_failure: bool = False,
timeout: float | None = None,
) -> Tuple[str, str]:
"""Runs a powershell command on the VM.
We have attempted using Invoke-WmiMethod and other long running
command and failed. Revert to just use RemoteComma... | Runs a powershell command on the VM.
We have attempted using Invoke-WmiMethod and other long running
command and failed. Revert to just use RemoteCommand on windows.
Args:
command: A valid powershell command.
ignore_failure: Ignore any failure if set to true.
timeout: Float. A timeout in... | RobustRemoteCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/windows_virtual_machine.py | Apache-2.0 |
def RemoteCommand(
self,
command: str,
ignore_failure: bool = False,
timeout: float | None = None,
) -> Tuple[str, str]:
"""Runs a powershell command on the VM.
Args:
command: A valid powershell command.
ignore_failure: Ignore any failure if set to true.
timeout: Flo... | Runs a powershell command on the VM.
Args:
command: A valid powershell command.
ignore_failure: Ignore any failure if set to true.
timeout: Float. A timeout in seconds for the command. If None is passed,
no timeout is applied. Timeout kills the winrm session which then kills
the p... | RemoteCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/windows_virtual_machine.py | Apache-2.0 |
def RemoteCopy(self, local_path, remote_path='', copy_to=True):
"""Copies a file to or from the VM.
Args:
local_path: Local path to file.
remote_path: Optional path of where to copy file on remote host.
copy_to: True to copy to vm, False to copy from vm.
Raises:
RemoteCommandError:... | Copies a file to or from the VM.
Args:
local_path: Local path to file.
remote_path: Optional path of where to copy file on remote host.
copy_to: True to copy to vm, False to copy from vm.
Raises:
RemoteCommandError: If there was a problem copying the file.
| RemoteCopy | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/windows_virtual_machine.py | Apache-2.0 |
def _SmbclientRemoteCopy(
self, local_path, remote_path, copy_to, network_drive
):
"""Copies a file to or from the VM using smbclient.
Args:
local_path: Local path to file.
remote_path: Optional path of where to copy file on remote host.
copy_to: True to copy to vm, False to copy from... | Copies a file to or from the VM using smbclient.
Args:
local_path: Local path to file.
remote_path: Optional path of where to copy file on remote host.
copy_to: True to copy to vm, False to copy from vm.
network_drive: The smb specification for the remote drive
(//{ip_address}/{shar... | _SmbclientRemoteCopy | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/windows_virtual_machine.py | Apache-2.0 |
def _PsDriveRemoteCopy(self, local_path, remote_path, copy_to, network_drive):
"""Copies a file to or from the VM using New-PSDrive and Copy-Item.
Args:
local_path: Local path to file.
remote_path: Optional path of where to copy file on remote host.
copy_to: True to copy to vm, False to copy ... | Copies a file to or from the VM using New-PSDrive and Copy-Item.
Args:
local_path: Local path to file.
remote_path: Optional path of where to copy file on remote host.
copy_to: True to copy to vm, False to copy from vm.
network_drive: The smb specification for the remote drive
(//{i... | _PsDriveRemoteCopy | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/windows_virtual_machine.py | Apache-2.0 |
def WaitForBootCompletion(self):
"""Waits until VM is has booted."""
to_wait_for = [self._WaitForWinRmCommand]
if FLAGS.cluster_boot_test_rdp_port_listening:
to_wait_for.append(self._WaitForRdpPort)
background_tasks.RunParallelThreads(
[(method, [], {}) for method in to_wait_for], 2
) | Waits until VM is has booted. | WaitForBootCompletion | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/windows_virtual_machine.py | Apache-2.0 |
def _WaitForWinRmCommand(self):
"""Waits for WinRM command and optionally for the WinRM port to listen."""
# Test for listening on the port first, because this will happen strictly
# first.
if (
FLAGS.cluster_boot_test_port_listening
and self.port_listening_time is None
):
self... | Waits for WinRM command and optionally for the WinRM port to listen. | _WaitForWinRmCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/windows_virtual_machine.py | Apache-2.0 |
def _WaitForSSH(self):
"""Waits for the VMs to be ready."""
stdout, _ = self.RemoteCommand('hostname', timeout=5)
if self.hostname is None:
self.hostname = stdout.rstrip() | Waits for the VMs to be ready. | _WaitForSSH | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/windows_virtual_machine.py | Apache-2.0 |
def Uninstall(self, package_name):
"""Uninstalls a Perfkit package on the VM."""
package = windows_packages.PACKAGES[package_name]
if hasattr(package, 'Uninstall'):
package.Uninstall() | Uninstalls a Perfkit package on the VM. | Uninstall | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/windows_virtual_machine.py | Apache-2.0 |
def PackageCleanup(self):
"""Cleans up all installed packages.
Deletes the Perfkit Benchmarker temp directory on the VM
and uninstalls all PerfKit packages.
"""
for package_name in self._installed_packages:
self.Uninstall(package_name)
self.RemoteCommand('rm -recurse -force %s' % self.tem... | Cleans up all installed packages.
Deletes the Perfkit Benchmarker temp directory on the VM
and uninstalls all PerfKit packages.
| PackageCleanup | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/windows_virtual_machine.py | Apache-2.0 |
def WaitForProcessRunning(self, process, timeout):
"""Blocks until either the timeout passes or the process is running.
Args:
process: string name of the process.
timeout: number of seconds to block while the process is not running.
Raises:
WaitTimeoutError: raised if the process does no... | Blocks until either the timeout passes or the process is running.
Args:
process: string name of the process.
timeout: number of seconds to block while the process is not running.
Raises:
WaitTimeoutError: raised if the process does not run within "timeout"
seconds.
... | WaitForProcessRunning | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/windows_virtual_machine.py | Apache-2.0 |
def IsProcessRunning(self, process):
"""Checks if a given process is running on the system.
Args:
process: string name of the process.
Returns:
Whether the process name is in the PS output.
"""
stdout, _ = self.RemoteCommand('ps')
return process in stdout | Checks if a given process is running on the system.
Args:
process: string name of the process.
Returns:
Whether the process name is in the PS output.
| IsProcessRunning | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/windows_virtual_machine.py | Apache-2.0 |
def _GetNumCpus(self):
"""Returns the number of logical CPUs on the VM.
This method does not cache results (unlike "num_cpus").
Returns:
int. Number of logical CPUs.
"""
stdout, _ = self.RemoteCommand(
'Get-WmiObject -class Win32_processor | '
'Select-Object -ExpandProperty N... | Returns the number of logical CPUs on the VM.
This method does not cache results (unlike "num_cpus").
Returns:
int. Number of logical CPUs.
| _GetNumCpus | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/windows_virtual_machine.py | Apache-2.0 |
def _GetTotalMemoryKb(self):
"""Returns the amount of physical memory on the VM in Kilobytes.
This method does not cache results (unlike "total_memory_kb").
"""
stdout, _ = self.RemoteCommand(
'Get-WmiObject -class Win32_PhysicalMemory | select -exp Capacity'
)
result = sum(int(capacity... | Returns the amount of physical memory on the VM in Kilobytes.
This method does not cache results (unlike "total_memory_kb").
| _GetTotalMemoryKb | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/windows_virtual_machine.py | Apache-2.0 |
def DownloadFile(self, url, dest):
"""Downloads the content at the url to the specified destination."""
# Allow more security protocols to make it easier to download from
# sites where we don't know the security protocol beforehand
command = (
'[Net.ServicePointManager]::SecurityProtocol = '
... | Downloads the content at the url to the specified destination. | DownloadFile | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/windows_virtual_machine.py | Apache-2.0 |
def UnzipFile(self, zip_file, dest):
"""Unzips the file with the given path."""
command = (
'Add-Type -A System.IO.Compression.FileSystem; '
"[IO.Compression.ZipFile]::ExtractToDirectory('{zip_file}', "
"'{dest}')"
).format(zip_file=zip_file, dest=dest)
self.RemoteCommand(command... | Unzips the file with the given path. | UnzipFile | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/windows_virtual_machine.py | Apache-2.0 |
def RunDiskpartScript(self, script):
"""Runs the supplied Diskpart script on the VM."""
logging.info('Writing diskpart script \n %s', script)
with vm_util.NamedTemporaryFile(prefix='diskpart', mode='w') as tf:
tf.write(script)
tf.close()
script_path = ntpath.join(self.temp_dir, os.path.bas... | Runs the supplied Diskpart script on the VM. | RunDiskpartScript | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/windows_virtual_machine.py | Apache-2.0 |
def SetProcessPriorityToHighByFlag(self, executable_name: str):
"""Sets the CPU priority for a given executable name.
Note this only sets the CPU priority if FLAGS.set_cpu_priority_high is set.
Args:
executable_name: string. The executable name.
"""
if not FLAGS.set_cpu_priority_high:
... | Sets the CPU priority for a given executable name.
Note this only sets the CPU priority if FLAGS.set_cpu_priority_high is set.
Args:
executable_name: string. The executable name.
| SetProcessPriorityToHighByFlag | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/windows_virtual_machine.py | Apache-2.0 |
def _IsSmtEnabled(self):
"""Whether SMT is enabled on the vm."""
# TODO(user): find way to do this in Windows
raise NotImplementedError('SMT detection currently not implemented') | Whether SMT is enabled on the vm. | _IsSmtEnabled | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/windows_virtual_machine.py | Apache-2.0 |
def GetRegisteredClass(
registry: dict[tuple[Any], type[T]],
base_class: type[T],
default_class: type[T] | None = None,
**kwargs
) -> type[T]:
"""Returns the subclass with the corresponding attributes.
Args:
Args:
registry: The dictionary of types, pointing from spec attributes -> classes.
... | Returns the subclass with the corresponding attributes.
Args:
Args:
registry: The dictionary of types, pointing from spec attributes -> classes.
base_class: The parent class whose subclass will be returned.
default_class: If provided, the class to return if no subclass is found. If
not provided,... | GetRegisteredClass | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/configs/auto_registry.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/configs/auto_registry.py | Apache-2.0 |
def RegisterClass(
registry: dict[tuple[Any], type[T]],
cls: type[T],
required_attrs: list[str] | None,
cls_type: str | None,
):
"""Adds the class with its attributes to the registry.
Args:
registry: The dictionary of types, pointing from spec attributes -> classes.
cls: The given class whi... | Adds the class with its attributes to the registry.
Args:
registry: The dictionary of types, pointing from spec attributes -> classes.
cls: The given class which is being added to the dictionary.
required_attrs: The required attributes which a class must have defined to
be registered.
cls_type:... | RegisterClass | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/configs/auto_registry.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/configs/auto_registry.py | Apache-2.0 |
def Decode(self, value, component_full_name, flag_values):
"""Verifies dpb service dictionary of a benchmark config object.
Args:
value: dict Dpb Service config dictionary
component_full_name: string. Fully qualified name of the configurable
component containing the config option.
fl... | Verifies dpb service dictionary of a benchmark config object.
Args:
value: dict Dpb Service config dictionary
component_full_name: string. Fully qualified name of the configurable
component containing the config option.
flag_values: flags.FlagValues. Runtime flag values to be propagated... | Decode | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/configs/benchmark_config_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/configs/benchmark_config_spec.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/configs/benchmark_config_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/configs/benchmark_config_spec.py | Apache-2.0 |
def Decode(self, value, component_full_name, flag_values):
"""Verify example_resource dict of a benchmark config object.
Args:
value: dict. Config dictionary
component_full_name: string. Fully qualified name of the configurable
component containing the config option.
flag_values: fla... | Verify example_resource dict of a benchmark config object.
Args:
value: dict. Config dictionary
component_full_name: string. Fully qualified name of the configurable
component containing the config option.
flag_values: flags.FlagValues. Runtime flag values to be propagated to
Ba... | Decode | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/configs/benchmark_config_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/configs/benchmark_config_spec.py | Apache-2.0 |
def Decode(self, value, component_full_name, flag_values):
"""Verifies base_job dictionary of a benchmark config object.
Args :
value: dict base_job config dictionary
component_full_name: string. Fully qualified name of the configurable
component containing the config option.
flag_va... | Verifies base_job dictionary of a benchmark config object.
Args :
value: dict base_job config dictionary
component_full_name: string. Fully qualified name of the configurable
component containing the config option.
flag_values: flags.FlagValues. Runtime flag values to be propagated to
... | Decode | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/configs/benchmark_config_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/configs/benchmark_config_spec.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.