def test_get_lock_tooz(self, mock_get_coord, mock_tooz, mock_internal):
        CONF.set_override('standalone', False)
        mock_lock = mock.Mock()
        coordinator = mock.Mock()
        coordinator.get_lock.return_value = mock_lock
        mock_get_coord.return_value = coordinator

        locking.get_lock(self.node.uuid)

        mock_tooz.assert_called_once_with(mock_lock)
        mock_internal.assert_not_called()
 def __init__(self,
              uuid,
              version_id=None,
              state=None,
              started_at=None,
              finished_at=None,
              error=None,
              node=None,
              ports=None,
              ironic=None,
              manage_boot=True):
     self.uuid = uuid
     self.started_at = started_at
     self.finished_at = finished_at
     self.error = error
     self.invalidate_cache()
     self._version_id = version_id
     self._state = state
     self._node = node
     if ports is not None and not isinstance(ports, dict):
         ports = {p.address: p for p in ports}
     self._ports = ports
     self._attributes = None
     self._ironic = ironic
     # On upgrade existing records will have manage_boot=NULL, which is
     # equivalent to True actually.
     self._manage_boot = manage_boot if manage_boot is not None else True
     # This is a lock on a node UUID, not on a NodeInfo object
     self._lock = locking.get_lock(uuid)
     # Whether lock was acquired using this NodeInfo object
     self._fsm = None
Exemple #3
0
def delete_nodes_not_in_list(uuids):
    """Delete nodes which don't exist in Ironic node UUIDs.

    :param uuids: Ironic node UUIDs
    """
    inspector_uuids = _list_node_uuids()
    for uuid in inspector_uuids - uuids:
        LOG.warning('Node %s was deleted from Ironic, dropping from Ironic '
                    'Inspector database', uuid)
        with locking.get_lock(uuid):
            _delete_node(uuid)
    def test_get_lock_internal(self, mock_tooz, mock_internal):
        locking.get_lock(self.node.uuid)

        mock_internal.assert_called_once_with(self.node.uuid)
        mock_tooz.assert_not_called()