Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
snf-ganeti
Commits
fc72a3a3
Commit
fc72a3a3
authored
Jan 29, 2009
by
Oleksiy Mishchenko
Browse files
RAPI: Implement /2 resource
Reviewed-by: iustinp
parent
dc824c9f
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/rapi/connector.py
View file @
fc72a3a3
...
...
@@ -114,12 +114,47 @@ class R_root(baserlib.R_Generic):
return
baserlib
.
BuildUriList
(
rootlist
,
"/%s"
)
def
_getResources
(
id
):
"""Return a list of resources underneath given id.
This is to generalize querying of version resources lists.
@return: a list of resources names.
"""
r_pattern
=
re
.
compile
(
'^R_%s_([a-zA-Z0-9]+)$'
%
id
)
rlist
=
[]
for
handler
in
CONNECTOR
.
values
():
m
=
r_pattern
.
match
(
handler
.
__name__
)
if
m
:
name
=
m
.
group
(
1
)
rlist
.
append
(
name
)
return
rlist
class
R_2
(
baserlib
.
R_Generic
):
""" /2 resourse.
"""
DOC_URI
=
"/2"
def
GET
(
self
):
"""Show the list of mapped resources.
@return: a dictionary with 'name' and 'uri' keys for each of them.
"""
return
baserlib
.
BuildUriList
(
_getResources
(
"2"
),
"/2/%s"
)
CONNECTOR
.
update
({
"/"
:
R_root
,
"/version"
:
rlib1
.
R_version
,
"/2"
:
R_2
,
"/2/jobs"
:
rlib2
.
R_2_jobs
,
"/2/nodes"
:
rlib2
.
R_2_nodes
,
"/2/instances"
:
rlib2
.
R_2_instances
,
...
...
test/ganeti.rapi.resources_unittest.py
View file @
fc72a3a3
...
...
@@ -76,7 +76,7 @@ class R_RootTests(unittest.TestCase):
def
testGet
(
self
):
expected
=
[
# TODO:
{'name': '
info
', 'uri': '/2'},
{
'name'
:
'
2
'
,
'uri'
:
'/2'
},
{
'name'
:
'version'
,
'uri'
:
'/version'
},
]
self
.
assertEquals
(
self
.
root
.
GET
(),
expected
)
...
...
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