VMware: add serial port device
Add virtual serial port which sends console output to a configurable service URI. At the service URI there will be a virtual serial port concentrator (VSPC) that will collect console logs and save them on the filesystem. The VSPC will be deployed along with nova-compute and will provide both console log and serial console to VMware instances. Reference: http://goo.gl/oMD2xx DocImpact Change-Id: Ib1aafce6ddc04cb7774e6b4921c9dbfcc25acc91 Partially Implements: blueprint vmware-console-log
This commit is contained in:
@@ -502,6 +502,38 @@ class VMwareVMUtilTestCase(test.NoDBTestCase):
|
|||||||
def test_detach_virtual_disk_destroy_spec(self):
|
def test_detach_virtual_disk_destroy_spec(self):
|
||||||
self._test_detach_virtual_disk_spec(destroy_disk=True)
|
self._test_detach_virtual_disk_spec(destroy_disk=True)
|
||||||
|
|
||||||
|
def _create_vm_config_spec(self):
|
||||||
|
fake_factory = fake.FakeFactory()
|
||||||
|
spec = fake_factory.create('ns0:VirtualMachineConfigSpec')
|
||||||
|
spec.name = self._instance.uuid
|
||||||
|
spec.instanceUuid = self._instance.uuid
|
||||||
|
spec.deviceChange = []
|
||||||
|
spec.numCPUs = 2
|
||||||
|
|
||||||
|
spec.version = None
|
||||||
|
spec.memoryMB = 2048
|
||||||
|
spec.guestId = 'otherGuest'
|
||||||
|
spec.extraConfig = []
|
||||||
|
|
||||||
|
extra_config = fake_factory.create("ns0:OptionValue")
|
||||||
|
extra_config.value = self._instance.uuid
|
||||||
|
extra_config.key = 'nvp.vm-uuid'
|
||||||
|
spec.extraConfig.append(extra_config)
|
||||||
|
spec.files = fake_factory.create('ns0:VirtualMachineFileInfo')
|
||||||
|
spec.files.vmPathName = '[fake-datastore]'
|
||||||
|
|
||||||
|
spec.managedBy = fake_factory.create('ns0:ManagedByInfo')
|
||||||
|
spec.managedBy.extensionKey = 'org.openstack.compute'
|
||||||
|
spec.managedBy.type = 'instance'
|
||||||
|
|
||||||
|
spec.tools = fake_factory.create('ns0:ToolsConfigInfo')
|
||||||
|
spec.tools.afterPowerOn = True
|
||||||
|
spec.tools.afterResume = True
|
||||||
|
spec.tools.beforeGuestReboot = True
|
||||||
|
spec.tools.beforeGuestShutdown = True
|
||||||
|
spec.tools.beforeGuestStandby = True
|
||||||
|
return spec
|
||||||
|
|
||||||
def test_get_vm_create_spec(self):
|
def test_get_vm_create_spec(self):
|
||||||
extra_specs = vm_util.ExtraSpecs()
|
extra_specs = vm_util.ExtraSpecs()
|
||||||
fake_factory = fake.FakeFactory()
|
fake_factory = fake.FakeFactory()
|
||||||
@@ -510,35 +542,28 @@ class VMwareVMUtilTestCase(test.NoDBTestCase):
|
|||||||
'fake-datastore', [],
|
'fake-datastore', [],
|
||||||
extra_specs)
|
extra_specs)
|
||||||
|
|
||||||
expected = fake_factory.create('ns0:VirtualMachineConfigSpec')
|
expected = self._create_vm_config_spec()
|
||||||
expected.name = self._instance.uuid
|
self.assertEqual(expected, result)
|
||||||
expected.instanceUuid = self._instance.uuid
|
|
||||||
expected.deviceChange = []
|
|
||||||
expected.numCPUs = 2
|
|
||||||
|
|
||||||
expected.version = None
|
expected.version = None
|
||||||
expected.memoryMB = 2048
|
expected.memoryMB = 2048
|
||||||
expected.guestId = constants.DEFAULT_OS_TYPE
|
expected.guestId = constants.DEFAULT_OS_TYPE
|
||||||
expected.extraConfig = []
|
expected.extraConfig = []
|
||||||
|
|
||||||
extra_config = fake_factory.create("ns0:OptionValue")
|
def test_get_vm_create_spec_with_serial_port(self):
|
||||||
extra_config.value = self._instance.uuid
|
extra_specs = vm_util.ExtraSpecs()
|
||||||
extra_config.key = 'nvp.vm-uuid'
|
fake_factory = fake.FakeFactory()
|
||||||
expected.extraConfig.append(extra_config)
|
self.flags(serial_port_service_uri='foobar', group='vmware')
|
||||||
expected.files = fake_factory.create('ns0:VirtualMachineFileInfo')
|
self.flags(serial_port_proxy_uri='telnet://example.com:31337',
|
||||||
expected.files.vmPathName = '[fake-datastore]'
|
group='vmware')
|
||||||
|
result = vm_util.get_vm_create_spec(fake_factory,
|
||||||
expected.managedBy = fake_factory.create('ns0:ManagedByInfo')
|
self._instance,
|
||||||
expected.managedBy.extensionKey = 'org.openstack.compute'
|
'fake-datastore', [],
|
||||||
expected.managedBy.type = 'instance'
|
extra_specs)
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
serial_port_spec = vm_util.create_serial_port_spec(fake_factory)
|
||||||
|
expected = self._create_vm_config_spec()
|
||||||
|
expected.deviceChange = [serial_port_spec]
|
||||||
self.assertEqual(expected, result)
|
self.assertEqual(expected, result)
|
||||||
|
|
||||||
def test_get_vm_create_spec_with_allocations(self):
|
def test_get_vm_create_spec_with_allocations(self):
|
||||||
|
@@ -45,7 +45,15 @@ vmware_utils_opts = [
|
|||||||
cfg.IntOpt('console_delay_seconds',
|
cfg.IntOpt('console_delay_seconds',
|
||||||
help='Set this value if affected by an increased network '
|
help='Set this value if affected by an increased network '
|
||||||
'latency causing repeated characters when typing in '
|
'latency causing repeated characters when typing in '
|
||||||
'a remote console.')
|
'a remote console.'),
|
||||||
|
cfg.StrOpt('serial_port_service_uri',
|
||||||
|
help='Identifies the remote system that serial port traffic '
|
||||||
|
'will be sent to. If this is not set, no serial ports '
|
||||||
|
'will be added to the created VMs.'),
|
||||||
|
cfg.StrOpt('serial_port_proxy_uri',
|
||||||
|
help='Identifies a proxy service that provides network access '
|
||||||
|
'to the serial_port_service_uri. This option is ignored '
|
||||||
|
'if serial_port_service_uri is not specified.'),
|
||||||
]
|
]
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
@@ -246,14 +254,16 @@ def get_vm_create_spec(client_factory, instance, data_store_name,
|
|||||||
client_factory, extra_specs.memory_limits,
|
client_factory, extra_specs.memory_limits,
|
||||||
'ns0:ResourceAllocationInfo')
|
'ns0:ResourceAllocationInfo')
|
||||||
|
|
||||||
vif_spec_list = []
|
devices = []
|
||||||
for vif_info in vif_infos:
|
for vif_info in vif_infos:
|
||||||
vif_spec = _create_vif_spec(client_factory, vif_info)
|
vif_spec = _create_vif_spec(client_factory, vif_info)
|
||||||
vif_spec_list.append(vif_spec)
|
devices.append(vif_spec)
|
||||||
|
|
||||||
device_config_spec = vif_spec_list
|
serial_port_spec = create_serial_port_spec(client_factory)
|
||||||
|
if serial_port_spec:
|
||||||
|
devices.append(serial_port_spec)
|
||||||
|
|
||||||
config_spec.deviceChange = device_config_spec
|
config_spec.deviceChange = devices
|
||||||
|
|
||||||
# add vm-uuid and iface-id.x values for Neutron
|
# add vm-uuid and iface-id.x values for Neutron
|
||||||
extra_config = []
|
extra_config = []
|
||||||
@@ -288,6 +298,33 @@ def get_vm_create_spec(client_factory, instance, data_store_name,
|
|||||||
return config_spec
|
return config_spec
|
||||||
|
|
||||||
|
|
||||||
|
def create_serial_port_spec(client_factory):
|
||||||
|
"""Creates config spec for serial port."""
|
||||||
|
if not CONF.vmware.serial_port_service_uri:
|
||||||
|
return
|
||||||
|
|
||||||
|
backing = client_factory.create('ns0:VirtualSerialPortURIBackingInfo')
|
||||||
|
backing.direction = "server"
|
||||||
|
backing.serviceURI = CONF.vmware.serial_port_service_uri
|
||||||
|
backing.proxyURI = CONF.vmware.serial_port_proxy_uri
|
||||||
|
|
||||||
|
connectable_spec = client_factory.create('ns0:VirtualDeviceConnectInfo')
|
||||||
|
connectable_spec.startConnected = True
|
||||||
|
connectable_spec.allowGuestControl = True
|
||||||
|
connectable_spec.connected = True
|
||||||
|
|
||||||
|
serial_port = client_factory.create('ns0:VirtualSerialPort')
|
||||||
|
serial_port.connectable = connectable_spec
|
||||||
|
serial_port.backing = backing
|
||||||
|
# we are using unique negative integers as temporary keys
|
||||||
|
serial_port.key = -2
|
||||||
|
serial_port.yieldOnPoll = True
|
||||||
|
dev_spec = client_factory.create('ns0:VirtualDeviceConfigSpec')
|
||||||
|
dev_spec.operation = "add"
|
||||||
|
dev_spec.device = serial_port
|
||||||
|
return dev_spec
|
||||||
|
|
||||||
|
|
||||||
def get_vm_boot_spec(client_factory, device):
|
def get_vm_boot_spec(client_factory, device):
|
||||||
"""Returns updated boot settings for the instance.
|
"""Returns updated boot settings for the instance.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user