Merge "Refactor neutron resources lookup"

This commit is contained in:
Jenkins 2014-05-22 08:43:27 +00:00 committed by Gerrit Code Review
commit 61290febf7
14 changed files with 113 additions and 93 deletions

View File

@ -16,7 +16,7 @@ from testtools import skipIf
from heat.common import template_format
from heat.engine import clients
from heat.engine import resource
from heat.engine.resources.neutron import neutron
from heat.engine.resources.neutron import neutron_utils
from heat.engine import scheduler
from heat.openstack.common.importutils import try_import
from heat.tests.common import HeatTestCase
@ -60,7 +60,7 @@ neutron_template = '''
@skipIf(neutronclient is None, 'neutronclient unavailable')
class NeutronExtraRouteTest(HeatTestCase):
@skipIf(neutron.neutronV20 is None, "Missing Neutron v2_0")
@skipIf(neutron_utils.neutronV20 is None, "Missing Neutron v2_0")
def setUp(self):
super(NeutronExtraRouteTest, self).setUp()
self.m.StubOutWithMock(neutronclient.Client, 'show_router')

View File

@ -15,6 +15,7 @@ from heat.engine import attributes
from heat.engine import clients
from heat.engine import properties
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 import support
@ -119,7 +120,7 @@ class FloatingIP(neutron.NeutronResource):
props = self.prepare_properties(
self.properties,
self.physical_resource_name())
self._resolve_network(
neutron_utils.resolve_network(
self.neutron(), props, self.FLOATING_NETWORK,
'floating_network_id')
fip = self.neutron().create_floatingip({

View File

@ -18,6 +18,7 @@ from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
from heat.engine.resources.neutron import neutron
from heat.engine.resources.neutron import neutron_utils
from heat.engine.resources import nova_utils
from heat.engine import scheduler
from heat.engine import support
@ -374,7 +375,7 @@ class Pool(neutron.NeutronResource):
properties = self.prepare_properties(
self.properties,
self.physical_resource_name())
self._resolve_subnet(
neutron_utils.resolve_subnet(
self.neutron(), properties, self.SUBNET, 'subnet_id')
vip_properties = properties.pop(self.VIP)
monitors = properties.pop(self.MONITORS)
@ -400,7 +401,7 @@ class Pool(neutron.NeutronResource):
if vip_arguments.get(self.VIP_SUBNET) is None:
vip_arguments['subnet_id'] = properties[self.SUBNET_ID]
else:
vip_arguments['subnet_id'] = self._resolve_subnet(
vip_arguments['subnet_id'] = neutron_utils.resolve_subnet(
self.neutron(),
vip_arguments, self.VIP_SUBNET, 'subnet_id')

View File

@ -20,6 +20,7 @@ from heat.engine import clients
from heat.engine import constraints
from heat.engine import properties
from heat.engine.resources.neutron import neutron
from heat.engine.resources.neutron import neutron_utils
from heat.engine import support
if clients.neutronclient is not None:
@ -175,7 +176,7 @@ class NetworkGateway(neutron.NeutronResource):
{'network_gateway': props})['network_gateway']
for connection in connections:
self._resolve_network(
neutron_utils.resolve_network(
self.neutron(), connection, self.NETWORK, 'network_id')
if self.NETWORK in connection.keys():
connection.pop(self.NETWORK)
@ -193,7 +194,7 @@ class NetworkGateway(neutron.NeutronResource):
connections = self.properties[self.CONNECTIONS]
for connection in connections:
try:
self._resolve_network(
neutron_utils.resolve_network(
self.neutron(), connection, self.NETWORK, 'network_id')
if self.NETWORK in connection.keys():
connection.pop(self.NETWORK)
@ -229,7 +230,7 @@ class NetworkGateway(neutron.NeutronResource):
if self.CONNECTIONS in prop_diff:
for connection in self.properties[self.CONNECTIONS]:
try:
self._resolve_network(
neutron_utils.resolve_network(
self.neutron(), connection, self.NETWORK, 'network_id')
if self.NETWORK in connection.keys():
connection.pop(self.NETWORK)
@ -239,7 +240,7 @@ class NetworkGateway(neutron.NeutronResource):
except NeutronClientException as ex:
self._handle_not_found_exception(ex)
for connection in connections:
self._resolve_network(
neutron_utils.resolve_network(
self.neutron(), connection, self.NETWORK, 'network_id')
if self.NETWORK in connection.keys():
connection.pop(self.NETWORK)

View File

@ -12,7 +12,6 @@
# under the License.
from neutronclient.common.exceptions import NeutronClientException
from neutronclient.neutron import v2_0 as neutronV20
from heat.common import exception
from heat.engine import function
@ -67,27 +66,6 @@ class NeutronResource(resource.Resource):
'depr_prop_key': depr_prop_key}
raise exception.StackValidationFailed(message=msg)
@staticmethod
def _find_neutron_resource(neutron_client, props, key, key_type):
return neutronV20.find_resourceid_by_name_or_id(
neutron_client, key_type, props.get(key))
@staticmethod
def _resolve_network(neutron_client, props, net_key, net_id_key):
if props.get(net_key):
props[net_id_key] = NeutronResource._find_neutron_resource(
neutron_client, props, net_key, 'network')
props.pop(net_key)
return props[net_id_key]
@staticmethod
def _resolve_subnet(neutron_client, props, subnet_key, subnet_id_key):
if props.get(subnet_key):
props[subnet_id_key] = NeutronResource._find_neutron_resource(
neutron_client, props, subnet_key, 'subnet')
props.pop(subnet_key)
return props[subnet_id_key]
@staticmethod
def prepare_properties(properties, name):
'''

