示例#1
0
 def test_class_variables(self):
     self.assertEqual(['boot', 'deploy', 'management', 'network', 'power'],
                      driver_base.BareDriver().core_interfaces)
     self.assertEqual(
         ['bios', 'console', 'inspect', 'raid', 'rescue', 'storage'],
         driver_base.BareDriver().optional_interfaces
     )
示例#2
0
def build_driver_for_task(task):
    """Builds a composable driver for a given task.

    Starts with a `BareDriver` object, and attaches implementations of the
    various driver interfaces to it. They come from separate
    driver factories and are configurable via the database.

    :param task: The task containing the node to build a driver for.
    :returns: A driver object for the task.
    :raises: DriverNotFound if node.driver could not be found in the
             "ironic.hardware.types" namespaces.
    :raises: InterfaceNotFoundInEntrypoint if some node interfaces are set
             to invalid or unsupported values.
    :raises: IncompatibleInterface the requested implementation is not
             compatible with it with the hardware type.
    """
    node = task.node

    hw_type = get_hardware_type(node.driver)
    check_and_update_node_interfaces(node, hw_type=hw_type)

    bare_driver = driver_base.BareDriver()
    _attach_interfaces_to_driver(bare_driver, node, hw_type)

    return bare_driver
示例#3
0
def build_driver_for_task(task, driver_name=None):
    """Builds a composable driver for a given task.

    Starts with a `BareDriver` object, and attaches implementations of the
    various driver interfaces to it. For classic drivers these all come from
    the monolithic driver singleton, for hardware types - from separate
    driver factories and are configurable via the database.

    :param task: The task containing the node to build a driver for.
    :param driver_name: The name of the classic driver or hardware type to use
                        as a base, if different than task.node.driver.
    :returns: A driver object for the task.
    :raises: DriverNotFound if node.driver could not be found in either
             "ironic.drivers" or "ironic.hardware.types" namespaces.
    :raises: InterfaceNotFoundInEntrypoint if some node interfaces are set
             to invalid or unsupported values.
    :raises: IncompatibleInterface if driver is a hardware type and
             the requested implementation is not compatible with it.
    """
    node = task.node
    driver_name = driver_name or node.driver

    driver_or_hw_type = get_driver_or_hardware_type(driver_name)
    check_and_update_node_interfaces(node, driver_or_hw_type=driver_or_hw_type)

    bare_driver = driver_base.BareDriver()
    _attach_interfaces_to_driver(bare_driver, node, driver_or_hw_type)

    return bare_driver
示例#4
0
    def test_class_variables_immutable(self):
        # Test to make sure that our *_interfaces variables in the class don't
        # get modified by a child class
        self.assertEqual(('deploy', 'power'),
                         driver_base.BaseDriver.core_interfaces)
        self.assertEqual(('boot', 'console', 'inspect', 'management', 'raid'),
                         driver_base.BaseDriver.standard_interfaces)
        # Ensure that instantiating an instance of a derived class does not
        # change our variables.
        driver_base.BareDriver()

        self.assertEqual(('deploy', 'power'),
                         driver_base.BaseDriver.core_interfaces)
        self.assertEqual(('boot', 'console', 'inspect', 'management', 'raid'),
                         driver_base.BaseDriver.standard_interfaces)
示例#5
0
def build_driver_for_task(task, driver_name=None):
    """Builds a composable driver for a given task.

    Starts with a `BareDriver` object, and attaches implementations of the
    various driver interfaces to it. Currently these all come from the
    monolithic driver singleton, but later will come from separate
    driver factories and configurable via the database.

    :param task: The task containing the node to build a driver for.
    :param driver_name: The name of the monolithic driver to use as a base,
                        if different than task.node.driver.
    :returns: A driver object for the task.
    :raises: DriverNotFound if node.driver could not be
             found in the "ironic.drivers" namespace.
    """
    node = task.node
    driver = driver_base.BareDriver()
    _attach_interfaces_to_driver(driver, node, driver_name=driver_name)
    return driver
