Skip to content
Snippets Groups Projects
Commit 0a7f4d43 authored by Filippos Giannakos's avatar Filippos Giannakos
Browse files

Add userspace access support

parent 846c601d
Branches
No related tags found
No related merge requests found
...@@ -42,6 +42,7 @@ The following variables are optional: ...@@ -42,6 +42,7 @@ The following variables are optional:
- EXTP_IMAGE_FEATURES: The enabled features of the new RBD volume - EXTP_IMAGE_FEATURES: The enabled features of the new RBD volume
- EXTP_STRIPE_UNIT Size (in bytes) of a block of data - EXTP_STRIPE_UNIT Size (in bytes) of a block of data
- EXTP_STRIPE_COUNT Number of consecutive objects in a stripe - EXTP_STRIPE_COUNT Number of consecutive objects in a stripe
- EXTP_USERSPACE_ONLY Number of consecutive objects in a stripe
The code branches to the correct function, depending on the name (sys.argv[0]) The code branches to the correct function, depending on the name (sys.argv[0])
of the executed script (attach, create, etc). of the executed script (attach, create, etc).
...@@ -212,6 +213,13 @@ def read_env(): ...@@ -212,6 +213,13 @@ def read_env():
flags=re.IGNORECASE) is not None flags=re.IGNORECASE) is not None
extp_params.pop("reuse_data") extp_params.pop("reuse_data")
userspace_only = False
if extp_params.get("userspace_only"):
userspace_only = re.match(
TRUE_PATTERN, os.getenv("EXTP_USERSPACE_ONLY"),
flags=re.IGNORECASE) is not None
extp_params.pop("userspace_only")
cephx_keys = ['cephx_id', 'cephx_keyring', 'cephx_keyfile'] cephx_keys = ['cephx_id', 'cephx_keyring', 'cephx_keyfile']
cephx = {} cephx = {}
for k in cephx_keys: for k in cephx_keys:
...@@ -225,6 +233,7 @@ def read_env(): ...@@ -225,6 +233,7 @@ def read_env():
"snapshot_name": os.getenv("VOL_SNAPSHOT_NAME"), "snapshot_name": os.getenv("VOL_SNAPSHOT_NAME"),
"cephx": cephx, "cephx": cephx,
"reuse_data": reuse_data, "reuse_data": reuse_data,
"userspace_only": userspace_only
} }
env.update(extp_params) env.update(extp_params)
return env return env
...@@ -282,8 +291,12 @@ def attach(env): ...@@ -282,8 +291,12 @@ def attach(env):
""" """
userspace_only = env.get("userspace_only")
name = env.get("name") name = env.get("name")
pool = env.get("rbd_pool") pool = env.get("rbd_pool")
if userspace_only:
device = ""
else:
device = RBD.get_device(name) device = RBD.get_device(name)
cephx = env.get("cephx") cephx = env.get("cephx")
if device is None: if device is None:
...@@ -295,6 +308,7 @@ def attach(env): ...@@ -295,6 +308,7 @@ def attach(env):
% (RBD.format_name(name, pool=pool), device)) % (RBD.format_name(name, pool=pool), device))
sys.stdout.write("%s" % device) sys.stdout.write("%s" % device)
sys.stdout.write("\nkvm:rbd:%s" % RBD.format_name(name, pool=pool))
return 0 return 0
...@@ -306,6 +320,8 @@ def detach(env): ...@@ -306,6 +320,8 @@ def detach(env):
If mapping doesn't exist at all, it does nothing. If mapping doesn't exist at all, it does nothing.
""" """
userspace_only = env.get("userspace_only")
if not userspace_only:
name = env.get("name") name = env.get("name")
pool = env.get("rbd_pool") pool = env.get("rbd_pool")
cephx = env.get("cephx") cephx = env.get("cephx")
...@@ -314,6 +330,7 @@ def detach(env): ...@@ -314,6 +330,7 @@ def detach(env):
RBD.unmap(device, cephx=cephx) RBD.unmap(device, cephx=cephx)
sys.stderr.write("Unmapped %s\n" % RBD.format_name(name, pool=pool)) sys.stderr.write("Unmapped %s\n" % RBD.format_name(name, pool=pool))
return 0 return 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment