Merge "Refactor neutron constraints"

This commit is contained in:
Jenkins 2015-12-11 01:57:41 +00:00 committed by Gerrit Code Review
commit 4c649151cf
14 changed files with 245 additions and 180 deletions

View File

@ -69,8 +69,13 @@ class NeutronClientPlugin(client_plugin.ClientPlugin):
return isinstance(ex, exceptions.NeutronClientNoUniqueMatch)
def find_neutron_resource(self, props, key, key_type):
return self.find_resourceid_by_name_or_id(
key_type, props.get(key))
def find_resourceid_by_name_or_id(self, resource, name_or_id,
cmd_resource=None):
return neutronV20.find_resourceid_by_name_or_id(
self.client(), key_type, props.get(key))
self.client(), resource, name_or_id, cmd_resource=cmd_resource)
@os_client.MEMOIZE
def _list_extensions(self):
@ -110,8 +115,8 @@ class NeutronClientPlugin(client_plugin.ClientPlugin):
Args:
policy: ID or name of the policy.
"""
return neutronV20.find_resourceid_by_name_or_id(
self.client(), 'policy', policy, cmd_resource='qos_policy')
return self.find_resourceid_by_name_or_id(
'policy', policy, cmd_resource='qos_policy')
def get_secgroup_uuids(self, security_groups):
'''Returns a list of security group UUIDs.

View File

@ -14,38 +14,22 @@
#
# Copyright 2015 IBM Corp.
from neutronclient.common import exceptions
from neutronclient.neutron import v2_0 as neutronV20
from heat.engine import constraints
from heat.engine.clients.os.neutron import neutron_constraints as nc
class LoadbalancerConstraint(constraints.BaseCustomConstraint):
expected_exceptions = (exceptions.NeutronClientException,)
def validate_with_client(self, client, value):
neutron_client = client.client('neutron')
neutronV20.find_resourceid_by_name_or_id(
neutron_client, 'loadbalancer', value)
class LoadbalancerConstraint(nc.NeutronConstraint):
resource_name = 'loadbalancer'
cmd_resource = 'lbaas_loadbalancer'
extension = 'lbaasv2'
class ListenerConstraint(constraints.BaseCustomConstraint):
expected_exceptions = (exceptions.NeutronClientException,)
def validate_with_client(self, client, value):
neutron_client = client.client('neutron')
neutronV20.find_resourceid_by_name_or_id(
neutron_client, 'listener', value)
class ListenerConstraint(nc.NeutronConstraint):
resource_name = 'listener'
extension = 'lbaasv2'
class PoolConstraint(constraints.BaseCustomConstraint):
expected_exceptions = (exceptions.NeutronClientException,)
def validate_with_client(self, client, value):
neutron_client = client.client('neutron')
# v2 pool is called lbaas_pool to differentiate from v1 pool
neutronV20.find_resourceid_by_name_or_id(
neutron_client, 'lbaas_pool', value)
class PoolConstraint(nc.NeutronConstraint):
# Pool constraint for lbaas v2
resource_name = 'pool'
cmd_resource = 'lbaas_pool'
extension = 'lbaasv2'

View File

@ -13,8 +13,7 @@
#
# Copyright 2015 IBM Corp.
from neutronclient.common import exceptions
from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.common import exceptions as qe
from heat.common import exception
from heat.engine import constraints
@ -22,76 +21,62 @@ from heat.engine import constraints
class NetworkConstraint(constraints.BaseCustomConstraint):
expected_exceptions = (exceptions.NeutronClientException,
expected_exceptions = (qe.NeutronClientException,
exception.EntityNotFound,
exception.PhysicalResourceNameAmbiguity)
def validate_with_client(self, client, value):
try:
neutron_client = client.client('neutron')
client.client('neutron')
except Exception:
# is not using neutron
client.client_plugin('nova').get_nova_network_id(value)
else:
neutronV20.find_resourceid_by_name_or_id(
neutron_client, 'network', value)
neutron_plugin = client.client_plugin('neutron')
neutron_plugin.find_resourceid_by_name_or_id(
'network', value, cmd_resource=None)
class PortConstraint(constraints.BaseCustomConstraint):
class NeutronConstraint(constraints.BaseCustomConstraint):
expected_exceptions = (exceptions.NeutronClientException,)
expected_exceptions = (qe.NeutronClientException,
exception.EntityNotFound)
resource_name = None
cmd_resource = None
extension = None
def validate_with_client(self, client, value):
neutron_client = client.client('neutron')
neutronV20.find_resourceid_by_name_or_id(
neutron_client, 'port', value)
neutron_plugin = client.client_plugin('neutron')
if (self.extension and
not neutron_plugin.has_extension(self.extension)):
raise exception.EntityNotFound(entity='neutron extension',
name=self.extension)
neutron_plugin.find_resourceid_by_name_or_id(
self.resource_name, value, cmd_resource=self.cmd_resource)
class RouterConstraint(constraints.BaseCustomConstraint):
expected_exceptions = (exceptions.NeutronClientException,)
def validate_with_client(self, client, value):
neutron_client = client.client('neutron')
neutronV20.find_resourceid_by_name_or_id(
neutron_client, 'router', value)
class PortConstraint(NeutronConstraint):
resource_name = 'port'
class SubnetConstraint(constraints.BaseCustomConstraint):
expected_exceptions = (exceptions.NeutronClientException,)
def validate_with_client(self, client, value):
neutron_client = client.client('neutron')
neutronV20.find_resourceid_by_name_or_id(
neutron_client, 'subnet', value)
class RouterConstraint(NeutronConstraint):
resource_name = 'router'
class SubnetPoolConstraint(constraints.BaseCustomConstraint):
expected_exceptions = (exceptions.NeutronClientException,)
def validate_with_client(self, client, value):
neutron_client = client.client('neutron')
neutronV20.find_resourceid_by_name_or_id(
neutron_client, 'subnetpool', value)
class SubnetConstraint(NeutronConstraint):
resource_name = 'subnet'
class AddressScopeConstraint(constraints.BaseCustomConstraint):
expected_exceptions = (exceptions.NeutronClientException,)
def validate_with_client(self, client, value):
neutron_client = client.client('neutron')
neutronV20.find_resourceid_by_name_or_id(
neutron_client, 'address_scope', value)
class SubnetPoolConstraint(NeutronConstraint):
resource_name = 'subnetpool'
class QoSPolicyConstraint(constraints.BaseCustomConstraint):
class AddressScopeConstraint(NeutronConstraint):
resource_name = 'address_scope'
extension = 'address-scope'
expected_exceptions = (exceptions.NeutronClientException,)
def validate_with_client(self, client, value):
neutron_client = client.client('neutron')
neutronV20.find_resourceid_by_name_or_id(
neutron_client, 'policy', value, cmd_resource='qos_policy')
class QoSPolicyConstraint(NeutronConstraint):
resource_name = 'policy'
cmd_resource = 'qos_policy'
extension = 'qos'

View File

@ -11,7 +11,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutronclient.neutron import v2_0 as neutronV20
from oslo_utils import netutils
from heat.common import exception
@ -327,8 +326,9 @@ class Subnet(neutron.NeutronResource):
self.client_plugin().resolve_network(props, self.NETWORK,
'network_id')
if self.SUBNETPOOL in props and props[self.SUBNETPOOL]:
props['subnetpool_id'] = neutronV20.find_resourceid_by_name_or_id(
self.client(), 'subnetpool', props.pop('subnetpool'))
props['subnetpool_id'] = self.client_plugin(
).find_resourceid_by_name_or_id(
'subnetpool', props.pop('subnetpool'))
self._null_gateway_ip(props)
subnet = self.client().create_subnet({'subnet': props})['subnet']
self.resource_id_set(subnet['id'])

View File

@ -11,8 +11,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutronclient.neutron import v2_0 as nV20
from heat.common import exception
from heat.common.i18n import _
from heat.common import netutils
@ -174,8 +172,9 @@ class SubnetPool(neutron.NeutronResource):
self.properties,
self.physical_resource_name())
if self.ADDRESS_SCOPE in props and props[self.ADDRESS_SCOPE]:
props['address_scope_id'] = nV20.find_resourceid_by_name_or_id(
self.client(), 'address_scope', props.pop(self.ADDRESS_SCOPE))
props['address_scope_id'] = self.client_plugin(
).find_resourceid_by_name_or_id(
'address_scope', props.pop(self.ADDRESS_SCOPE))
subnetpool = self.client().create_subnetpool(
{'subnetpool': props})['subnetpool']
self.resource_id_set(subnetpool['id'])
@ -195,7 +194,8 @@ class SubnetPool(neutron.NeutronResource):
if self.ADDRESS_SCOPE in prop_diff:
if prop_diff[self.ADDRESS_SCOPE]:
prop_diff[
'address_scope_id'] = nV20.find_resourceid_by_name_or_id(
'address_scope_id'] = self.client_plugin(
).find_resourceid_by_name_or_id(
self.client(), 'address_scope',
prop_diff.pop(self.ADDRESS_SCOPE))
else:

View File

@ -11,6 +11,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
import mock
from neutronclient.common import exceptions as qe
@ -47,7 +49,8 @@ class NeutronClientPluginTests(NeutronClientPluginTestCase):
'network')
self.assertEqual(42, res)
self.mock_find.assert_called_once_with(self.neutron_client, 'network',
'test_network')
'test_network',
cmd_resource=None)
def test_resolve_network(self):
props = {'net': 'test_network'}
@ -55,7 +58,8 @@ class NeutronClientPluginTests(NeutronClientPluginTestCase):
res = self.neutron_plugin.resolve_network(props, 'net', 'net_id')
self.assertEqual(42, res)
self.mock_find.assert_called_once_with(self.neutron_client, 'network',
'test_network')
'test_network',
cmd_resource=None)
# check resolve if was send id instead of name
props = {'net_id': 77}
@ -63,7 +67,8 @@ class NeutronClientPluginTests(NeutronClientPluginTestCase):
self.assertEqual(77, res)
# in this case find_resourceid_by_name_or_id is not called
self.mock_find.assert_called_once_with(self.neutron_client, 'network',
'test_network')
'test_network',
cmd_resource=None)
def test_resolve_subnet(self):
props = {'snet': 'test_subnet'}
@ -71,7 +76,8 @@ class NeutronClientPluginTests(NeutronClientPluginTestCase):
res = self.neutron_plugin.resolve_subnet(props, 'snet', 'snet_id')
self.assertEqual(42, res)
self.mock_find.assert_called_once_with(self.neutron_client, 'subnet',
'test_subnet')
'test_subnet',
cmd_resource=None)
# check resolve if was send id instead of name
props = {'snet_id': 77}
@ -79,7 +85,8 @@ class NeutronClientPluginTests(NeutronClientPluginTestCase):
self.assertEqual(77, res)
# in this case find_resourceid_by_name_or_id is not called
self.mock_find.assert_called_once_with(self.neutron_client, 'subnet',
'test_subnet')
'test_subnet',
cmd_resource=None)
def test_get_secgroup_uuids(self):
# test get from uuids
@ -182,15 +189,15 @@ class NeutronConstraintsValidate(common.HeatTestCase):
('validate_loadbalancer',
dict(constraint_class=lc.LoadbalancerConstraint,
resource_type='loadbalancer',
cmd_resource=None)),
cmd_resource='lbaas_loadbalancer')),
('validate_listener',
dict(constraint_class=lc.ListenerConstraint,
resource_type='listener',
cmd_resource=None)),
('validate_pool',
dict(constraint_class=lc.PoolConstraint,
resource_type='lbaas_pool',
cmd_resource=None)),
resource_type='pool',
cmd_resource='lbaas_pool')),
('validate_qos_policy',
dict(constraint_class=nc.QoSPolicyConstraint,
resource_type='policy',
@ -198,27 +205,40 @@ class NeutronConstraintsValidate(common.HeatTestCase):
]
def test_validate(self):
mock_extension = self.patchobject(
neutron.NeutronClientPlugin, 'has_extension', return_value=True)
nc = mock.Mock()
mock_create = self.patchobject(neutron.NeutronClientPlugin, '_create')
mock_create.return_value = nc
mock_find = self.patchobject(neutron.neutronV20,
mock_find = self.patchobject(neutron.NeutronClientPlugin,
'find_resourceid_by_name_or_id')
mock_find.side_effect = ['foo',
qe.NeutronClientException(status_code=404)]
mock_find.side_effect = [
'foo',
qe.NeutronClientException(status_code=404)
]
constraint = self.constraint_class()
ctx = utils.dummy_context()
if hasattr(constraint, 'extension') and constraint.extension:
mock_extension.side_effect = [
False,
True,
True,
]
ex = self.assertRaises(
exception.EntityNotFound,
constraint.validate_with_client, ctx.clients, "foo"
)
expected = ("The neutron extension (%s) could not be found." %
constraint.extension)
self.assertEqual(expected, six.text_type(ex))
self.assertTrue(constraint.validate("foo", ctx))
self.assertFalse(constraint.validate("bar", ctx))
if self.cmd_resource:
mock_calls = [mock.call(nc, self.resource_type, 'foo',
cmd_resource=self.cmd_resource),
mock.call(nc, self.resource_type, 'bar',
cmd_resource=self.cmd_resource)]
else:
mock_calls = [mock.call(nc, self.resource_type, 'foo'),
mock.call(nc, self.resource_type, 'bar')]
mock_find.assert_has_calls(mock_calls)
mock_find.assert_has_calls(
[mock.call(self.resource_type, 'foo',
cmd_resource=self.cmd_resource),
mock.call(self.resource_type, 'bar',
cmd_resource=self.cmd_resource)])
class NeutronClientPluginExtensionsTests(NeutronClientPluginTestCase):

View File

@ -163,7 +163,8 @@ class NeutronFloatingIPTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'abcd1234'
'abcd1234',
cmd_resource=None,
).MultipleTimes().AndReturn('abcd1234')
self._test_floating_ip(t, resolve_neutron=False)
@ -173,7 +174,8 @@ class NeutronFloatingIPTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'abcd1234'
'abcd1234',
cmd_resource=None,
).MultipleTimes().AndReturn('abcd1234')
self._test_floating_ip(t, resolve_neutron=False, r_iface=False)
@ -205,7 +207,8 @@ class NeutronFloatingIPTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'abcd1234'
'abcd1234',
cmd_resource=None,
).MultipleTimes().AndReturn('abcd1234')
stack = utils.parse_stack(tmpl)
@ -269,17 +272,20 @@ class NeutronFloatingIPTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'abcd1234'
'abcd1234',
cmd_resource=None,
).MultipleTimes().AndReturn('abcd1234')
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'xyz1234'
'xyz1234',
cmd_resource=None,
).MultipleTimes().AndReturn('xyz1234')
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub1234'
'sub1234',
cmd_resource=None,
).MultipleTimes().AndReturn('sub1234')
neutronclient.Client.create_floatingip({
'floatingip': {'floating_network_id': u'abcd1234'}
@ -497,7 +503,8 @@ class NeutronFloatingIPTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'abcd1234'
'abcd1234',
cmd_resource=None,
).AndReturn('xyz1234')
neutronclient.Client.create_floatingip({
'floatingip': {'floating_network_id': u'xyz1234',
@ -527,17 +534,20 @@ class NeutronFloatingIPTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'xyz1234'
'xyz1234',
cmd_resource=None,
).MultipleTimes().AndReturn('xyz1234')
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub1234'
'sub1234',
cmd_resource=None,
).MultipleTimes().AndReturn('sub1234')
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'router',
'None'
'None',
cmd_resource=None,
).MultipleTimes().AndReturn('None')
neutronclient.Client.create_port({'port': {
@ -560,7 +570,8 @@ class NeutronFloatingIPTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'abcd1234'
'abcd1234',
cmd_resource=None,
).MultipleTimes().AndReturn('abcd1234')
neutronclient.Client.create_floatingip({
'floatingip': {

View File

@ -342,13 +342,15 @@ class PoolTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'
'sub123',
cmd_resource=None,
).AndReturn('sub123')
if resolve_neutron and with_vip_subnet:
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub9999'
'sub9999',
cmd_resource=None,
).AndReturn('sub9999')
snippet = template_format.parse(pool_template_with_vip_subnet)
neutronclient.Client.create_vip(stvipvsn
@ -391,7 +393,8 @@ class PoolTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'
'sub123',
cmd_resource=None,
).MultipleTimes().AndReturn('sub123')
neutronclient.Client.create_pool({
@ -431,7 +434,8 @@ class PoolTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'
'sub123',
cmd_resource=None,
).MultipleTimes().AndReturn('sub123')
neutronclient.Client.create_pool({
@ -468,7 +472,8 @@ class PoolTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'
'sub123',
cmd_resource=None,
).MultipleTimes().AndReturn('sub123')
neutronclient.Client.create_pool({
@ -507,7 +512,8 @@ class PoolTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'
'sub123',
cmd_resource=None,
).MultipleTimes().AndReturn('sub123')
neutronclient.Client.create_pool({
@ -536,7 +542,8 @@ class PoolTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'
'sub123',
cmd_resource=None,
).MultipleTimes().AndReturn('sub123')
neutronclient.Client.create_pool({
'pool': {
@ -572,7 +579,8 @@ class PoolTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'
'sub123',
cmd_resource=None,
).MultipleTimes().AndReturn('sub123')
neutronclient.Client.create_pool({
'pool': {
@ -638,7 +646,8 @@ class PoolTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'
'sub123',
cmd_resource=None,
).MultipleTimes().AndReturn('sub123')
neutronclient.Client.create_pool({
@ -792,7 +801,8 @@ class PoolTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'
'sub123',
cmd_resource=None,
).MultipleTimes().AndReturn('sub123')
neutronclient.Client.create_pool({
'pool': {
@ -1064,7 +1074,8 @@ class PoolUpdateHealthMonitorsTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'
'sub123',
cmd_resource=None,
).AndReturn('sub123')
neutronclient.Client.create_pool({
'pool': {

View File

@ -106,7 +106,8 @@ class NeutronNetTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'router',
'None'
'None',
cmd_resource=None,
).AndReturn('None')
# Create script

View File

@ -117,7 +117,8 @@ class NeutronNetworkGatewayTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35'
'6af055d3-26f6-48dd-a597-7611d7e58d35',
cmd_resource=None,
).MultipleTimes().AndRaise(qe.NeutronClientException(status_code=404))
# mock successful to delete the network_gateway
neutronclient.Client.delete_network_gateway(
@ -174,7 +175,8 @@ class NeutronNetworkGatewayTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35'
'6af055d3-26f6-48dd-a597-7611d7e58d35',
cmd_resource=None,
).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35')
t = template_format.parse(gw_template)
else:
@ -192,7 +194,8 @@ class NeutronNetworkGatewayTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35'
'6af055d3-26f6-48dd-a597-7611d7e58d35',
cmd_resource=None,
).MultipleTimes().AndReturn(
'6af055d3-26f6-48dd-a597-7611d7e58d35')
@ -278,32 +281,38 @@ class NeutronNetworkGatewayTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35'
'6af055d3-26f6-48dd-a597-7611d7e58d35',
cmd_resource=None,
).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35')
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35'
'6af055d3-26f6-48dd-a597-7611d7e58d35',
cmd_resource=None,
).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35')
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35'
'6af055d3-26f6-48dd-a597-7611d7e58d35',
cmd_resource=None,
).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35')
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35'
'6af055d3-26f6-48dd-a597-7611d7e58d35',
cmd_resource=None,
).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35')
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35'
'6af055d3-26f6-48dd-a597-7611d7e58d35',
cmd_resource=None,
).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35')
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'6af055d3-26f6-48dd-a597-7611d7e58d35'
'6af055d3-26f6-48dd-a597-7611d7e58d35',
cmd_resource=None,
).AndReturn('6af055d3-26f6-48dd-a597-7611d7e58d35')
neutronclient.Client.update_network_gateway(

View File

@ -82,7 +82,8 @@ class NeutronPortTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'net1234'
'net1234',
cmd_resource=None,
).MultipleTimes().AndReturn('net1234')
neutronclient.Client.create_port({'port': {
'network_id': u'net1234',
@ -118,12 +119,14 @@ class NeutronPortTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'net1234'
'net1234',
cmd_resource=None,
).MultipleTimes().AndReturn('net1234')
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub1234'
'sub1234',
cmd_resource=None,
).MultipleTimes().AndReturn('sub1234')
neutronclient.Client.create_port({'port': {
@ -159,7 +162,8 @@ class NeutronPortTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'net1234'
'net1234',
cmd_resource=None,
).MultipleTimes().AndReturn('net1234')
neutronclient.Client.create_port({'port': {
'network_id': u'net1234',
@ -195,7 +199,8 @@ class NeutronPortTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'abcd1234'
'abcd1234',
cmd_resource=None,
).MultipleTimes().AndReturn('abcd1234')
neutronclient.Client.create_port({'port': {
'network_id': u'abcd1234',
@ -229,7 +234,8 @@ class NeutronPortTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'abcd1234'
'abcd1234',
cmd_resource=None,
).MultipleTimes().AndReturn('abcd1234')
neutronclient.Client.create_port({'port': {
@ -262,7 +268,8 @@ class NeutronPortTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'abcd1234'
'abcd1234',
cmd_resource=None,
).MultipleTimes().AndReturn('abcd1234')
neutronclient.Client.create_port({'port': {
'network_id': u'abcd1234',
@ -298,7 +305,8 @@ class NeutronPortTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'abcd1234'
'abcd1234',
cmd_resource=None,
).MultipleTimes().AndReturn('abcd1234')
neutronclient.Client.create_port({'port': {
'network_id': u'abcd1234',
@ -334,12 +342,14 @@ class NeutronPortTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'net1234'
'net1234',
cmd_resource=None,
).MultipleTimes().AndReturn('net1234')
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub1234'
'sub1234',
cmd_resource=None,
).MultipleTimes().AndReturn('sub1234')
neutronclient.Client.create_port({'port': port_prop}).AndReturn(
{'port': {
@ -422,7 +432,8 @@ class NeutronPortTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'net1234'
'net1234',
cmd_resource=None,
).MultipleTimes().AndReturn('net1234')
neutronclient.Client.create_port(
{'port': props}
@ -495,7 +506,8 @@ class NeutronPortTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'net1234'
'net1234',
cmd_resource=None,
).MultipleTimes().AndReturn('net1234')
neutronclient.Client.create_port(
{'port': props}
@ -557,7 +569,8 @@ class NeutronPortTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'net1234'
'net1234',
cmd_resource=None,
).MultipleTimes().AndReturn('net1234')
neutronclient.Client.create_port({'port': {
'network_id': u'net1234',
@ -619,7 +632,8 @@ class NeutronPortTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'net1234'
'net1234',
cmd_resource=None,
).MultipleTimes().AndReturn('net1234')
neutronclient.Client.create_port({'port': {
'network_id': u'net1234',
@ -688,12 +702,14 @@ class NeutronPortTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'net1234'
'net1234',
cmd_resource=None,
).AndReturn('net1234')
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub1234'
'sub1234',
cmd_resource=None,
).MultipleTimes().AndReturn('sub1234')
neutronclient.Client.create_port({'port': port_prop}).AndReturn(
{'port': {

View File

@ -465,13 +465,15 @@ class NeutronRouterTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'router',
'3e46229d-8fce-4733-819a-b5fe630550f8'
'3e46229d-8fce-4733-819a-b5fe630550f8',
cmd_resource=None,
).AndReturn('3e46229d-8fce-4733-819a-b5fe630550f8')
router_key = 'router'
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'91e47a57-7508-46fe-afc9-fc454e8580e1'
'91e47a57-7508-46fe-afc9-fc454e8580e1',
cmd_resource=None,
).AndReturn('91e47a57-7508-46fe-afc9-fc454e8580e1')
subnet_key = 'subnet'
@ -499,13 +501,15 @@ class NeutronRouterTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'router',
'3e46229d-8fce-4733-819a-b5fe630550f8'
'3e46229d-8fce-4733-819a-b5fe630550f8',
cmd_resource=None,
).AndReturn('3e46229d-8fce-4733-819a-b5fe630550f8')
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'91e47a57-7508-46fe-afc9-fc454e8580e1'
'91e47a57-7508-46fe-afc9-fc454e8580e1',
cmd_resource=None,
).AndReturn('91e47a57-7508-46fe-afc9-fc454e8580e1')
neutronclient.Client.add_interface_router(
'3e46229d-8fce-4733-819a-b5fe630550f8',
@ -552,13 +556,15 @@ class NeutronRouterTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'router',
'ae478782-53c0-4434-ab16-49900c88016c'
'ae478782-53c0-4434-ab16-49900c88016c',
cmd_resource=None,
).AndReturn('ae478782-53c0-4434-ab16-49900c88016c')
port_key = 'port'
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'port',
'9577cafd-8e98-4059-a2e6-8a771b4d318e'
'9577cafd-8e98-4059-a2e6-8a771b4d318e',
cmd_resource=None,
).AndReturn('9577cafd-8e98-4059-a2e6-8a771b4d318e')
neutronclient.Client.add_interface_router(
@ -646,7 +652,8 @@ class NeutronRouterTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
'fc68ea2c-b60b-4b4f-bd82-94ec81110766',
cmd_resource=None,
).MultipleTimes().AndReturn('fc68ea2c-b60b-4b4f-bd82-94ec81110766')
neutronclient.Client.add_gateway_router(
'3e46229d-8fce-4733-819a-b5fe630550f8',
@ -679,7 +686,8 @@ class NeutronRouterTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'public'
'public',
cmd_resource=None,
).MultipleTimes().AndReturn('fc68ea2c-b60b-4b4f-bd82-94ec81110766')
neutronclient.Client.create_router({
@ -758,7 +766,8 @@ class NeutronRouterTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'public'
'public',
cmd_resource=None,
).AndReturn('fc68ea2c-b60b-4b4f-bd82-94ec81110766')
neutronclient.Client.create_router({
@ -819,7 +828,8 @@ class NeutronRouterTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'other_public'
'other_public',
cmd_resource=None,
).AndReturn('91e47a57-7508-46fe-afc9-fc454e8580e1')
neutronclient.Client.update_router(

View File

@ -128,12 +128,14 @@ class NeutronSubnetTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'None'
'None',
cmd_resource=None,
).AndReturn('None')
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'router',
'None'
'None',
cmd_resource=None,
).AndReturn('None')
stack = utils.parse_stack(t)
rsrc = self.create_subnet(t, stack, 'sub_net')
@ -201,17 +203,20 @@ class NeutronSubnetTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnetpool',
'None'
'None',
cmd_resource=None,
).AndReturn('None')
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'None'
'None',
cmd_resource=None,
).AndReturn('None')
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnetpool',
'None'
'None',
cmd_resource=None,
).AndReturn('None')
neutronclient.Client.create_subnet({
'subnet': {
@ -267,12 +272,14 @@ class NeutronSubnetTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'None'
'None',
cmd_resource=None,
).AndReturn('None')
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'router',
'None'
'None',
cmd_resource=None,
).AndReturn('None')
self.m.ReplayAll()
scheduler.TaskRunner(rsrc.create)()
@ -389,7 +396,8 @@ class NeutronSubnetTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'None'
'None',
cmd_resource=None,
).AndReturn('None')
neutronclient.Client.create_subnet({
'subnet': {
@ -513,7 +521,8 @@ class NeutronSubnetTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'network',
'None'
'None',
cmd_resource=None,
).AndReturn('None')
neutronclient.Client.create_subnet({
'subnet': {

View File

@ -137,12 +137,14 @@ class VPNServiceTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'
'sub123',
cmd_resource=None,
).AndReturn('sub123')
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'router',
'rou123'
'rou123',
cmd_resource=None,
).AndReturn('rou123')
if resolve_neutron:
snippet = template_format.parse(vpnservice_template)
@ -186,12 +188,14 @@ class VPNServiceTest(common.HeatTestCase):
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'subnet',
'sub123'
'sub123',
cmd_resource=None,
).MultipleTimes().AndReturn('sub123')
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
'router',
'rou123'
'rou123',
cmd_resource=None,
).MultipleTimes().AndReturn('rou123')
self.stub_RouterConstraint_validate()