Commit 2e915611 authored by Dimitris Aragiorgis's avatar Dimitris Aragiorgis Committed by Hrvoje Ribicic

Extend ExtStorage with open/close scripts

Introduce open/close scripts to the ExtStorage interface in order
to start a unification among BlockDev classes.

Both scripts will be optional for backwards compatibility.
Signed-off-by: default avatarDimitris Aragiorgis <dimitris.aragiorgis@gmail.com>
Reviewed-by: default avatarHrvoje Ribicic <riba@google.com>
parent 58609486
......@@ -185,7 +185,9 @@ An “ExtStorage provider” will have to provide the following methods:
- Detach a disk from a given node
- SetInfo to a disk (add metadata)
- Verify its supported parameters
- Snapshot a disk (currently used during gnt-backup export)
- Snapshot a disk (optional)
- Open a disk (optional)
- Close a disk (optional)
The proposed ExtStorage interface borrows heavily from the OS
interface and follows a one-script-per-function approach. An ExtStorage
......@@ -199,16 +201,19 @@ provider is expected to provide the following scripts:
- ``setinfo``
- ``verify``
- ``snapshot`` (optional)
- ``open`` (optional)
- ``close`` (optional)
All scripts will be called with no arguments and get their input via
environment variables. A common set of variables will be exported for
all commands, and some of them might have extra ones.
all commands, and some commands might have extra variables.
``VOL_NAME``
The name of the volume. This is unique for Ganeti and it
uses it to refer to a specific volume inside the external storage.
``VOL_SIZE``
The volume's size in mebibytes.
Available only to the `create` and `grow` scripts.
``VOL_NEW_SIZE``
Available only to the `grow` script. It declares the
new size of the volume after grow (in mebibytes).
......@@ -221,10 +226,10 @@ all commands, and some of them might have extra ones.
``VOL_CNAME``
The human readable name of the disk (if any).
``VOL_SNAPSHOT_NAME``
The name of the volume's snapshot to be taken.
The name of the volume's snapshot.
Available only to the `snapshot` script.
``VOL_SNAPSHOT_SIZE``
The size of the volume's snapshot to be taken.
The size of the volume's snapshot.
Available only to the `snapshot` script.
All scripts except `attach` should return 0 on success and non-zero on
......@@ -233,9 +238,14 @@ error, accompanied by an appropriate error message on stderr. The
the block device's full path, after it has been successfully attached to
the host node. On error it should return non-zero.
To keep backwards compatibility we let the ``snapshot`` script be
optional. If present then the provider will support instance backup
export as well.
The ``snapshot``, ``open`` and ``close`` scripts are introduced after
the first implementation of the ExtStorage Interface. To keep backwards
compatibility with the first implementation, we make these scripts
optional.
The ``snapshot`` script, if present, will be used for instance backup
export. The ``open`` script makes the device ready for I/O. The ``close``
script disables the I/O on the device.
Implementation
--------------
......@@ -243,7 +253,8 @@ Implementation
To support the ExtStorage interface, we will introduce a new disk
template called `ext`. This template will implement the existing Ganeti
disk interface in `lib/bdev.py` (create, remove, attach, assemble,
shutdown, grow, setinfo), and will simultaneously pass control to the
shutdown, grow, setinfo, open, close),
and will simultaneously pass control to the
external scripts to actually handle the above actions. The `ext` disk
template will act as a translation layer between the current Ganeti disk
interface and the ExtStorage providers.
......
......@@ -1378,6 +1378,8 @@ class ExtStorage(ConfigObject):
"setinfo_script",
"verify_script",
"snapshot_script",
"open_script",
"close_script",
"supported_parameters",
]
......
......@@ -185,13 +185,17 @@ class ExtStorageDevice(base.BlockDev):
"""Make the device ready for I/O.
"""
pass
_ExtStorageAction(constants.ES_ACTION_OPEN, self.unique_id,
self.ext_params,
name=self.name, uuid=self.uuid)
def Close(self):
"""Notifies that the device will no longer be used for I/O.
"""
pass
_ExtStorageAction(constants.ES_ACTION_CLOSE, self.unique_id,
self.ext_params,
name=self.name, uuid=self.uuid)
def Grow(self, amount, dryrun, backingstore, excl_stor):
"""Grow the Volume.
......@@ -443,8 +447,11 @@ def ExtStorageFromDisk(name, base_dir=None):
# required (True) or optional (False)
es_files = dict.fromkeys(constants.ES_SCRIPTS, True)
# Let the snapshot script be optional for backwards compatibility
# Let the snapshot, open, and close scripts be optional
# for backwards compatibility
es_files[constants.ES_SCRIPT_SNAPSHOT] = False
es_files[constants.ES_SCRIPT_OPEN] = False
es_files[constants.ES_SCRIPT_CLOSE] = False
es_files[constants.ES_PARAMETERS_FILE] = True
......@@ -477,6 +484,8 @@ def ExtStorageFromDisk(name, base_dir=None):
setinfo_script=es_files[constants.ES_SCRIPT_SETINFO],
verify_script=es_files[constants.ES_SCRIPT_VERIFY],
snapshot_script=es_files[constants.ES_SCRIPT_SNAPSHOT],
open_script=es_files[constants.ES_SCRIPT_OPEN],
close_script=es_files[constants.ES_SCRIPT_CLOSE],
supported_parameters=parameters)
return True, es_obj
......
......@@ -25,7 +25,8 @@ There are eight required files: *create*, *attach*, *detach*, *remove*,
*grow*, *setinfo*, *verify*, (executables) and *parameters.list*
(text file).
Currenlty there is also one optional file: *snapshot* (executable).
There are also three optional files: *open*, *close*, and
*snapshot* (executables).
Common environment
~~~~~~~~~~~~~~~~~~
......@@ -227,6 +228,30 @@ Please note that this script is optional and not all providers should
implement it. Of course if it is not present, instance backup export
will not be supported for the given provider.
open
~~~~
The *open* script is used to open the given volume.
This makes the volume ready for I/O.
The script returns ``0`` on success.
Please note that this script is optional and not all providers should
implement it.
close
~~~~~
The *close* script is used to close the given volume.
This disables I/O on the volume.
The script returns ``0`` on success.
Please note that this script is optional and not all providers should
implement it.
TEXT FILES
----------
......
......@@ -1470,6 +1470,12 @@ esActionVerify = "verify"
esActionSnapshot :: String
esActionSnapshot = "snapshot"
esActionOpen :: String
esActionOpen = "open"
esActionClose :: String
esActionClose = "close"
esScriptCreate :: String
esScriptCreate = esActionCreate
......@@ -1494,6 +1500,12 @@ esScriptVerify = esActionVerify
esScriptSnapshot :: String
esScriptSnapshot = esActionSnapshot
esScriptOpen :: String
esScriptOpen = esActionOpen
esScriptClose :: String
esScriptClose = esActionClose
esScripts :: FrozenSet String
esScripts =
ConstantUtils.mkSet [esScriptAttach,
......@@ -1503,7 +1515,9 @@ esScripts =
esScriptRemove,
esScriptSetinfo,
esScriptVerify,
esScriptSnapshot]
esScriptSnapshot,
esScriptOpen,
esScriptClose]
esParametersFile :: String
esParametersFile = "parameters.list"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment