Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Ganeti ext storage provider for RBD
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
infra
Ganeti ext storage provider for RBD
Commits
cf60c85a
Commit
cf60c85a
authored
7 years ago
by
Filippos Giannakos
Browse files
Options
Downloads
Patches
Plain Diff
Add support for arbitrary userspace QEMU URI params
parent
b2017320
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ext_scripts/ext_rbd.py
+18
-3
18 additions, 3 deletions
ext_scripts/ext_rbd.py
with
18 additions
and
3 deletions
ext_scripts/ext_rbd.py
+
18
−
3
View file @
cf60c85a
...
@@ -43,6 +43,7 @@ The following variables are optional:
...
@@ -43,6 +43,7 @@ The following variables are optional:
- 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
- EXTP_USERSPACE_ONLY Number of consecutive objects in a stripe
- EXTP_USP_* Parameters to append to the userspace URI
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).
...
@@ -59,6 +60,7 @@ import re
...
@@ -59,6 +60,7 @@ import re
TRUE_PATTERN
=
'
^(yes|true|on|1|set)$
'
TRUE_PATTERN
=
'
^(yes|true|on|1|set)$
'
PREFIX_EXTP
=
'
EXTP_
'
PREFIX_EXTP
=
'
EXTP_
'
PREFIX_USP
=
'
usp_
'
def
cmd_open
(
cmd
,
bufsize
=-
1
,
env
=
None
):
def
cmd_open
(
cmd
,
bufsize
=-
1
,
env
=
None
):
...
@@ -228,12 +230,19 @@ def read_env():
...
@@ -228,12 +230,19 @@ def read_env():
cephx
[
k
[
len
(
'
cephx_
'
):]]
=
param
cephx
[
k
[
len
(
'
cephx_
'
):]]
=
param
extp_params
.
pop
(
k
)
extp_params
.
pop
(
k
)
userspace_params
=
{}
for
p
,
v
in
extp_params
.
iteritems
():
if
p
.
startswith
(
PREFIX_USP
):
userspace_params
[
p
[
len
(
PREFIX_USP
):]]
=
v
extp_params
.
pop
(
p
)
env
=
{
"
name
"
:
os
.
getenv
(
"
VOL_CNAME
"
),
env
=
{
"
name
"
:
os
.
getenv
(
"
VOL_CNAME
"
),
"
size
"
:
os
.
getenv
(
"
VOL_SIZE
"
),
"
size
"
:
os
.
getenv
(
"
VOL_SIZE
"
),
"
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
"
userspace_only
"
:
userspace_only
,
"
userspace_params
"
:
userspace_params
}
}
env
.
update
(
extp_params
)
env
.
update
(
extp_params
)
return
env
return
env
...
@@ -281,11 +290,13 @@ def snapshot(env):
...
@@ -281,11 +290,13 @@ def snapshot(env):
return
1
return
1
def
format_qemu_uri
(
name
,
pool
=
None
,
cephx
=
None
,
conf_file
=
None
,
cache
=
None
):
def
format_qemu_uri
(
name
,
pool
=
None
,
cephx
=
None
,
conf_file
=
None
,
cache
=
None
,
**
kwargs
):
"""
Create a QEMU RBD URI for the specific image / environment
"""
"""
Create a QEMU RBD URI for the specific image / environment
"""
uri
=
'
kvm:rbd:%s
'
%
RBD
.
format_name
(
name
,
pool
=
pool
)
uri
=
'
kvm:rbd:%s
'
%
RBD
.
format_name
(
name
,
pool
=
pool
)
extra_conf
=
''
extra_conf
=
''
# Only id is supported for cephx authentication, for the userspace URI.
if
cephx
[
'
id
'
]:
if
cephx
[
'
id
'
]:
extra_conf
+=
'
:id=%s
'
%
cephx
[
'
id
'
]
extra_conf
+=
'
:id=%s
'
%
cephx
[
'
id
'
]
if
conf_file
:
if
conf_file
:
...
@@ -293,6 +304,8 @@ def format_qemu_uri(name, pool=None, cephx=None, conf_file=None, cache=None):
...
@@ -293,6 +304,8 @@ def format_qemu_uri(name, pool=None, cephx=None, conf_file=None, cache=None):
# TODO: we need to revisit this, to support more caching modes correctly.
# TODO: we need to revisit this, to support more caching modes correctly.
if
cache
in
[
'
writeback
'
]:
if
cache
in
[
'
writeback
'
]:
extra_conf
+=
'
:rbd_cache=true
'
extra_conf
+=
'
:rbd_cache=true
'
for
k
,
v
in
kwargs
.
iteritems
():
extra_conf
+=
'
:%s=%s
'
%
(
k
,
v
)
if
extra_conf
:
if
extra_conf
:
uri
+=
extra_conf
uri
+=
extra_conf
...
@@ -315,6 +328,7 @@ def attach(env):
...
@@ -315,6 +328,7 @@ def attach(env):
pool
=
env
.
get
(
"
rbd_pool
"
)
pool
=
env
.
get
(
"
rbd_pool
"
)
cephx
=
env
.
get
(
"
cephx
"
)
cephx
=
env
.
get
(
"
cephx
"
)
cache
=
env
.
get
(
"
cache
"
)
cache
=
env
.
get
(
"
cache
"
)
userspace_params
=
env
.
get
(
"
userspace_params
"
)
if
userspace_only
:
if
userspace_only
:
device
=
""
device
=
""
else
:
else
:
...
@@ -329,7 +343,8 @@ def attach(env):
...
@@ -329,7 +343,8 @@ 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
)
qemu_uri
=
format_qemu_uri
(
name
,
pool
=
pool
,
cephx
=
cephx
,
cache
=
cache
)
qemu_uri
=
format_qemu_uri
(
name
,
pool
=
pool
,
cephx
=
cephx
,
cache
=
cache
,
**
userspace_params
)
sys
.
stdout
.
write
(
"
\n
%s
"
%
qemu_uri
)
sys
.
stdout
.
write
(
"
\n
%s
"
%
qemu_uri
)
return
0
return
0
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment