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:
Ilya Etingof 2019-04-09 13:34:12 +02:00
parent bff0e6c73a
commit 216b60c961
3 changed files with 13 additions and 5 deletions

View File

@ -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 client is merely a command-line tool sending commands to the server and
rendering responses to the user. 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 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 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 the tool running persistently on the system. Once the server is up and

View 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.

View File

@ -19,15 +19,13 @@ from virtualbmc import utils
__all__ = ['get_config'] __all__ = ['get_config']
_CONFIG_FILE_PATHS = ( _CONFIG_FILE_PATHS = (
os.environ.get('VIRTUALBMC_CONFIG', ''),
os.path.join(os.path.expanduser('~'), '.vbmc', 'virtualbmc.conf'), os.path.join(os.path.expanduser('~'), '.vbmc', 'virtualbmc.conf'),
'/etc/virtualbmc/virtualbmc.conf') '/etc/virtualbmc/virtualbmc.conf')
CONFIG_FILE = next((x for x in _CONFIG_FILE_PATHS if os.path.exists(x)), '')
CONFIG = None CONFIG = None
CONFIG_FILE = ''
for config in _CONFIG_FILE_PATHS:
if os.path.exists(config):
CONFIG_FILE = config
break
class VirtualBMCConfig(object): class VirtualBMCConfig(object):