Using neutron utils function from neutron plugin

This patch replaces calls in resources and tests to use the client
plugin methods.

File neutron_utils.py was deleted as unnecessary.

Change-Id: If0db1da7079a9bfc3208ff1b209653d1dc7de01d
This commit is contained in:
Sergey Kraynev 2014-08-19 04:15:04 -04:00
parent 8f0035ed99
commit 319651aaf8
12 changed files with 78 additions and 142 deletions

View File

@ -14,7 +14,6 @@
from heat.engine import attributes from heat.engine import attributes
from heat.engine import properties from heat.engine import properties
from heat.engine.resources.neutron import neutron from heat.engine.resources.neutron import neutron
from heat.engine.resources.neutron import neutron_utils
from heat.engine.resources.neutron import router from heat.engine.resources.neutron import router
from heat.engine import support from heat.engine import support
@ -116,9 +115,8 @@ class FloatingIP(neutron.NeutronResource):
props = self.prepare_properties( props = self.prepare_properties(
self.properties, self.properties,
self.physical_resource_name()) self.physical_resource_name())
neutron_utils.resolve_network( self.client_plugin().resolve_network(props, self.FLOATING_NETWORK,
self.neutron(), props, self.FLOATING_NETWORK, 'floating_network_id')
'floating_network_id')
fip = self.neutron().create_floatingip({ fip = self.neutron().create_floatingip({
'floatingip': props})['floatingip'] 'floatingip': props})['floatingip']
self.resource_id_set(fip['id']) self.resource_id_set(fip['id'])

View File

@ -17,7 +17,6 @@ from heat.engine import constraints
from heat.engine import properties from heat.engine import properties
from heat.engine import resource from heat.engine import resource
from heat.engine.resources.neutron import neutron from heat.engine.resources.neutron import neutron
from heat.engine.resources.neutron import neutron_utils
from heat.engine import scheduler from heat.engine import scheduler
from heat.engine import support from heat.engine import support
@ -370,8 +369,8 @@ class Pool(neutron.NeutronResource):
properties = self.prepare_properties( properties = self.prepare_properties(
self.properties, self.properties,
self.physical_resource_name()) self.physical_resource_name())
neutron_utils.resolve_subnet( self.client_plugin().resolve_subnet(
self.neutron(), properties, self.SUBNET, 'subnet_id') properties, self.SUBNET, 'subnet_id')
vip_properties = properties.pop(self.VIP) vip_properties = properties.pop(self.VIP)
monitors = properties.pop(self.MONITORS) monitors = properties.pop(self.MONITORS)
client = self.neutron() client = self.neutron()
@ -396,8 +395,7 @@ class Pool(neutron.NeutronResource):
if vip_arguments.get(self.VIP_SUBNET) is None: if vip_arguments.get(self.VIP_SUBNET) is None:
vip_arguments['subnet_id'] = properties[self.SUBNET_ID] vip_arguments['subnet_id'] = properties[self.SUBNET_ID]
else: else:
vip_arguments['subnet_id'] = neutron_utils.resolve_subnet( vip_arguments['subnet_id'] = self.client_plugin().resolve_subnet(
self.neutron(),
vip_arguments, self.VIP_SUBNET, 'subnet_id') vip_arguments, self.VIP_SUBNET, 'subnet_id')
vip_arguments['pool_id'] = pool['id'] vip_arguments['pool_id'] = pool['id']

View File