View File

@ -0,0 +1,35 @@
#
# 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
def find_neutron_resource(neutron_client, props, key, key_type):
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):
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):
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

@ -15,6 +15,7 @@ from heat.engine import attributes
from heat.engine import clients
from heat.engine import properties
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 import support
from heat.openstack.common import log as logging
@ -226,8 +227,8 @@ class Port(neutron.NeutronResource):
props = self.prepare_properties(
self.properties,
self.physical_resource_name())
self._resolve_network(self.neutron(),
props, self.NETWORK, 'network_id')
neutron_utils.resolve_network(self.neutron(),
props, self.NETWORK, 'network_id')
self._prepare_list_properties(props)
if not props['fixed_ips']:
@ -242,7 +243,7 @@ class Port(neutron.NeutronResource):
if value is None:
fixed_ip.pop(key)
if fixed_ip.get(self.FIXED_IP_SUBNET):
self._resolve_subnet(
neutron_utils.resolve_subnet(
self.neutron(), fixed_ip,
self.FIXED_IP_SUBNET, 'subnet_id')
# delete empty MAC addresses so that Neutron validation code

View File

@ -16,6 +16,7 @@ from heat.engine import attributes
from heat.engine import clients
from heat.engine import properties
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 import support
@ -132,7 +133,7 @@ class Router(neutron.NeutronResource):
props = super(Router, self).prepare_properties(properties, name)
gateway = props.get(self.EXTERNAL_GATEWAY)
if gateway:
self._resolve_network(
neutron_utils.resolve_network(
self.neutron(), gateway,
self.EXTERNAL_GATEWAY_NETWORK, 'network_id')
if gateway[self.EXTERNAL_GATEWAY_ENABLE_SNAT] is None:
@ -254,7 +255,7 @@ class RouterInterface(neutron.NeutronResource):
def handle_create(self):
router_id = self.properties.get(self.ROUTER_ID)
key = 'subnet_id'
value = self._resolve_subnet(
value = neutron_utils.resolve_subnet(
self.neutron(), dict(self.properties), self.SUBNET, key)
if not value:
key = self.PORT_ID
@ -346,7 +347,7 @@ class RouterGateway(neutron.NeutronResource):
def handle_create(self):
router_id = self.properties.get(self.ROUTER_ID)
network_id = self._resolve_network(
network_id = neutron_utils.resolve_network(
self.neutron(), dict(self.properties), self.NETWORK,
'network_id')
self.neutron().add_gateway_router(

View File

@ -16,6 +16,7 @@ from heat.engine import clients
from heat.engine import constraints
from heat.engine import properties
from heat.engine.resources.neutron import neutron
from heat.engine.resources.neutron import neutron_utils
from heat.engine import support
if clients.neutronclient is not None:
@ -207,7 +208,7 @@ class Subnet(neutron.NeutronResource):
props = self.prepare_properties(
self.properties,
self.physical_resource_name())
self._resolve_network(
neutron_utils.resolve_network(
self.neutron(), props, self.NETWORK, 'network_id')
self._null_gateway_ip(props)

View File

@ -16,6 +16,7 @@ from heat.engine import clients
from heat.engine import constraints
from heat.engine import properties
from heat.engine.resources.neutron import neutron
from heat.engine.resources.neutron import neutron_utils
from heat.engine import support
if clients.neutronclient is not None:
@ -121,7 +122,7 @@ class VPNService(neutron.NeutronResource):
props = self.prepare_properties(
self.properties,
self.physical_resource_name())
self._resolve_subnet(
neutron_utils.resolve_subnet(
self.neutron(), props,
self.SUBNET, 'subnet_id')
vpnservice = self.neutron().create_vpnservice({'vpnservice': props})[

View File

@ -22,8 +22,8 @@ from heat.engine import clients
from heat.engine import properties
from heat.engine import resource
from heat.engine.resources.neutron import net
from heat.engine.resources.neutron import neutron
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 router
from heat.engine.resources.neutron import subnet
@ -857,7 +857,7 @@ class NeutronSubnetTest(HeatTestCase):
self.m.StubOutWithMock(neutronclient.Client, 'delete_subnet')
self.m.StubOutWithMock(neutronclient.Client, 'show_subnet')
self.m.StubOutWithMock(neutronclient.Client, 'update_subnet')
self.m.StubOutWithMock(neutron.neutronV20,
self.m.StubOutWithMock(neutron_utils.neutronV20,
'find_resourceid_by_name_or_id')
self.m.StubOutWithMock(clients.OpenStackClients, 'keystone')
@ -868,7 +868,7 @@ class NeutronSubnetTest(HeatTestCase):
def test_subnet(self):
t = self._test_subnet()
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'None'
@ -1031,7 +1031,7 @@ class NeutronSubnetTest(HeatTestCase):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'None'
@ -1158,7 +1158,7 @@ class NeutronSubnetTest(HeatTestCase):
@skipIf(neutronclient is None, 'neutronclient unavailable')
class NeutronRouterTest(HeatTestCase):
@skipIf(neutron.neutronV20 is None, "Missing Neutron v2_0")
@skipIf(neutron_utils.neutronV20 is None, "Missing Neutron v2_0")
def setUp(self):
super(NeutronRouterTest, self).setUp()
self.m.StubOutWithMock(neutronclient.Client, 'create_router')
@ -1175,7 +1175,7 @@ class NeutronRouterTest(HeatTestCase):
'remove_router_from_l3_agent')
self.m.StubOutWithMock(neutronclient.Client,
'list_l3_agent_hosting_routers')
self.m.StubOutWithMock(neutron.neutronV20,
self.m.StubOutWithMock(neutron_utils.neutronV20,
'find_resourceid_by_name_or_id')
self.m.StubOutWithMock(clients.OpenStackClients, 'keystone')
@ -1405,7 +1405,7 @@ class NeutronRouterTest(HeatTestCase):
t = template_format.parse(neutron_template)
stack = utils.parse_stack(t)
if resolve_neutron:
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'91e47a57-7508-46fe-afc9-fc454e8580e1'
@ -1529,7 +1529,7 @@ class NeutronRouterTest(HeatTestCase):
def test_gateway_router(self):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
@ -1563,7 +1563,7 @@ class NeutronRouterTest(HeatTestCase):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'public'
@ -1645,7 +1645,7 @@ class NeutronRouterTest(HeatTestCase):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'public'
@ -1706,7 +1706,7 @@ class NeutronRouterTest(HeatTestCase):
def test_update_router_gateway_as_property(self):
self._create_router_with_gateway()
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'other_public'
@ -1791,7 +1791,7 @@ class NeutronFloatingIPTest(HeatTestCase):
self.m.StubOutWithMock(neutronclient.Client, 'delete_port')
self.m.StubOutWithMock(neutronclient.Client, 'update_port')
self.m.StubOutWithMock(neutronclient.Client, 'show_port')
self.m.StubOutWithMock(neutron.neutronV20,
self.m.StubOutWithMock(neutron_utils.neutronV20,
'find_resourceid_by_name_or_id')
self.m.StubOutWithMock(clients.OpenStackClients, 'keystone')
@ -1829,7 +1829,7 @@ class NeutronFloatingIPTest(HeatTestCase):
qe.NeutronClientException(status_code=404))
if resolve_neutron:
t = template_format.parse(neutron_floating_template)
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'abcd1234'
@ -1874,12 +1874,12 @@ class NeutronFloatingIPTest(HeatTestCase):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'xyz1234'
).AndReturn('xyz1234')
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub1234'
@ -1974,17 +1974,17 @@ class NeutronFloatingIPTest(HeatTestCase):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'abcd1234'
).AndReturn('abcd1234')
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'xyz1234'
).AndReturn('xyz1234')
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub1234'
@ -2104,14 +2104,14 @@ class NeutronPortTest(HeatTestCase):
super(NeutronPortTest, self).setUp()
self.m.StubOutWithMock(neutronclient.Client, 'create_port')
self.m.StubOutWithMock(neutronclient.Client, 'show_port')
self.m.StubOutWithMock(neutron.neutronV20,
self.m.StubOutWithMock(neutron_utils.neutronV20,
'find_resourceid_by_name_or_id')
self.m.StubOutWithMock(clients.OpenStackClients, 'keystone')
def test_missing_subnet_id(self):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'net1234'
@ -2149,12 +2149,12 @@ class NeutronPortTest(HeatTestCase):
def test_missing_ip_address(self):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'net1234'
).AndReturn('net1234')
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub1234'
@ -2192,7 +2192,7 @@ class NeutronPortTest(HeatTestCase):
def test_missing_fixed_ips(self):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'net1234'
@ -2230,7 +2230,7 @@ class NeutronPortTest(HeatTestCase):
def test_allowed_address_pair(self):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'abcd1234'
@ -2266,7 +2266,7 @@ class NeutronPortTest(HeatTestCase):
def test_missing_mac_address(self):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'abcd1234'
@ -2304,12 +2304,12 @@ class NeutronPortTest(HeatTestCase):
def test_security_groups(self):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'net1234'
).AndReturn('net1234')
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub1234'

View File

@ -20,7 +20,7 @@ from heat.common import exception
from heat.common import template_format
from heat.engine import clients
from heat.engine.resources.neutron import loadbalancer
from heat.engine.resources.neutron import neutron
from heat.engine.resources.neutron import neutron_utils
from heat.engine import scheduler
from heat.openstack.common.importutils import try_import
from heat.tests.common import HeatTestCase
@ -362,7 +362,7 @@ class PoolTest(HeatTestCase):
self.m.StubOutWithMock(neutronclient.Client,
'disassociate_health_monitor')
self.m.StubOutWithMock(neutronclient.Client, 'create_vip')
self.m.StubOutWithMock(neutron.neutronV20,
self.m.StubOutWithMock(neutron_utils.neutronV20,
'find_resourceid_by_name_or_id')
self.m.StubOutWithMock(neutronclient.Client, 'delete_vip')
self.m.StubOutWithMock(neutronclient.Client, 'show_vip')
@ -392,12 +392,12 @@ class PoolTest(HeatTestCase):
stvippsn['vip']['subnet_id'] = 'sub123'
if resolve_neutron and with_vip_subnet:
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'
).AndReturn('sub123')
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub9999'
@ -407,7 +407,7 @@ class PoolTest(HeatTestCase):
).AndReturn({'vip': {'id': 'xyz'}})
elif resolve_neutron and not with_vip_subnet:
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'
@ -446,7 +446,7 @@ class PoolTest(HeatTestCase):
def test_create_pending(self):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'
@ -485,7 +485,7 @@ class PoolTest(HeatTestCase):
def test_create_failed_unexpected_status(self):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'
@ -523,7 +523,7 @@ class PoolTest(HeatTestCase):
def test_create_failed_unexpected_vip_status(self):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'
@ -563,7 +563,7 @@ class PoolTest(HeatTestCase):
def test_create_failed(self):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'
@ -592,7 +592,7 @@ class PoolTest(HeatTestCase):
def test_create_with_session_persistence(self):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'
@ -654,7 +654,7 @@ class PoolTest(HeatTestCase):
def test_properties_are_prepared_for_session_persistence(self):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'
@ -804,7 +804,7 @@ class PoolTest(HeatTestCase):
def test_update_monitors(self):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'

View File

@ -22,7 +22,7 @@ from heat.common import exception
from heat.common import template_format
from heat.engine import clients
from heat.engine.resources.neutron import network_gateway
from heat.engine.resources.neutron import neutron
from heat.engine.resources.neutron import neutron_utils
from heat.engine import scheduler
from heat.openstack.common.importutils import try_import
from heat.tests.common import HeatTestCase
@ -110,7 +110,7 @@ class NeutronNetworkGatewayTest(HeatTestCase):
self.m.StubOutWithMock(neutronclient.Client,
'disconnect_network_gateway')
self.m.StubOutWithMock(neutronclient.Client, 'list_networks')
self.m.StubOutWithMock(neutron.neutronV20,
self.m.StubOutWithMock(neutron_utils.neutronV20,
'find_resourceid_by_name_or_id')
self.m.StubOutWithMock(clients.OpenStackClients, 'keystone')
@ -150,7 +150,7 @@ class NeutronNetworkGatewayTest(HeatTestCase):
}
})
if resolve_neutron:
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35'
@ -168,12 +168,12 @@ class NeutronNetworkGatewayTest(HeatTestCase):
def _test_network_gateway_create(self, resolve_neutron=True):
rsrc = self.prepare_create_network_gateway(resolve_neutron)
if resolve_neutron:
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35'
).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35')
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35'
@ -238,32 +238,32 @@ class NeutronNetworkGatewayTest(HeatTestCase):
def test_network_gateway_update(self):
rsrc = self.prepare_create_network_gateway()
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35'
).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35')
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35'
).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35')
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35'
).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35')
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35'
).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35')
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35'
).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35')
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35'

View File

@ -20,7 +20,7 @@ from heat.common import exception
from heat.common import template_format
from heat.engine import clients
from heat.engine.resources.neutron import vpnservice
from heat.engine.resources.neutron import neutron
from heat.engine.resources.neutron import neutron_utils
from heat.engine import scheduler
from heat.openstack.common.importutils import try_import
from heat.tests.common import HeatTestCase
@ -174,7 +174,7 @@ class VPNServiceTest(HeatTestCase):
self.m.StubOutWithMock(neutronclient.Client, 'delete_vpnservice')
self.m.StubOutWithMock(neutronclient.Client, 'show_vpnservice')
self.m.StubOutWithMock(neutronclient.Client, 'update_vpnservice')
self.m.StubOutWithMock(neutron.neutronV20,
self.m.StubOutWithMock(neutron_utils.neutronV20,
'find_resourceid_by_name_or_id')
self.m.StubOutWithMock(clients.OpenStackClients, 'keystone')
@ -182,7 +182,7 @@ class VPNServiceTest(HeatTestCase):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
if resolve_neutron:
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'
@ -214,7 +214,7 @@ class VPNServiceTest(HeatTestCase):
def test_create_failed(self):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
neutron.neutronV20.find_resourceid_by_name_or_id(
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'