Change DVR to use ip_lib.add_ip_address() directly

The DVR Edge router code creates an IPDevice() object just
to make a single call to add an IP address.  Change it to
call ip_lib.add_ip_address() directly instead since that's
what's being done in the IpAddrCommand.add() code anways.

Trivialfix

Change-Id: Ie7640fc54494de89e85b2f528bddc79875a16046
This commit is contained in:
Brian Haley 2019-01-11 12:28:37 -05:00 committed by LIU Yulong
parent 8a547d869b
commit ee19fa49b7
1 changed files with 2 additions and 3 deletions

View File

@ -314,10 +314,9 @@ class DvrEdgeRouter(dvr_local_router.DvrLocalRouter):
return
interface_name = self.get_snat_external_device_interface_name(
self.get_ex_gw_port())
device = ip_lib.IPDevice(
interface_name, namespace=self.snat_namespace.name)
try:
device.addr.add(fip_cidr)
ip_lib.add_ip_address(fip_cidr, interface_name,
namespace=self.snat_namespace.name)
except RuntimeError:
LOG.warning("Unable to configure IP address for centralized "
"floating IP: %s", fip['id'])