Skip to content

Commit

Permalink
Merge "VMware: enable configuring of console delay"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Apr 22, 2015
2 parents 9d2c0c2 + eb7c890 commit 0bc763f
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
44 changes: 44 additions & 0 deletions nova/tests/unit/virt/vmwareapi/test_vm_util.py
Expand Up @@ -1236,6 +1236,50 @@ def test_validate_cpu_limits(self):
self.assertRaises(exception.InvalidInput,
cpu_limits.validate)

def test_get_vm_create_spec_with_console_delay(self):
extra_specs = vm_util.ExtraSpecs()
self.flags(console_delay_seconds=2, group='vmware')
fake_factory = fake.FakeFactory()
result = vm_util.get_vm_create_spec(fake_factory,
self._instance,
'fake-datastore', [],
extra_specs)

expected = fake_factory.create('ns0:VirtualMachineConfigSpec')
expected.name = self._instance.uuid
expected.instanceUuid = self._instance.uuid
expected.deviceChange = []
expected.numCPUs = 2

expected.version = None
expected.memoryMB = 2048
expected.guestId = constants.DEFAULT_OS_TYPE
expected.extraConfig = []

extra_config = fake_factory.create("ns0:OptionValue")
extra_config.value = self._instance.uuid
extra_config.key = 'nvp.vm-uuid'
expected.extraConfig.append(extra_config)
extra_config = fake_factory.create("ns0:OptionValue")
extra_config.value = 2000000
extra_config.key = 'keyboard.typematicMinDelay'
expected.extraConfig.append(extra_config)
expected.files = fake_factory.create('ns0:VirtualMachineFileInfo')
expected.files.vmPathName = '[fake-datastore]'

expected.managedBy = fake_factory.create('ns0:ManagedByInfo')
expected.managedBy.extensionKey = 'org.openstack.compute'
expected.managedBy.type = 'instance'

expected.tools = fake_factory.create('ns0:ToolsConfigInfo')
expected.tools.afterPowerOn = True
expected.tools.afterResume = True
expected.tools.beforeGuestReboot = True
expected.tools.beforeGuestShutdown = True
expected.tools.beforeGuestStandby = True

self.assertEqual(expected, result)


@mock.patch.object(driver.VMwareAPISession, 'vim', stubs.fake_vim_prop)
class VMwareVMUtilGetHostRefTestCase(test.NoDBTestCase):
Expand Down
17 changes: 17 additions & 0 deletions nova/virt/vmwareapi/vm_util.py
Expand Up @@ -40,6 +40,16 @@
CONF = cfg.CONF
LOG = logging.getLogger(__name__)

vmware_utils_opts = [
cfg.IntOpt('console_delay_seconds',
help='Set this value if affected by an increased network '
'latency causing repeated characters when typing in '
'a remote console.')
]

CONF = cfg.CONF
CONF.register_opts(vmware_utils_opts, 'vmware')

ALL_SUPPORTED_NETWORK_DEVICES = ['VirtualE1000', 'VirtualE1000e',
'VirtualPCNet32', 'VirtualSriovEthernetCard',
'VirtualVmxnet', 'VirtualVmxnet3']
Expand Down Expand Up @@ -240,6 +250,13 @@ def get_vm_create_spec(client_factory, instance, data_store_name,
port_index))
port_index += 1

if (CONF.vmware.console_delay_seconds and
CONF.vmware.console_delay_seconds > 0):
opt = client_factory.create('ns0:OptionValue')
opt.key = 'keyboard.typematicMinDelay'
opt.value = CONF.vmware.console_delay_seconds * 1000000
extra_config.append(opt)

config_spec.extraConfig = extra_config

# Set the VM to be 'managed' by 'OpenStack'
Expand Down

0 comments on commit 0bc763f

Please sign in to comment.