Commit Graph

40 Commits (master)

Author SHA1 Message Date
Kaifeng Wang 132fe3ce24 Restore pep8 checking on import order
Currently not checking import orders, this patch restore it.

Change-Id: I101814591eaffb694a090aa640ca9ac70db2ecf1
2020-04-27 15:24:17 +02:00
Sean McGinnis 0947b53bdf
Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: I436eab174b823c1e0e028529fed9009cc38776bc
Signed-off-by: Sean McGinnis <>
2020-04-18 12:01:29 -05:00
Riccardo Pittau 4f2aa4540b [trivial] change vbmc error message
Changes error message received if client fails to connect to vbmcd.

Change-Id: Ide55ef32b456f6ebb3c8b28001d7cf1557d7179e
2020-03-09 08:53:15 +01:00
Ilya Etingof bddca37807 Remove `vbmc` feature of starting up `vbmcd`
Removes the backward compatibility feature of `vbmc` to
automatically start up `vbmcd` daemon process if it is not running.
From now on, `vbmcd` should be started by systemd or some other

Change-Id: I931751d7cdd591cae6f9a1bca8d72a4b3935a45f
2020-03-06 09:12:17 +01:00
Ilya Etingof 2651f13f28 Fix hanging on shell-pipe
Properly closes standard I/O streams to prevent shell-piped
processes from hanging infinitely on a dead pipe.

Change-Id: Id9dedac4f778cf37d626f2777d519f73cc4b5f2c
Story: 2007219
Task: 38471
2020-03-06 09:08:56 +01:00
William Caban 0884014df2 Fix error triggered by reading intergers as string from virtualbmc.conf
Add validation to fix error of "'<' not supported between
instances of 'str' and 'int'" when defining server_response_timeout
value in virtualbmc.conf. The error is trigger because the
config parameters from the configuration file are read as strings
and everything else assume that value is an integer (as the default of 5000).

The patch also include validations for server_spawn_wait and server_port to
check the values are valid integers.

Updates test_config.test_validate for test coverage

Task: 37947
Story: 2007066

Change-Id: Ie4e74585d8e14bd73e5e30b21b4dd7bd7d88f13d
Signed-off-by: William Caban <>
2020-01-03 12:56:56 -05:00
Riccardo Pittau 26b7ff6063 Stop using six library
Since we've dropped support for Python 2.7, it's time to look at
the bright future that Python 3.x will bring and stop forcing
compatibility with older versions.
This patch removes the six library from requirements, not
looking back.

Change-Id: Iff319bfedc2c20c139419bb625aa5de83de93538
2019-12-02 17:48:54 +01:00
Ilya Etingof 8c407df1a3 Enable debug logging in tests
Since log messages interpolation is frequently postponed
till the logging time, occasional bugs in message
templates may go unnoticed.

This patch attempts to enable full logging in unit tests.

Unfortunately, exceptions caused by interpolation failures
get inhibited by the logging module code so they do not
actually fail tests. But at least those exceptions are
noticeable on stdout.

Change-Id: I1b32476c5bb631cef9b1269effd05a88a9fafd2d
2018-08-07 11:27:29 +02:00
Zuul 3ce2501ca1 Merge "Make server spawn and response times configurable" 2018-06-20 11:02:05 +00:00
Zuul a800f72812 Merge "Domain `start` command accepts multiple domain names" 2018-06-20 10:59:59 +00:00
Zuul d8e66cb06a Merge "Fix power status command error reporting" 2018-06-18 19:49:51 +00:00
Ilya Etingof c70d2aa4df Domain `start` command accepts multiple domain names
This is a followup patch to [1] making the `start` command accepting
multiple domain names in the same way as `stop` command does.

Possible duplicate domain names given on the command line removed
to avoid runtime errors.


Change-Id: I48987d01187e4b4878e5d501d263e958be4e7693
2018-06-18 13:28:41 +02:00
Ilya Etingof cf52ba4f1f Make server spawn and response times configurable
This is a followup patch to [1] introducing configurable timing
parameters for the client to wait for automatic vbmcd start up and
vbmcd response timeout.


