Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
2364ac9a
Commit
2364ac9a
authored
Mar 02, 2017
by
Marcin Siodelski
Browse files
[5165] Control agent uses configured server address and port.
parent
fe19cac6
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/bin/agent/ca_process.cc
View file @
2364ac9a
...
...
@@ -9,6 +9,7 @@
#include
<agent/ca_response_creator_factory.h>
#include
<agent/ca_log.h>
#include
<asiolink/io_address.h>
#include
<asiolink/io_error.h>
#include
<cc/command_interpreter.h>
#include
<http/listener.h>
#include
<boost/pointer_cast.hpp>
...
...
@@ -21,8 +22,6 @@ using namespace isc::process;
/// @todo: remove once 5134 is merged.
namespace
{
const
IOAddress
SERVER_ADDRESS
(
"127.0.0.1"
);
const
unsigned
short
SERVER_PORT
=
8081
;
const
long
REQUEST_TIMEOUT
=
10000
;
}
...
...
@@ -53,10 +52,27 @@ CtrlAgentProcess::run() {
// answer to specific request.
HttpResponseCreatorFactoryPtr
rcf
(
new
CtrlAgentResponseCreatorFactory
());
DCfgContextBasePtr
base_ctx
=
getCfgMgr
()
->
getContext
();
CtrlAgentCfgContextPtr
ctx
=
boost
::
dynamic_pointer_cast
<
CtrlAgentCfgContext
>
(
base_ctx
);
if
(
!
ctx
)
{
isc_throw
(
Unexpected
,
"Interal logic error: bad context type"
);
}
/// @todo: If the parameter is a hostname, we need to resolve it.
IOAddress
server_address
(
"::"
);
try
{
server_address
=
IOAddress
(
ctx
->
getHttpHost
());
}
catch
(
const
IOError
&
e
)
{
isc_throw
(
BadValue
,
"Failed to convert "
<<
ctx
->
getHttpHost
()
<<
" to IP address:"
<<
e
.
what
());
}
uint16_t
server_port
=
ctx
->
getHttpPort
();
// Create http listener. It will open up a TCP socket and be prepared
// to accept incoming connection.
HttpListener
http_listener
(
*
getIoService
(),
SERVER_ADDRESS
,
SERVER_PORT
,
rcf
,
REQUEST_TIMEOUT
);
HttpListener
http_listener
(
*
getIoService
(),
server_address
,
server_port
,
rcf
,
REQUEST_TIMEOUT
);
// Instruct the http listener to actually open socket, install callback
// and start listening.
...
...
@@ -64,7 +80,7 @@ CtrlAgentProcess::run() {
// Ok, seems we're good to go.
LOG_INFO
(
agent_logger
,
CTRL_AGENT_HTTP_SERVICE_STARTED
)
.
arg
(
SERVER_ADDRESS
.
toText
()).
arg
(
SERVER_PORT
);
.
arg
(
server_address
.
toText
()).
arg
(
server_port
);
// Let's process incoming data or expiring timers in a loop until
// shutdown condition is detected.
...
...
src/bin/agent/simple_parser.cc
View file @
2364ac9a
...
...
@@ -33,7 +33,7 @@ namespace agent {
///
/// These are global Control Agent parameters.
const
SimpleDefaults
AgentSimpleParser
::
AGENT_DEFAULTS
=
{
{
"http-host"
,
Element
::
string
,
"
localhost
"
},
{
"http-host"
,
Element
::
string
,
"
127.0.0.1
"
},
{
"http-port"
,
Element
::
integer
,
"8000"
}
};
...
...
src/bin/agent/tests/ca_controller_unittests.cc
View file @
2364ac9a
...
...
@@ -16,8 +16,11 @@ using namespace isc::process;
namespace
{
/// @brief Valid Control Agent Config used in tests.
/// @todo Use actual config once configuration parsing is implemented.
const
char
*
valid_agent_config
=
"{ }"
;
const
char
*
valid_agent_config
=
"{"
"
\"
http-host
\"
:
\"
127.0.0.1
\"
,"
"
\"
http-port
\"
: 8081"
"}"
;
/// @brief test fixture class for testing CtrlAgentController class. This
/// class derives from DControllerTest and wraps CtrlAgentController. Much
...
...
src/bin/agent/tests/ca_process_unittests.cc
View file @
2364ac9a
...
...
@@ -29,6 +29,9 @@ public:
CtrlAgentProcessTest
()
:
CtrlAgentProcess
(
"agent-test"
,
IOServicePtr
(
new
isc
::
asiolink
::
IOService
()))
{
CtrlAgentCfgContextPtr
ctx
=
getCtrlAgentCfgMgr
()
->
getCtrlAgentCfgContext
();
ctx
->
setHttpHost
(
"127.0.0.1"
);
ctx
->
setHttpPort
(
8081
);
}
/// @brief Destructor
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment