Remove required=True for name property
Some neutron resources have required=True for `name` property. This should be changed as we use physical_resource_name if it's not specified. Change-Id: I8a363c7d69d288aaa2d1a947ff69619ecd09b5d8
This commit is contained in:
parent
e37e73e63d
commit
6855fae757
|
@ -41,7 +41,6 @@ class AddressScope(neutron.NeutronResource):
|
|||
NAME: properties.Schema(
|
||||
properties.Schema.STRING,
|
||||
_('The name for the address scope.'),
|
||||
required=True,
|
||||
update_allowed=True
|
||||
),
|
||||
SHARED: properties.Schema(
|
||||
|
@ -89,6 +88,7 @@ class AddressScope(neutron.NeutronResource):
|
|||
|
||||
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
||||
if prop_diff:
|
||||
self.prepare_update_properties(prop_diff)
|
||||
self.client().update_address_scope(
|
||||
self.resource_id,
|
||||
{'address_scope': prop_diff})
|
||||
|
|
|
@ -50,7 +50,6 @@ class QoSPolicy(neutron.NeutronResource):
|
|||
NAME: properties.Schema(
|
||||
properties.Schema.STRING,
|
||||
_('The name for the QoS policy.'),
|
||||
required=True,
|
||||
update_allowed=True
|
||||
),
|
||||
DESCRIPTION: properties.Schema(
|
||||
|
|
|
@ -202,6 +202,7 @@ class SubnetPool(neutron.NeutronResource):
|
|||
prop_diff[
|
||||
'address_scope_id'] = prop_diff.pop(self.ADDRESS_SCOPE)
|
||||
if prop_diff:
|
||||
self.prepare_update_properties(prop_diff)
|
||||
self.client().update_subnetpool(
|
||||
self.resource_id, {'subnetpool': prop_diff})
|
||||
|
||||
|
|
|
@ -178,6 +178,7 @@ class VPNService(neutron.NeutronResource):
|
|||
|
||||
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
||||
if prop_diff:
|
||||
self.prepare_update_properties(prop_diff)
|
||||
self.client().update_vpnservice(self.resource_id,
|
||||
{'vpnservice': prop_diff})
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ resources:
|
|||
my_address_scope:
|
||||
type: OS::Neutron::AddressScope
|
||||
properties:
|
||||
name: test_address_scope
|
||||
shared: False
|
||||
tenant_id: d66c74c01d6c41b9846088c1ad9634d0
|
||||
'''
|
||||
|
@ -54,11 +53,12 @@ class NeutronAddressScopeTest(common.HeatTestCase):
|
|||
self.my_address_scope = self.stack['my_address_scope']
|
||||
self.my_address_scope.client = mock.MagicMock(
|
||||
return_value=self.neutronclient)
|
||||
self.patchobject(self.my_address_scope, 'physical_resource_name',
|
||||
return_value='test_address_scope')
|
||||
|
||||
def test_address_scope_handle_create(self):
|
||||
addrs = {
|
||||
'address_scope': {
|
||||
'name': 'test_address_scope',
|
||||
'id': '9c1eb3fe-7bba-479d-bd43-1d497e53c384',
|
||||
'tenant_id': 'd66c74c01d6c41b9846088c1ad9634d0',
|
||||
'shared': False,
|
||||
|
@ -108,22 +108,31 @@ class NeutronAddressScopeTest(common.HeatTestCase):
|
|||
self.my_address_scope.resource_id = addrs_id
|
||||
|
||||
props = {
|
||||
'name': 'new_name',
|
||||
'name': 'test_address_scope',
|
||||
'shared': True
|
||||
}
|
||||
|
||||
update_dict = props.copy()
|
||||
update_snippet = rsrc_defn.ResourceDefinition(
|
||||
self.my_address_scope.name,
|
||||
self.my_address_scope.type(),
|
||||
props)
|
||||
|
||||
# with name
|
||||
self.my_address_scope.handle_update(
|
||||
json_snippet=update_snippet,
|
||||
tmpl_diff={},
|
||||
prop_diff=props)
|
||||
|
||||
self.neutronclient.update_address_scope.assert_called_once_with(
|
||||
addrs_id, {'address_scope': props})
|
||||
# without name
|
||||
props['name'] = None
|
||||
self.my_address_scope.handle_update(
|
||||
json_snippet=update_snippet,
|
||||
tmpl_diff={},
|
||||
prop_diff=props)
|
||||
self.assertEqual(2, self.neutronclient.update_address_scope.call_count)
|
||||
self.neutronclient.update_address_scope.assert_called_with(
|
||||
addrs_id, {'address_scope': update_dict})
|
||||
|
||||
def test_address_scope_get_attr(self):
|
||||
self.my_address_scope.resource_id = 'addrs_id'
|
||||
|
|
|
@ -145,6 +145,8 @@ class NeutronSubnetPoolTest(common.HeatTestCase):
|
|||
update_subnetpool = self.patchobject(neutronclient.Client,
|
||||
'update_subnetpool')
|
||||
rsrc = self.create_subnetpool()
|
||||
self.patchobject(rsrc, 'physical_resource_name',
|
||||
return_value='the_new_sp')
|
||||
ref_id = rsrc.FnGetRefId()
|
||||
self.assertEqual('fc68ea2c-b60b-4b4f-bd82-94ec81110766', ref_id)
|
||||
props = {
|
||||
|
@ -159,10 +161,22 @@ class NeutronSubnetPoolTest(common.HeatTestCase):
|
|||
'max_prefixlen': '28',
|
||||
'is_default': False,
|
||||
}
|
||||
update_dict = props.copy()
|
||||
update_dict['name'] = 'the_new_sp'
|
||||
update_dict['address_scope_id'] = update_dict.pop('address_scope')
|
||||
update_snippet = rsrc_defn.ResourceDefinition(rsrc.name, rsrc.type(),
|
||||
props)
|
||||
# with name
|
||||
self.assertIsNone(rsrc.handle_update(update_snippet, {}, props))
|
||||
self.assertEqual(1, update_subnetpool.call_count)
|
||||
|
||||
# without name
|
||||
props['name'] = None
|
||||
self.assertIsNone(rsrc.handle_update(update_snippet, {}, props))
|
||||
|
||||
self.assertEqual(2, update_subnetpool.call_count)
|
||||
update_subnetpool.assert_called_with(
|
||||
'fc68ea2c-b60b-4b4f-bd82-94ec81110766',
|
||||
{'subnetpool': update_dict})
|
||||
|
||||
def test_update_subnetpool_no_prop_diff(self):
|
||||
update_subnetpool = self.patchobject(neutronclient.Client,
|
||||
|
|
|
@ -280,13 +280,23 @@ class VPNServiceTest(common.HeatTestCase):
|
|||
|
||||
def test_update(self):
|
||||
rsrc = self.create_vpnservice()
|
||||
self.patchobject(rsrc, 'physical_resource_name',
|
||||
return_value='VPNService')
|
||||
|
||||
upd_dict = {'vpnservice': {'name': 'VPNService',
|
||||
'admin_state_up': False}}
|
||||
neutronclient.Client.update_vpnservice(
|
||||
'vpn123', {'vpnservice': {'admin_state_up': False}})
|
||||
'vpn123', upd_dict).MultipleTimes().AndReturn(None)
|
||||
|
||||
self.m.ReplayAll()
|
||||
scheduler.TaskRunner(rsrc.create)()
|
||||
update_template = copy.deepcopy(rsrc.t)
|
||||
update_template['Properties']['admin_state_up'] = False
|
||||
scheduler.TaskRunner(rsrc.update, update_template)()
|
||||
# with name
|
||||
prop_diff = {'name': 'VPNService', 'admin_state_up': False}
|
||||
self.assertIsNone(rsrc.handle_update({}, {}, prop_diff))
|
||||
|
||||
# without name
|
||||
prop_diff = {'name': None, 'admin_state_up': False}
|
||||
self.assertIsNone(rsrc.handle_update({}, {}, prop_diff))
|
||||
self.m.VerifyAll()
|
||||
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ resources:
|
|||
my_qos_policy:
|
||||
type: OS::Neutron::QoSPolicy
|
||||
properties:
|
||||
name: test_policy
|
||||
description: a policy for test
|
||||
shared: true
|
||||
tenant_id: d66c74c01d6c41b9846088c1ad9634d0
|
||||
|
@ -68,11 +67,12 @@ class NeutronQoSPolicyTest(common.HeatTestCase):
|
|||
self.my_qos_policy = self.stack['my_qos_policy']
|
||||
self.my_qos_policy.client = mock.MagicMock(
|
||||
return_value=self.neutronclient)
|
||||
self.patchobject(self.my_qos_policy, 'physical_resource_name',
|
||||
return_value='test_policy')
|
||||
|
||||
def test_qos_policy_handle_create(self):
|
||||
policy = {
|
||||
'policy': {
|
||||
'name': 'test_policy',
|
||||
'description': 'a policy for test',
|
||||
'id': '9c1eb3fe-7bba-479d-bd43-1d497e53c384',
|
||||
'rules': [],
|
||||
|
@ -122,22 +122,29 @@ class NeutronQoSPolicyTest(common.HeatTestCase):
|
|||
self.my_qos_policy.resource_id = policy_id
|
||||
|
||||
props = {
|
||||
'name': 'new_name',
|
||||
'name': 'test_policy',
|
||||
'description': 'test',
|
||||
'shared': False
|
||||
}
|
||||
|
||||
prop_dict = props.copy()
|
||||
update_snippet = rsrc_defn.ResourceDefinition(
|
||||
self.my_qos_policy.name,
|
||||
self.my_qos_policy.type(),
|
||||
props)
|
||||
|
||||
# with name
|
||||
self.my_qos_policy.handle_update(json_snippet=update_snippet,
|
||||
tmpl_diff={},
|
||||
prop_diff=props)
|
||||
# without name
|
||||
props['name'] = None
|
||||
self.my_qos_policy.handle_update(json_snippet=update_snippet,
|
||||
tmpl_diff={},
|
||||
prop_diff=props)
|
||||
|
||||
self.neutronclient.update_qos_policy.assert_called_once_with(
|
||||
policy_id, {'policy': props})
|
||||
self.assertEqual(2, self.neutronclient.update_qos_policy.call_count)
|
||||
self.neutronclient.update_qos_policy.assert_called_with(
|
||||
policy_id, {'policy': prop_dict})
|
||||
|
||||
def test_qos_policy_get_attr(self):
|
||||
self.my_qos_policy.resource_id = 'test policy'
|
||||
|
|
Loading…
Reference in New Issue