Kea
1.5.0
d2_controller.cc
Go to the documentation of this file.
1
// Copyright (C) 2013-2017 Internet Systems Consortium, Inc. ("ISC")
2
//
3
// This Source Code Form is subject to the terms of the Mozilla Public
4
// License, v. 2.0. If a copy of the MPL was not distributed with this
5
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7
#include <config.h>
8
9
#include <
d2/d2_controller.h
>
10
#include <
d2/d2_process.h
>
11
#include <
d2/parser_context.h
>
12
13
#include <stdlib.h>
14
15
using namespace
isc::process
;
16
17
namespace
isc
{
18
namespace
d2 {
19
22
const
char
* D2Controller::d2_app_name_ =
"DhcpDdns"
;
23
25
const
char
* D2Controller::d2_bin_name_ =
"kea-dhcp-ddns"
;
26
27
DControllerBasePtr
&
28
D2Controller::instance() {
29
// If the instance hasn't been created yet, create it. Note this method
30
// must use the base class singleton instance methods.
31
if
(!getController()) {
32
DControllerBasePtr
controller_ptr(
new
D2Controller
());
33
setController(controller_ptr);
34
}
35
36
return
(getController());
37
}
38
39
DProcessBase
* D2Controller::createProcess() {
40
// Instantiate and return an instance of the D2 application process. Note
41
// that the process is passed the controller's io_service.
42
return
(
new
D2Process
(getAppName().c_str(), getIOService()));
43
}
44
45
D2Controller::D2Controller()
46
:
DControllerBase
(d2_app_name_, d2_bin_name_) {
47
}
48
49
isc::data::ConstElementPtr
50
D2Controller::parseFile(
const
std::string& file_name) {
51
isc::data::ConstElementPtr
elements;
52
53
// Read contents of the file and parse it as JSON
54
D2ParserContext
parser;
55
elements = parser.
parseFile
(file_name,
D2ParserContext::PARSER_DHCPDDNS
);
56
if
(!elements) {
57
isc_throw
(
isc::BadValue
,
"no configuration found in file"
);
58
}
59
60
return
(elements);
61
}
62
63
D2Controller::~D2Controller
() {
64
}
65
66
std::string
67
D2Controller::getVersionAddendum
() {
68
std::stringstream stream;
69
// Currently the only dependency D2 adds to base is cryptolink
70
stream <<
isc::cryptolink::CryptoLink::getVersion
() << std::endl;
71
return
(stream.str());
72
73
}
74
75
};
// end namespace isc::d2
76
};
// end namespace isc
isc::cryptolink::CryptoLink::getVersion
static std::string getVersion()
Get version string.
Definition:
botan1_link.cc:80
isc::d2::D2Controller
Process Controller for D2 Process This class is the DHCP-DDNS specific derivation of DControllerBase.
Definition:
d2_controller.h:25
isc::process::DControllerBase
Application Controller.
Definition:
d_controller.h:104
isc::d2::D2ParserContext::PARSER_DHCPDDNS
@ PARSER_DHCPDDNS
Used for parsing content of DhcpDdns.
Definition:
d2/parser_context.h:52
isc::d2::D2Controller::~D2Controller
virtual ~D2Controller()
Destructor.
Definition:
d2_controller.cc:63
d2_controller.h
isc::d2::D2Controller::getVersionAddendum
virtual std::string getVersionAddendum()
Returns version info specific to D2.
Definition:
d2_controller.cc:67
isc::d2::D2ParserContext::parseFile
isc::data::ElementPtr parseFile(const std::string &filename, ParserType parser_type)
Run the parser on the file specified.
Definition:
d2/parser_context.cc:33
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition:
agent_parser.cc:144
isc::d2::D2Process
DHCP-DDNS Application Process.
Definition:
d2_process.h:24
isc_throw
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Definition:
exceptions/exceptions.h:192
isc::BadValue
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Definition:
exceptions/exceptions.h:132
isc::process::DControllerBasePtr
boost::shared_ptr< DControllerBase > DControllerBasePtr
Definition:
d_controller.h:78
isc::process::DProcessBase
Application Process Interface.
Definition:
d_process.h:67
d2_process.h
isc::process
Definition:
config_base.cc:16
parser_context.h
isc::d2::D2ParserContext
Evaluation context, an interface to the expression evaluation.
Definition:
d2/parser_context.h:37
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition:
data.h:23
src
bin
d2
d2_controller.cc
Generated on Fri Jul 10 2020 09:12:51 for Kea by
1.8.18