Exemple #1
0
    def validate_config_data(cls, config_data_dict):
        """Validates distributor config data.

        This will validate a distributor config dataset against the config
        settings the distributor l3 driver supports.

        :param config_data_dict: The config data dictionary to validate.
        :type config_data: dict
        :return: None
        :raises DriverError: An unexpected error occurred.
        :raises UnsupportedOptionError: If the driver does not support
          one of the config_data settings.
        """
        try:
            validate(config_data_dict, config_data_schema.SCHEMAS)
        except js_exceptions.ValidationError as e:
            error_object = ''
            if e.relative_path:
                error_object = '{} '.format(e.relative_path[0])
            raise exceptions.UnsupportedOptionError(
                user_fault_string='{0}{1}'.format(error_object, e.message),
                operator_fault_string=str(e))
        except Exception as e:
            raise exceptions.DriverError(
                user_fault_string='Failed to validate the distributor '
                'config data due to: {}'.format(str(e)),
                operator_fault_string='Failed to validate the distributor '
                'config data due to: {}'.format(str(e)))
Exemple #2
0
    def test_UnsupportedOptionError(self):
        unsupported_option_error = exceptions.UnsupportedOptionError(
            user_fault_string=self.user_fault_string,
            operator_fault_string=self.operator_fault_string)

        self.assertEqual(self.user_fault_string,
                         unsupported_option_error.user_fault_string)
        self.assertEqual(self.operator_fault_string,
                         unsupported_option_error.operator_fault_string)
        self.assertIsInstance(unsupported_option_error, Exception)
Exemple #3
0
    def validate_flavor(self, flavor_dict):
        """Validates flavor profile data.

        This will validate a flavor profile dataset against the flavor
        settings the amphora driver supports.

        :param flavor_dict: The flavor dictionary to validate.
        :type flavor: dict
        :return: None
        :raises DriverError: An unexpected error occurred.
        :raises UnsupportedOptionError: If the driver does not support
          one of the flavor settings.
        """
        try:
            validate(flavor_dict, flavor_schema.SUPPORTED_FLAVOR_SCHEMA)
        except js_exceptions.ValidationError as e:
            error_object = ''
            if e.relative_path:
                error_object = '{} '.format(e.relative_path[0])
            raise exceptions.UnsupportedOptionError(
                user_fault_string='{0}{1}'.format(error_object, e.message),
                operator_fault_string=str(e))
        except Exception as e:
            raise exceptions.DriverError(
                user_fault_string='Failed to validate the flavor metadata '
                'due to: {}'.format(str(e)),
                operator_fault_string='Failed to validate the flavor metadata '
                'due to: {}'.format(str(e)))
        compute_flavor = flavor_dict.get(consts.COMPUTE_FLAVOR, None)
        if compute_flavor:
            compute_driver = stevedore_driver.DriverManager(
                namespace='octavia.compute.drivers',
                name=CONF.controller_worker.compute_driver,
                invoke_on_load=True).driver

            # TODO(johnsom) Fix this to raise a NotFound error
            # when the octavia-lib supports it.
            compute_driver.validate_flavor(compute_flavor)