Fix OS::Neutron:Net handle_update
Fix handle_update of OS::Neutron:Net resource to use prop_diff. Change-Id: I0e1f9f01b41ffeac18e536302680185dd22f2044 Partial-Bug: #1521836
This commit is contained in:
parent
3fc7deef63
commit
4808c931cb
|
@ -45,9 +45,8 @@ class Net(neutron.NeutronResource):
|
||||||
),
|
),
|
||||||
VALUE_SPECS: properties.Schema(
|
VALUE_SPECS: properties.Schema(
|
||||||
properties.Schema.MAP,
|
properties.Schema.MAP,
|
||||||
_('Extra parameters to include in the "network" object in the '
|
_('Extra parameters to include in the request. Parameters are '
|
||||||
'creation request. Parameters are often specific to installed '
|
'often specific to installed hardware or extensions.'),
|
||||||
'hardware or extensions.'),
|
|
||||||
default={},
|
default={},
|
||||||
update_allowed=True
|
update_allowed=True
|
||||||
),
|
),
|
||||||
|
@ -170,21 +169,24 @@ class Net(neutron.NeutronResource):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
||||||
props = self.prepare_update_properties(json_snippet)
|
if prop_diff:
|
||||||
qos_policy = props.pop(self.QOS_POLICY, None)
|
if self.DHCP_AGENT_IDS in prop_diff:
|
||||||
if self.QOS_POLICY in prop_diff:
|
dhcp_agent_ids = prop_diff.pop(self.DHCP_AGENT_IDS, [])
|
||||||
props['qos_policy_id'] = self.client_plugin().get_qos_policy_id(
|
|
||||||
qos_policy) if qos_policy else None
|
|
||||||
dhcp_agent_ids = props.pop(self.DHCP_AGENT_IDS, None)
|
|
||||||
|
|
||||||
if self.DHCP_AGENT_IDS in prop_diff:
|
|
||||||
if dhcp_agent_ids is not None:
|
|
||||||
self._replace_dhcp_agents(dhcp_agent_ids)
|
self._replace_dhcp_agents(dhcp_agent_ids)
|
||||||
del prop_diff[self.DHCP_AGENT_IDS]
|
if self.QOS_POLICY in prop_diff:
|
||||||
|
qos_policy = prop_diff.pop(self.QOS_POLICY)
|
||||||
|
prop_diff[
|
||||||
|
'qos_policy_id'] = self.client_plugin().get_qos_policy_id(
|
||||||
|
qos_policy) if qos_policy else None
|
||||||
|
if self.VALUE_SPECS in prop_diff:
|
||||||
|
self.merge_value_specs(prop_diff)
|
||||||
|
if (self.NAME in prop_diff and
|
||||||
|
prop_diff[self.NAME] is None):
|
||||||
|
prop_diff[self.NAME] = self.physical_resource_name()
|
||||||
|
|
||||||
if len(prop_diff) > 0:
|
if prop_diff:
|
||||||
self.client().update_network(
|
self.client().update_network(self.resource_id,
|
||||||
self.resource_id, {'network': props})
|
{'network': prop_diff})
|
||||||
|
|
||||||
def check_update_complete(self, *args):
|
def check_update_complete(self, *args):
|
||||||
attributes = self._show_resource()
|
attributes = self._show_resource()
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import copy
|
|
||||||
import mox
|
import mox
|
||||||
|
|
||||||
from neutronclient.common import exceptions as qe
|
from neutronclient.common import exceptions as qe
|
||||||
|
@ -230,26 +229,36 @@ class NeutronNetTest(common.HeatTestCase):
|
||||||
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
|
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
|
||||||
).AndReturn(None)
|
).AndReturn(None)
|
||||||
|
|
||||||
|
# Update script
|
||||||
neutronclient.Client.update_network(
|
neutronclient.Client.update_network(
|
||||||
'fc68ea2c-b60b-4b4f-bd82-94ec81110766',
|
'fc68ea2c-b60b-4b4f-bd82-94ec81110766',
|
||||||
{'network': {
|
{'network': {
|
||||||
'shared': True,
|
|
||||||
'name': 'mynet',
|
'name': 'mynet',
|
||||||
'admin_state_up': True,
|
|
||||||
'port_security_enabled': False,
|
|
||||||
'qos_policy_id': '0389f747-7785-4757-b7bb-2ab07e4b09c3'
|
'qos_policy_id': '0389f747-7785-4757-b7bb-2ab07e4b09c3'
|
||||||
}}).AndReturn(None)
|
}}).AndReturn(None)
|
||||||
# update again to detach qos_policy
|
# update again to detach qos_policy
|
||||||
neutronclient.Client.update_network(
|
neutronclient.Client.update_network(
|
||||||
'fc68ea2c-b60b-4b4f-bd82-94ec81110766',
|
'fc68ea2c-b60b-4b4f-bd82-94ec81110766',
|
||||||
{'network': {
|
{'network': {
|
||||||
'shared': True,
|
'name': 'mynet',
|
||||||
'name': 'mynet_update_again',
|
|
||||||
'admin_state_up': True,
|
|
||||||
'port_security_enabled': False,
|
|
||||||
'qos_policy_id': None
|
'qos_policy_id': None
|
||||||
}}).AndReturn(None)
|
}}).AndReturn(None)
|
||||||
|
|
||||||
|
neutronclient.Client.update_network(
|
||||||
|
'fc68ea2c-b60b-4b4f-bd82-94ec81110766',
|
||||||
|
{'network': {
|
||||||
|
'name': 'mynet',
|
||||||
|
'port_security_enabled': True,
|
||||||
|
'qos_policy_id': None
|
||||||
|
}}).AndReturn(None)
|
||||||
|
|
||||||
|
# update with name = None
|
||||||
|
neutronclient.Client.update_network(
|
||||||
|
'fc68ea2c-b60b-4b4f-bd82-94ec81110766',
|
||||||
|
{'network': {
|
||||||
|
'name': utils.PhysName('test_stack', 'test_net'),
|
||||||
|
}}).AndReturn(None)
|
||||||
|
|
||||||
# Delete script
|
# Delete script
|
||||||
neutronclient.Client.delete_network(
|
neutronclient.Client.delete_network(
|
||||||
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
|
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
|
||||||
|
@ -296,21 +305,23 @@ class NeutronNetTest(common.HeatTestCase):
|
||||||
],
|
],
|
||||||
'qos_policy': '0389f747-7785-4757-b7bb-2ab07e4b09c3'
|
'qos_policy': '0389f747-7785-4757-b7bb-2ab07e4b09c3'
|
||||||
}
|
}
|
||||||
props = copy.copy(rsrc.properties.data)
|
|
||||||
props.update(prop_diff)
|
|
||||||
update_snippet = rsrc_defn.ResourceDefinition(rsrc.name, rsrc.type(),
|
update_snippet = rsrc_defn.ResourceDefinition(rsrc.name, rsrc.type(),
|
||||||
props)
|
prop_diff)
|
||||||
rsrc.handle_update(update_snippet, {}, prop_diff)
|
rsrc.handle_update(update_snippet, {}, prop_diff)
|
||||||
|
|
||||||
prop_diff1 = {
|
# Update with None qos_policy
|
||||||
"name": "mynet_update_again",
|
prop_diff['qos_policy'] = None
|
||||||
'qos_policy': None
|
rsrc.handle_update(update_snippet, {}, prop_diff)
|
||||||
}
|
|
||||||
props1 = copy.copy(rsrc.properties.data)
|
# Update with value_specs
|
||||||
props1.update(prop_diff1)
|
prop_diff['value_specs'] = {"port_security_enabled": True}
|
||||||
update_snippet = rsrc_defn.ResourceDefinition(rsrc.name, rsrc.type(),
|
rsrc.handle_update(update_snippet, {}, prop_diff)
|
||||||
props1)
|
|
||||||
rsrc.handle_update(update_snippet, {}, prop_diff1)
|
# Update with name = None
|
||||||
|
rsrc.handle_update(update_snippet, {}, {'name': None})
|
||||||
|
|
||||||
|
# Update with empty prop_diff
|
||||||
|
rsrc.handle_update(update_snippet, {}, {})
|
||||||
|
|
||||||
scheduler.TaskRunner(rsrc.delete)()
|
scheduler.TaskRunner(rsrc.delete)()
|
||||||
rsrc.state_set(rsrc.CREATE, rsrc.COMPLETE, 'to delete again')
|
rsrc.state_set(rsrc.CREATE, rsrc.COMPLETE, 'to delete again')
|
||||||
|
|
Loading…
Reference in New Issue