Allow updating the segment property of OS::Neutron::Subnet

Neutron allows updating the segment_id property of a subnet
to enable migration from non routed network to a routed
network.

This changes the Subnet resource to allow updating the
segment property so that heat users can migrate ro a routed
network.

Story: 2001988
Task: 19609
Depends-On: Iffda823a149a1143f46ee9a05e9640b34bf42c51
Change-Id: I6682a67da1b728f65f603ee40a200e9e0ee2e5b3
This commit is contained in:
Harald Jensås 2018-05-09 12:53:57 +02:00
parent a4a6a00809
commit 066f95815a
2 changed files with 32 additions and 1 deletions

View File

@ -242,7 +242,16 @@ class Subnet(neutron.NeutronResource):
constraints=[
constraints.CustomConstraint('neutron.segment')
],
support_status=support.SupportStatus(version='9.0.0')
update_allowed=True,
support_status=support.SupportStatus(
version='11.0.0',
status=support.SUPPORTED,
message=_('Update allowed since version 11.0.0.'),
previous_status=support.SupportStatus(
version='9.0.0',
status=support.SUPPORTED
)
)
),
TAGS: properties.Schema(
properties.Schema.LIST,
@ -402,12 +411,28 @@ class Subnet(neutron.NeutronResource):
else:
return True
def _validate_segment_update_supported(self):
# TODO(hjensas): Validation to ensure the subnet-segmentid-writable
# extension is available.
# https://storyboard.openstack.org/#!/story/2002189
# Current segment id must be None
if self.properties[self.SEGMENT] is not None:
msg = _('Updating the subnet segment assciation only allowed '
'when the current segment_id is None. The subnet is '
'currently associated with segment. In this state update')
raise exception.ResourceActionNotSupported(action=msg)
else:
return True
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
if prop_diff:
self.prepare_update_properties(prop_diff)
if (self.ALLOCATION_POOLS in prop_diff and
prop_diff[self.ALLOCATION_POOLS] is None):
prop_diff[self.ALLOCATION_POOLS] = []
if (self.SEGMENT in prop_diff and prop_diff[self.SEGMENT] and
self._validate_segment_update_supported()):
prop_diff['segment_id'] = prop_diff.pop(self.SEGMENT)
# If the new value is '', set to None
self._null_gateway_ip(prop_diff)

View File

@ -0,0 +1,6 @@
---
features:
- |
Adds support to update the ``segment_id`` of ``OS::Neutron::Subnet``
resource. This enables migration from non routed network to a routed
network.