summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-01-04 22:36:39 +0000
committerGerrit Code Review <review@openstack.org>2013-01-04 22:36:39 +0000
commit130807036a7574fe81c957ed2635ad9f9db51aba (patch)
tree6656d3f9608f469afb2c485dc494e8b834257653
parent3e3111f137bc14bb4aa4522bd1fcabaac154ad17 (diff)
parent340c35865ef32cc75612980b0c51524e0c19cfe1 (diff)
downloadnova-130807036a7574fe81c957ed2635ad9f9db51aba.tar.gz
nova-130807036a7574fe81c957ed2635ad9f9db51aba.tar.xz
nova-130807036a7574fe81c957ed2635ad9f9db51aba.zip
Merge "Remove unused VMWare VIF driver abstraction"
-rw-r--r--nova/virt/vmwareapi/driver.py3
-rw-r--r--nova/virt/vmwareapi/vif.py96
-rw-r--r--nova/virt/vmwareapi/vmops.py17
3 files changed, 49 insertions, 67 deletions
diff --git a/nova/virt/vmwareapi/driver.py b/nova/virt/vmwareapi/driver.py
index f6aa91e85..51df7a38a 100644
--- a/nova/virt/vmwareapi/driver.py
+++ b/nova/virt/vmwareapi/driver.py
@@ -75,9 +75,6 @@ vmwareapi_opts = [
'socket error, etc. '
'Used only if compute_driver is '
'vmwareapi.VMWareESXDriver.'),
- cfg.StrOpt('vmwareapi_vlan_interface',
- default='vmnic0',
- help='Physical ethernet adapter name for vlan networking'),
]
CONF = cfg.CONF
diff --git a/nova/virt/vmwareapi/vif.py b/nova/virt/vmwareapi/vif.py
index 2e70a7a49..4d53e266d 100644
--- a/nova/virt/vmwareapi/vif.py
+++ b/nova/virt/vmwareapi/vif.py
@@ -26,63 +26,55 @@ from nova.virt.vmwareapi import network_utils
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
-CONF.set_default('vmwareapi_vlan_interface', 'vmnic0')
+vmwareapi_vif_opts = [
+ cfg.StrOpt('vmwareapi_vlan_interface',
+ default='vmnic0',
+ help='Physical ethernet adapter name for vlan networking'),
+]
-class VMWareVlanBridgeDriver(object):
- """VIF Driver to setup bridge/VLAN networking using VMWare API."""
+CONF.register_opts(vmwareapi_vif_opts)
- def plug(self, instance, vif):
- """Plug the VIF to specified instance using information passed.
- Currently we are plugging the VIF(s) during instance creation itself.
- We can use this method when we add support to add additional NIC to
- an existing instance."""
- pass
- def ensure_vlan_bridge(self, session, network):
- """Create a vlan and bridge unless they already exist."""
- vlan_num = network['vlan']
- bridge = network['bridge']
- vlan_interface = CONF.vmwareapi_vlan_interface
+def ensure_vlan_bridge(self, session, network):
+ """Create a vlan and bridge unless they already exist."""
+ vlan_num = network['vlan']
+ bridge = network['bridge']
+ vlan_interface = CONF.vmwareapi_vlan_interface
- # Check if the vlan_interface physical network adapter exists on the
- # host.
- if not network_utils.check_if_vlan_interface_exists(session,
- vlan_interface):
- raise exception.NetworkAdapterNotFound(adapter=vlan_interface)
-
- # Get the vSwitch associated with the Physical Adapter
- vswitch_associated = network_utils.get_vswitch_for_vlan_interface(
- session, vlan_interface)
- if vswitch_associated is None:
- raise exception.SwitchNotFoundForNetworkAdapter(
- adapter=vlan_interface)
- # Check whether bridge already exists and retrieve the the ref of the
- # network whose name_label is "bridge"
- network_ref = network_utils.get_network_with_the_name(session, bridge)
- if network_ref is None:
- # Create a port group on the vSwitch associated with the
- # vlan_interface corresponding physical network adapter on the ESX
- # host.
- network_utils.create_port_group(session, bridge,
- vswitch_associated, vlan_num)
- else:
- # Get the vlan id and vswitch corresponding to the port group
- _get_pg_info = network_utils.get_vlanid_and_vswitch_for_portgroup
- pg_vlanid, pg_vswitch = _get_pg_info(session, bridge)
+ # Check if the vlan_interface physical network adapter exists on the
+ # host.
+ if not network_utils.check_if_vlan_interface_exists(session,
+ vlan_interface):
+ raise exception.NetworkAdapterNotFound(adapter=vlan_interface)
- # Check if the vswitch associated is proper
- if pg_vswitch != vswitch_associated:
- raise exception.InvalidVLANPortGroup(
- bridge=bridge, expected=vswitch_associated,
- actual=pg_vswitch)
+ # Get the vSwitch associated with the Physical Adapter
+ vswitch_associated = network_utils.get_vswitch_for_vlan_interface(
+ session, vlan_interface)
+ if vswitch_associated is None:
+ raise exception.SwitchNotFoundForNetworkAdapter(
+ adapter=vlan_interface)
+ # Check whether bridge already exists and retrieve the the ref of the
+ # network whose name_label is "bridge"
+ network_ref = network_utils.get_network_with_the_name(session, bridge)
+ if network_ref is None:
+ # Create a port group on the vSwitch associated with the
+ # vlan_interface corresponding physical network adapter on the ESX
+ # host.
+ network_utils.create_port_group(session, bridge,
+ vswitch_associated, vlan_num)
+ else:
+ # Get the vlan id and vswitch corresponding to the port group
+ _get_pg_info = network_utils.get_vlanid_and_vswitch_for_portgroup
+ pg_vlanid, pg_vswitch = _get_pg_info(session, bridge)
- # Check if the vlan id is proper for the port group
- if pg_vlanid != vlan_num:
- raise exception.InvalidVLANTag(bridge=bridge, tag=vlan_num,
- pgroup=pg_vlanid)
+ # Check if the vswitch associated is proper
+ if pg_vswitch != vswitch_associated:
+ raise exception.InvalidVLANPortGroup(
+ bridge=bridge, expected=vswitch_associated,
+ actual=pg_vswitch)
- def unplug(self, instance, vif):
- """Cleanup operations like deleting port group if no instance
- is associated with it."""
- pass
+ # Check if the vlan id is proper for the port group
+ if pg_vlanid != vlan_num:
+ raise exception.InvalidVLANTag(bridge=bridge, tag=vlan_num,
+ pgroup=pg_vlanid)
diff --git a/nova/virt/vmwareapi/vmops.py b/nova/virt/vmwareapi/vmops.py
index 97270fc06..5d2685b18 100644
--- a/nova/virt/vmwareapi/vmops.py
+++ b/nova/virt/vmwareapi/vmops.py
@@ -32,17 +32,13 @@ from nova.openstack.common import cfg
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
from nova.virt.vmwareapi import network_utils
+from nova.virt.vmwareapi import vif as vmwarevif
from nova.virt.vmwareapi import vim_util
from nova.virt.vmwareapi import vm_util
from nova.virt.vmwareapi import vmware_images
-vmware_vif_driver_opt = cfg.StrOpt('vmware_vif_driver',
- default='nova.virt.vmwareapi.vif.VMWareVlanBridgeDriver',
- help='The VMWare VIF driver to configure the VIFs.')
-
CONF = cfg.CONF
-CONF.register_opt(vmware_vif_driver_opt)
LOG = logging.getLogger(__name__)
@@ -58,7 +54,6 @@ class VMWareVMOps(object):
def __init__(self, session):
"""Initializer."""
self._session = session
- self._vif_driver = importutils.import_object(CONF.vmware_vif_driver)
def list_instances(self):
"""Lists the VM instances that are registered with the ESX host."""
@@ -173,8 +168,8 @@ class VMWareVMOps(object):
mac_address = mapping['mac']
network_name = network['bridge']
if mapping.get('should_create_vlan'):
- network_ref = self._vif_driver.ensure_vlan_bridge(
- self._session, network)
+ network_ref = vmwarevif.ensure_vlan_bridge(
+ self._session, network)
else:
network_ref = _check_if_network_bridge_exists(network_name)
vif_infos.append({'network_name': network_name,
@@ -823,10 +818,8 @@ class VMWareVMOps(object):
def plug_vifs(self, instance, network_info):
"""Plug VIFs into networks."""
- for (network, mapping) in network_info:
- self._vif_driver.plug(instance, (network, mapping))
+ pass
def unplug_vifs(self, instance, network_info):
"""Unplug VIFs from networks."""
- for (network, mapping) in network_info:
- self._vif_driver.unplug(instance, (network, mapping))
+ pass