Пример #1
0
    def update_cell(self, request, datum, name, cell_name, new_cell_value):
        config_param = datum

        config = config_param_manager.get(request,
                                          config_param.configuration_id)
        validation_param = config_param_manager.find_parameter(
            name,
            self.parameters(request, config.configuration.datastore_name,
                            config.configuration.datastore_version_name))
        if validation_param:
            error_msg = config_param_manager.validate_config_param_value(
                validation_param, new_cell_value)
            if error_msg:
                raise core_exceptions.ValidationError(error_msg)

        if isinstance(config_param.value, types.IntType):
            value = int(new_cell_value)
        elif isinstance(config_param.value, types.LongType):
            value = long(new_cell_value)
        else:
            value = new_cell_value

        setattr(datum, cell_name, value)

        (config_param_manager.get(request,
                                  config_param.configuration_id).update_param(
                                      name, value))

        return True
    def update_cell(self, request, datum, name,
                    cell_name, new_cell_value):
        config_param = datum

        config = config_param_manager.get(request,
                                          config_param.configuration_id)
        validation_param = config_param_manager.find_parameter(
            name,
            self.parameters(request,
                            config.configuration.datastore_name,
                            config.configuration.datastore_version_name))
        if validation_param:
            error_msg = config_param_manager.validate_config_param_value(
                validation_param, new_cell_value)
            if error_msg:
                raise core_exceptions.ValidationError(error_msg)

        if isinstance(config_param.value, types.IntType):
            value = int(new_cell_value)
        elif isinstance(config_param.value, types.LongType):
            value = long(new_cell_value)
        else:
            value = new_cell_value

        setattr(datum, cell_name, value)

        (config_param_manager
            .get(request, config_param.configuration_id)
            .update_param(name, value))

        return True
Пример #3
0
    def clean(self):
        cleaned_data = super(AddParameterForm, self).clean()

        if "value" in cleaned_data:
            config_param = config_param_manager.find_parameter(
                cleaned_data["name"], self.parameters)
            if config_param:
                error_msg = config_param_manager.validate_config_param_value(
                    config_param, cleaned_data["value"])
                if error_msg:
                    self._errors['value'] = self.error_class([error_msg])
        return cleaned_data
    def clean(self):
        cleaned_data = super(AddParameterForm, self).clean()

        if "value" in cleaned_data:
            config_param = config_param_manager.find_parameter(
                cleaned_data["name"], self.parameters)
            if config_param:
                error_msg = config_param_manager.validate_config_param_value(
                    config_param, cleaned_data["value"])
                if error_msg:
                    self._errors['value'] = self.error_class([error_msg])
        return cleaned_data
 def handle(self, request, data):
     try:
         (config_param_manager
             .get(request, self.initial["configuration_id"])
             .add_param(data["name"],
                        config_param_manager.adjust_type(
                            config_param_manager.find_parameter(
                                data["name"], self.parameters).type,
                            data["value"])))
         messages.success(request, _('Successfully added parameter'))
     except Exception as e:
         redirect = reverse("horizon:project:database_configurations:index")
         exceptions.handle(request, _('Unable to add new parameter: %s')
                           % e.message, redirect=redirect)
     return True
Пример #6
0
 def handle(self, request, data):
     try:
         (config_param_manager.get(
             request, self.initial["configuration_id"]).add_param(
                 data["name"],
                 config_param_manager.adjust_type(
                     config_param_manager.find_parameter(
                         data["name"], self.parameters).type,
                     data["value"])))
         messages.success(request, _('Successfully added parameter'))
     except Exception as e:
         redirect = reverse("horizon:project:database_configurations:index")
         exceptions.handle(request,
                           _('Unable to add new parameter: %s') % e.message,
                           redirect=redirect)
     return True
Пример #7
0
    def handle(self, request, data):
        try:
            (config_param_manager.get(
                request, self.initial["configuration_id"]).add_param(
                    data["name"],
                    config_param_manager.adjust_type(
                        config_param_manager.find_parameter(
                            data["name"], self.parameters).type,
                        data["value"])))

            new_values = config_param_manager.get(
                request, self.initial["configuration_id"],
                use_cache=True).to_json()
            api.trove.configuration_update(request,
                                           self.initial["configuration_id"],
                                           new_values)

            messages.success(request, _('Successfully added parameter'))
        except Exception:
            redirect = reverse("horizon:project:database_configurations:index")
            exceptions.handle(request,
                              _('Unable to add new parameter.'),
                              redirect=redirect)
        return True