From: Jenkins Date: Tue, 2 Sep 2014 21:17:49 +0000 (+0000) Subject: Merge "Make log level in linux.utils.execute configurable" X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=eab2a21f6257807fe4c4bb36e7e346e6e737646b;p=openstack-build%2Fneutron-build.git Merge "Make log level in linux.utils.execute configurable" --- eab2a21f6257807fe4c4bb36e7e346e6e737646b diff --cc neutron/agent/linux/ip_lib.py index 0a5bbde11,02fe15474..f085b4ded --- a/neutron/agent/linux/ip_lib.py +++ b/neutron/agent/linux/ip_lib.py @@@ -549,33 -558,18 +558,36 @@@ class IpNetnsCommand(IpCommandBase) def device_exists(device_name, root_helper=None, namespace=None): + """Return True if the device exists in the namespace.""" try: - address = IPDevice(device_name, root_helper, namespace).link.address + dev = IPDevice(device_name, root_helper, namespace) + dev.set_log_fail_as_error(False) + address = dev.link.address except RuntimeError: return False return bool(address) +def device_exists_with_ip_mac(device_name, ip_cidr, mac, namespace=None, + root_helper=None): + """Return True if the device with the given IP and MAC addresses + exists in the namespace. + """ + try: + device = IPDevice(device_name, root_helper, namespace) + if mac != device.link.address: + return False + if ip_cidr not in (ip['cidr'] for ip in device.addr.list()): + return False + except RuntimeError: + return False + else: + return True + + def ensure_device_is_ready(device_name, root_helper=None, namespace=None): dev = IPDevice(device_name, root_helper, namespace) + dev.set_log_fail_as_error(False) try: # Ensure the device is up, even if it is already up. If the device # doesn't exist, a RuntimeError will be raised.