@ -19,7 +19,6 @@ from heat.engine import attributes
from heat.engine import constraints from heat.engine import constraints
from heat.engine import properties from heat.engine import properties
from heat.engine.resources.neutron import neutron from heat.engine.resources.neutron import neutron
from heat.engine.resources.neutron import neutron_utils
from heat.engine import support from heat.engine import support
@ -172,8 +171,8 @@ class NetworkGateway(neutron.NeutronResource):
{'network_gateway': props})['network_gateway'] {'network_gateway': props})['network_gateway']
for connection in connections: for connection in connections:
neutron_utils.resolve_network( self.client_plugin().resolve_network(
self.neutron(), connection, self.NETWORK, 'network_id') connection, self.NETWORK, 'network_id')
if self.NETWORK in connection.keys(): if self.NETWORK in connection.keys():
connection.pop(self.NETWORK) connection.pop(self.NETWORK)
self.neutron().connect_network_gateway( self.neutron().connect_network_gateway(
@ -190,8 +189,8 @@ class NetworkGateway(neutron.NeutronResource):
connections = self.properties[self.CONNECTIONS] connections = self.properties[self.CONNECTIONS]
for connection in connections: for connection in connections:
try: try:
neutron_utils.resolve_network( self.client_plugin().resolve_network(
self.neutron(), connection, self.NETWORK, 'network_id') connection, self.NETWORK, 'network_id')
if self.NETWORK in connection.keys(): if self.NETWORK in connection.keys():
connection.pop(self.NETWORK) connection.pop(self.NETWORK)
client.disconnect_network_gateway( client.disconnect_network_gateway(
@ -226,8 +225,8 @@ class NetworkGateway(neutron.NeutronResource):
if self.CONNECTIONS in prop_diff: if self.CONNECTIONS in prop_diff:
for connection in self.properties[self.CONNECTIONS]: for connection in self.properties[self.CONNECTIONS]:
try: try:
neutron_utils.resolve_network( self.client_plugin().resolve_network(
self.neutron(), connection, self.NETWORK, 'network_id') connection, self.NETWORK, 'network_id')
if self.NETWORK in connection.keys(): if self.NETWORK in connection.keys():
connection.pop(self.NETWORK) connection.pop(self.NETWORK)
self.neutron().disconnect_network_gateway( self.neutron().disconnect_network_gateway(
@ -236,8 +235,8 @@ class NetworkGateway(neutron.NeutronResource):
except Exception as ex: except Exception as ex:
self.client_plugin().ignore_not_found(ex) self.client_plugin().ignore_not_found(ex)
for connection in connections: for connection in connections:
neutron_utils.resolve_network( self.client_plugin().resolve_network(
self.neutron(), connection, self.NETWORK, 'network_id') connection, self.NETWORK, 'network_id')
if self.NETWORK in connection.keys(): if self.NETWORK in connection.keys():
connection.pop(self.NETWORK) connection.pop(self.NETWORK)
self.neutron().connect_network_gateway( self.neutron().connect_network_gateway(

View File

@ -1,42 +0,0 @@
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from neutronclient.neutron import v2_0 as neutronV20
import warnings
def find_neutron_resource(neutron_client, props, key, key_type):
warnings.warn('neutron_utils.find_neutron_resource is deprecated. '
'Use self.client_plugin("neutron").find_neutron_resource')
return neutronV20.find_resourceid_by_name_or_id(
neutron_client, key_type, props.get(key))
def resolve_network(neutron_client, props, net_key, net_id_key):
warnings.warn('neutron_utils.resolve_network is deprecated. '
'Use self.client_plugin("neutron").resolve_network')
if props.get(net_key):
props[net_id_key] = find_neutron_resource(
neutron_client, props, net_key, 'network')
props.pop(net_key)
return props[net_id_key]
def resolve_subnet(neutron_client, props, subnet_key, subnet_id_key):
warnings.warn('neutron_utils.resolve_subnet is deprecated. '
'Use self.client_plugin("neutron").resolve_subnet')
if props.get(subnet_key):
props[subnet_id_key] = find_neutron_resource(
neutron_client, props, subnet_key, 'subnet')
props.pop(subnet_key)
return props[subnet_id_key]

View File

@ -14,7 +14,6 @@
from heat.engine import attributes from heat.engine import attributes
from heat.engine import properties from heat.engine import properties
from heat.engine.resources.neutron import neutron from heat.engine.resources.neutron import neutron
from heat.engine.resources.neutron import neutron_utils
from heat.engine.resources.neutron import subnet from heat.engine.resources.neutron import subnet
from heat.engine import support from heat.engine import support
from heat.openstack.common import log as logging from heat.openstack.common import log as logging
@ -223,8 +222,7 @@ class Port(neutron.NeutronResource):
props = self.prepare_properties( props = self.prepare_properties(
self.properties, self.properties,
self.physical_resource_name()) self.physical_resource_name())
neutron_utils.resolve_network(self.neutron(), self.client_plugin().resolve_network(props, self.NETWORK, 'network_id')
props, self.NETWORK, 'network_id')
self._prepare_list_properties(props) self._prepare_list_properties(props)
port = self.neutron().create_port({'port': props})['port'] port = self.neutron().create_port({'port': props})['port']
@ -236,9 +234,8 @@ class Port(neutron.NeutronResource):
if value is None: if value is None:
fixed_ip.pop(key) fixed_ip.pop(key)
if fixed_ip.get(self.FIXED_IP_SUBNET): if fixed_ip.get(self.FIXED_IP_SUBNET):
neutron_utils.resolve_subnet( self.client_plugin().resolve_subnet(
self.neutron(), fixed_ip, fixed_ip, self.FIXED_IP_SUBNET, 'subnet_id')
self.FIXED_IP_SUBNET, 'subnet_id')
# delete empty MAC addresses so that Neutron validation code # delete empty MAC addresses so that Neutron validation code
# wouldn't fail as it not accepts Nones # wouldn't fail as it not accepts Nones
for pair in props.get(self.ALLOWED_ADDRESS_PAIRS, []): for pair in props.get(self.ALLOWED_ADDRESS_PAIRS, []):

View File

@ -15,7 +15,6 @@ from heat.common import exception
from heat.engine import attributes from heat.engine import attributes
from heat.engine import properties from heat.engine import properties
from heat.engine.resources.neutron import neutron from heat.engine.resources.neutron import neutron
from heat.engine.resources.neutron import neutron_utils
from heat.engine.resources.neutron import subnet from heat.engine.resources.neutron import subnet
from heat.engine import support from heat.engine import support
@ -129,9 +128,8 @@ class Router(neutron.NeutronResource):
props = super(Router, self).prepare_properties(properties, name) props = super(Router, self).prepare_properties(properties, name)
gateway = props.get(self.EXTERNAL_GATEWAY) gateway = props.get(self.EXTERNAL_GATEWAY)
if gateway: if gateway:
neutron_utils.resolve_network( self.client_plugin().resolve_network(
self.neutron(), gateway, gateway, self.EXTERNAL_GATEWAY_NETWORK, 'network_id')
self.EXTERNAL_GATEWAY_NETWORK, 'network_id')
if gateway[self.EXTERNAL_GATEWAY_ENABLE_SNAT] is None: if gateway[self.EXTERNAL_GATEWAY_ENABLE_SNAT] is None:
del gateway[self.EXTERNAL_GATEWAY_ENABLE_SNAT] del gateway[self.EXTERNAL_GATEWAY_ENABLE_SNAT]
return props return props
@ -251,8 +249,8 @@ class RouterInterface(neutron.NeutronResource):
def handle_create(self): def handle_create(self):
router_id = self.properties.get(self.ROUTER_ID) router_id = self.properties.get(self.ROUTER_ID)
key = 'subnet_id' key = 'subnet_id'
value = neutron_utils.resolve_subnet( value = self.client_plugin().resolve_subnet(
self.neutron(), dict(self.properties), self.SUBNET, key) dict(self.properties), self.SUBNET, key)
if not value: if not value:
key = self.PORT_ID key = self.PORT_ID
value = self.properties.get(key) value = self.properties.get(key)
@ -343,9 +341,8 @@ class RouterGateway(neutron.NeutronResource):
def handle_create(self): def handle_create(self):
router_id = self.properties.get(self.ROUTER_ID) router_id = self.properties.get(self.ROUTER_ID)
network_id = neutron_utils.resolve_network( network_id = self.client_plugin().resolve_network(
self.neutron(), dict(self.properties), self.NETWORK, dict(self.properties), self.NETWORK, 'network_id')
'network_id')
self.neutron().add_gateway_router( self.neutron().add_gateway_router(
router_id, router_id,
{'network_id': network_id}) {'network_id': network_id})

View File

@ -15,7 +15,6 @@ from heat.engine import attributes
from heat.engine import constraints from heat.engine import constraints
from heat.engine import properties from heat.engine import properties
from heat.engine.resources.neutron import neutron from heat.engine.resources.neutron import neutron
from heat.engine.resources.neutron import neutron_utils
from heat.engine import support from heat.engine import support
@ -204,8 +203,7 @@ class Subnet(neutron.NeutronResource):
props = self.prepare_properties( props = self.prepare_properties(
self.properties, self.properties,
self.physical_resource_name()) self.physical_resource_name())
neutron_utils.resolve_network( self.client_plugin().resolve_network(props, self.NETWORK, 'network_id')
self.neutron(), props, self.NETWORK, 'network_id')
self._null_gateway_ip(props) self._null_gateway_ip(props)
subnet = self.neutron().create_subnet({'subnet': props})['subnet'] subnet = self.neutron().create_subnet({'subnet': props})['subnet']

View File

@ -15,7 +15,6 @@ from heat.engine import attributes
from heat.engine import constraints from heat.engine import constraints
from heat.engine import properties from heat.engine import properties
from heat.engine.resources.neutron import neutron from heat.engine.resources.neutron import neutron
from heat.engine.resources.neutron import neutron_utils
from heat.engine import support from heat.engine import support
@ -118,9 +117,7 @@ class VPNService(neutron.NeutronResource):
props = self.prepare_properties( props = self.prepare_properties(
self.properties, self.properties,
self.physical_resource_name()) self.physical_resource_name())
neutron_utils.resolve_subnet( self.client_plugin().resolve_subnet(props, self.SUBNET, 'subnet_id')
self.neutron(), props,
self.SUBNET, 'subnet_id')
vpnservice = self.neutron().create_vpnservice({'vpnservice': props})[ vpnservice = self.neutron().create_vpnservice({'vpnservice': props})[
'vpnservice'] 'vpnservice']
self.resource_id_set(vpnservice['id']) self.resource_id_set(vpnservice['id'])

View File

@ -17,6 +17,7 @@ import six
import mock import mock
import mox import mox
from neutronclient.common import exceptions as qe from neutronclient.common import exceptions as qe
from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.v2_0 import client as neutronclient from neutronclient.v2_0 import client as neutronclient
from heat.common import exception from heat.common import exception
@ -27,7 +28,6 @@ from heat.engine import properties
from heat.engine import resource from heat.engine import resource
from heat.engine.resources.neutron import net from heat.engine.resources.neutron import net
from heat.engine.resources.neutron.neutron import NeutronResource as qr from heat.engine.resources.neutron.neutron import NeutronResource as qr
from heat.engine.resources.neutron import neutron_utils
from heat.engine.resources.neutron import provider_net from heat.engine.resources.neutron import provider_net
from heat.engine.resources.neutron import router from heat.engine.resources.neutron import router
from heat.engine.resources.neutron import subnet from heat.engine.resources.neutron import subnet
@ -863,8 +863,7 @@ class NeutronSubnetTest(HeatTestCase):
self.m.StubOutWithMock(neutronclient.Client, 'delete_subnet') self.m.StubOutWithMock(neutronclient.Client, 'delete_subnet')
self.m.StubOutWithMock(neutronclient.Client, 'show_subnet') self.m.StubOutWithMock(neutronclient.Client, 'show_subnet')
self.m.StubOutWithMock(neutronclient.Client, 'update_subnet') self.m.StubOutWithMock(neutronclient.Client, 'update_subnet')
self.m.StubOutWithMock(neutron_utils.neutronV20, self.m.StubOutWithMock(neutronV20, 'find_resourceid_by_name_or_id')
'find_resourceid_by_name_or_id')
self.stub_keystoneclient() self.stub_keystoneclient()
def create_subnet(self, t, stack, resource_name): def create_subnet(self, t, stack, resource_name):
@ -875,7 +874,7 @@ class NeutronSubnetTest(HeatTestCase):
def test_subnet(self): def test_subnet(self):
t = self._test_subnet() t = self._test_subnet()
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'None' 'None'
@ -1032,7 +1031,7 @@ class NeutronSubnetTest(HeatTestCase):
return t return t
def test_subnet_disable_dhcp(self): def test_subnet_disable_dhcp(self):
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'None' 'None'
@ -1174,8 +1173,7 @@ class NeutronRouterTest(HeatTestCase):
'remove_router_from_l3_agent') 'remove_router_from_l3_agent')
self.m.StubOutWithMock(neutronclient.Client, self.m.StubOutWithMock(neutronclient.Client,
'list_l3_agent_hosting_routers') 'list_l3_agent_hosting_routers')
self.m.StubOutWithMock(neutron_utils.neutronV20, self.m.StubOutWithMock(neutronV20, 'find_resourceid_by_name_or_id')
'find_resourceid_by_name_or_id')
self.stub_keystoneclient() self.stub_keystoneclient()
def create_router(self, t, stack, resource_name): def create_router(self, t, stack, resource_name):
@ -1402,7 +1400,7 @@ class NeutronRouterTest(HeatTestCase):
t = template_format.parse(neutron_template) t = template_format.parse(neutron_template)
stack = utils.parse_stack(t) stack = utils.parse_stack(t)
if resolve_neutron: if resolve_neutron:
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'subnet', 'subnet',
'91e47a57-7508-46fe-afc9-fc454e8580e1' '91e47a57-7508-46fe-afc9-fc454e8580e1'
@ -1532,7 +1530,7 @@ class NeutronRouterTest(HeatTestCase):
six.text_type(ex)) six.text_type(ex))
def test_gateway_router(self): def test_gateway_router(self):
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'fc68ea2c-b60b-4b4f-bd82-94ec81110766' 'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
@ -1563,7 +1561,7 @@ class NeutronRouterTest(HeatTestCase):
self.m.VerifyAll() self.m.VerifyAll()
def _create_router_with_gateway(self): def _create_router_with_gateway(self):
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'public' 'public'
@ -1642,7 +1640,7 @@ class NeutronRouterTest(HeatTestCase):
self.m.VerifyAll() self.m.VerifyAll()
def test_create_router_gateway_enable_snat(self): def test_create_router_gateway_enable_snat(self):
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'public' 'public'
@ -1703,7 +1701,7 @@ class NeutronRouterTest(HeatTestCase):
def test_update_router_gateway_as_property(self): def test_update_router_gateway_as_property(self):
self._create_router_with_gateway() self._create_router_with_gateway()
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'other_public' 'other_public'
@ -1786,7 +1784,7 @@ class NeutronFloatingIPTest(HeatTestCase):
self.m.StubOutWithMock(neutronclient.Client, 'delete_port') self.m.StubOutWithMock(neutronclient.Client, 'delete_port')
self.m.StubOutWithMock(neutronclient.Client, 'update_port') self.m.StubOutWithMock(neutronclient.Client, 'update_port')
self.m.StubOutWithMock(neutronclient.Client, 'show_port') self.m.StubOutWithMock(neutronclient.Client, 'show_port')
self.m.StubOutWithMock(neutron_utils.neutronV20, self.m.StubOutWithMock(neutronV20,
'find_resourceid_by_name_or_id') 'find_resourceid_by_name_or_id')
self.stub_keystoneclient() self.stub_keystoneclient()
@ -1821,7 +1819,7 @@ class NeutronFloatingIPTest(HeatTestCase):
qe.NeutronClientException(status_code=404)) qe.NeutronClientException(status_code=404))
if resolve_neutron: if resolve_neutron:
t = template_format.parse(neutron_floating_template) t = template_format.parse(neutron_floating_template)
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'abcd1234' 'abcd1234'
@ -1861,12 +1859,12 @@ class NeutronFloatingIPTest(HeatTestCase):
self.m.VerifyAll() self.m.VerifyAll()
def test_port(self): def test_port(self):
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'xyz1234' 'xyz1234'
).AndReturn('xyz1234') ).AndReturn('xyz1234')
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'subnet', 'subnet',
'sub1234' 'sub1234'
@ -1956,17 +1954,17 @@ class NeutronFloatingIPTest(HeatTestCase):
self.m.VerifyAll() self.m.VerifyAll()
def test_floatip_port(self): def test_floatip_port(self):
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'abcd1234' 'abcd1234'
).AndReturn('abcd1234') ).AndReturn('abcd1234')
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'xyz1234' 'xyz1234'
).AndReturn('xyz1234') ).AndReturn('xyz1234')
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'subnet', 'subnet',
'sub1234' 'sub1234'
@ -2160,12 +2158,11 @@ class NeutronPortTest(HeatTestCase):
self.m.StubOutWithMock(neutronclient.Client, 'create_port') self.m.StubOutWithMock(neutronclient.Client, 'create_port')
self.m.StubOutWithMock(neutronclient.Client, 'show_port') self.m.StubOutWithMock(neutronclient.Client, 'show_port')
self.m.StubOutWithMock(neutronclient.Client, 'update_port') self.m.StubOutWithMock(neutronclient.Client, 'update_port')
self.m.StubOutWithMock(neutron_utils.neutronV20, self.m.StubOutWithMock(neutronV20, 'find_resourceid_by_name_or_id')
'find_resourceid_by_name_or_id')
self.stub_keystoneclient() self.stub_keystoneclient()
def test_missing_subnet_id(self): def test_missing_subnet_id(self):
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'net1234' 'net1234'
@ -2201,12 +2198,12 @@ class NeutronPortTest(HeatTestCase):
self.m.VerifyAll() self.m.VerifyAll()
def test_missing_ip_address(self): def test_missing_ip_address(self):
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'net1234' 'net1234'
).AndReturn('net1234') ).AndReturn('net1234')
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'subnet', 'subnet',
'sub1234' 'sub1234'
@ -2242,7 +2239,7 @@ class NeutronPortTest(HeatTestCase):
self.m.VerifyAll() self.m.VerifyAll()
def test_missing_fixed_ips(self): def test_missing_fixed_ips(self):
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'net1234' 'net1234'
@ -2278,7 +2275,7 @@ class NeutronPortTest(HeatTestCase):
self.m.VerifyAll() self.m.VerifyAll()
def test_allowed_address_pair(self): def test_allowed_address_pair(self):
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'abcd1234' 'abcd1234'
@ -2312,7 +2309,7 @@ class NeutronPortTest(HeatTestCase):
self.m.VerifyAll() self.m.VerifyAll()
def test_missing_mac_address(self): def test_missing_mac_address(self):
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'abcd1234' 'abcd1234'
@ -2348,12 +2345,12 @@ class NeutronPortTest(HeatTestCase):
self.m.VerifyAll() self.m.VerifyAll()
def test_security_groups(self): def test_security_groups(self):
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'net1234' 'net1234'
).AndReturn('net1234') ).AndReturn('net1234')
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'subnet', 'subnet',
'sub1234' 'sub1234'
@ -2402,7 +2399,7 @@ class NeutronPortTest(HeatTestCase):
new_props_update = new_props.copy() new_props_update = new_props.copy()
new_props_update.pop('network_id') new_props_update.pop('network_id')
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'net1234' 'net1234'

View File

@ -17,13 +17,13 @@ from oslo.config import cfg
import six import six
from neutronclient.common import exceptions from neutronclient.common import exceptions
from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.v2_0 import client as neutronclient from neutronclient.v2_0 import client as neutronclient
from heat.common import exception from heat.common import exception
from heat.common import template_format from heat.common import template_format
from heat.engine.clients.os import nova from heat.engine.clients.os import nova
from heat.engine.resources.neutron import loadbalancer from heat.engine.resources.neutron import loadbalancer
from heat.engine.resources.neutron import neutron_utils
from heat.engine import scheduler from heat.engine import scheduler
from heat.tests.common import HeatTestCase from heat.tests.common import HeatTestCase
from heat.tests import utils from heat.tests import utils
@ -358,8 +358,7 @@ class PoolTest(HeatTestCase):
self.m.StubOutWithMock(neutronclient.Client, self.m.StubOutWithMock(neutronclient.Client,
'disassociate_health_monitor') 'disassociate_health_monitor')
self.m.StubOutWithMock(neutronclient.Client, 'create_vip') self.m.StubOutWithMock(neutronclient.Client, 'create_vip')
self.m.StubOutWithMock(neutron_utils.neutronV20, self.m.StubOutWithMock(neutronV20, 'find_resourceid_by_name_or_id')
'find_resourceid_by_name_or_id')
self.m.StubOutWithMock(neutronclient.Client, 'delete_vip') self.m.StubOutWithMock(neutronclient.Client, 'delete_vip')
self.m.StubOutWithMock(neutronclient.Client, 'show_vip') self.m.StubOutWithMock(neutronclient.Client, 'show_vip')
self.stub_keystoneclient() self.stub_keystoneclient()
@ -386,12 +385,12 @@ class PoolTest(HeatTestCase):
stvippsn['vip']['subnet_id'] = 'sub123' stvippsn['vip']['subnet_id'] = 'sub123'
if resolve_neutron and with_vip_subnet: if resolve_neutron and with_vip_subnet:
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'subnet', 'subnet',
'sub123' 'sub123'
).AndReturn('sub123') ).AndReturn('sub123')
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'subnet', 'subnet',
'sub9999' 'sub9999'
@ -401,7 +400,7 @@ class PoolTest(HeatTestCase):
).AndReturn({'vip': {'id': 'xyz'}}) ).AndReturn({'vip': {'id': 'xyz'}})
elif resolve_neutron and not with_vip_subnet: elif resolve_neutron and not with_vip_subnet:
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'subnet', 'subnet',
'sub123' 'sub123'
@ -439,7 +438,7 @@ class PoolTest(HeatTestCase):
self.m.VerifyAll() self.m.VerifyAll()
def test_create_pending(self): def test_create_pending(self):
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'subnet', 'subnet',
'sub123' 'sub123'
@ -479,7 +478,7 @@ class PoolTest(HeatTestCase):
def test_create_failed_error_status(self): def test_create_failed_error_status(self):
cfg.CONF.set_override('action_retry_limit', 0) cfg.CONF.set_override('action_retry_limit', 0)
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'subnet', 'subnet',
'sub123' 'sub123'
@ -515,7 +514,7 @@ class PoolTest(HeatTestCase):
self.m.VerifyAll() self.m.VerifyAll()
def test_create_failed_unexpected_vip_status(self): def test_create_failed_unexpected_vip_status(self):
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'subnet', 'subnet',
'sub123' 'sub123'
@ -553,7 +552,7 @@ class PoolTest(HeatTestCase):
self.m.VerifyAll() self.m.VerifyAll()
def test_create_failed(self): def test_create_failed(self):
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'subnet', 'subnet',
'sub123' 'sub123'
@ -581,7 +580,7 @@ class PoolTest(HeatTestCase):
self.m.VerifyAll() self.m.VerifyAll()
def test_create_with_session_persistence(self): def test_create_with_session_persistence(self):
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'subnet', 'subnet',
'sub123' 'sub123'
@ -645,7 +644,7 @@ class PoolTest(HeatTestCase):
self.assertIsNone(resource.validate()) self.assertIsNone(resource.validate())
def test_properties_are_prepared_for_session_persistence(self): def test_properties_are_prepared_for_session_persistence(self):
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'subnet', 'subnet',
'sub123' 'sub123'
@ -796,7 +795,7 @@ class PoolTest(HeatTestCase):
self.m.VerifyAll() self.m.VerifyAll()
def test_update_monitors(self): def test_update_monitors(self):
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'subnet', 'subnet',
'sub123' 'sub123'

View File

@ -17,13 +17,13 @@
import mox import mox
from mox import IgnoreArg from mox import IgnoreArg
from neutronclient.common import exceptions as qe from neutronclient.common import exceptions as qe
from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.v2_0 import client as neutronclient from neutronclient.v2_0 import client as neutronclient
import six import six
from heat.common import exception from heat.common import exception
from heat.common import template_format from heat.common import template_format
from heat.engine.resources.neutron import network_gateway from heat.engine.resources.neutron import network_gateway
from heat.engine.resources.neutron import neutron_utils
from heat.engine import rsrc_defn from heat.engine import rsrc_defn
from heat.engine import scheduler from heat.engine import scheduler
from heat.tests.common import HeatTestCase from heat.tests.common import HeatTestCase
@ -104,8 +104,7 @@ class NeutronNetworkGatewayTest(HeatTestCase):
self.m.StubOutWithMock(neutronclient.Client, self.m.StubOutWithMock(neutronclient.Client,
'disconnect_network_gateway') 'disconnect_network_gateway')
self.m.StubOutWithMock(neutronclient.Client, 'list_networks') self.m.StubOutWithMock(neutronclient.Client, 'list_networks')
self.m.StubOutWithMock(neutron_utils.neutronV20, self.m.StubOutWithMock(neutronV20, 'find_resourceid_by_name_or_id')
'find_resourceid_by_name_or_id')
self.stub_keystoneclient() self.stub_keystoneclient()
def prepare_create_network_gateway(self, resolve_neutron=True): def prepare_create_network_gateway(self, resolve_neutron=True):
@ -142,7 +141,7 @@ class NeutronNetworkGatewayTest(HeatTestCase):
} }
}) })
if resolve_neutron: if resolve_neutron:
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35' '6af055d3-26f6-48dd-a597-7611d7e58d35'
@ -161,12 +160,12 @@ class NeutronNetworkGatewayTest(HeatTestCase):
def _test_network_gateway_create(self, resolve_neutron=True): def _test_network_gateway_create(self, resolve_neutron=True):
rsrc = self.prepare_create_network_gateway(resolve_neutron) rsrc = self.prepare_create_network_gateway(resolve_neutron)
if resolve_neutron: if resolve_neutron:
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35' '6af055d3-26f6-48dd-a597-7611d7e58d35'
).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35') ).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35')
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35' '6af055d3-26f6-48dd-a597-7611d7e58d35'
@ -231,32 +230,32 @@ class NeutronNetworkGatewayTest(HeatTestCase):
def test_network_gateway_update(self): def test_network_gateway_update(self):
rsrc = self.prepare_create_network_gateway() rsrc = self.prepare_create_network_gateway()
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35' '6af055d3-26f6-48dd-a597-7611d7e58d35'
).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35') ).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35')
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35' '6af055d3-26f6-48dd-a597-7611d7e58d35'
).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35') ).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35')
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35' '6af055d3-26f6-48dd-a597-7611d7e58d35'
).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35') ).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35')
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35' '6af055d3-26f6-48dd-a597-7611d7e58d35'
).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35') ).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35')
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35' '6af055d3-26f6-48dd-a597-7611d7e58d35'
).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35') ).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35')
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'network', 'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35' '6af055d3-26f6-48dd-a597-7611d7e58d35'

