Activate interface before duplicate IP check
Runs ifconfig IFACE up before duplicate IP check so that arping can work correctly in Fuel Setup. Change-Id: If6336af9f260429db5e8889717554aa0bc325595 Closes-Bug: #1451811
This commit is contained in:
parent
f81c1a0c64
commit
4ed8131a36
|
@ -14,5 +14,9 @@
|
|||
# under the License.
|
||||
|
||||
|
||||
class NetworkException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class BadIPException(Exception):
|
||||
pass
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
# under the License.
|
||||
|
||||
from fuelmenu.common.errors import BadIPException
|
||||
from fuelmenu.common.errors import NetworkException
|
||||
|
||||
import netaddr
|
||||
import subprocess
|
||||
|
@ -83,7 +84,12 @@ def duplicateIPExists(ip, iface):
|
|||
noout = open('/dev/null', 'w')
|
||||
no_dupes = subprocess.call(["arping", "-D", "-c3", "-w1", "-I", iface,
|
||||
ip], stdout=noout, stderr=noout)
|
||||
if no_dupes == 0:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
return (no_dupes != 0)
|
||||
|
||||
|
||||
def upIface(iface):
|
||||
noout = open('/dev/null', 'w')
|
||||
result = subprocess.call(["ifconfig", iface, "up"], stdout=noout,
|
||||
stderr=noout)
|
||||
if result != 0:
|
||||
raise NetworkException("Failed to up interface {0}".format(iface))
|
||||
|
|
|
@ -17,6 +17,7 @@ import dhcp_checker.api
|
|||
import dhcp_checker.utils
|
||||
from fuelmenu.common import dialog
|
||||
from fuelmenu.common.errors import BadIPException
|
||||
from fuelmenu.common.errors import NetworkException
|
||||
from fuelmenu.common.modulehelper import ModuleHelper
|
||||
from fuelmenu.common import network
|
||||
from fuelmenu.common import puppet
|
||||
|
@ -242,6 +243,12 @@ class interfaces(urwid.WidgetWrap):
|
|||
errors.append(e)
|
||||
self.parent.footer.set_text("Scanning for duplicate IP address..")
|
||||
if len(responses["ipaddr"]) > 0:
|
||||
if self.netsettings[self.activeiface]['link'].upper() != "UP":
|
||||
try:
|
||||
network.upIface(self.activeiface)
|
||||
except NetworkException as e:
|
||||
errors.append("Cannot activate {0} to check for "
|
||||
"duplicate IP.".format(self.activeiface))
|
||||
if network.duplicateIPExists(responses["ipaddr"],
|
||||
self.activeiface):
|
||||
errors.append("Duplicate host found with IP {0}.".format(
|
||||
|
|
Loading…
Reference in New Issue