72        if (arguments->size() != 1) {
 
   74                      "invalid number of arguments " << arguments->size()
 
   75                      << 
" for the '" << command_name << 
"' command. " 
   76                      << 
"Expecting 'client-classes' list");
 
   83                      "missing 'client-classes' argument for the '" 
   84                       << command_name << 
"' command");
 
   90                      "'client-classes' argument specified for the '" 
   91                      << command_name << 
"' command is not a list");
 
   95        if (list->size() != 1) {
 
   97                      "invalid number of classes specified for the '" 
   98                       << command_name << 
"' command. Expected one class");
 
  125                          "invalid class definition specified for the " 
  126                          "'class-add' command. Expected a map");
 
  138            parser.
parse(dictionary, class_def, family_, 
false);
 
  144            if (!class_def->contains(
"name")) {
 
  148            string name = class_def->get(
"name")->stringValue();
 
  149            text << 
"Class '" << name << 
"' added";
 
  156        } 
catch (
const std::exception& ex) {
 
 
  178            if (arguments->size() != 1) {
 
  180                          "invalid number of arguments " << arguments->size()
 
  181                          << 
" for the 'class-get' command. " 
  182                          << 
"Expecting 'name' string");
 
  189                          "missing 'name' argument for the 'class-get' command");
 
  195                          "'name' argument specified for the 'class-get' " 
  196                          "command is not a string");
 
  199            string name_str = name->stringValue();
 
  207                list->add(def->toElement());
 
  209                map->set(
"client-classes", list);
 
  212                text << 
"Class '" << name_str << 
"' definition returned";
 
  219                text << 
"Class '" << name_str << 
"' not found";
 
  226        } 
catch (
const std::exception& ex) {
 
 
  249            args->set(
"client-classes", list);
 
  253                getClientClassDictionary()->getClasses();
 
  256            for (
auto const& c : *classes) {
 
  264            text << classes->size() << 
" class";
 
  266            if (classes->size() != 1) {
 
  271            if (classes->size() > 0) {
 
  281        } 
catch (
const std::exception& ex) {
 
 
  310                          "invalid class definition specified for the " 
  311                          "'class-update' command. Expected a map");
 
  316            if (!class_def->contains(
"name")) {
 
  318                          "mandatory 'name' parameter");
 
  326            string name = class_def->get(
"name")->stringValue();
 
  331                auto const& template_cfg = class_def->get(
"template-test");
 
  333                    ElementPtr mutable_class_def = boost::const_pointer_cast<Element>(class_def);
 
  334                    mutable_class_def->set(
"template-test", 
Element::create(previous->getTest()));
 
  338                text << 
"Class '" << name << 
"' is not found";
 
  352            for (
auto const& it : *classes) {
 
  353                if (it->getName() == name) {
 
  358                    before->addClass(it);
 
  364            parser.
parse(before, class_def, family_, 
false);
 
  368                          "Class '" << name << 
"' updated but does not show");
 
  375            if (previous->getDependOnKnown() != next->getDependOnKnown()) {
 
  377                          "modification of the class '" << name << 
"' would " 
  378                          "affect its dependency on the KNOWN and/or UNKNOWN built-in " 
  379                          "classes. Such modification is not allowed because " 
  380                          "there may be other classes depending on those built-ins " 
  381                          "via the updated class");
 
  385            classes = after->getClasses();
 
  386            for (
auto const& it : *classes) {
 
  387                before->addClass(it);
 
  395            text << 
"Class '" << name << 
"' updated";
 
  402        } 
catch (
const std::exception& ex) {
 
 
  424            if (arguments->size() != 1) {
 
  426                          "invalid number of arguments " << arguments->size()
 
  427                          << 
" for the 'class-del' command. " 
  428                          << 
"Expecting 'name' string");
 
  435                          "missing 'name' argument for the 'class-del' command");
 
  441                          "'name' argument specified for the 'class-del' " 
  442                          "command is not a string");
 
  445            string name_str = name->stringValue();
 
  454                text << 
"Class '" << name_str << 
"' not found";
 
  465            if (dictionary->dependOnClass(name_str, depend)) {
 
  467                          "Class '" << name_str << 
"' is used by class '" 
  472            dictionary->removeClass(name_str);
 
  474            text << 
"Class '" << name_str << 
"' deleted";
 
  480        } 
catch (
const std::exception& ex) {
 
 
 
  502    impl_->getClass(callout_handle);
 
 
  507    impl_->getClassList(callout_handle);
 
 
  515    impl_->addClass(callout_handle);
 
 
  521    impl_->updateClass(callout_handle);
 
 
  527    impl_->delClass(callout_handle);
 
 
 
static ElementPtr create(const Position &pos=ZERO_POSITION())
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
int class_list(CalloutHandle &handle)
This is a command callout for 'class-list' command.
const isc::log::MessageID CLASS_CMDS_CLASS_UPDATE_EMPTY
const isc::log::MessageID CLASS_CMDS_CLASS_UPDATE
const isc::log::MessageID CLASS_CMDS_CLASS_DEL_EMPTY
const isc::log::MessageID CLASS_CMDS_CLASS_ADD_FAILED
const isc::log::MessageID CLASS_CMDS_CLASS_LIST_FAILED
const isc::log::MessageID CLASS_CMDS_CLASS_DEL_FAILED
const isc::log::MessageID CLASS_CMDS_CLASS_GET
const isc::log::MessageID CLASS_CMDS_CLASS_LIST
const isc::log::MessageID CLASS_CMDS_CLASS_GET_FAILED
const isc::log::MessageID CLASS_CMDS_CLASS_LIST_EMPTY
const isc::log::MessageID CLASS_CMDS_CLASS_UPDATE_FAILED
const isc::log::MessageID CLASS_CMDS_CLASS_GET_EMPTY
const isc::log::MessageID CLASS_CMDS_CLASS_DEL
const isc::log::MessageID CLASS_CMDS_CLASS_ADD
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
A generic exception that is thrown when an unexpected error condition occurs.
Implementation of the ClassCmds class.
void delClass(CalloutHandle &callout_handle)
Processes and returns a response to 'class-del' command.
ClassCmdsImpl()
Constructor.
void getClassList(CalloutHandle &callout_handle) const
Returns a response to a 'class-list' command.
void addClass(CalloutHandle &callout_handle)
Returns a response to a 'class-add' command.
void getClass(CalloutHandle &callout_handle) const
Returns a response to a 'class-get' command.
void updateClass(CalloutHandle &callout_handle)
Returns a response to a 'class-update' command.
~ClassCmdsImpl()
Destructor.
void updateClass(hooks::CalloutHandle &callout_handle)
Returns a response to a 'class-update' command.
void getClass(hooks::CalloutHandle &callout_handle) const
Returns a response to a 'class-get' command.
void getClassList(hooks::CalloutHandle &callout_handle) const
Returns a response to a 'class-list' command.
void delClass(hooks::CalloutHandle &callout_handle)
Processes and returns a response to 'class-del' command.
void addClass(hooks::CalloutHandle &callout_handle)
Returns a response to a 'class-add' command.
Thrown upon an attempt to update a class when dependency on KNOWN or UNKNOWN built-in class is remove...
Thrown upon an attempt to delete a class which would result in leaving dangling dependencies.
uint16_t getFamily() const
Returns address family.
static CfgMgr & instance()
returns a single instance of Configuration Manager
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
Parser for a single client class definition.
void parse(ClientClassDictionaryPtr &class_dictionary, isc::data::ConstElementPtr client_class_def, uint16_t family, bool append_error_position=true, bool check_dependencies=true)
Parses an entry that describes single client class definition.
void checkParametersSupported(const isc::data::ConstElementPtr &class_def_cfg, const uint16_t family)
Iterates over class parameters and checks if they are supported.
Maintains a list of ClientClassDef's.
Per-packet callout handle.
void getArgument(const std::string &name, T &value) const
Get argument.
void setArgument(const std::string &name, T value)
Set argument.
RAII class creating a critical section.
Defines classes for storing client class definitions.
Parsers for client class definitions.
This file contains several functions and constants that are used for handling commands and responses ...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
isc::log::Logger class_cmds_logger("class-cmds-hooks")
const int CONTROL_RESULT_EMPTY
Status code indicating that the specified command was completed correctly, but failed to produce any ...
const int CONTROL_RESULT_ERROR
Status code indicating a general failure.
std::string parseCommandWithArgs(ConstElementPtr &arg, ConstElementPtr command)
Parses the given command into a string containing the command name and an ElementPtr containing the m...
ConstElementPtr createAnswer()
Creates a standard config/command level success answer message (i.e.
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< ClientClassDef > ClientClassDefPtr
a pointer to an ClientClassDef
boost::shared_ptr< ClientClassDictionary > ClientClassDictionaryPtr
Defines a pointer to a ClientClassDictionary.
boost::shared_ptr< ClientClassDefList > ClientClassDefListPtr
Defines a pointer to a ClientClassDefList.
Defines the logger used by the top-level component of kea-lfc.