View File

@ -14,12 +14,12 @@
import copy import copy
import mox import mox
from neutronclient.common import exceptions from neutronclient.common import exceptions
from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.v2_0 import client as neutronclient from neutronclient.v2_0 import client as neutronclient
import six import six
from heat.common import exception from heat.common import exception
from heat.common import template_format from heat.common import template_format
from heat.engine.resources.neutron import neutron_utils
from heat.engine.resources.neutron import vpnservice from heat.engine.resources.neutron import vpnservice
from heat.engine import scheduler from heat.engine import scheduler
from heat.tests.common import HeatTestCase from heat.tests.common import HeatTestCase
@ -169,13 +169,12 @@ class VPNServiceTest(HeatTestCase):
self.m.StubOutWithMock(neutronclient.Client, 'delete_vpnservice') self.m.StubOutWithMock(neutronclient.Client, 'delete_vpnservice')
self.m.StubOutWithMock(neutronclient.Client, 'show_vpnservice') self.m.StubOutWithMock(neutronclient.Client, 'show_vpnservice')
self.m.StubOutWithMock(neutronclient.Client, 'update_vpnservice') self.m.StubOutWithMock(neutronclient.Client, 'update_vpnservice')
self.m.StubOutWithMock(neutron_utils.neutronV20, self.m.StubOutWithMock(neutronV20, 'find_resourceid_by_name_or_id')
'find_resourceid_by_name_or_id')
self.stub_keystoneclient() self.stub_keystoneclient()
def create_vpnservice(self, resolve_neutron=True): def create_vpnservice(self, resolve_neutron=True):
if resolve_neutron: if resolve_neutron:
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'subnet', 'subnet',
'sub123' 'sub123'
@ -206,7 +205,7 @@ class VPNServiceTest(HeatTestCase):
self.m.VerifyAll() self.m.VerifyAll()
def test_create_failed(self): def test_create_failed(self):
neutron_utils.neutronV20.find_resourceid_by_name_or_id( neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client), mox.IsA(neutronclient.Client),
'subnet', 'subnet',
'sub123' 'sub123'