summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-09-16 12:17:57 +0000
committerGerrit Code Review <review@openstack.org>2015-09-16 12:17:57 +0000
commit3cd59fac63ffb80f07d54e724031aa5269300786 (patch)
treeb8c8abf129c4148e59c36ea11c8a39bf63b3f20d
parent3d097f5fdcdbd99a29c72f63f2276a331254c317 (diff)
parente3e600052470af5052018c8a43f8a4269c23266f (diff)
downloadironic-python-agent-3cd59fac63ffb80f07d54e724031aa5269300786.tar.gz
Merge "Follow-up to inspection patch 096830414b"
-rw-r--r--doc/source/index.rst4
-rw-r--r--ironic_python_agent/inspector.py26
-rw-r--r--ironic_python_agent/tests/unit/test_inspector.py5
-rw-r--r--requirements.txt1
4 files changed, 32 insertions, 4 deletions
diff --git a/doc/source/index.rst b/doc/source/index.rst
index 4cc5a569..256df00d 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -66,8 +66,8 @@ initiating in-band cleaning tasks or deploying an image to the node.
Inspection
~~~~~~~~~~
IPA can conduct hardware inspection on start up and post data to the `Ironic
-Inspector`_. Edit your default PXE/iPXE configuration or kernel command
-options baked in the image, and set ``ipa-inspection-callback-url`` to the
+Inspector`_. Edit your default PXE/iPXE configuration or IPA options
+baked in the image, and set ``ipa-inspection-callback-url`` to the
full endpoint of Ironic Inspector, for example::
ipa-inspection-callback-url=http://IP:5050/v1/continue
diff --git a/ironic_python_agent/inspector.py b/ironic_python_agent/inspector.py
index 1f2e9f6c..084991e9 100644
--- a/ironic_python_agent/inspector.py
+++ b/ironic_python_agent/inspector.py
@@ -15,6 +15,7 @@
import logging
+import netaddr
from oslo_concurrency import processutils
from oslo_config import cfg
from oslo_utils import excutils
@@ -151,6 +152,10 @@ def discover_network_properties(inventory, data, failures):
"""Discover network and BMC related properties.
Populates 'boot_interface', 'ipmi_address' and 'interfaces' keys.
+
+ :param inventory: hardware inventory from a hardware manager
+ :param data: mutable data that we'll send to inspector
+ :param failures: AccumulatedFailures object
"""
# Both boot interface and IPMI address might not be present,
# we don't count it as failure
@@ -161,7 +166,9 @@ def discover_network_properties(inventory, data, failures):
data.setdefault('interfaces', {})
for iface in inventory['interfaces']:
- if iface.name == 'lo' or iface.ipv4_address == '127.0.0.1':
+ is_loopback = (iface.ipv4_address and
+ netaddr.IPAddress(iface.ipv4_address).is_loopback())
+ if iface.name == 'lo' or is_loopback:
LOG.debug('ignoring local network interface %s', iface.name)
continue
@@ -184,6 +191,13 @@ def discover_network_properties(inventory, data, failures):
def discover_scheduling_properties(inventory, data):
+ """Discover properties required for nova scheduler.
+
+ This logic should eventually move to inspector itself.
+
+ :param inventory: hardware inventory from a hardware manager
+ :param data: mutable data that we'll send to inspector
+ """
data['cpus'] = inventory['cpu'].count
data['cpu_arch'] = inventory['cpu'].architecture
data['memory_mb'] = inventory['memory'].physical_mb
@@ -209,6 +223,16 @@ def discover_scheduling_properties(inventory, data):
def collect_default(data, failures):
+ """The default inspection collector.
+
+ This is the only collector that is called by default. It is designed to be
+ both backward and future compatible:
+ 1. it collects exactly the same data as the old bash-based ramdisk
+ 2. it also posts the whole inventory which we'll eventually use.
+
+ :param data: mutable data that we'll send to inspector
+ :param failures: AccumulatedFailures object
+ """
inventory = hardware.dispatch_to_managers('list_hardware_info')
# These 2 calls are required for backward compatibility and should be
# dropped after inspector is ready (probably in Mitaka cycle).
diff --git a/ironic_python_agent/tests/unit/test_inspector.py b/ironic_python_agent/tests/unit/test_inspector.py
index 6a675dfa..29a2bb92 100644
--- a/ironic_python_agent/tests/unit/test_inspector.py
+++ b/ironic_python_agent/tests/unit/test_inspector.py
@@ -261,7 +261,10 @@ class TestDiscoverNetworkProperties(BaseDiscoverTest):
self.inventory['interfaces'] = [
hardware.NetworkInterface(name='lo',
mac_addr='aa:bb:cc:dd:ee:ff',
- ipv4_address='127.0.0.1')
+ ipv4_address='127.0.0.1'),
+ hardware.NetworkInterface(name='local-2',
+ mac_addr='aa:bb:cc:dd:ee:ff',
+ ipv4_address='127.0.1.42'),
]
inspector.discover_network_properties(self.inventory, self.data,
diff --git a/requirements.txt b/requirements.txt
index 37841f23..01cf7313 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -5,6 +5,7 @@ pbr<2.0,>=1.6
Babel>=1.3
eventlet>=0.17.4
iso8601>=0.1.9
+netaddr>=0.7.12,!=0.7.16
netifaces>=0.10.4
oslo.config>=2.3.0 # Apache-2.0
oslo.concurrency>=2.3.0 # Apache-2.0