示例#1
0
    def _register_and_validate_hardware_interfaces(self, hardware_types):
        """Register and validate hardware interfaces for this conductor.

        Registers a row in the database for each combination of
        (hardware type, interface type, interface) that is supported and
        enabled.

        TODO: Validates against other conductors to check if the
        set of registered hardware interfaces for a given hardware type is the
        same, and warns if not (we can't error out, otherwise all conductors
        must be restarted at once to change configuration).

        :param hardware_types: Dictionary mapping hardware type name to
                               hardware type object.
        :raises: ConductorHardwareInterfacesAlreadyRegistered
        :raises: InterfaceNotFoundInEntrypoint
        :raises: NoValidDefaultForInterface if the default value cannot be
                 calculated and is not provided in the configuration
        """
        # first unregister, in case we have cruft laying around
        self.conductor.unregister_all_hardware_interfaces()

        for ht_name, ht in hardware_types.items():
            interface_map = driver_factory.enabled_supported_interfaces(ht)
            for interface_type, interface_names in interface_map.items():
                default_interface = driver_factory.default_interface(
                    ht, interface_type, driver_name=ht_name)
                self.conductor.register_hardware_interfaces(ht_name,
                                                            interface_type,
                                                            interface_names,
                                                            default_interface)
    def _register_and_validate_hardware_interfaces(self, hardware_types):
        """Register and validate hardware interfaces for this conductor.

        Registers a row in the database for each combination of
        (hardware type, interface type, interface) that is supported and
        enabled.

        TODO: Validates against other conductors to check if the
        set of registered hardware interfaces for a given hardware type is the
        same, and warns if not (we can't error out, otherwise all conductors
        must be restarted at once to change configuration).

        :param hardware_types: Dictionary mapping hardware type name to
                               hardware type object.
        :raises: ConductorHardwareInterfacesAlreadyRegistered
        :raises: InterfaceNotFoundInEntrypoint
        :raises: NoValidDefaultForInterface if the default value cannot be
                 calculated and is not provided in the configuration
        """
        # first unregister, in case we have cruft laying around
        self.conductor.unregister_all_hardware_interfaces()

        for ht_name, ht in hardware_types.items():
            interface_map = driver_factory.enabled_supported_interfaces(ht)
            for interface_type, interface_names in interface_map.items():
                default_interface = driver_factory.default_interface(
                    ht, interface_type, driver_name=ht_name)
                self.conductor.register_hardware_interfaces(
                    ht_name, interface_type, interface_names,
                    default_interface)
示例#3
0
    def _test_enabled_supported_interfaces(self, enable_storage):
        ht = fake_hardware.FakeHardware()
        expected = {
            'boot': set(['fake']),
            'console': set(['fake']),
            'deploy': set(['fake']),
            'inspect': set(['fake']),
            'management': set(['fake']),
            'network': set(['noop']),
            'power': set(['fake']),
            'raid': set(['fake']),
            'storage': set([]),
            'vendor': set(['fake'])
        }
        if enable_storage:
            self.config(enabled_storage_interfaces=['fake'])
            expected['storage'] = set(['fake'])

        mapping = driver_factory.enabled_supported_interfaces(ht)
        self.assertEqual(expected, mapping)
示例#4
0
    def _test_enabled_supported_interfaces(self, enable_storage):
        ht = fake_hardware.FakeHardware()
        expected = {
            'boot': set(['fake']),
            'console': set(['fake']),
            'deploy': set(['fake']),
            'inspect': set(['fake']),
            'management': set(['fake']),
            'network': set(['noop']),
            'power': set(['fake']),
            'raid': set(['fake']),
            'storage': set([]),
            'vendor': set(['fake'])
        }
        if enable_storage:
            self.config(enabled_storage_interfaces=['fake'])
            expected['storage'] = set(['fake'])

        mapping = driver_factory.enabled_supported_interfaces(ht)
        self.assertEqual(expected, mapping)