Respect VIRTUAL_BMC for non-default config path
Adds the ability to override default configuration file location by exporting the ``VIRTUALBMC_CONFIG`` variable, pointing to the desired config file, into ``vbmcd`` and ``vbmc`` processes environment. Change-Id: I89f7cab09f4c0b2c1d2517c4b6f607ed291f235c
This commit is contained in:
parent
bff0e6c73a
commit
216b60c961
@ -10,6 +10,11 @@ does all the heavy-lifting (speaks IPMI, calls libvirt) while ``vbmc``
|
||||
client is merely a command-line tool sending commands to the server and
|
||||
rendering responses to the user.
|
||||
|
||||
Both tools can optionally consume optional configuration file, which
|
||||
defaults to ``$HOME/.vbmc/virtualbmc.conf``,
|
||||
``/etc/virtualbmc/virtualbmc.conf``, but can be overridden with the
|
||||
``VIRTUALBMC_CONFIG`` environment variable.
|
||||
|
||||
You should set up your systemd to launch the ``vbmcd`` server on system
|
||||
start up or you can just run ``vbmcd`` from command line if you do not need
|
||||
the tool running persistently on the system. Once the server is up and
|
||||
|
5
releasenotes/notes/add-config-env-8287bea486821653.yaml
Normal file
5
releasenotes/notes/add-config-env-8287bea486821653.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
features:
|
||||
- |
|
||||
Adds the ability to override default configuration file location by
|
||||
exporting the ``$VIRTUALBMC_CONFIG`` variable, pointing to the desired
|
||||
config file, into ``vbmcd`` and ``vbmc`` processes environment.
|
@ -19,15 +19,13 @@ from virtualbmc import utils
|
||||
__all__ = ['get_config']
|
||||
|
||||
_CONFIG_FILE_PATHS = (
|
||||
os.environ.get('VIRTUALBMC_CONFIG', ''),
|
||||
os.path.join(os.path.expanduser('~'), '.vbmc', 'virtualbmc.conf'),
|
||||
'/etc/virtualbmc/virtualbmc.conf')
|
||||
|
||||
CONFIG_FILE = next((x for x in _CONFIG_FILE_PATHS if os.path.exists(x)), '')
|
||||
|
||||
CONFIG = None
|
||||
CONFIG_FILE = ''
|
||||
for config in _CONFIG_FILE_PATHS:
|
||||
if os.path.exists(config):
|
||||
CONFIG_FILE = config
|
||||
break
|
||||
|
||||
|
||||
class VirtualBMCConfig(object):
|
||||
|
Loading…
Reference in New Issue
Block a user