Add snat ports cache to dvr router
This reverses the effect of [1] but in a way that works with the current structure of the code and keeps DVR details in DVR classes [1] https://review.openstack.org/#/c/200293 Change-Id: Ia8468881de6538882d4a14725b55db53e23d2e4c Closes-Bug: #1479130
This commit is contained in:
parent
381cac9139
commit
3a9e778399
|
@ -101,7 +101,7 @@ class DvrEdgeRouter(dvr_local_router.DvrLocalRouter):
|
|||
if not self.ex_gw_port:
|
||||
return
|
||||
|
||||
sn_port = self.get_snat_port_for_internal_port(port)
|
||||
sn_port = self.get_snat_port_for_internal_port(port, self.snat_ports)
|
||||
if not sn_port:
|
||||
return
|
||||
|
||||
|
|
|
@ -302,7 +302,7 @@ class DvrLocalRouter(dvr_router_base.DvrRouterBase):
|
|||
if not self.ex_gw_port:
|
||||
return
|
||||
|
||||
sn_port = self.get_snat_port_for_internal_port(port)
|
||||
sn_port = self.get_snat_port_for_internal_port(port, self.snat_ports)
|
||||
if not sn_port:
|
||||
return
|
||||
|
||||
|
|
|
@ -26,12 +26,18 @@ class DvrRouterBase(router.RouterInfo):
|
|||
self.agent = agent
|
||||
self.host = host
|
||||
|
||||
def process(self, agent):
|
||||
super(DvrRouterBase, self).process(agent)
|
||||
# NOTE: Keep a copy of the interfaces around for when they are removed
|
||||
self.snat_ports = self.get_snat_interfaces()
|
||||
|
||||
def get_snat_interfaces(self):
|
||||
return self.router.get(l3_constants.SNAT_ROUTER_INTF_KEY, [])
|
||||
|
||||
def get_snat_port_for_internal_port(self, int_port):
|
||||
def get_snat_port_for_internal_port(self, int_port, snat_ports=None):
|
||||
"""Return the SNAT port for the given internal interface port."""
|
||||
snat_ports = self.get_snat_interfaces()
|
||||
if snat_ports is None:
|
||||
snat_ports = self.get_snat_interfaces()
|
||||
fixed_ip = int_port['fixed_ips'][0]
|
||||
subnet_id = fixed_ip['subnet_id']
|
||||
match_port = [p for p in snat_ports
|
||||
|
|
Loading…
Reference in New Issue