Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
vmdriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
2
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d09b32a3
authored
8 years ago
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ceph: fix path of commands and add ipv4 regex
parent
5410badc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
ceph.py
+9
-8
No files found.
ceph.py
View file @
d09b32a3
...
@@ -16,7 +16,8 @@ logger = logging.getLogger(__name__)
...
@@ -16,7 +16,8 @@ logger = logging.getLogger(__name__)
DUMP_SIZE_LIMIT
=
int
(
os
.
getenv
(
"DUMP_SIZE_LIMIT"
,
20
*
1024
**
3
))
# 20GB
DUMP_SIZE_LIMIT
=
int
(
os
.
getenv
(
"DUMP_SIZE_LIMIT"
,
20
*
1024
**
3
))
# 20GB
mon_regex
=
re
.
compile
(
r"^\[(?P<address>.+)\]\:(?P<port>\d+).*$"
)
mon_regex_ipv6
=
re
.
compile
(
r"^\[(?P<address>.+)\]\:(?P<port>\d+).*$"
)
mon_regex_ipv4
=
re
.
compile
(
r"^(?P<address>.+)\:(?P<port>\d+).*$"
)
class
CephConfig
:
class
CephConfig
:
...
@@ -65,35 +66,35 @@ class CephConnection:
...
@@ -65,35 +66,35 @@ class CephConnection:
def
sudo
(
*
args
):
def
sudo
(
*
args
):
subprocess
.
check_output
([
"/bin/sudo"
]
+
list
(
args
))
subprocess
.
check_output
([
"/
usr/
bin/sudo"
]
+
list
(
args
))
def
unmap_rbd
(
conf
,
local_path
):
def
unmap_rbd
(
conf
,
local_path
):
sudo
(
"/bin/rbd"
,
"unmap"
,
local_path
,
*
conf
.
cmd_args
())
sudo
(
"/
usr/
bin/rbd"
,
"unmap"
,
local_path
,
*
conf
.
cmd_args
())
def
map_rbd
(
conf
,
ceph_path
,
local_path
):
def
map_rbd
(
conf
,
ceph_path
,
local_path
):
try
:
try
:
sudo
(
"/bin/rbd"
,
"map"
,
ceph_path
,
*
conf
.
cmd_args
())
sudo
(
"/
usr/
bin/rbd"
,
"map"
,
ceph_path
,
*
conf
.
cmd_args
())
except
:
except
:
unmap_rbd
(
conf
,
local_path
)
unmap_rbd
(
conf
,
local_path
)
sudo
(
"/bin/rbd"
,
"map"
,
ceph_path
,
*
conf
.
cmd_args
())
sudo
(
"/
usr/
bin/rbd"
,
"map"
,
ceph_path
,
*
conf
.
cmd_args
())
def
get_secret_key
(
conf
):
def
get_secret_key
(
conf
):
return
subprocess
.
check_output
(
return
subprocess
.
check_output
(
([
"/bin/ceph"
,
"auth"
,
"print-key"
,
"client.
%
s"
%
conf
.
user
]
+
([
"/
usr/
bin/ceph"
,
"auth"
,
"print-key"
,
"client.
%
s"
%
conf
.
user
]
+
conf
.
cmd_args
()))
conf
.
cmd_args
()))
def
parse_endpoint
(
mon
):
def
parse_endpoint
(
mon
):
m
=
mon_regex
.
match
(
mon
[
"addr"
])
m
=
mon_regex
_ipv6
.
match
(
mon
[
"addr"
])
or
mon_regex_ipv4
(
mon
[
"addr"
])
return
(
m
.
group
(
"address"
),
m
.
group
(
"port"
))
return
(
m
.
group
(
"address"
),
m
.
group
(
"port"
))
def
_get_endpoints
(
conf
):
def
_get_endpoints
(
conf
):
output
=
subprocess
.
check_output
(
output
=
subprocess
.
check_output
(
([
"/bin/ceph"
,
"mon"
,
"dump"
,
"--format=json"
]
+
conf
.
cmd_args
()))
([
"/
usr/
bin/ceph"
,
"mon"
,
"dump"
,
"--format=json"
]
+
conf
.
cmd_args
()))
mon_data
=
json
.
loads
(
output
)
mon_data
=
json
.
loads
(
output
)
mons
=
mon_data
[
"mons"
]
mons
=
mon_data
[
"mons"
]
return
map
(
parse_endpoint
,
mons
)
return
map
(
parse_endpoint
,
mons
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment