Merge "Enabled adding tags to nat rules"

This commit is contained in:
Zuul 2018-03-08 05:48:31 +00:00 committed by Gerrit Code Review
commit e69d8de2e6
2 changed files with 13 additions and 7 deletions

View File

@ -517,7 +517,8 @@ class NsxLibLogicalRouter(utils.NsxLibApiBase):
enabled=True, rule_priority=None,
match_ports=None, match_protocol=None,
match_resource_type=None,
bypass_firewall=True):
bypass_firewall=True,
tags=None):
resource = 'logical-routers/%s/nat/rules' % logical_router_id
body = {'action': action,
'enabled': enabled,
@ -543,7 +544,8 @@ class NsxLibLogicalRouter(utils.NsxLibApiBase):
elif not bypass_firewall:
LOG.error("Ignoring bypass_firewall for router %s nat rule: "
"this feature is not supported.", logical_router_id)
if tags is not None:
body['tags'] = tags
return self.client.create(resource, body)
def add_static_route(self, logical_router_id, dest_cidr, nexthop):

View File

@ -153,13 +153,14 @@ class RouterLib(object):
skip_not_found=True, strict_mode=False)
def add_gw_snat_rule(self, logical_router_id, gw_ip, source_net=None,
bypass_firewall=True):
bypass_firewall=True, tags=None):
return self.nsxlib.logical_router.add_nat_rule(
logical_router_id, action="SNAT",
translated_network=gw_ip,
source_net=source_net,
rule_priority=GW_NAT_PRI,
bypass_firewall=bypass_firewall)
bypass_firewall=bypass_firewall,
tags=tags)
def update_router_edge_cluster(self, nsx_router_id, edge_cluster_uuid):
return self._router_client.update(nsx_router_id,
@ -198,20 +199,23 @@ class RouterLib(object):
relay_service_uuid=relay_service_uuid)
def add_fip_nat_rules(self, logical_router_id, ext_ip, int_ip,
match_ports=None, bypass_firewall=True):
match_ports=None, bypass_firewall=True,
tags=None):
self.nsxlib.logical_router.add_nat_rule(
logical_router_id, action="SNAT",
translated_network=ext_ip,
source_net=int_ip,
rule_priority=FIP_NAT_PRI,
bypass_firewall=bypass_firewall)
bypass_firewall=bypass_firewall,
tags=tags)
self.nsxlib.logical_router.add_nat_rule(
logical_router_id, action="DNAT",
translated_network=int_ip,
dest_net=ext_ip,
rule_priority=FIP_NAT_PRI,
match_ports=match_ports,
bypass_firewall=bypass_firewall)
bypass_firewall=bypass_firewall,
tags=tags)
def delete_fip_nat_rules_by_internal_ip(self, logical_router_id, int_ip):
self.nsxlib.logical_router.delete_nat_rule_by_values(