summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-05-10 21:49:56 +0000
committerGerrit Code Review <review@openstack.org>2013-05-10 21:49:56 +0000
commitfffbf7cfefaa8e47514ec2c44cce7f12f23ccfbe (patch)
tree4cd186e7c510f157dfe72d06f075224c85167c44 /nova/virt
parent9629c8eb14104a31872f9e3757dd64c637142f9b (diff)
parentb7f9940769618616d37267a50afe495bb8608d27 (diff)
downloadnova-fffbf7cfefaa8e47514ec2c44cce7f12f23ccfbe.tar.gz
nova-fffbf7cfefaa8e47514ec2c44cce7f12f23ccfbe.tar.xz
nova-fffbf7cfefaa8e47514ec2c44cce7f12f23ccfbe.zip
Merge "Add unitests for VMware vif, and fix code logical error."
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/vmwareapi/fake.py6
-rw-r--r--nova/virt/vmwareapi/vif.py34
2 files changed, 22 insertions, 18 deletions
diff --git a/nova/virt/vmwareapi/fake.py b/nova/virt/vmwareapi/fake.py
index ab4bf10e0..86b6e5fc2 100644
--- a/nova/virt/vmwareapi/fake.py
+++ b/nova/virt/vmwareapi/fake.py
@@ -308,7 +308,13 @@ class HostSystem(ManagedObject):
config.product = product
summary.config = config
+ pnic_do = DataObject()
+ pnic_do.device = "vmnic0"
+ net_info_pnic = DataObject()
+ net_info_pnic.PhysicalNic = [pnic_do]
+
self.set("summary", summary)
+ self.set("config.network.pnic", net_info_pnic)
if _db_content.get("Network", None) is None:
create_network()
diff --git a/nova/virt/vmwareapi/vif.py b/nova/virt/vmwareapi/vif.py
index cb8ce52c0..c98f619e1 100644
--- a/nova/virt/vmwareapi/vif.py
+++ b/nova/virt/vmwareapi/vif.py
@@ -45,17 +45,15 @@ def ensure_vlan_bridge(session, vif, cluster=None, create_vlan=True):
# Get the vSwitch associated with the Physical Adapter
vswitch_associated = network_util.get_vswitch_for_vlan_interface(
session, vlan_interface, cluster)
+ if vswitch_associated is None:
+ raise exception.SwitchNotFoundForNetworkAdapter(
+ adapter=vlan_interface)
+ # Check if the vlan_interface physical network adapter exists on the
+ # host.
+ if not network_util.check_if_vlan_interface_exists(session,
+ vlan_interface, cluster):
+ raise exception.NetworkAdapterNotFound(adapter=vlan_interface)
if create_vlan:
- # Check if the vlan_interface physical network adapter exists on the
- # host.
- if not network_util.check_if_vlan_interface_exists(session,
- vlan_interface,
- cluster):
- raise exception.NetworkAdapterNotFound(adapter=vlan_interface)
-
- if vswitch_associated is None:
- raise exception.SwitchNotFoundForNetworkAdapter(
- adapter=vlan_interface)
if network_ref is None:
# Create a port group on the vSwitch associated with the
@@ -69,15 +67,15 @@ def ensure_vlan_bridge(session, vif, cluster=None, create_vlan=True):
_get_pg_info = network_util.get_vlanid_and_vswitch_for_portgroup
pg_vlanid, pg_vswitch = _get_pg_info(session, bridge, cluster)
- # Check if the vswitch associated is proper
- if pg_vswitch != vswitch_associated:
- raise exception.InvalidVLANPortGroup(
- bridge=bridge, expected=vswitch_associated,
- actual=pg_vswitch)
+ # Check if the vswitch associated is proper
+ if pg_vswitch != vswitch_associated:
+ raise exception.InvalidVLANPortGroup(
+ bridge=bridge, expected=vswitch_associated,
+ actual=pg_vswitch)
- # Check if the vlan id is proper for the port group
- if pg_vlanid != vlan_num:
- raise exception.InvalidVLANTag(bridge=bridge, tag=vlan_num,
+ # 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)
else:
if network_ref is None: