Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snf-ganeti
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
itminedu
snf-ganeti
Commits
fc72a3a3
Commit
fc72a3a3
authored
16 years ago
by
Oleksiy Mishchenko
Browse files
Options
Downloads
Patches
Plain Diff
RAPI: Implement /2 resource
Reviewed-by: iustinp
parent
dc824c9f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/rapi/connector.py
+36
-1
36 additions, 1 deletion
lib/rapi/connector.py
test/ganeti.rapi.resources_unittest.py
+1
-1
1 addition, 1 deletion
test/ganeti.rapi.resources_unittest.py
with
37 additions
and
2 deletions
lib/rapi/connector.py
+
36
−
1
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
,
...
...
This diff is collapsed.
Click to expand it.
test/ganeti.rapi.resources_unittest.py
+
1
−
1
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
)
...
...
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