-
Notifications
You must be signed in to change notification settings - Fork 523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows on GCE #338
Windows on GCE #338
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,17 @@ def __init__(self, disk_spec): | |
self.mount_point = disk_spec.mount_point | ||
self.iops = disk_spec.iops | ||
|
||
# Windows related attributes. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't necessarily Windows specific. I think keeping count of the per-instance disks would benefit some Linux implementations also, such as the rather ugly /dev/vdN name allocation in azure_disk.py. If the base class can track this generically, would be nice to document this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added more documentation in case we want to use it later. |
||
|
||
# The disk number corresponds to the order in which disks were attached to | ||
# the instance. The System Disk has a disk number of 0. Any local disks | ||
# have disk numbers ranging from 1 to the number of local disks on the | ||
# system. Any additional disks that were attached after boot will have | ||
# disk numbers starting at the number of local disks + 1. These disk | ||
# numbers are used in diskpart scripts in order to identify the disks | ||
# that we want to operate on. | ||
self.disk_number = None | ||
|
||
@abc.abstractmethod | ||
def Attach(self, vm): | ||
"""Attaches the disk to a VM. | ||
|
@@ -77,9 +88,8 @@ def Detach(self): | |
"""Detaches the disk from a VM.""" | ||
pass | ||
|
||
@abc.abstractmethod | ||
def GetDevicePath(self): | ||
"""Returns the path to the device inside the VM.""" | ||
"""Returns the path to the device inside a Linux VM.""" | ||
pass | ||
|
||
|
||
|
@@ -88,13 +98,13 @@ class StripedDisk(BaseDisk): | |
|
||
is_striped = True | ||
|
||
def __init__(self, disk_spec, disks, device_path): | ||
def __init__(self, disk_spec, disks, device_path=None): | ||
"""Initializes a StripedDisk object. | ||
|
||
Args: | ||
disk_spec: A BaseDiskSpec containing the desired mount point. | ||
disks: A list of BaseDisk objects that constitute the StripedDisk. | ||
device_path: The path of the striped device. | ||
device_path: The path of the striped device in a Linux VM. | ||
""" | ||
super(StripedDisk, self).__init__(disk_spec) | ||
self.disks = disks | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
from perfkitbenchmarker import linux_virtual_machine | ||
from perfkitbenchmarker import virtual_machine | ||
from perfkitbenchmarker import vm_util | ||
from perfkitbenchmarker import windows_virtual_machine | ||
from perfkitbenchmarker.gcp import gce_disk | ||
from perfkitbenchmarker.gcp import gce_network | ||
from perfkitbenchmarker.gcp import util | ||
|
@@ -47,12 +48,11 @@ | |
|
||
FLAGS = flags.FLAGS | ||
|
||
BOOT_DISK_SIZE_GB = 10 | ||
BOOT_DISK_TYPE = disk.STANDARD | ||
NVME = 'nvme' | ||
SCSI = 'SCSI' | ||
UBUNTU_IMAGE = 'ubuntu-14-04' | ||
RHEL_IMAGE = 'rhel-7' | ||
WINDOWS_IMAGE = 'windows-2012-r2' | ||
|
||
|
||
class GceVirtualMachine(virtual_machine.BaseVirtualMachine): | ||
|
@@ -78,6 +78,7 @@ def __init__(self, vm_spec): | |
self.boot_disk = gce_disk.GceDisk( | ||
disk_spec, self.name, self.zone, self.project, self.image) | ||
self.max_local_disks = FLAGS.gce_num_local_ssds | ||
self.boot_metadata = {} | ||
|
||
|
||
@classmethod | ||
|
@@ -122,6 +123,8 @@ def _Create(self): | |
'sshKeys=%s' % tf.name, | ||
'--metadata', | ||
'owner=%s' % FLAGS.owner] | ||
for key, value in self.boot_metadata.iteritems(): | ||
create_cmd.append('%s=%s' % (key, value)) | ||
ssd_interface_option = NVME if NVME in self.image else SCSI | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think nvme is supported on Windows. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right - but the ssd_interface_option will only be "nvme" if the string "nvme" is present in the image name - which it isn't for windows. So this works as it's supposed to |
||
for _ in range(self.max_local_disks): | ||
create_cmd.append('--local-ssd') | ||
|
@@ -175,21 +178,26 @@ def CreateScratchDisk(self, disk_spec): | |
Args: | ||
disk_spec: virtual_machine.BaseDiskSpec object of the disk. | ||
""" | ||
# Get the names for the disk(s) we are going to create. | ||
if disk_spec.disk_type == disk.LOCAL: | ||
new_count = self.local_disk_counter + disk_spec.num_striped_disks | ||
if new_count > self.max_local_disks: | ||
raise errors.Error('Not enough local disks.') | ||
disk_names = ['local-ssd-%d' % i | ||
for i in range(self.local_disk_counter, new_count)] | ||
self.local_disk_counter = new_count | ||
else: | ||
disk_names = ['%s-data-%d-%d' % (self.name, len(self.scratch_disks), i) | ||
for i in range(disk_spec.num_striped_disks)] | ||
|
||
# Instantiate the disk(s). | ||
disks = [gce_disk.GceDisk(disk_spec, name, self.zone, self.project) | ||
for name in disk_names] | ||
disks = [] | ||
|
||
for i in xrange(disk_spec.num_striped_disks): | ||
if disk_spec.disk_type == disk.LOCAL: | ||
name = 'local-ssd-%d' % self.local_disk_counter | ||
data_disk = gce_disk.GceDisk(disk_spec, name, self.zone, self.project) | ||
# Local disk numbers start at 1 (0 is the system disk). | ||
data_disk.disk_number = self.local_disk_counter + 1 | ||
self.local_disk_counter += 1 | ||
if self.local_disk_counter > self.max_local_disks: | ||
raise errors.Error('Not enough local disks.') | ||
else: | ||
name = '%s-data-%d-%d' % (self.name, len(self.scratch_disks), i) | ||
data_disk = gce_disk.GceDisk(disk_spec, name, self.zone, self.project) | ||
# Remote disk numbers start at 1+max_local_disks (0 is the system disk | ||
# and local disks occupy 1-max_local_disks). | ||
data_disk.disk_number = (self.remote_disk_counter + | ||
1 + self.max_local_disks) | ||
self.remote_disk_counter += 1 | ||
disks.append(data_disk) | ||
|
||
self._CreateScratchDiskFromDisks(disk_spec, disks) | ||
|
||
|
@@ -223,3 +231,29 @@ class DebianBasedGceVirtualMachine(GceVirtualMachine, | |
class RhelBasedGceVirtualMachine(GceVirtualMachine, | ||
linux_virtual_machine.RhelMixin): | ||
DEFAULT_IMAGE = RHEL_IMAGE | ||
|
||
|
||
class WindowsGceVirtualMachine(GceVirtualMachine, | ||
windows_virtual_machine.WindowsMixin): | ||
|
||
DEFAULT_IMAGE = WINDOWS_IMAGE | ||
BOOT_DISK_SIZE_GB = 50 | ||
BOOT_DISK_TYPE = disk.REMOTE_SSD | ||
|
||
def __init__(self, vm_spec): | ||
super(WindowsGceVirtualMachine, self).__init__(vm_spec) | ||
self.boot_metadata[ | ||
'windows-startup-script-ps1'] = windows_virtual_machine.STARTUP_SCRIPT | ||
|
||
def _PostCreate(self): | ||
super(WindowsGceVirtualMachine, self)._PostCreate() | ||
reset_password_cmd = [FLAGS.gcloud_path, | ||
'compute', | ||
'reset-windows-password', | ||
'--user', | ||
self.user_name, | ||
self.name] | ||
reset_password_cmd.extend(util.GetDefaultGcloudFlags(self)) | ||
stdout, _ = vm_util.IssueRetryableCommand(reset_password_cmd) | ||
response = json.loads(stdout) | ||
self.password = response['password'] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright 2015 Google Inc. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Contains benchmark imports and a list of benchmarks. | ||
|
||
All modules within this package are considered benchmarks, and are loaded | ||
dynamically. Add non-benchmark code to other packages. | ||
""" | ||
|
||
from perfkitbenchmarker import import_util | ||
|
||
|
||
def _LoadBenchmarks(): | ||
return list(import_util.LoadModulesForPath(__path__, __name__)) | ||
|
||
|
||
BENCHMARKS = _LoadBenchmarks() | ||
|
||
VALID_BENCHMARKS = {module.BENCHMARK_INFO['name']: module | ||
for module in BENCHMARKS} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 163 below - can you expand the error message to say "benchmark %s not valid on %platform"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done