Skip to content

Commit ce5b7f0

Browse files
committed
storage: add dynamic managed storage dispatcher
Add an optional "adapter" field in the ManagedVolumeConnection struct, allowing dispatching to vendor managedvolume-helper adapters. Signed-off-by: Viktor Ivanov <viktor.ivanov@storpool.com>
1 parent d4535af commit ce5b7f0

3 files changed

Lines changed: 63 additions & 1 deletion

File tree

doc/managed-volume-adapters.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<!--
2+
SPDX-FileCopyrightText: Red Hat, Inc.
3+
SPDX-License-Identifier: GPL-2.0-or-later
4+
-->
5+
6+
# Managed Volume Adapters
7+
8+
By default the managed volumes in Vdsm are manipulated through an external
9+
helper that interfaces with the `os_brick` package (part of OpenStack).
10+
11+
Similarly on the oVirt Engine side there is another external helper that
12+
interfaces with CinderLib.
13+
14+
The two together can expose any supported Cinder storage driver to oVirt.
15+
16+
- on the oVirt Engine side the helper deals with creating and managing volumes,
17+
snapshots and preparing them to be attached to a VM;
18+
19+
- on the Vdsm side the helper deals only with attaching and detaching volumes
20+
that have been created by the oVirt Engine.
21+
22+
The adapter mechanism redirects the execution to vendor-provided helper
23+
executables. To facilitate this redirection both the oVirt Engine and Vdsm have
24+
the notion of `adapter`.
25+
26+
This allows storage vendors to integrate their managed storage directly in
27+
oVirt/Vdsm.
28+
29+
## oVirt Engine
30+
31+
Managed Storage Domains with adapter dispatch have an `adapter` field in their
32+
`driver_options` map that indicates the helper executable to run instead of
33+
the default `cinderlib-client.py` helper.
34+
35+
The vendor packaging is expected to install a symlink in the Managed Block
36+
Storage data directory (defaults to `/usr/share/ovirt-engine/managedblock/`)
37+
named `{adapter}-adapter`.
38+
39+
## Vdsm
40+
41+
The `adapter` field is passed to Vdsm in the `connection_info` parameter (of
42+
type `ManagedVolumeConnection`).
43+
44+
If the `adapter` field is not present, Vdsm uses the default OS-Brick helper
45+
`managedvolume-helper`.
46+
47+
If the `adapter` field is present, Vdsm will instead execute
48+
`managedvolume-helper-{adapter}` when attaching and detaching volumes.

lib/vdsm/api/vdsm-api.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,11 @@ types:
11851185
volume type.
11861186
name: data
11871187
type: *StringMap
1188+
- defaultvalue: null
1189+
description: Adapter vendor
1190+
name: adapter
1191+
type: string
1192+
added: '4.5.8'
11881193
type: object
11891194

11901195
ManagedVolumeAttachement: &ManagedVolumeAttachement

lib/vdsm/storage/managedvolume.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,22 @@ def run_helper(sub_cmd, vol_info=None):
187187
return supervdsm.getProxy().managedvolume_run_helper(
188188
sub_cmd, vol_info=vol_info)
189189
try:
190+
adapter = None
190191
cmd_input = None
191192
if vol_info:
192193
cmd_input = json.dumps(vol_info).encode("utf-8")
194+
adapter = vol_info.get("connection_info", {}).get("adapter")
195+
helper = HELPER
196+
if adapter:
197+
helper = f"{HELPER}-{adapter}"
198+
if not os.path.exists(helper):
199+
raise se.ManagedVolumeHelperFailed(
200+
f"Helper for adapter '{adapter}' not found"
201+
f" at '{helper}'")
193202
# This is the only sane way to run python scripts that work with both
194203
# python2 and python3 in the tests.
195204
# TODO: Remove when we drop python 2.
196-
cmd = [sys.executable, HELPER, sub_cmd]
205+
cmd = [sys.executable, helper, sub_cmd]
197206
result = commands.run(cmd, input=cmd_input)
198207
except cmdutils.Error as e:
199208
raise se.ManagedVolumeHelperFailed("Error executing helper: %s" % e)

0 commit comments

Comments
 (0)