summaryrefslogtreecommitdiff
path: root/ironic/drivers/modules/noop_mgmt.py
blob: 0efc089e9932c6c25902c35209c4712a7a348bac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# 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.

"""No-op management interface implementation."""

from oslo_log import log

from ironic.common import boot_devices
from ironic.common import exception
from ironic.common.i18n import _
from ironic.drivers import base


LOG = log.getLogger(__name__)


class NoopManagement(base.ManagementInterface):
    """No-op management interface implementation.

    Using this implementation requires the boot order to be preconfigured
    to first try PXE booting, then fall back to hard drives.
    """

    def get_properties(self):
        return {}

    def validate(self, task):
        pass

    def get_supported_boot_devices(self, task):
        return [boot_devices.PXE, boot_devices.DISK]

    def set_boot_device(self, task, device, persistent=False):
        supported = self.get_supported_boot_devices(task)
        if device not in supported:
            raise exception.InvalidParameterValue(
                _("Invalid boot device %(dev)s specified, supported are "
                  "%(supported)s.") % {'dev': device,
                                       'supported': ', '.join(supported)})
        LOG.debug('Setting boot device to %(target)s requested for node '
                  '%(node)s with noop management. Assuming the correct '
                  'boot order is already configured',
                  {'target': device, 'node': task.node.uuid})

    def get_boot_device(self, task):
        return {'boot_device': boot_devices.PXE, 'persistent': True}

    def get_sensors_data(self, task):
        raise NotImplementedError()