]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Merge "Make log level in linux.utils.execute configurable"
authorJenkins <jenkins@review.openstack.org>
Tue, 2 Sep 2014 21:17:49 +0000 (21:17 +0000)
committerGerrit Code Review <review@openstack.org>
Tue, 2 Sep 2014 21:17:49 +0000 (21:17 +0000)
1  2 
neutron/agent/linux/ip_lib.py
neutron/tests/unit/test_linux_ip_lib.py

index 0a5bbde118bad46a552d892f342dca659a4db1c2,02fe154747f49ecf3ca9f8875bdf863824a824f0..f085b4ded87ee837af839ca469983099c238d3dd
@@@ -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.