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
028c6b76
Commit
028c6b76
authored
16 years ago
by
Oleksiy Mishchenko
Browse files
Options
Downloads
Patches
Plain Diff
RAPI:Fix root list and unittest for it.
Reviewed-by: imsnah
parent
a0dcf7c2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/rapi/connector.py
+2
-2
2 additions, 2 deletions
lib/rapi/connector.py
lib/rapi/rlib1.py
+0
-118
0 additions, 118 deletions
lib/rapi/rlib1.py
lib/rapi/rlib2.py
+16
-0
16 additions, 0 deletions
lib/rapi/rlib2.py
test/ganeti.rapi.resources_unittest.py
+2
-1
2 additions, 1 deletion
test/ganeti.rapi.resources_unittest.py
with
20 additions
and
121 deletions
lib/rapi/connector.py
+
2
−
2
View file @
028c6b76
...
...
@@ -125,11 +125,11 @@ CONNECTOR.update({
"
/tags
"
:
rlib1
.
R_tags
,
"
/info
"
:
rlib1
.
R_info
,
"
/nodes
"
:
rlib2
.
R_
2_
nodes
,
"
/nodes
"
:
rlib2
.
R_nodes
,
re
.
compile
(
r
'
^/nodes/([\w\._-]+)$
'
):
rlib1
.
R_nodes_name
,
re
.
compile
(
r
'
^/nodes/([\w\._-]+)/tags$
'
):
rlib1
.
R_nodes_name_tags
,
"
/instances
"
:
rlib2
.
R_
2_
instances
,
"
/instances
"
:
rlib2
.
R_instances
,
re
.
compile
(
r
'
^/instances/([\w\._-]+)$
'
):
rlib1
.
R_instances_name
,
re
.
compile
(
r
'
^/instances/([\w\._-]+)/tags$
'
):
rlib1
.
R_instances_name_tags
,
...
...
This diff is collapsed.
Click to expand it.
lib/rapi/rlib1.py
+
0
−
118
View file @
028c6b76
...
...
@@ -104,60 +104,6 @@ class R_info(baserlib.R_Generic):
return
ganeti
.
cli
.
SubmitOpCode
(
op
)
class
R_nodes
(
baserlib
.
R_Generic
):
"""
/nodes resource.
"""
DOC_URI
=
"
/nodes
"
def
GET
(
self
):
"""
Returns a list of all nodes.
Returns:
A dictionary with
'
name
'
and
'
uri
'
keys for each of them.
Example: [
{
"
name
"
:
"
node1.example.com
"
,
"
uri
"
:
"
\/instances\/node1.example.com
"
},
{
"
name
"
:
"
node2.example.com
"
,
"
uri
"
:
"
\/instances\/node2.example.com
"
}]
If the optional
'
bulk
'
argument is provided and set to
'
true
'
value (i.e
'
?bulk=1
'
), the output contains detailed
information about nodes as a list.
Example: [
{
"
pinst_cnt
"
: 1,
"
mfree
"
: 31280,
"
mtotal
"
: 32763,
"
name
"
:
"
www.example.com
"
,
"
tags
"
: [],
"
mnode
"
: 512,
"
dtotal
"
: 5246208,
"
sinst_cnt
"
: 2,
"
dfree
"
: 5171712
},
...
]
"""
op
=
ganeti
.
opcodes
.
OpQueryNodes
(
output_fields
=
[
"
name
"
],
names
=
[])
nodeslist
=
baserlib
.
ExtractField
(
ganeti
.
cli
.
SubmitOpCode
(
op
),
0
)
if
'
bulk
'
in
self
.
queryargs
:
op
=
ganeti
.
opcodes
.
OpQueryNodes
(
output_fields
=
N_FIELDS
,
names
=
nodeslist
)
result
=
ganeti
.
cli
.
SubmitOpCode
(
op
)
return
baserlib
.
MapBulkFields
(
result
,
N_FIELDS
)
return
baserlib
.
BuildUriList
(
nodeslist
,
"
/nodes/%s
"
)
class
R_nodes_name
(
baserlib
.
R_Generic
):
"""
/nodes/[node_name] resources.
...
...
@@ -193,70 +139,6 @@ class R_nodes_name_tags(baserlib.R_Generic):
return
baserlib
.
_Tags_GET
(
constants
.
TAG_NODE
,
name
=
self
.
items
[
0
])
class
R_instances
(
baserlib
.
R_Generic
):
"""
/instances resource.
"""
DOC_URI
=
"
/instances
"
def
GET
(
self
):
"""
Returns a list of all available instances.
Returns:
A dictionary with
'
name
'
and
'
uri
'
keys for each of them.
Example: [
{
"
name
"
:
"
web.example.com
"
,
"
uri
"
:
"
\/instances\/web.example.com
"
},
{
"
name
"
:
"
mail.example.com
"
,
"
uri
"
:
"
\/instances\/mail.example.com
"
}]
If the optional
'
bulk
'
argument is provided and set to
'
true
'
value (i.e
'
?bulk=1
'
), the output contains detailed
information about instances as a list.
Example: [
{
"
status
"
:
"
running
"
,
"
bridge
"
:
"
xen-br0
"
,
"
name
"
:
"
web.example.com
"
,
"
tags
"
: [
"
tag1
"
,
"
tag2
"
],
"
admin_ram
"
: 512,
"
sda_size
"
: 20480,
"
pnode
"
:
"
node1.example.com
"
,
"
mac
"
:
"
01:23:45:67:89:01
"
,
"
sdb_size
"
: 4096,
"
snodes
"
: [
"
node2.example.com
"
],
"
disk_template
"
:
"
drbd
"
,
"
ip
"
: null,
"
admin_state
"
: true,
"
os
"
:
"
debian-etch
"
,
"
vcpus
"
: 2,
"
oper_state
"
: true
},
...
]
"""
op
=
ganeti
.
opcodes
.
OpQueryInstances
(
output_fields
=
[
"
name
"
],
names
=
[])
instanceslist
=
baserlib
.
ExtractField
(
ganeti
.
cli
.
SubmitOpCode
(
op
),
0
)
if
'
bulk
'
in
self
.
queryargs
:
op
=
ganeti
.
opcodes
.
OpQueryInstances
(
output_fields
=
I_FIELDS
,
names
=
instanceslist
)
result
=
ganeti
.
cli
.
SubmitOpCode
(
op
)
return
baserlib
.
MapBulkFields
(
result
,
I_FIELDS
)
else
:
return
baserlib
.
BuildUriList
(
instanceslist
,
"
/instances/%s
"
)
class
R_instances_name
(
baserlib
.
R_Generic
):
"""
/instances/[instance_name] resources.
...
...
This diff is collapsed.
Click to expand it.
lib/rapi/rlib2.py
+
16
−
0
View file @
028c6b76
...
...
@@ -140,6 +140,14 @@ class R_2_nodes(baserlib.R_Generic):
uri_fields
=
(
"
id
"
,
"
uri
"
))
class
R_nodes
(
R_2_nodes
):
"""
/nodes resource
"""
# TODO: Temporary resource will be deprecated
DOC_URI
=
"
/nodes
"
class
R_2_instances
(
baserlib
.
R_Generic
):
"""
/2/instances resource.
...
...
@@ -241,6 +249,14 @@ class R_2_instances(baserlib.R_Generic):
return
job_id
class
R_instances
(
R_2_instances
):
"""
/instances resource.
"""
# TODO: Temporary resource will be deprecated
DOC_URI
=
"
/instances
"
class
R_2_instances_name_reboot
(
baserlib
.
R_Generic
):
"""
/2/instances/[instance_name]/reboot resource.
...
...
This diff is collapsed.
Click to expand it.
test/ganeti.rapi.resources_unittest.py
+
2
−
1
View file @
028c6b76
...
...
@@ -30,6 +30,7 @@ from ganeti import http
from
ganeti.rapi
import
connector
from
ganeti.rapi
import
rlib1
from
ganeti.rapi
import
rlib2
class
MapperTests
(
unittest
.
TestCase
):
...
...
@@ -48,7 +49,7 @@ class MapperTests(unittest.TestCase):
"""
Testing Mapper
"""
self
.
_TestUri
(
"
/tags
"
,
(
rlib1
.
R_tags
,
[],
{}))
self
.
_TestUri
(
"
/instances
"
,
(
rlib
1
.
R_instances
,
[],
{}))
self
.
_TestUri
(
"
/instances
"
,
(
rlib
2
.
R_instances
,
[],
{}))
self
.
_TestUri
(
'
/instances/www.test.com
'
,
(
rlib1
.
R_instances_name
,
...
...
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