Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Kea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
416
Issues
416
List
Boards
Labels
Service Desk
Milestones
Merge Requests
67
Merge Requests
67
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ISC Open Source Projects
Kea
Commits
ce6e519c
Commit
ce6e519c
authored
Aug 27, 2014
by
Marcin Siodelski
Browse files
Options
Browse Files
Download
Plain Diff
[master] Merge branch 'trac3501'
parents
c00f72b2
05d934f2
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
74 additions
and
98 deletions
+74
-98
src/bin/dhcp4/dhcp4_messages.mes
src/bin/dhcp4/dhcp4_messages.mes
+5
-4
src/bin/dhcp4/json_config_parser.cc
src/bin/dhcp4/json_config_parser.cc
+7
-9
src/bin/dhcp4/kea_controller.cc
src/bin/dhcp4/kea_controller.cc
+24
-37
src/bin/dhcp6/dhcp6_messages.mes
src/bin/dhcp6/dhcp6_messages.mes
+5
-4
src/bin/dhcp6/json_config_parser.cc
src/bin/dhcp6/json_config_parser.cc
+7
-9
src/bin/dhcp6/kea_controller.cc
src/bin/dhcp6/kea_controller.cc
+24
-33
src/lib/cc/data.cc
src/lib/cc/data.cc
+2
-2
No files found.
src/bin/dhcp4/dhcp4_messages.mes
View file @
ce6e519c
...
...
@@ -50,10 +50,11 @@ new configuration. It is output during server startup, and when an updated
configuration is committed by the administrator. Additional information
may be provided.
% DHCP4_CONFIG_LOAD_FAIL failed to load configuration: %1
This critical error message indicates that the initial DHCPv4
configuration has failed. The server will start, but nothing will be
served until the configuration has been corrected.
% DHCP4_CONFIG_LOAD_FAIL configuration error using file: %1, reason: %2
This error message indicates that the DHCPv4 configuration has failed.
If this is an initial configuration (during server's startup) the server
will fail to start. If this is a dynamic reconfiguration attempt the
server will continue to use an old configuration.
% DHCP4_CONFIG_NEW_SUBNET a new subnet has been added to configuration: %1
This is an informational message reporting that the configuration has
...
...
src/bin/dhcp4/json_config_parser.cc
View file @
ce6e519c
...
...
@@ -594,8 +594,7 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set) {
}
catch
(
const
isc
::
Exception
&
ex
)
{
LOG_ERROR
(
dhcp4_logger
,
DHCP4_PARSER_FAIL
)
.
arg
(
config_pair
.
first
).
arg
(
ex
.
what
());
answer
=
isc
::
config
::
createAnswer
(
1
,
string
(
"Configuration parsing failed: "
)
+
ex
.
what
());
answer
=
isc
::
config
::
createAnswer
(
1
,
ex
.
what
());
// An error occured, so make sure that we restore original data.
rollback
=
true
;
...
...
@@ -603,8 +602,8 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set) {
}
catch
(...)
{
// For things like bad_cast in boost::lexical_cast
LOG_ERROR
(
dhcp4_logger
,
DHCP4_PARSER_EXCEPTION
).
arg
(
config_pair
.
first
);
answer
=
isc
::
config
::
createAnswer
(
1
,
string
(
"Configuration parsing failed"
)
);
answer
=
isc
::
config
::
createAnswer
(
1
,
"undefined configuration"
" processing error"
);
// An error occured, so make sure that we restore original data.
rollback
=
true
;
...
...
@@ -636,14 +635,13 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set) {
}
catch
(
const
isc
::
Exception
&
ex
)
{
LOG_ERROR
(
dhcp4_logger
,
DHCP4_PARSER_COMMIT_FAIL
).
arg
(
ex
.
what
());
answer
=
isc
::
config
::
createAnswer
(
2
,
string
(
"Configuration commit failed: "
)
+
ex
.
what
());
answer
=
isc
::
config
::
createAnswer
(
2
,
ex
.
what
());
rollback
=
true
;
}
catch
(...)
{
// For things like bad_cast in boost::lexical_cast
LOG_ERROR
(
dhcp4_logger
,
DHCP4_PARSER_COMMIT_EXCEPTION
);
answer
=
isc
::
config
::
createAnswer
(
2
,
string
(
"Configuration commit failed"
)
);
answer
=
isc
::
config
::
createAnswer
(
2
,
"undefined configuration"
" parsing error"
);
rollback
=
true
;
}
}
...
...
@@ -659,7 +657,7 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set) {
getConfigSummary
(
Configuration
::
CFGSEL_ALL4
));
// Everything was fine. Configuration is successful.
answer
=
isc
::
config
::
createAnswer
(
0
,
"Configuration
committed
."
);
answer
=
isc
::
config
::
createAnswer
(
0
,
"Configuration
successful
."
);
return
(
answer
);
}
...
...
src/bin/dhcp4/kea_controller.cc
View file @
ce6e519c
...
...
@@ -56,12 +56,8 @@ void configure(const std::string& file_name) {
// Read contents of the file and parse it as JSON
json
=
isc
::
data
::
Element
::
fromJSONFile
(
file_name
,
true
);
if
(
!
json
)
{
LOG_ERROR
(
dhcp4_logger
,
DHCP4_CONFIG_LOAD_FAIL
)
.
arg
(
"Config file "
+
file_name
+
" missing or empty."
);
isc_throw
(
isc
::
BadValue
,
"Unable to process JSON configuration"
" file: "
<<
file_name
);
isc_throw
(
isc
::
BadValue
,
"no configuration found"
);
}
// Let's configure logging before applying the configuration,
...
...
@@ -75,46 +71,37 @@ void configure(const std::string& file_name) {
// Get Dhcp4 component from the config
dhcp4
=
json
->
get
(
"Dhcp4"
);
if
(
!
dhcp4
)
{
LOG_ERROR
(
dhcp4_logger
,
DHCP4_CONFIG_LOAD_FAIL
)
.
arg
(
"Config file "
+
file_name
+
" does not include 'Dhcp4'"
" entry."
);
isc_throw
(
isc
::
BadValue
,
"Unable to process JSON configuration"
" file: "
<<
file_name
);
isc_throw
(
isc
::
BadValue
,
"no mandatory 'Dhcp4' entry in"
" the configuration"
);
}
// Use parsed JSON structures to configure the server
result
=
ControlledDhcpv4Srv
::
processCommand
(
"config-reload"
,
dhcp4
);
if
(
!
result
)
{
// Undetermined status of the configuration. This should never
// happen, but as the configureDhcp4Server returns a pointer, it is
// theoretically possible that it will return NULL.
isc_throw
(
isc
::
BadValue
,
"undefined result of "
"processCommand(
\"
config-reload
\"
, dhcp4)"
);
}
}
catch
(
const
std
::
exception
&
ex
)
{
LOG_ERROR
(
dhcp4_logger
,
DHCP4_CONFIG_LOAD_FAIL
).
arg
(
ex
.
what
());
isc_throw
(
isc
::
BadValue
,
"Unable to process JSON configuration file: "
<<
file_name
);
}
// Now check is the returned result is successful (rcode=0) or not
// (see @ref isc::config::parseAnswer).
int
rcode
;
isc
::
data
::
ConstElementPtr
comment
=
isc
::
config
::
parseAnswer
(
rcode
,
result
);
if
(
rcode
!=
0
)
{
string
reason
=
comment
?
comment
->
stringValue
()
:
"no details available"
;
isc_throw
(
isc
::
BadValue
,
reason
);
}
if
(
!
result
)
{
// Undetermined status of the configuration. This should never happen,
// but as the configureDhcp4Server returns a pointer, it is
// theoretically possible that it will return NULL.
}
catch
(
const
std
::
exception
&
ex
)
{
LOG_ERROR
(
dhcp4_logger
,
DHCP4_CONFIG_LOAD_FAIL
)
.
arg
(
"Configuration failed: Undefined result of processCommand("
"config-reload, "
+
file_name
+
")"
);
isc_throw
(
isc
::
BadValue
,
"Configuration failed: Undefined result of "
"processCommand('config-reload', "
<<
file_name
<<
")"
);
}
// Now check is the returned result is successful (rcode=0) or not
isc
::
data
::
ConstElementPtr
comment
;
/// see @ref isc::config::parseAnswer
int
rcode
;
comment
=
isc
::
config
::
parseAnswer
(
rcode
,
result
);
if
(
rcode
!=
0
)
{
string
reason
=
""
;
if
(
comment
)
{
reason
=
comment
->
stringValue
();
}
LOG_ERROR
(
dhcp4_logger
,
DHCP4_CONFIG_LOAD_FAIL
).
arg
(
reason
);
isc_throw
(
isc
::
BadValue
,
"Failed to apply configuration: "
<<
reason
);
.
arg
(
file_name
).
arg
(
ex
.
what
());
isc_throw
(
isc
::
BadValue
,
"configuration error using file '"
<<
file_name
<<
"': "
<<
ex
.
what
());
}
}
...
...
src/bin/dhcp6/dhcp6_messages.mes
View file @
ce6e519c
...
...
@@ -46,10 +46,11 @@ new configuration. it is output during server startup, and when an updated
configuration is committed by the administrator. Additional information
may be provided.
% DHCP6_CONFIG_LOAD_FAIL failed to load configuration: %1
This critical error message indicates that the initial DHCPv6
configuration has failed. The server will start, but nothing will be
served until the configuration has been corrected.
% DHCP6_CONFIG_LOAD_FAIL configuration error using file: %1, reason: %2
This error message indicates that the DHCPv6 configuration has failed.
If this is an initial configuration (during server's startup) the server
will fail to start. If this is a dynamic reconfiguration attempt the
server will continue to use an old configuration.
% DHCP6_CONFIG_NEW_SUBNET a new subnet has been added to configuration: %1
This is an informational message reporting that the configuration has
...
...
src/bin/dhcp6/json_config_parser.cc
View file @
ce6e519c
...
...
@@ -798,16 +798,15 @@ configureDhcp6Server(Dhcpv6Srv&, isc::data::ConstElementPtr config_set) {
}
catch
(
const
isc
::
Exception
&
ex
)
{
LOG_ERROR
(
dhcp6_logger
,
DHCP6_PARSER_FAIL
)
.
arg
(
config_pair
.
first
).
arg
(
ex
.
what
());
answer
=
isc
::
config
::
createAnswer
(
1
,
string
(
"Configuration parsing failed: "
)
+
ex
.
what
());
answer
=
isc
::
config
::
createAnswer
(
1
,
ex
.
what
());
// An error occured, so make sure that we restore original data.
rollback
=
true
;
}
catch
(...)
{
// for things like bad_cast in boost::lexical_cast
LOG_ERROR
(
dhcp6_logger
,
DHCP6_PARSER_EXCEPTION
).
arg
(
config_pair
.
first
);
answer
=
isc
::
config
::
createAnswer
(
1
,
string
(
"Configuration parsing failed"
)
);
answer
=
isc
::
config
::
createAnswer
(
1
,
"undefined configuration"
" processing error"
);
// An error occured, so make sure that we restore original data.
rollback
=
true
;
}
...
...
@@ -835,15 +834,14 @@ configureDhcp6Server(Dhcpv6Srv&, isc::data::ConstElementPtr config_set) {
}
catch
(
const
isc
::
Exception
&
ex
)
{
LOG_ERROR
(
dhcp6_logger
,
DHCP6_PARSER_COMMIT_FAIL
).
arg
(
ex
.
what
());
answer
=
isc
::
config
::
createAnswer
(
2
,
string
(
"Configuration commit failed:"
)
+
ex
.
what
());
answer
=
isc
::
config
::
createAnswer
(
2
,
ex
.
what
());
// An error occured, so make sure to restore the original data.
rollback
=
true
;
}
catch
(...)
{
// for things like bad_cast in boost::lexical_cast
LOG_ERROR
(
dhcp6_logger
,
DHCP6_PARSER_COMMIT_EXCEPTION
);
answer
=
isc
::
config
::
createAnswer
(
2
,
string
(
"Configuration commit failed"
)
);
answer
=
isc
::
config
::
createAnswer
(
2
,
"undefined configuration"
" parsing error"
);
// An error occured, so make sure to restore the original data.
rollback
=
true
;
}
...
...
@@ -860,7 +858,7 @@ configureDhcp6Server(Dhcpv6Srv&, isc::data::ConstElementPtr config_set) {
getConfigSummary
(
Configuration
::
CFGSEL_ALL6
));
// Everything was fine. Configuration is successful.
answer
=
isc
::
config
::
createAnswer
(
0
,
"Configuration
committed
."
);
answer
=
isc
::
config
::
createAnswer
(
0
,
"Configuration
successful
."
);
return
(
answer
);
}
...
...
src/bin/dhcp6/kea_controller.cc
View file @
ce6e519c
...
...
@@ -60,12 +60,8 @@ void configure(const std::string& file_name) {
// Read contents of the file and parse it as JSON
json
=
isc
::
data
::
Element
::
fromJSONFile
(
file_name
,
true
);
if
(
!
json
)
{
LOG_ERROR
(
dhcp6_logger
,
DHCP6_CONFIG_LOAD_FAIL
)
.
arg
(
"Config file "
+
file_name
+
" missing or empty."
);
isc_throw
(
isc
::
BadValue
,
"Unable to process JSON configuration file:"
+
file_name
);
isc_throw
(
isc
::
BadValue
,
"no configuration found"
);
}
// Let's configure logging before applying the configuration,
...
...
@@ -80,43 +76,38 @@ void configure(const std::string& file_name) {
dhcp6
=
json
->
get
(
"Dhcp6"
);
if
(
!
dhcp6
)
{
LOG_ERROR
(
dhcp6_logger
,
DHCP6_CONFIG_LOAD_FAIL
)
.
arg
(
"Config file "
+
file_name
+
" does not include 'Dhcp6' entry."
);
isc_throw
(
isc
::
BadValue
,
"Unable to process JSON configuration file:"
+
file_name
);
isc_throw
(
isc
::
BadValue
,
"no mandatory 'Dhcp6' entry in"
" the configuration"
);
}
// Use parsed JSON structures to configure the server
result
=
ControlledDhcpv6Srv
::
processCommand
(
"config-reload"
,
dhcp6
);
if
(
!
result
)
{
// Undetermined status of the configuration. This should never
// happen, but as the configureDhcp6Server returns a pointer, it is
// theoretically possible that it will return NULL.
isc_throw
(
isc
::
BadValue
,
"undefined result of "
"processCommand(
\"
config-reload
\"
, dhcp6)"
);
}
}
catch
(
const
std
::
exception
&
ex
)
{
LOG_ERROR
(
dhcp6_logger
,
DHCP6_CONFIG_LOAD_FAIL
).
arg
(
ex
.
what
());
isc_throw
(
isc
::
BadValue
,
"Unable to process JSON configuration file:"
+
file_name
);
}
// Now check is the returned result is successful (rcode=0) or not
// (see @ref isc::config::parseAnswer).
int
rcode
;
isc
::
data
::
ConstElementPtr
comment
=
isc
::
config
::
parseAnswer
(
rcode
,
result
);
if
(
rcode
!=
0
)
{
string
reason
=
comment
?
comment
->
stringValue
()
:
"no details available"
;
isc_throw
(
isc
::
BadValue
,
reason
);
}
if
(
!
result
)
{
// Undetermined status of the configuration. This should never happen,
// but as the configureDhcp6Server returns a pointer, it is theoretically
// possible that it will return NULL.
}
catch
(
const
std
::
exception
&
ex
)
{
LOG_ERROR
(
dhcp6_logger
,
DHCP6_CONFIG_LOAD_FAIL
)
.
arg
(
"Configuration failed: Undefined result of configureDhcp6Server"
"() function after attempting to read "
+
file_name
);
return
;
.
arg
(
file_name
).
arg
(
ex
.
what
());
isc_throw
(
isc
::
BadValue
,
"configuration error using file '"
<<
file_name
<<
"': "
<<
ex
.
what
())
;
}
// Now check is the returned result is successful (rcode=0) or not
isc
::
data
::
ConstElementPtr
comment
;
/// see @ref isc::config::parseAnswer
int
rcode
;
comment
=
isc
::
config
::
parseAnswer
(
rcode
,
result
);
if
(
rcode
!=
0
)
{
string
reason
=
""
;
if
(
comment
)
{
reason
=
comment
->
stringValue
();
}
LOG_ERROR
(
dhcp6_logger
,
DHCP6_CONFIG_LOAD_FAIL
).
arg
(
reason
);
isc_throw
(
isc
::
BadValue
,
"Failed to apply configuration:"
<<
reason
);
}
}
/// @brief Signals handler for DHCPv6 server.
...
...
src/lib/cc/data.cc
View file @
ce6e519c
...
...
@@ -736,8 +736,8 @@ Element::fromJSONFile(const std::string& file_name,
if
(
!
infile
.
is_open
())
{
const
char
*
error
=
strerror
(
errno
);
isc_throw
(
InvalidOperation
,
"
F
ailed to read file '"
<<
file_name
<<
"'
, error:
"
<<
error
);
isc_throw
(
InvalidOperation
,
"
f
ailed to read file '"
<<
file_name
<<
"'
:
"
<<
error
);
}
return
(
fromJSON
(
infile
,
file_name
,
preproc
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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