Commit 76213e78 authored by Dimitris Aragiorgis's avatar Dimitris Aragiorgis Committed by Klaus Aehlig

Gen nic_type related opts inside _WriteNicConfig()

The xen-hvm hypervisor has two extra hvparams concerning NICS;
nic_type, and vif_type. Let _WriteNicConfig() calculate all needed
extra options for the instance's NICs based on its hvparams.
Signed-off-by: default avatarDimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent f8a2a06f
...@@ -560,9 +560,24 @@ class XenHypervisor(hv_base.BaseHypervisor): ...@@ -560,9 +560,24 @@ class XenHypervisor(hv_base.BaseHypervisor):
""" """
raise NotImplementedError raise NotImplementedError
def _WriteNicConfig(self, config, instance, hvp, nic_type_str=""): def _WriteNicConfig(self, config, instance, hvp):
vif_data = [] vif_data = []
# only XenHvmHypervisor has these hvparams
nic_type = hvp.get(constants.HV_NIC_TYPE, None)
vif_type = hvp.get(constants.HV_VIF_TYPE, None)
nic_type_str = ""
if nic_type or vif_type:
if nic_type is None:
if vif_type:
nic_type_str = ", type=%s" % vif_type
elif nic_type == constants.HT_NIC_PARAVIRTUAL:
nic_type_str = ", type=paravirtualized"
else:
# parameter 'model' is only valid with type 'ioemu'
nic_type_str = ", model=%s, type=%s" % \
(nic_type, constants.HT_HVM_VIF_IOEMU)
for idx, nic in enumerate(instance.nics): for idx, nic in enumerate(instance.nics):
nic_str = "mac=%s%s" % (nic.mac, nic_type_str) nic_str = "mac=%s%s" % (nic.mac, nic_type_str)
...@@ -1401,21 +1416,7 @@ class XenHvmHypervisor(XenHypervisor): ...@@ -1401,21 +1416,7 @@ class XenHvmHypervisor(XenHypervisor):
if hvp[constants.HV_USE_LOCALTIME]: if hvp[constants.HV_USE_LOCALTIME]:
config.write("localtime = 1\n") config.write("localtime = 1\n")
nic_type = hvp[constants.HV_NIC_TYPE] self._WriteNicConfig(config, instance, hvp)
if nic_type is None:
vif_type_str = ""
if hvp[constants.HV_VIF_TYPE]:
vif_type_str = ", type=%s" % hvp[constants.HV_VIF_TYPE]
# ensure old instances don't change
nic_type_str = vif_type_str
elif nic_type == constants.HT_NIC_PARAVIRTUAL:
nic_type_str = ", type=paravirtualized"
else:
# parameter 'model' is only valid with type 'ioemu'
nic_type_str = ", model=%s, type=%s" % \
(nic_type, constants.HT_HVM_VIF_IOEMU)
self._WriteNicConfig(config, instance, hvp, nic_type_str=nic_type_str)
disk_data = \ disk_data = \
_GetConfigFileDiskData(block_devices, hvp[constants.HV_BLOCKDEV_PREFIX]) _GetConfigFileDiskData(block_devices, hvp[constants.HV_BLOCKDEV_PREFIX])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment