use the HostPortGroupSpec.vswitchName instead of HostPortGroup.vswitch.split

add the mock attribute

Change-Id: I76406114c546213b5d6bb9d35b17def1ca939cdd
This commit is contained in:
Fang He 2016-08-03 09:12:42 +08:00
parent 29e03572cb
commit 7e6e3366fd
2 changed files with 2 additions and 1 deletions

View File

@ -224,6 +224,7 @@ class GetVlanIdAndVswitchForPortgroupTestCase(test.NoDBTestCase):
port_group_spec = fake.DataObject()
port_group_spec.name = 'port_group_name'
port_group_spec.vlanId = 100
port_group_spec.vswitchName = 'vswitch_name'
port_group = fake.DataObject()
port_group.vswitch = 'vswitch_name'

View File

@ -167,7 +167,7 @@ def get_vlanid_and_vswitch_for_portgroup(session, pg_name, cluster=None):
port_grps_on_host = port_grps_on_host_ret.HostPortGroup
for p_gp in port_grps_on_host:
if p_gp.spec.name == pg_name:
p_grp_vswitch_name = p_gp.vswitch.split("-")[-1]
p_grp_vswitch_name = p_gp.spec.vswitchName
return p_gp.spec.vlanId, p_grp_vswitch_name
return None, None