Merge "Revert "NSX|P: No need to add resource name on update""

This commit is contained in:
Zuul 2019-01-16 09:26:59 +00:00 committed by Gerrit Code Review
commit d1540e9337
1 changed files with 15 additions and 1 deletions

View File

@ -1101,6 +1101,8 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
new_enable_snat = router.enable_snat
newaddr, newmask, _newnexthop = self._get_external_attachment_info(
context, router)
router_name = utils.get_name_and_uuid(router['name'] or 'router',
router['id'])
router_subnets = self._find_router_subnets(
context.elevated(), router_id)
actions = self._get_update_router_gw_actions(
@ -1121,7 +1123,11 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
if (actions['remove_router_link_port'] or
actions['add_router_link_port']):
# GW was changed
self.nsxpolicy.tier1.update(router_id, tier0=new_tier0_uuid)
#TODO(asarfaty): adding the router name even though it was not
# changed because otherwise the NSX will set it to default.
# This code should be removed once NSX supports it.
self.nsxpolicy.tier1.update(router_id, name=router_name,
tier0=new_tier0_uuid)
# Set/Unset the router TZ to allow vlan switches traffic
if cfg.CONF.nsx_p.allow_passthrough:
@ -1330,6 +1336,13 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
#TODO(asarfaty): it is enough to validate only the new subnet,
# and not all
self._validate_router_tz(context.elevated(), tier0_uuid, subnets)
#TODO(asarfaty): adding the segment name even though it was not
# changed because otherwise the NSX will set it to default.
# This code should be removed once NSX supports it.
net = self._get_network(context, network_id)
net_name = utils.get_name_and_uuid(
net['name'] or 'network', network_id)
segment_id = self._get_network_nsx_segment_id(context, network_id)
subnet = self.get_subnet(context, info['subnet_ids'][0])
cidr_prefix = int(subnet['cidr'].split('/')[1])
@ -1337,6 +1350,7 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
pol_subnet = policy_defs.Subnet(
gateway_address=gw_addr)
self.nsxpolicy.segment.update(segment_id,
name=net_name,
tier1_id=router_id,
subnets=[pol_subnet])