Пример #1
0
def get_all_power_types(controllers=None, ignore_errors=True):
    """Query the PowerDriverRegistry and obtain all known power driver types.

    :return: a list of power types matching the schema
        provisioningserver.drivers.power.JSON_POWER_DRIVERS_SCHEMA or
        provisioningserver.drivers.pod.JSON_POD_DRIVERS_SCHEMA
    """
    merged_types = []
    for power_type_orig in PowerDriverRegistry.get_schema(
            detect_missing_packages=False):
        power_type = deepcopy(power_type_orig)
        driver_type = power_type.get("driver_type", "power")
        name = power_type["name"]
        fields = power_type.get("fields", [])
        description = power_type["description"]
        chassis = power_type["chassis"]
        missing_packages = power_type["missing_packages"]
        queryable = power_type.get("queryable")
        add_power_driver_parameters(
            driver_type,
            name,
            description,
            chassis,
            fields,
            missing_packages,
            merged_types,
            queryable=queryable,
        )
    return sorted(merged_types, key=itemgetter("description"))
Пример #2
0
 def test_get_schema(self):
     fake_driver_one = make_power_driver_base()
     fake_driver_two = make_power_driver_base()
     fake_pod_driver = make_pod_driver_base()
     PowerDriverRegistry.register_item(fake_driver_one.name,
                                       fake_driver_one)
     PowerDriverRegistry.register_item(fake_driver_two.name,
                                       fake_driver_two)
     PowerDriverRegistry.register_item(fake_pod_driver.name,
                                       fake_pod_driver)
     self.assertItemsEqual(
         [{
             'driver_type': 'power',
             'name': fake_driver_one.name,
             'description': fake_driver_one.description,
             'fields': [],
             'queryable': fake_driver_one.queryable,
             'missing_packages': fake_driver_one.detect_missing_packages(),
         }, {
             'driver_type': 'power',
             'name': fake_driver_two.name,
             'description': fake_driver_two.description,
             'fields': [],
             'queryable': fake_driver_two.queryable,
             'missing_packages': fake_driver_two.detect_missing_packages(),
         }, {
             'driver_type': 'pod',
             'name': fake_pod_driver.name,
             'description': fake_pod_driver.description,
             'fields': [],
             'queryable': fake_pod_driver.queryable,
             'missing_packages': fake_pod_driver.detect_missing_packages(),
         }], PowerDriverRegistry.get_schema())
Пример #3
0
    def prepare_rack_rpc(self):
        rack_controller = factory.make_RackController()
        self.useFixture(RegionEventLoopFixture('rpc'))
        self.useFixture(RunningEventLoopFixture())

        fixture = self.useFixture(MockLiveRegionToClusterRPCFixture())
        protocol = fixture.makeCluster(rack_controller, DescribePowerTypes)
        self.power_types = PowerDriverRegistry.get_schema()
        protocol.DescribePowerTypes.side_effect = always_succeed_with(
            {'power_types': self.power_types})
        return protocol
Пример #4
0
    def _interceptPowerTypesQuery(self):
        power_types = PowerDriverRegistry.get_schema(
            detect_missing_packages=False)

        @wraps(driver_parameters.get_all_power_types)
        def get_all_power_types(controllers=None, ignore_errors=True):
            # Callers can mutate this, so deep copy.
            return deepcopy(power_types)

        restore = monkey.patch(driver_parameters, "get_all_power_types",
                               get_all_power_types)
        self.addCleanup(restore)
Пример #5
0
 def test_get_schema(self):
     fake_driver_one = make_power_driver_base()
     fake_driver_two = make_power_driver_base()
     fake_pod_driver = make_pod_driver_base()
     PowerDriverRegistry.register_item(fake_driver_one.name,
                                       fake_driver_one)
     PowerDriverRegistry.register_item(fake_driver_two.name,
                                       fake_driver_two)
     PowerDriverRegistry.register_item(fake_pod_driver.name,
                                       fake_pod_driver)
     self.assertItemsEqual(
         [
             {
                 "driver_type": "power",
                 "name": fake_driver_one.name,
                 "description": fake_driver_one.description,
                 "chassis": fake_driver_one.chassis,
                 "can_probe": fake_driver_one.can_probe,
                 "fields": [],
                 "queryable": fake_driver_one.queryable,
                 "missing_packages":
                 fake_driver_one.detect_missing_packages(),
             },
             {
                 "driver_type": "power",
                 "name": fake_driver_two.name,
                 "description": fake_driver_two.description,
                 "chassis": fake_driver_two.chassis,
                 "can_probe": fake_driver_two.can_probe,
                 "fields": [],
                 "queryable": fake_driver_two.queryable,
                 "missing_packages":
                 fake_driver_two.detect_missing_packages(),
             },
             {
                 "driver_type": "pod",
                 "name": fake_pod_driver.name,
                 "description": fake_pod_driver.description,
                 "chassis": fake_pod_driver.chassis,
                 "can_probe": fake_pod_driver.can_probe,
                 "fields": [],
                 "queryable": fake_pod_driver.queryable,
                 "missing_packages":
                 fake_pod_driver.detect_missing_packages(),
             },
         ],
         PowerDriverRegistry.get_schema(),
     )