mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
Fix address module config (mtu, alias etc) when addr_method is dhcp
Ticket: CA-269 Reviewed By: Testing Done: Tested setting alias on an interface with addr_method dhcp
This commit is contained in:
@@ -151,9 +151,10 @@ class address(moduleBase):
|
|||||||
def _up(self, ifaceobj):
|
def _up(self, ifaceobj):
|
||||||
if not self.ipcmd.link_exists(ifaceobj.name):
|
if not self.ipcmd.link_exists(ifaceobj.name):
|
||||||
return
|
return
|
||||||
|
addr_method = ifaceobj.addr_method
|
||||||
try:
|
try:
|
||||||
# release any stale dhcp addresses if present
|
# release any stale dhcp addresses if present
|
||||||
if (not self.PERFMODE and
|
if (addr_method != "dhcp" and not self.PERFMODE and
|
||||||
not (ifaceobj.flags & iface.HAS_SIBLINGS)):
|
not (ifaceobj.flags & iface.HAS_SIBLINGS)):
|
||||||
# if not running in perf mode and ifaceobj does not have
|
# if not running in perf mode and ifaceobj does not have
|
||||||
# any sibling iface objects, kill any stale dhclient
|
# any sibling iface objects, kill any stale dhclient
|
||||||
@@ -168,7 +169,8 @@ class address(moduleBase):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
self.ipcmd.batch_start()
|
self.ipcmd.batch_start()
|
||||||
self._inet_address_config(ifaceobj)
|
if addr_method != "dhcp":
|
||||||
|
self._inet_address_config(ifaceobj)
|
||||||
mtu = ifaceobj.get_attr_value_first('mtu')
|
mtu = ifaceobj.get_attr_value_first('mtu')
|
||||||
if mtu:
|
if mtu:
|
||||||
self.ipcmd.link_set(ifaceobj.name, 'mtu', mtu)
|
self.ipcmd.link_set(ifaceobj.name, 'mtu', mtu)
|
||||||
@@ -180,20 +182,27 @@ class address(moduleBase):
|
|||||||
self.ipcmd.link_set(ifaceobj.name, 'address', hwaddress)
|
self.ipcmd.link_set(ifaceobj.name, 'address', hwaddress)
|
||||||
self.ipcmd.batch_commit()
|
self.ipcmd.batch_commit()
|
||||||
|
|
||||||
# Handle special things on a bridge
|
try:
|
||||||
self._process_bridge(ifaceobj, True)
|
# Handle special things on a bridge
|
||||||
|
self._process_bridge(ifaceobj, True)
|
||||||
|
except Exception, e:
|
||||||
|
self.log_warn('%s: %s' %(ifaceobj.name, str(e)))
|
||||||
|
pass
|
||||||
|
|
||||||
self.ipcmd.route_add_gateway(ifaceobj.name,
|
if addr_method != "dhcp":
|
||||||
ifaceobj.get_attr_value_first('gateway'))
|
self.ipcmd.route_add_gateway(ifaceobj.name,
|
||||||
|
ifaceobj.get_attr_value_first('gateway'))
|
||||||
|
|
||||||
def _down(self, ifaceobj):
|
def _down(self, ifaceobj):
|
||||||
try:
|
try:
|
||||||
if not self.ipcmd.link_exists(ifaceobj.name):
|
if not self.ipcmd.link_exists(ifaceobj.name):
|
||||||
return
|
return
|
||||||
self.ipcmd.route_del_gateway(ifaceobj.name,
|
addr_method = ifaceobj.addr_method
|
||||||
|
if addr_method != "dhcp":
|
||||||
|
self.ipcmd.route_del_gateway(ifaceobj.name,
|
||||||
ifaceobj.get_attr_value_first('gateway'),
|
ifaceobj.get_attr_value_first('gateway'),
|
||||||
ifaceobj.get_attr_value_first('metric'))
|
ifaceobj.get_attr_value_first('metric'))
|
||||||
self.ipcmd.del_addr_all(ifaceobj.name)
|
self.ipcmd.del_addr_all(ifaceobj.name)
|
||||||
mtu = ifaceobj.get_attr_value_first('mtu')
|
mtu = ifaceobj.get_attr_value_first('mtu')
|
||||||
if mtu:
|
if mtu:
|
||||||
self.ipcmd.link_set(ifaceobj.name, 'mtu',
|
self.ipcmd.link_set(ifaceobj.name, 'mtu',
|
||||||
@@ -374,14 +383,6 @@ class address(moduleBase):
|
|||||||
op_handler = self._run_ops.get(operation)
|
op_handler = self._run_ops.get(operation)
|
||||||
if not op_handler:
|
if not op_handler:
|
||||||
return
|
return
|
||||||
if (operation != 'query-running' and ifaceobj.addr_family and
|
|
||||||
ifaceobj.addr_family != 'inet' and
|
|
||||||
ifaceobj.addr_family != 'inet6'):
|
|
||||||
return
|
|
||||||
if (operation != 'query-running' and ifaceobj.addr_method and
|
|
||||||
ifaceobj.addr_method != 'static' and
|
|
||||||
ifaceobj.addr_method != 'loopback'):
|
|
||||||
return
|
|
||||||
self._init_command_handlers()
|
self._init_command_handlers()
|
||||||
if operation == 'query-checkcurr':
|
if operation == 'query-checkcurr':
|
||||||
op_handler(self, ifaceobj, query_ifaceobj)
|
op_handler(self, ifaceobj, query_ifaceobj)
|
||||||
|
Reference in New Issue
Block a user