Transition to DPMVIF object
The previous patch has introduced the DPMVIF object. We now make use of it in our code. Change-Id: Ifbfcb391ec619127fd7de7a3aa88f4f5868ed28c
This commit is contained in:
parent
3e57711742
commit
443a1bd547
|
@ -221,26 +221,19 @@ class VmPartitionInstanceTestCase(TestCase):
|
|||
self.partition_inst.get_partition().get_property('name'))
|
||||
|
||||
def test_attach_nic(self):
|
||||
vif = {
|
||||
"details":
|
||||
{"port_filter": False,
|
||||
"object_id": "3ea09d2a-b18d-11e6-89a4-42f2e9ef1641"},
|
||||
"address": "fa:16:3e:e4:9a:98",
|
||||
"type": "dpm_vswitch",
|
||||
"id": "703da361-9d4d-4441-b99b-e081c3e9cfbb"}
|
||||
vif = mock.Mock()
|
||||
vif.mac = "fa:16:3e:e4:9a:98"
|
||||
vif.dpm_nic_object_id = "3ea09d2a-b18d-11e6-89a4-42f2e9ef1641"
|
||||
vif.type = "dpm_vswitch"
|
||||
vif.port_id = "703da361-9d4d-4441-b99b-e081c3e9cfbb"
|
||||
nic_interface = self.partition_inst.attach_nic(vif)
|
||||
self.assertEqual(
|
||||
'OpenStack_Port_703da361-9d4d-4441-b99b-e081c3e9cfbb',
|
||||
nic_interface.properties['name'])
|
||||
|
||||
def test_attach_nic_with_non_dpm_vswitch(self):
|
||||
vif = {
|
||||
"details":
|
||||
{"port_filter": False,
|
||||
"object_id": "3ea09d2a-b18d-11e6-89a4-42f2e9ef1641"},
|
||||
"address": "fa:16:3e:e4:9a:98",
|
||||
"type": "non_dpm_vswitch",
|
||||
"id": "703da361-9d4d-4441-b99b-e081c3e9cfbb"}
|
||||
vif = mock.Mock()
|
||||
vif.type = "non_dpm_vswitch"
|
||||
|
||||
self.assertRaises(
|
||||
Exception,
|
||||
|
|
|
@ -28,6 +28,7 @@ from nova_dpm.virt.dpm import constants
|
|||
from nova_dpm.virt.dpm import exceptions
|
||||
from nova_dpm.virt.dpm import host as Host
|
||||
from nova_dpm.virt.dpm import utils
|
||||
from nova_dpm.virt.dpm.vif import DPMVIF
|
||||
from nova_dpm.virt.dpm import vm
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import importutils
|
||||
|
@ -280,7 +281,7 @@ class DPMDriver(driver.ComputeDriver):
|
|||
"""
|
||||
self.prep_for_spawn(context=None, instance=instance)
|
||||
|
||||
def _get_nic_string_for_guest_os(self, nic, vif):
|
||||
def _get_nic_string_for_guest_os(self, nic, vif_obj):
|
||||
"""Generate the NIC string that must be available from inside the OS
|
||||
|
||||
Passing the string into the operating system is achieved via appending
|
||||
|
@ -312,7 +313,7 @@ class DPMDriver(driver.ComputeDriver):
|
|||
# then default to 0
|
||||
nic_boot_parms = "{devno},0,{mac};".format(
|
||||
devno=nic.get_property("device-number"),
|
||||
mac=vif["address"].replace(":", "")
|
||||
mac=vif_obj.mac.replace(":", "")
|
||||
)
|
||||
return nic_boot_parms
|
||||
|
||||
|
@ -355,9 +356,10 @@ class DPMDriver(driver.ComputeDriver):
|
|||
current_ports=len(network_info)
|
||||
))
|
||||
nic_boot_string = ""
|
||||
for vif in network_info:
|
||||
nic = inst.attach_nic(vif)
|
||||
nic_boot_string += self._get_nic_string_for_guest_os(nic, vif)
|
||||
for vif_dict in network_info:
|
||||
vif_obj = DPMVIF(vif_dict)
|
||||
nic = inst.attach_nic(vif_obj)
|
||||
nic_boot_string += self._get_nic_string_for_guest_os(nic, vif_obj)
|
||||
inst.set_boot_os_specific_parameters(nic_boot_string)
|
||||
|
||||
inst.set_boot_properties(
|
||||
|
|
|
@ -171,16 +171,15 @@ class PartitionInstance(object):
|
|||
'boot-os-specific-parameters': data
|
||||
})
|
||||
|
||||
def attach_nic(self, vif):
|
||||
def attach_nic(self, vif_obj):
|
||||
# TODO(preethipy): Implement the listener flow to register for
|
||||
# nic creation events
|
||||
LOG.debug("Creating nic interface for the instance")
|
||||
|
||||
port_id = vif['id']
|
||||
vif_type = vif['type']
|
||||
mac = vif['address']
|
||||
vif_details = vif['details']
|
||||
dpm_object_id = vif_details['object_id']
|
||||
port_id = vif_obj.port_id
|
||||
vif_type = vif_obj.type
|
||||
mac = vif_obj.mac
|
||||
dpm_object_id = vif_obj.dpm_nic_object_id
|
||||
|
||||
# Only dpm_vswitch attachments are supported for now
|
||||
if vif_type != "dpm_vswitch":
|
||||
|
|
Loading…
Reference in New Issue