def test_adapter_with_bmc(self):
     node_info = node.Node(mock.Mock(), dict(uuid='NNN'))
     data = {'boot_interface': '01-aa-bb-cc-dd-ee-ff',
             'inventory': {'bmc_address': '1.2.3.4'}}
     logger = utils.getProcessingLogger(__name__)
     msg, _kwargs = logger.process('foo', {'node_info': node_info,
                                           'data': data})
     self.assertEqual(
         '[node: NNN MAC aa:bb:cc:dd:ee:ff BMC 1.2.3.4] foo',
         msg)
 def test_adapter_no_bmc(self):
     CONF.set_override('log_bmc_address', False, 'processing')
     node_info = mock.Mock(uuid='NNN')
     data = {'boot_interface': '01-aa-bb-cc-dd-ee-ff',
             'inventory': {'bmc_address': '1.2.3.4'}}
     logger = utils.getProcessingLogger(__name__)
     msg, _kwargs = logger.process('foo', {'node_info': node_info,
                                           'data': data})
     self.assertEqual(
         '[node: NNN MAC aa:bb:cc:dd:ee:ff] foo',
         msg)
Beispiel #3
0
 def test_adapter_with_bmc(self):
     node_info = mock.Mock(uuid='NNN')
     data = {
         'boot_interface': '01-aa-bb-cc-dd-ee-ff',
         'inventory': {
             'bmc_address': '1.2.3.4'
         }
     }
     logger = utils.getProcessingLogger(__name__)
     msg, _kwargs = logger.process('foo', {
         'node_info': node_info,
         'data': data
     })
     self.assertEqual('[node: NNN MAC aa:bb:cc:dd:ee:ff BMC 1.2.3.4] foo',
                      msg)
 def test_adapter_no_bmc(self):
     CONF.set_override('log_bmc_address', False, 'processing')
     node_info = node.Node(mock.Mock(), dict(uuid='NNN'))
     data = {
         'boot_interface': '01-aa-bb-cc-dd-ee-ff',
         'inventory': {
             'bmc_address': '1.2.3.4'
         }
     }
     logger = utils.getProcessingLogger(__name__)
     msg, _kwargs = logger.process('foo', {
         'node_info': node_info,
         'data': data
     })
     self.assertEqual('[node: NNN MAC aa:bb:cc:dd:ee:ff] foo', msg)
from ironic_lib import utils as il_utils
import netaddr
from oslo_config import cfg
from oslo_utils import netutils
from oslo_utils import units
import six

from ironic_inspector.common.i18n import _, _LC, _LE, _LI, _LW
from ironic_inspector import conf
from ironic_inspector.plugins import base
from ironic_inspector import utils

CONF = cfg.CONF


LOG = utils.getProcessingLogger('ironic_inspector.plugins.standard')


class RootDiskSelectionHook(base.ProcessingHook):
    """Smarter root disk selection using Ironic root device hints.

    This hook must always go before SchedulerHook, otherwise root_disk field
    might not be updated.
    """

    def before_update(self, introspection_data, node_info, **kwargs):
        """Detect root disk from root device hints and IPA inventory."""
        hints = node_info.node().properties.get('root_device')
        if not hints:
            LOG.debug('Root device hints are not provided',
                      node_info=node_info, data=introspection_data)
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Gather root device hint from recognized block devices."""

from ironic_inspector.common.i18n import _LI, _LW
from ironic_inspector.plugins import base
from ironic_inspector import utils


LOG = utils.getProcessingLogger(__name__)


class RaidDeviceDetection(base.ProcessingHook):
    """Processing hook for learning the root device after RAID creation.

    The plugin can figure out the root device in 2 runs. First, it saves the
    discovered block device serials in node.extra. The second run will check
    the difference between the recently discovered block devices and the
    previously saved ones. After saving the root device in node.properties, it
    will delete the temporarily saved block device serials in node.extra.

    This way, it helps to figure out the root device hint in cases when
    otherwise Ironic doesn't have enough information to do so. Such a usecase
    is DRAC RAID configuration where the BMC doesn't provide any useful
    information about the created RAID disks. Using this plugin immediately
Beispiel #7
0
from ironic_inspector import api_tools
from ironic_inspector.common import context
from ironic_inspector.common.i18n import _
from ironic_inspector.common import ironic as ir_utils
from ironic_inspector.common import rpc
import ironic_inspector.conf
from ironic_inspector.conf import opts as conf_opts
from ironic_inspector import node_cache
from ironic_inspector import process
from ironic_inspector import rules
from ironic_inspector import utils

CONF = ironic_inspector.conf.CONF

app = flask.Flask(__name__)
LOG = utils.getProcessingLogger(__name__)

MINIMUM_API_VERSION = (1, 0)
CURRENT_API_VERSION = (1, 15)
DEFAULT_API_VERSION = CURRENT_API_VERSION
_LOGGING_EXCLUDED_KEYS = ('logs', )


def _get_version():
    ver = flask.request.headers.get(conf_opts.VERSION_HEADER,
                                    _DEFAULT_API_VERSION)
    try:
        if ver.lower() == 'latest':
            requested = CURRENT_API_VERSION
        else:
            requested = tuple(int(x) for x in ver.split('.'))
Beispiel #8
0
"""Standard set of plugins."""

from ironic_lib import utils as il_utils
import netaddr
from oslo_config import cfg
from oslo_utils import netutils
from oslo_utils import units
import six

from ironic_inspector.common.i18n import _
from ironic_inspector.plugins import base
from ironic_inspector import utils

CONF = cfg.CONF

LOG = utils.getProcessingLogger('ironic_inspector.plugins.standard')


class RootDiskSelectionHook(base.ProcessingHook):
    """Smarter root disk selection using Ironic root device hints.

    This hook must always go before SchedulerHook, otherwise root_disk field
    might not be updated.
    """
    def _process_root_device_hints(self, introspection_data, node_info,
                                   inventory):
        """Detect root disk from root device hints and IPA inventory."""
        hints = node_info.node().properties.get('root_device')
        if not hints:
            LOG.debug('Root device hints are not provided',
                      node_info=node_info,
Beispiel #9
0
 def test_adapter_no_data(self):
     logger = utils.getProcessingLogger(__name__)
     msg, _kwargs = logger.process('foo', {})
     self.assertEqual('foo', msg)
Beispiel #10
0
 def test_adapter_empty_data(self):
     logger = utils.getProcessingLogger(__name__)
     msg, _kwargs = logger.process('foo', {'node_info': None, 'data': None})
     self.assertEqual('[unidentified node] foo', msg)
 def test_adapter_no_data(self):
     logger = utils.getProcessingLogger(__name__)
     msg, _kwargs = logger.process('foo', {})
     self.assertEqual('foo', msg)
 def test_adapter_empty_data(self):
     logger = utils.getProcessingLogger(__name__)
     msg, _kwargs = logger.process('foo', {'node_info': None,
                                           'data': None})
     self.assertEqual('[unidentified node] foo', msg)