mirror of
https://github.com/openkmip/pykmip
synced 2025-12-23 03:33:32 +00:00
Add server support for customizing the backend storage file
This change updates the server, adding in support for customizing the backend storage file used to store all server data. The server currently uses a simple SQLite database for storage. Prior versions of the server kept this database file in /tmp, to emphasize the testing focus of the server. This change loosens that restriction, now allowing users to customize where the database file lives. A new configuration option, 'database_path', has been added that will override the default /tmp location for the database file. This value can also be passed in if invoking the server via script using the '-d' flag.
This commit is contained in:
@@ -51,7 +51,8 @@ class KmipServerConfig(object):
|
||||
'policy_path',
|
||||
'enable_tls_client_auth',
|
||||
'tls_cipher_suites',
|
||||
'logging_level'
|
||||
'logging_level',
|
||||
'database_path'
|
||||
]
|
||||
|
||||
def set_setting(self, setting, value):
|
||||
@@ -93,8 +94,10 @@ class KmipServerConfig(object):
|
||||
self._set_enable_tls_client_auth(value)
|
||||
elif setting == 'tls_cipher_suites':
|
||||
self._set_tls_cipher_suites(value)
|
||||
else:
|
||||
elif setting == 'logging_level':
|
||||
self._set_logging_level(value)
|
||||
else:
|
||||
self._set_database_path(value)
|
||||
|
||||
def load_settings(self, path):
|
||||
"""
|
||||
@@ -179,6 +182,8 @@ class KmipServerConfig(object):
|
||||
self._set_logging_level(
|
||||
parser.get('server', 'logging_level')
|
||||
)
|
||||
if parser.has_option('server', 'database_path'):
|
||||
self._set_database_path(parser.get('server', 'database_path'))
|
||||
|
||||
def _set_hostname(self, value):
|
||||
if isinstance(value, six.string_types):
|
||||
@@ -334,3 +339,14 @@ class KmipServerConfig(object):
|
||||
"The logging level must be a string representing a valid "
|
||||
"logging level."
|
||||
)
|
||||
|
||||
def _set_database_path(self, value):
|
||||
if not value:
|
||||
self.settings['database_path'] = None
|
||||
elif isinstance(value, six.string_types):
|
||||
self.settings['database_path'] = value
|
||||
else:
|
||||
raise exceptions.ConfigurationError(
|
||||
"The database path, if specified, must be a valid path to a "
|
||||
"SQLite database file."
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user