Change-Id: Id1cdcecd8d407b31dc69166fb0fda555fc4a679f
2018-06-18 12:27:59 +02:00
Ilya Etingof 7ace4293e9 multiprocess server, ZMQ-based management cli tool
Original design of the VirtualBMC tool was that user manages
config files for individual VirtualBMC (via a cli tool), then
requests the tool to start the instances representing
individual VirtualBMC instances (via the cli tool). Then
the instances become independent processes. The only way
to know their whereabouts is through the pidfiles
they maintain.

There were certain practical inconveniences with the
original design, namely:

* Cumbersome to start/stop/monitor free-standing
  vBMC instances processes
* No two-way communication between the parent process
  and the VirtualBMC instances what makes child state check
  or modification unnecessary difficult

This commit turns server part of the tool into a single
process spawning multiple children processes and herding
them via ZMQ client/server.

The parent process runs server part of the control
interface, maintains persistent VirtualBMC instances
configuration and ensures all its children are alive
and kicking. Each VirtualBMC instance is still a separate
parent fork.

If child dies, parent respawns it right away. If parent
is about to die, it tries its best to kill all the
prospective orphans.

This new implementation tries to stay compatible with
the original one in part of `vbmc` tool CLI interface
and behaviour. Whenever it can't connect to the `vbmcd`
it tries to fork and spawn the daemon behind the scenes.

While the threading design for this tool might look better,
the underlying pyghmi library is apparently rather
complicated to use its concurrency capabilities reliably.
The other minor consideration is that running multiple
processes leverages CPU-based concurrency.

Other changes:

* The `start` command now accepts more than one domains
  to be started

Change-Id: Ie10f4598c7039a7afa9b45d01df3b3c3db252c1d
Story: 1751570
Task:  12057
2018-05-11 17:29:47 +02:00
Ilya Etingof ba4ced4657 Fix power status command error reporting
With pyghmi API, some methods return generic IPMI error
codes, while some return payload values. This patch fixes
the `get_power_state()` method to raise exception instead
of returning IPMI error code because the latter goes against
pyghmi API.

Change-Id: If30c1ee49982a7a1198a39a7afdc1edc2c516078
2018-05-11 11:36:27 +02:00
Ilya Etingof 30e168e792 Revert "Add Serial-over-LAN (SOL) support"
This reverts commit 9f7bfb9f6b.

It seems that the SOL feature introduced by patch [1] led to
the VirtualBMC daemons leaking two file descriptors (ends of
UNIX pipe, perhaps) per each IPMI query it processes. Given the
default ulimit of 1024 open files per process, in circa 500 IPMI
queries vbmc renders itself not quite functional.

The quick research of the problem reveals that the leak comes
to life once the virEventRegisterDefaultImpl() call is made
which prepares libvirt for asynchronous operations over a dedicated
connection to libvirtd. Even though once SOL session is gone and
libvirt is cleaned up (well, dedicated connection is closed),
the libvirt connection, which is open every time when IPMI query
comes in, leaks 2 FDs per query.

This problem has been reported about some other libvirt application
in the past [2] so the problem might go away if we turn the IPMI
part of vbmc to the asynchronous operation mode as well.

Another observation is that libvirt API may not [3] offer a full
clean up upon exiting from the asynchronous operation mode.

To summarize: the real cause of this behaviour is not yet properly


Change-Id: Id599f62e0eaf8c96e4552d2cd263f93155f8afa6
Story: 2001976
Task: 19585
2018-05-09 11:53:57 +02:00
Ilya Etingof 72f873d9f4 Report libvirt failures as IPMI-retryable
It seems that at times of high concurrency, libvirt
occassionally fails on supposedly some race condition
what leads to client failure (e.g. Ironic). This change
is to tell Ironic that it should try some more times rather
than bailing out right away.

Change-Id: I5848d721305c887fb7803ca4b302565aa4b83c88
Story: #2001798
Task: #15076
2018-05-02 18:25:55 +02:00
Akira Yoshiyama 9f7bfb9f6b Add Serial-over-LAN (SOL) support
This patch adds some methods to support Serial-over-LAN capability.
We'll be able to connect serial console of a domain with
"ipmitool sol activate" command.
SOL capability requires a persistent libvirt connection, so this
patchset adds libvirt_open.get_conn() method and use it.

