diff --git a/nova/virt/ironic/driver.py b/nova/virt/ironic/driver.py index 8f1ad2b28716..b4f70d02a1b3 100644 --- a/nova/virt/ironic/driver.py +++ b/nova/virt/ironic/driver.py @@ -162,7 +162,11 @@ class IronicDriver(virt_driver.ComputeDriver): self._migrated_instance_uuids = set() def _get_node(self, node_uuid): - """Get a node by its UUID.""" + """Get a node by its UUID. + + Some methods pass in variables named nodename, but are + actually UUID's. + """ return self.ironicclient.call('node.get', node_uuid, fields=_NODE_FIELDS) @@ -624,7 +628,9 @@ class IronicDriver(virt_driver.ComputeDriver): def node_is_available(self, nodename): """Confirms a Nova hypervisor node exists in the Ironic inventory. - :param nodename: The UUID of the node. + :param nodename: The UUID of the node. Parameter is called nodename + even though it is a UUID to keep method signature + the same as inherited class. :returns: True if the node exists, False if not. """ @@ -637,12 +643,15 @@ class IronicDriver(virt_driver.ComputeDriver): if not self.node_cache: # Empty cache, try to populate it. self._refresh_cache() + + # nodename is the ironic node's UUID. if nodename in self.node_cache: return True # NOTE(comstud): Fallback and check Ironic. This case should be # rare. try: + # nodename is the ironic node's UUID. self._get_node(nodename) return True except ironic.exc.NotFound: @@ -738,6 +747,7 @@ class IronicDriver(virt_driver.ComputeDriver): """Return a dict, keyed by resource class, of inventory information for the supplied node. """ + # nodename is the ironic node's UUID. node = self._node_from_cache(nodename) info = self._node_resource(node) # TODO(jaypipes): Completely remove the reporting of VCPU, MEMORY_MB, @@ -818,23 +828,24 @@ class IronicDriver(virt_driver.ComputeDriver): # cache, let's try to populate it. self._refresh_cache() + # nodename is the ironic node's UUID. node = self._node_from_cache(nodename) return self._node_resource(node) - def _node_from_cache(self, nodename): + def _node_from_cache(self, node_uuid): """Returns a node from the cache, retrieving the node from Ironic API if the node doesn't yet exist in the cache. """ cache_age = time.time() - self.node_cache_time - if nodename in self.node_cache: + if node_uuid in self.node_cache: LOG.debug("Using cache for node %(node)s, age: %(age)s", - {'node': nodename, 'age': cache_age}) - return self.node_cache[nodename] + {'node': node_uuid, 'age': cache_age}) + return self.node_cache[node_uuid] else: LOG.debug("Node %(node)s not found in cache, age: %(age)s", - {'node': nodename, 'age': cache_age}) - node = self._get_node(nodename) - self.node_cache[nodename] = node + {'node': node_uuid, 'age': cache_age}) + node = self._get_node(node_uuid) + self.node_cache[node_uuid] = node return node def get_info(self, instance): @@ -1431,6 +1442,7 @@ class IronicDriver(virt_driver.ComputeDriver): :param network_info: Instance network information. """ + # instance.node is the ironic node's UUID. node = self._get_node(instance.node) self._plug_vifs(node, instance, network_info) @@ -1441,6 +1453,7 @@ class IronicDriver(virt_driver.ComputeDriver): :param network_info: Instance network information. """ + # instance.node is the ironic node's UUID. node = self._get_node(instance.node) self._unplug_vifs(node, instance, network_info)