Revision 38206f3c lib/rapi/rlib1.py
b/lib/rapi/rlib1.py | ||
---|---|---|
23 | 23 |
|
24 | 24 |
""" |
25 | 25 |
|
26 |
import re |
|
27 |
|
|
28 | 26 |
import ganeti.cli |
29 | 27 |
import ganeti.errors |
30 | 28 |
import ganeti.opcodes |
31 | 29 |
|
32 | 30 |
from ganeti import constants |
33 |
from ganeti import utils |
|
34 | 31 |
|
35 |
from ganeti.rapi import baserlib
|
|
36 |
from ganeti.rapi import httperror
|
|
32 |
from ganeti.rapi import baserlib |
|
33 |
from ganeti.rapi import httperror |
|
37 | 34 |
|
38 | 35 |
|
39 | 36 |
I_FIELDS = ["name", "os", "pnode", "snodes", |
... | ... | |
42 | 39 |
"sda_size", "sdb_size", "vcpus", |
43 | 40 |
"oper_state", "status", "tags"] |
44 | 41 |
|
45 |
N_FIELDS = ["name","dtotal", "dfree", |
|
42 |
N_FIELDS = ["name", "dtotal", "dfree",
|
|
46 | 43 |
"mtotal", "mnode", "mfree", |
47 | 44 |
"pinst_cnt", "sinst_cnt", "tags"] |
48 | 45 |
|
... | ... | |
114 | 111 |
|
115 | 112 |
""" |
116 | 113 |
DOC_URI = "/nodes" |
117 |
|
|
114 |
|
|
118 | 115 |
def GET(self): |
119 | 116 |
"""Returns a list of all nodes. |
120 |
|
|
117 |
|
|
121 | 118 |
Returns: |
122 | 119 |
A dictionary with 'name' and 'uri' keys for each of them. |
123 | 120 |
|
... | ... | |
131 | 128 |
"uri": "\/instances\/node2.example.com" |
132 | 129 |
}] |
133 | 130 |
|
134 |
If the optional 'bulk' argument is provided and set to 'true'
|
|
131 |
If the optional 'bulk' argument is provided and set to 'true' |
|
135 | 132 |
value (i.e '?bulk=1'), the output contains detailed |
136 | 133 |
information about nodes as a list. |
137 | 134 |
|
... | ... | |
153 | 150 |
""" |
154 | 151 |
op = ganeti.opcodes.OpQueryNodes(output_fields=["name"], names=[]) |
155 | 152 |
nodeslist = baserlib.ExtractField(ganeti.cli.SubmitOpCode(op), 0) |
156 |
|
|
153 |
|
|
157 | 154 |
if 'bulk' in self.queryargs: |
158 | 155 |
op = ganeti.opcodes.OpQueryNodes(output_fields=N_FIELDS, |
159 | 156 |
names=nodeslist) |
... | ... | |
170 | 167 |
DOC_URI = "/nodes/[node_name]" |
171 | 168 |
|
172 | 169 |
def GET(self): |
173 |
"""Send information about a node.
|
|
170 |
"""Send information about a node. |
|
174 | 171 |
|
175 | 172 |
""" |
176 | 173 |
node_name = self.items[0] |
... | ... | |
207 | 204 |
|
208 | 205 |
def GET(self): |
209 | 206 |
"""Returns a list of all available instances. |
210 |
|
|
207 |
|
|
211 | 208 |
Returns: |
212 | 209 |
A dictionary with 'name' and 'uri' keys for each of them. |
213 | 210 |
|
... | ... | |
221 | 218 |
"uri": "\/instances\/mail.example.com" |
222 | 219 |
}] |
223 | 220 |
|
224 |
If the optional 'bulk' argument is provided and set to 'true'
|
|
221 |
If the optional 'bulk' argument is provided and set to 'true' |
|
225 | 222 |
value (i.e '?bulk=1'), the output contains detailed |
226 | 223 |
information about instances as a list. |
227 | 224 |
|
... | ... | |
250 | 247 |
""" |
251 | 248 |
op = ganeti.opcodes.OpQueryInstances(output_fields=["name"], names=[]) |
252 | 249 |
instanceslist = baserlib.ExtractField(ganeti.cli.SubmitOpCode(op), 0) |
253 |
|
|
250 |
|
|
254 | 251 |
if 'bulk' in self.queryargs: |
255 | 252 |
op = ganeti.opcodes.OpQueryInstances(output_fields=I_FIELDS, |
256 | 253 |
names=instanceslist) |
Also available in: Unified diff