Change-Id: I7f9dfbd2b3eb1320be755bade2f97b9f0621d409
2018-03-20 23:35:37 +09:00
Zuul 3a25646abe Merge "Migrate CLI to cliff" 2018-03-15 14:28:03 +00:00
Ilya Etingof eaf944f09e Migrate CLI to cliff
This patch replaces the use of argparse module
by the cliff package. The rationale is that
cliff infrastructure is easier to use and more
functional. Some other OpenStack projects seem
to migrate to cliff already.

Change-Id: Ib2185dad50e64de354222669d2e65f411ddc96a4
Closes-Bug: #1752911
2018-03-14 18:26:23 +01:00
Jacek Tomasiak 0e74342899 Remove devices/*/boot when setting bootdev
"boot" entries under "devices/*" are mutually exclusive with those
under "os". If such entries are present, vbmc fails when adding "boot"
entry under "os".

Closes-Bug: #1746983
Change-Id: I357d3b8a92ee764e6f47f564fdef54d3a79f0782
2018-02-05 11:31:13 +01:00
Zhijiang Hu d05eb2475b Support power reset command
Some OpenStack installer such as [1] use power reset when switching
from bootstrap kernel to OS installation kernel. So we'd better
implement this.


Change-Id: I60df3a31c7600d35d50212538fbfffd22bf7c729
Signed-off-by: Zhijiang Hu <>
2018-01-18 09:54:39 +08:00
Vu Cong Tuan 430fb92bbb Replace assertRaisesRegexp with assertRaisesRegex
assertRaisesRegexp was renamed to assertRaisesRegex in Py3.2
For more details, please check:

Change-Id: Ie23bfb774afa2894a6c69f1be79e2d6d236ec2b0
2017-06-03 11:31:31 +07:00
John L. Villalovos ef2c8818e6 Fix TypeError when writing config file in Python 3
When using Python 3 would have a type error when writing an integer
value to the config file. Convert it to a string before writing it.

Change-Id: I89f9f4983d497adc7ac89f9e89e648f58bed3510
Closes-Bug: #1670441
2017-03-06 10:40:07 -08:00
xiexs a2106ef58b Adds power diag support to vbmc
Also enhance vbmc to support power diag, i.e.
- Pulse a diagnostic interrupt (NMI) directly to
  the processor(s)

Change-Id: I7b1998d36fbcbbab3870085dd5a476f77853b3e4
2017-02-02 11:22:10 +00:00
xiexs dceecaf7c0 Adds power_soft support to vbmc
As the ipmitool supports the power soft, and meanwhile
the spec [1] is trying to support this feature
to ironic node. Correspondingly we should enhance
our vbmc to support it as well.

[1] I3dc6561ea7cecf8b8d998717fefa9cf8001d0f4c

Change-Id: I449a708f59c812bf93ae85e09f365bb23352d770
2017-02-02 11:22:07 +00:00
Jenkins bd3fca16a7 Merge "Return proper errors on BMC action failures" 2016-12-16 11:39:27 +00:00
Jenkins 2fd7500279 Merge "Add support for a "global" configuration file" 2016-12-14 21:50:20 +00:00
Lucas Alvares Gomes 0df3a0ed52 Return proper errors on BMC action failures
Prior to this patch VirtualBMC methods would return None on most on most
failures and that would get translated into return code 0 by pyghmi. So,
even when a node failed to stop, start, get or set the boot device the
error was never propagated to the IPMI client.

This patch changes such behavior to include proper errors upon failures.

Change-Id: If761f8b56c16d265c5e6917e4ee7352126b0c90e
Closes-Bug: #1647229
2016-12-12 12:10:23 +00:00
Lucas Alvares Gomes ba679b9109 Add support for a "global" configuration file
Prior to this patch, virutalbmc could only be configured in a per-user
basis. The configuration file as well the path where the VBMCs are going
to be created always lived in the users home directory.

This patch is adding support for a "global" configuration file which
will live in /etc/virtualbmc/virtualbmc.conf. When vbmc does not find a
configuration file in the user directory it will then fallback to the
global (if it exist, otherwise it will just uses the defaults values).

Also, a new configuration option called "config_dir" has been added.
This allows users to configure whatever directory they want to save the
created VirtualBMCs where before it always pointed to ~/.vbmc/config.

Closes-Bug: #1647341
Change-Id: Id8bca620d1543436f32ecc650fc28cbc3f13f373
2016-12-05 12:30:38 +00:00
Lucas Alvares Gomes ca8239860b Fix Python3 test errors
This patch is fixing few errors related to Python3 and tests:

* Add the attribute "message" to the exception because it doesn't exist
  by default.

* Add the py35 runtime to tox.ini since we now run tests on Python3.5

* Drop the spec=file syntax because "file" is not a builtin type for

Change-Id: I31d1a5719d605974912bc26f65b96734631691d5
Closes-Bug: #1647337
2016-12-05 12:21:15 +00:00
Lucas Alvares Gomes e3a4d8b707 Set IPMI session timeout for the virtual BMCs
This patch allows users to configure the IPMI session timeout
when starting a virtual BMC. This timeout indicates how long it should
wait for the data to come across.

The timeout can be configured using the "session_timeout" configuration
option under the [ipmi] section in the virtualbmc.conf.

Change-Id: I3d241dbc6459401d669b0dfa1aa6584440b013b9
2016-06-01 16:00:48 +01:00
Lucas Alvares Gomes af00ea2615 Add unittests for the module
This patch is adding unittests for the module. The patch also
adds a method called "initialize" in the VirtualBMCConfig class to
facilitate the tests.

Change-Id: Id6c90916c0b63d6ca70c16c3ff0b8830fbf72baf
2016-05-13 11:48:19 +01:00
Lucas Alvares Gomes ec1595ba3e Add unittests for the module
This patch is adding unittests for the module.

Change-Id: Ia2732189a4c9a57b69cf209a95b115d102a1d221
2016-05-12 17:03:36 +01:00
Lucas Alvares Gomes 5325880339 Raise an exception for domains already registered
This patch is replacing a sys.exit() in the VirtualBMCManager.add()
method with an exception, the manager class should never use the exit

Change-Id: I49bb4107e57ce11a851203a04f48621a6f5439b7
2016-05-12 09:49:19 +01:00
Lucas Alvares Gomes bba706e285 Add unittests for the module
This patch is adding unittests for the module.

Change-Id: Ia83df2dc44549e2bac8c478ad74af123c9f80f2e
2016-05-11 17:14:53 +01:00
Lucas Alvares Gomes 03cda5571a "vbmc list" to sort the result by domain name
This patch is making the result of "vbmc list" command to sort the table
by the domain name, that's visually easier to follow.

This patch also makes use of the PrettyTable's get_string() method when
printing a table for the "list" and "show" commands.

Change-Id: I6bd6d0d9f5a9d2eeaa791d1e9d56bb3dc4131da2
2016-05-10 12:33:36 +01:00
Lucas Alvares Gomes b14ae0b9ee Add unittests for the cmd/ module
This patch is adding unittests for the cmd/ module. The exit()
syscall was replaced with sys.exit() to facilitate the mock.

Change-Id: Iadf0acdddf576c7438fe96f8c1213619cef75805
2016-05-10 12:31:48 +01:00
Lucas Alvares Gomes 5d90759120 Add unittests for the module
This patch is adding unittests for the module. The functions
str2bool() and mask_dict_password() are not being unittested because
they should be removed and replaced oslo functions.

Change-Id: I47e5fed806f8143c68da9cb7d421f46c22d6cba9
2016-05-10 10:06:54 +01:00
Lucas Alvares Gomes 85a0b201ff Restructure the repository according to OpenStack
This patch is restructuring the VirtualBMC repository according to the
OpenStack template for projects (Cookiecutter).

This patch also removes the dependency on the python-daemon library
since it is not present in the OpenStack global-requirements, now a new
class called "detach_process" has been added to the virtualbmc/
module that will take care of detaching the process context from its
parent and session.

Change-Id: Id4ae1db5b73a18abc54276fe1dfbf3ceff7adc06
2016-05-09 12:35:50 +01:00