示例#6
0
def build_driver_for_task(task, driver_name=None):
    """Builds a composable driver for a given task.

    Starts with a `BareDriver` object, and attaches implementations of the
    various driver interfaces to it. For classic drivers these all come from
    the monolithic driver singleton, for hardware types - from separate
    driver factories and are configurable via the database.

    :param task: The task containing the node to build a driver for.
    :param driver_name: The name of the classic driver or hardware type to use
                        as a base, if different than task.node.driver.
    :returns: A driver object for the task.
    :raises: DriverNotFound if node.driver could not be found in either
             "ironic.drivers" or "ironic.hardware.types" namespaces.
    :raises: InterfaceNotFoundInEntrypoint if some node interfaces are set
             to invalid or unsupported values.
    :raises: IncompatibleInterface if driver is a hardware type and
             the requested implementation is not compatible with it.
    """
    node = task.node
    driver_name = driver_name or node.driver

    driver_or_hw_type = get_driver_or_hardware_type(driver_name)
    try:
        check_and_update_node_interfaces(node,
                                         driver_or_hw_type=driver_or_hw_type)
    except exception.MustBeNone as e:
        # NOTE(rloo). This was raised because nodes with classic drivers
        #             cannot have any interfaces (except for network and
        #             storage) set. However, there was a small window
        #             where this was possible so instead of breaking those
        #             users totally, we'll spam them with warnings instead.
        LOG.warning(
            '%s They will be ignored. To avoid this warning, '
            'please set them to None.', e)

    bare_driver = driver_base.BareDriver()
    _attach_interfaces_to_driver(bare_driver, node, driver_or_hw_type)

    return bare_driver
示例#7
0
    def supported_raid_interfaces(self):
        """List of supported raid interfaces."""
        return [fake.FakeRAID]

    @property
    def supported_rescue_interfaces(self):
        """List of supported rescue interfaces."""
        return [fake.FakeRescue]

    @property
    def supported_vendor_interfaces(self):
        """List of supported rescue interfaces."""
        return [fake.FakeVendorB, fake.FakeVendorA]


OPTIONAL_INTERFACES = (set(drivers_base.BareDriver().standard_interfaces) -
                       {'management', 'boot'}) | {'vendor'}


class HardwareTypeLoadTestCase(db_base.DbTestCase):
    def setUp(self):
        super(HardwareTypeLoadTestCase, self).setUp()
        self.config(dhcp_provider=None, group='dhcp')
        self.ifaces = {}
        self.node_kwargs = {}
        for iface in drivers_base.ALL_INTERFACES:
            if iface == 'network':
                self.ifaces[iface] = 'noop'
                enabled = ['noop']
            elif iface == 'storage':
                self.ifaces[iface] = 'noop'
示例#8
0
        """List of supported raid interfaces."""
        return [fake.FakeRAID]

    @property
    def supported_rescue_interfaces(self):
        """List of supported rescue interfaces."""
        return [fake.FakeRescue]

    @property
    def supported_vendor_interfaces(self):
        """List of supported rescue interfaces."""
        return [fake.FakeVendorB, fake.FakeVendorA]


OPTIONAL_INTERFACES = set(
    drivers_base.BareDriver().standard_interfaces) - {'management', 'boot'}


class HardwareTypeLoadTestCase(db_base.DbTestCase):
    def setUp(self):
        super(HardwareTypeLoadTestCase, self).setUp()
        self.config(dhcp_provider=None, group='dhcp')
        self.ifaces = {}
        self.node_kwargs = {}
        for iface in drivers_base.ALL_INTERFACES:
            if iface == 'network':
                self.ifaces[iface] = 'noop'
                enabled = ['noop']
            elif iface == 'storage':
                self.ifaces[iface] = 'noop'
                enabled = ['noop']
示例#9
0
    def supported_raid_interfaces(self):
        """List of supported raid interfaces."""
        return [fake.FakeRAID]

    @property
    def supported_rescue_interfaces(self):
        """List of supported rescue interfaces."""
        return [fake.FakeRescue]

    @property
    def supported_vendor_interfaces(self):
        """List of supported rescue interfaces."""
        return [fake.FakeVendorB, fake.FakeVendorA]


OPTIONAL_INTERFACES = (drivers_base.BareDriver().optional_interfaces +
                       ['vendor'])


class HardwareTypeLoadTestCase(db_base.DbTestCase):
    def setUp(self):
        super(HardwareTypeLoadTestCase, self).setUp()
        self.config(dhcp_provider=None, group='dhcp')
        self.ifaces = {}
        self.node_kwargs = {}
        for iface in drivers_base.ALL_INTERFACES:
            if iface == 'network':
                self.ifaces[iface] = 'noop'
                enabled = ['noop']
            elif iface == 'storage':
                self.ifaces[iface] = 'noop'