-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
callout_handle.getArgument("name", command_name);
if (command_name == "dhcp-enable") {
service_->adjustNetworkState();
+ } else if (command_name == "status-get") {
+ // Get the response.
+ ConstElementPtr response;
+ callout_handle.getArgument("response", response);
+ if (!response || (response->getType() != Element::map)) {
+ return;
+ }
+ // Get the arguments item from the response.
+ ConstElementPtr resp_args = response->get("arguments");
+ if (!resp_args || (resp_args->getType() != Element::map)) {
+ return;
+ }
+ // Add the ha state to arguments.
+ std::string state = stateToString(service_->getCurrState());
+ ElementPtr mutable_resp_args =
+ boost::const_pointer_cast<Element>(response);
+ mutable_resp_args->set("ha-state", Element::create(state));
}
}
-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
/// service is enabled in a state for which this is not allowed, e.g.
/// waiting, syncing etc. We don't want to rely on the HA partner to do
/// a correct thing in that respect.
+ /// It too adds the HA state to "status-get" commands.
///
/// @param callout_handle Callout handle provided to the callout.
void commandProcessed(hooks::CalloutHandle& callout_handle);