Statistics
| Branch: | Tag: | Revision:

root / doc / design-query2.rst @ 9189c902

History | View | Annotate | Download (12.5 kB)

1 e5a246df Michael Hanselmann
======================
2 e5a246df Michael Hanselmann
Query version 2 design
3 e5a246df Michael Hanselmann
======================
4 e5a246df Michael Hanselmann
5 e5a246df Michael Hanselmann
.. contents:: :depth: 4
6 e5a246df Michael Hanselmann
.. highlight:: python
7 e5a246df Michael Hanselmann
8 e5a246df Michael Hanselmann
Current state and shortcomings
9 e5a246df Michael Hanselmann
==============================
10 e5a246df Michael Hanselmann
11 e5a246df Michael Hanselmann
Queries are used to retrieve information about the cluster, e.g. a list
12 e5a246df Michael Hanselmann
of instances or nodes. For historical reasons they use a simple data
13 e5a246df Michael Hanselmann
structure for their result. The client submits the fields it would like
14 e5a246df Michael Hanselmann
to receive and the query returns a list for each item (instance, node,
15 e5a246df Michael Hanselmann
etc.) available. Each item consists of another list representing the
16 e5a246df Michael Hanselmann
fields' values.
17 e5a246df Michael Hanselmann
18 e5a246df Michael Hanselmann
This data structure has a few drawbacks. It can't associate a status
19 e5a246df Michael Hanselmann
(e.g. “node offline”) with fields as using special values can lead to
20 e5a246df Michael Hanselmann
ambiguities. Additionally it can't mark fields as “not found” as the
21 e5a246df Michael Hanselmann
list of returned columns must match the fields requested.
22 e5a246df Michael Hanselmann
23 e5a246df Michael Hanselmann
Example::
24 e5a246df Michael Hanselmann
25 e5a246df Michael Hanselmann
  >>> cli.GetClient().QueryNodes([], ["name", "pip", "mfree"], False)
26 e5a246df Michael Hanselmann
  [
27 e5a246df Michael Hanselmann
    ['node1.example.com', '192.0.2.18', 14800],
28 e5a246df Michael Hanselmann
    ['node2.example.com', '192.0.2.19', 31280]
29 e5a246df Michael Hanselmann
  ]
30 e5a246df Michael Hanselmann
31 e5a246df Michael Hanselmann
There is no way for clients to determine the list of possible fields,
32 e5a246df Michael Hanselmann
meaning they have to be hardcoded. Selecting unknown fields raises
33 e5a246df Michael Hanselmann
an exception::
34 e5a246df Michael Hanselmann
35 e5a246df Michael Hanselmann
  >>> cli.GetClient().QueryNodes([], ["name", "UnknownField"], False)
36 e5a246df Michael Hanselmann
  ganeti.errors.OpPrereqError: (u'Unknown output fields selected: UnknownField', u'wrong_input')
37 e5a246df Michael Hanselmann
38 e5a246df Michael Hanselmann
The client must also know each fields' kind, that is whether a field is
39 e5a246df Michael Hanselmann
numeric, boolean, describes a storage size, etc. Centralizing this
40 e5a246df Michael Hanselmann
information in one place, the master daemon, is desirable.
41 e5a246df Michael Hanselmann
42 e5a246df Michael Hanselmann
43 e5a246df Michael Hanselmann
Proposed changes
44 e5a246df Michael Hanselmann
----------------
45 e5a246df Michael Hanselmann
46 e5a246df Michael Hanselmann
The current query result format can not be changed as it's being used in
47 e5a246df Michael Hanselmann
various places. Changing the format from one Ganeti version to another
48 e5a246df Michael Hanselmann
would cause too much disruption. For this reason the ability to
49 e5a246df Michael Hanselmann
explicitly request a new result format must be added while the old
50 e5a246df Michael Hanselmann
format stays the default.
51 e5a246df Michael Hanselmann
52 e5a246df Michael Hanselmann
The implementation of query filters is planned for the future. To avoid
53 e5a246df Michael Hanselmann
having to change the calls again, a (hopefully) future-compatible
54 e5a246df Michael Hanselmann
interface will be implemented now.
55 e5a246df Michael Hanselmann
56 e5a246df Michael Hanselmann
In Python code, the objects described below will be implemented using
57 e5a246df Michael Hanselmann
subclasses of ``objects.ConfigObject``, providing existing facilities
58 e5a246df Michael Hanselmann
for de-/serializing.
59 e5a246df Michael Hanselmann
60 9189c902 Michael Hanselmann
Regular expressions
61 9189c902 Michael Hanselmann
+++++++++++++++++++
62 9189c902 Michael Hanselmann
63 9189c902 Michael Hanselmann
As it turned out, only very few fields for instances used regular
64 9189c902 Michael Hanselmann
expressions, all of which can easily be turned into static field names.
65 9189c902 Michael Hanselmann
Therefore their use in field names is dropped. Reasons:
66 9189c902 Michael Hanselmann
67 9189c902 Michael Hanselmann
- When regexps are used and a field name is not listed as a simple
68 9189c902 Michael Hanselmann
  string in the field dictionary, all keys in the field dictionary have
69 9189c902 Michael Hanselmann
  to be checked whether they're a regular expression object and if so,
70 9189c902 Michael Hanselmann
  matched (see ``utils.FindMatch``).
71 9189c902 Michael Hanselmann
- Code becomes simpler. There would be no need anymore to care about
72 9189c902 Michael Hanselmann
  regular expressions as field names—they'd all be simple strings, even
73 9189c902 Michael Hanselmann
  if there are many more. The list of field names would be static once
74 9189c902 Michael Hanselmann
  built at module-load time.
75 9189c902 Michael Hanselmann
- There's the issue of formatting titles for the clients. Should it be
76 9189c902 Michael Hanselmann
  done in the server? In the client? The field definition's title would
77 9189c902 Michael Hanselmann
  contain backreferences to the regexp groups in the field name
78 9189c902 Michael Hanselmann
  (``re.MatchObject.expand`` can be used). With just strings, the field
79 9189c902 Michael Hanselmann
  definitions can be passed directly to the client. They're static.
80 9189c902 Michael Hanselmann
- Only a side note: In the memory consumed for 1'000
81 9189c902 Michael Hanselmann
  ``_sre.SRE_Pattern`` objects (as returned by ``re.compile`` for an
82 9189c902 Michael Hanselmann
  expression with one group) one can easily store 10'000 strings of the
83 9189c902 Michael Hanselmann
  same length (the regexp objects keep the expression string around, so
84 9189c902 Michael Hanselmann
  compiling the expression always uses more memory).
85 9189c902 Michael Hanselmann
86 9189c902 Michael Hanselmann
87 9189c902 Michael Hanselmann
.. _item-types:
88 9189c902 Michael Hanselmann
89 9189c902 Michael Hanselmann
Item types
90 9189c902 Michael Hanselmann
++++++++++
91 9189c902 Michael Hanselmann
92 9189c902 Michael Hanselmann
The proposal is to implement this new interface for the following
93 9189c902 Michael Hanselmann
items:
94 9189c902 Michael Hanselmann
95 9189c902 Michael Hanselmann
``instance``
96 9189c902 Michael Hanselmann
  Instances
97 9189c902 Michael Hanselmann
``node``
98 9189c902 Michael Hanselmann
  Nodes
99 9189c902 Michael Hanselmann
``job``
100 9189c902 Michael Hanselmann
  Jobs
101 9189c902 Michael Hanselmann
``lock``
102 9189c902 Michael Hanselmann
  Locks
103 9189c902 Michael Hanselmann
104 9189c902 Michael Hanselmann
.. _data-query:
105 9189c902 Michael Hanselmann
106 9189c902 Michael Hanselmann
Data query
107 9189c902 Michael Hanselmann
++++++++++
108 9189c902 Michael Hanselmann
109 9189c902 Michael Hanselmann
.. _data-query-request:
110 9189c902 Michael Hanselmann
111 9189c902 Michael Hanselmann
Request
112 9189c902 Michael Hanselmann
^^^^^^^
113 9189c902 Michael Hanselmann
114 9189c902 Michael Hanselmann
The request is a dictionary with the following entries:
115 9189c902 Michael Hanselmann
116 9189c902 Michael Hanselmann
``kind`` (string, required)
117 9189c902 Michael Hanselmann
  An :ref:`item type <item-types>`.
118 9189c902 Michael Hanselmann
``fields`` (list of strings, required)
119 9189c902 Michael Hanselmann
  List of names of fields to return. Example::
120 9189c902 Michael Hanselmann
121 9189c902 Michael Hanselmann
    ["name", "mem", "nic0.ip", "disk0.size", "disk1.size"]
122 9189c902 Michael Hanselmann
123 9189c902 Michael Hanselmann
``filter`` (optional)
124 e5a246df Michael Hanselmann
  This will be used to filter queries. In this implementation only names
125 e5a246df Michael Hanselmann
  can be filtered to replace the previous ``names`` parameter to
126 e5a246df Michael Hanselmann
  queries. An empty filter (``None``) will return all items. To retrieve
127 e5a246df Michael Hanselmann
  specific names, the filter must be specified as follows, with the
128 e5a246df Michael Hanselmann
  inner part repeated for each name::
129 e5a246df Michael Hanselmann
130 e5a246df Michael Hanselmann
    ["|", ["=", "name", "node1"], ["=", "name", "node2"], …]
131 e5a246df Michael Hanselmann
132 e5a246df Michael Hanselmann
  Filters consist of S-expressions (``["operator", <operants…>]``) and
133 e5a246df Michael Hanselmann
  extensions will be made in the future to allow for more operators and
134 e5a246df Michael Hanselmann
  fields. Such extensions might include a Python-style "in" operator,
135 e5a246df Michael Hanselmann
  but for simplicity only "=" is supported in this implementation.
136 e5a246df Michael Hanselmann
137 e5a246df Michael Hanselmann
  To reiterate: Filters for this implementation must consist of exactly
138 e5a246df Michael Hanselmann
  one OR expression (``["|", …]``) and one or more name equality filters
139 e5a246df Michael Hanselmann
  (``["=", "name", "…"]``).
140 e5a246df Michael Hanselmann
141 e5a246df Michael Hanselmann
Support for synchronous queries, currently available in the interface
142 e5a246df Michael Hanselmann
but disabled in the master daemon, will be dropped. Direct calls to
143 e5a246df Michael Hanselmann
opcodes have to be used instead.
144 e5a246df Michael Hanselmann
145 9189c902 Michael Hanselmann
.. _data-query-response:
146 e5a246df Michael Hanselmann
147 9189c902 Michael Hanselmann
Response
148 9189c902 Michael Hanselmann
^^^^^^^^
149 e5a246df Michael Hanselmann
150 e5a246df Michael Hanselmann
The result is a dictionary with the following entries:
151 e5a246df Michael Hanselmann
152 9189c902 Michael Hanselmann
``fields`` (list of :ref:`field definitions <field-def>`)
153 e5a246df Michael Hanselmann
  In-order list of a :ref:`field definition <field-def>` for each
154 e5a246df Michael Hanselmann
  requested field, unknown fields are returned with the kind
155 e5a246df Michael Hanselmann
  ``unknown``. Length must be equal to number of requested fields.
156 9189c902 Michael Hanselmann
``data`` (list of lists of tuples)
157 9189c902 Michael Hanselmann
  List of lists, one list for each item found. Each item's list must
158 9189c902 Michael Hanselmann
  have one entry for each field listed in ``fields`` (meaning their
159 9189c902 Michael Hanselmann
  length is equal). Each field entry is a tuple of ``(status, value)``.
160 9189c902 Michael Hanselmann
  ``status`` must be one of the following values:
161 e5a246df Michael Hanselmann
162 e5a246df Michael Hanselmann
  Normal (numeric 0)
163 e5a246df Michael Hanselmann
    Value is available and matches the kind in the :ref:`field
164 e5a246df Michael Hanselmann
    definition <field-def>`.
165 9189c902 Michael Hanselmann
  Unknown field (numeric 1)
166 9189c902 Michael Hanselmann
    Field for this column is not known. Value must be ``None``.
167 9189c902 Michael Hanselmann
  No data (numeric 2)
168 e5a246df Michael Hanselmann
    Exact meaning depends on query, e.g. node is unreachable or marked
169 e5a246df Michael Hanselmann
    offline. Value must be ``None``.
170 9189c902 Michael Hanselmann
  Value unavailable for item (numeric 3)
171 9189c902 Michael Hanselmann
    Used if, for example, NIC 3 is requested for an instance with only
172 9189c902 Michael Hanselmann
    one network interface. Value must be ``None``.
173 e5a246df Michael Hanselmann
174 9189c902 Michael Hanselmann
Example response after requesting the fields ``name``, ``mfree``,
175 9189c902 Michael Hanselmann
``xyz``, ``mtotal``, ``nic0.ip``, ``nic1.ip`` and ``nic2.ip``::
176 e5a246df Michael Hanselmann
177 e5a246df Michael Hanselmann
  {
178 e5a246df Michael Hanselmann
    "fields": [
179 e5a246df Michael Hanselmann
      { "name": "name", "title": "Name", "kind": "text", },
180 e5a246df Michael Hanselmann
      { "name": "mfree", "title": "MemFree", "kind": "unit", },
181 e5a246df Michael Hanselmann
      # Unknown field
182 e5a246df Michael Hanselmann
      { "name": "xyz", "title": None, "kind": "unknown", },
183 e5a246df Michael Hanselmann
      { "name": "mtotal", "title": "MemTotal", "kind": "unit", },
184 9189c902 Michael Hanselmann
      { "name": "nic0.ip", "title": "Nic.IP/0", "kind": "text", },
185 9189c902 Michael Hanselmann
      { "name": "nic1.ip", "title": "Nic.IP/1", "kind": "text", },
186 9189c902 Michael Hanselmann
      { "name": "nic2.ip", "title": "Nic.IP/2", "kind": "text", },
187 e5a246df Michael Hanselmann
      ],
188 e5a246df Michael Hanselmann
189 e5a246df Michael Hanselmann
    "data": [
190 9189c902 Michael Hanselmann
      [(0, "node1"), (0, 128), (1, None), (0, 4096),
191 9189c902 Michael Hanselmann
       (0, "192.0.2.1"), (0, "192.0.2.2"), (3, None)],
192 9189c902 Michael Hanselmann
      [(0, "node2"), (0, 96), (1, None), (0, 5000),
193 9189c902 Michael Hanselmann
       (0, "192.0.2.21"), (0, "192.0.2.39"), (3, "192.0.2.90")],
194 9189c902 Michael Hanselmann
      # Node not available, can't get "mfree" or "mtotal"
195 9189c902 Michael Hanselmann
      [(0, "node3"), (2, None), (1, None), (2, None),
196 9189c902 Michael Hanselmann
       (0, "192.0.2.30"), (3, None), (3, None)],
197 e5a246df Michael Hanselmann
      ],
198 e5a246df Michael Hanselmann
  }
199 e5a246df Michael Hanselmann
200 9189c902 Michael Hanselmann
.. _fields-query:
201 9189c902 Michael Hanselmann
202 9189c902 Michael Hanselmann
Fields query
203 9189c902 Michael Hanselmann
++++++++++++
204 9189c902 Michael Hanselmann
205 9189c902 Michael Hanselmann
.. _fields-query-request:
206 9189c902 Michael Hanselmann
207 9189c902 Michael Hanselmann
Request
208 9189c902 Michael Hanselmann
^^^^^^^
209 9189c902 Michael Hanselmann
210 9189c902 Michael Hanselmann
The request is a dictionary with the following entries:
211 9189c902 Michael Hanselmann
212 9189c902 Michael Hanselmann
``kind`` (string, required)
213 9189c902 Michael Hanselmann
  An :ref:`item type <item-types>`.
214 9189c902 Michael Hanselmann
``fields`` (list of strings, optional)
215 9189c902 Michael Hanselmann
  List of names of fields to return. If not set, all fields are
216 9189c902 Michael Hanselmann
  returned. Example::
217 9189c902 Michael Hanselmann
218 9189c902 Michael Hanselmann
    ["name", "mem", "nic0.ip", "disk0.size", "disk1.size"]
219 e5a246df Michael Hanselmann
220 9189c902 Michael Hanselmann
.. _fields-query-response:
221 9189c902 Michael Hanselmann
222 9189c902 Michael Hanselmann
Response
223 9189c902 Michael Hanselmann
^^^^^^^^
224 e5a246df Michael Hanselmann
225 e5a246df Michael Hanselmann
The result is a dictionary with the following entries:
226 e5a246df Michael Hanselmann
227 9189c902 Michael Hanselmann
``fields`` (list of :ref:`field definitions <field-def>`)
228 9189c902 Michael Hanselmann
  List of a :ref:`field definition <field-def>` for each field. If
229 9189c902 Michael Hanselmann
  ``fields`` was set in the request and contained an unknown field, it
230 9189c902 Michael Hanselmann
  is returned as type ``unknown``.
231 e5a246df Michael Hanselmann
232 e5a246df Michael Hanselmann
Example::
233 e5a246df Michael Hanselmann
234 e5a246df Michael Hanselmann
  {
235 e5a246df Michael Hanselmann
    "fields": [
236 e5a246df Michael Hanselmann
      { "name": "name", "title": "Name", "kind": "text", },
237 e5a246df Michael Hanselmann
      { "name": "mfree", "title": "MemFree", "kind": "unit", },
238 e5a246df Michael Hanselmann
      { "name": "mtotal", "title": "MemTotal", "kind": "unit", },
239 9189c902 Michael Hanselmann
      { "name": "nic0.ip", "title": "Nic.IP/0", "kind": "text", },
240 9189c902 Michael Hanselmann
      { "name": "nic1.ip", "title": "Nic.IP/1", "kind": "text", },
241 9189c902 Michael Hanselmann
      { "name": "nic2.ip", "title": "Nic.IP/2", "kind": "text", },
242 9189c902 Michael Hanselmann
      { "name": "nic3.ip", "title": "Nic.IP/3", "kind": "text", },
243 9189c902 Michael Hanselmann
      # …
244 9189c902 Michael Hanselmann
      { "name": "disk0.size", "title": "Disk.Size/0", "kind": "unit", },
245 9189c902 Michael Hanselmann
      { "name": "disk1.size", "title": "Disk.Size/1", "kind": "unit", },
246 9189c902 Michael Hanselmann
      { "name": "disk2.size", "title": "Disk.Size/2", "kind": "unit", },
247 9189c902 Michael Hanselmann
      { "name": "disk3.size", "title": "Disk.Size/3", "kind": "unit", },
248 9189c902 Michael Hanselmann
      # …
249 e5a246df Michael Hanselmann
      ]
250 e5a246df Michael Hanselmann
  }
251 e5a246df Michael Hanselmann
252 e5a246df Michael Hanselmann
.. _field-def:
253 e5a246df Michael Hanselmann
254 e5a246df Michael Hanselmann
Field definition
255 e5a246df Michael Hanselmann
++++++++++++++++
256 e5a246df Michael Hanselmann
257 e5a246df Michael Hanselmann
A field definition is a dictionary with the following entries:
258 e5a246df Michael Hanselmann
259 9189c902 Michael Hanselmann
``name`` (string)
260 9189c902 Michael Hanselmann
  Field name. Must only contain characters matching ``[a-z0-9/._]``.
261 9189c902 Michael Hanselmann
``title`` (string)
262 e5a246df Michael Hanselmann
  Human-readable title to use in output. Must not contain whitespace.
263 9189c902 Michael Hanselmann
``kind`` (string)
264 e5a246df Michael Hanselmann
  Field type, one of the following:
265 e5a246df Michael Hanselmann
266 e5a246df Michael Hanselmann
  ``unknown``
267 9189c902 Michael Hanselmann
    Unknown field
268 e5a246df Michael Hanselmann
  ``text``
269 e5a246df Michael Hanselmann
    String
270 e5a246df Michael Hanselmann
  ``bool``
271 e5a246df Michael Hanselmann
    Boolean, true/false
272 e5a246df Michael Hanselmann
  ``number``
273 e5a246df Michael Hanselmann
    Numeric
274 e5a246df Michael Hanselmann
  ``unit``
275 e5a246df Michael Hanselmann
    Numeric, in megabytes
276 9189c902 Michael Hanselmann
  ``timestamp``
277 9189c902 Michael Hanselmann
    Unix timestamp in seconds since the epoch
278 e5a246df Michael Hanselmann
  ``other``
279 e5a246df Michael Hanselmann
    Free-form type, depending on query
280 e5a246df Michael Hanselmann
281 e5a246df Michael Hanselmann
  More types can be added in the future, so clients should default to
282 e5a246df Michael Hanselmann
  formatting any unknown types the same way as "other", which should be
283 e5a246df Michael Hanselmann
  a string representation in most cases.
284 e5a246df Michael Hanselmann
285 9189c902 Michael Hanselmann
.. TODO: Investigate whether there are fields with floating point
286 9189c902 Michael Hanselmann
.. numbers
287 9189c902 Michael Hanselmann
288 e5a246df Michael Hanselmann
Example 1 (item name)::
289 e5a246df Michael Hanselmann
290 e5a246df Michael Hanselmann
  {
291 e5a246df Michael Hanselmann
    "name": "name",
292 e5a246df Michael Hanselmann
    "title": "Name",
293 e5a246df Michael Hanselmann
    "kind": "text",
294 e5a246df Michael Hanselmann
  }
295 e5a246df Michael Hanselmann
296 e5a246df Michael Hanselmann
Example 2 (free memory)::
297 e5a246df Michael Hanselmann
298 e5a246df Michael Hanselmann
  {
299 e5a246df Michael Hanselmann
    "name": "mfree",
300 e5a246df Michael Hanselmann
    "title": "MemFree",
301 e5a246df Michael Hanselmann
    "kind": "unit",
302 e5a246df Michael Hanselmann
  }
303 e5a246df Michael Hanselmann
304 e5a246df Michael Hanselmann
Example 3 (list of primary instances)::
305 e5a246df Michael Hanselmann
306 e5a246df Michael Hanselmann
  {
307 e5a246df Michael Hanselmann
    "name": "pinst",
308 e5a246df Michael Hanselmann
    "title": "PrimaryInstances",
309 e5a246df Michael Hanselmann
    "kind": "other",
310 e5a246df Michael Hanselmann
  }
311 e5a246df Michael Hanselmann
312 e5a246df Michael Hanselmann
.. _old-result-format:
313 e5a246df Michael Hanselmann
314 e5a246df Michael Hanselmann
Old result format
315 e5a246df Michael Hanselmann
+++++++++++++++++
316 e5a246df Michael Hanselmann
317 e5a246df Michael Hanselmann
To limit the amount of code necessary, the :ref:`new result format
318 9189c902 Michael Hanselmann
<data-query-response>` will be converted for clients calling the old
319 9189c902 Michael Hanselmann
methods.  Unavailable values are set to ``None``. If unknown fields were
320 9189c902 Michael Hanselmann
requested, the whole query fails as the client expects exactly the
321 9189c902 Michael Hanselmann
fields it requested.
322 9189c902 Michael Hanselmann
323 9189c902 Michael Hanselmann
.. _luxi:
324 e5a246df Michael Hanselmann
325 e5a246df Michael Hanselmann
LUXI
326 e5a246df Michael Hanselmann
++++
327 e5a246df Michael Hanselmann
328 e5a246df Michael Hanselmann
Currently query calls take a number of parameters, e.g. names, fields
329 e5a246df Michael Hanselmann
and whether to use locking. These will continue to work and return the
330 9189c902 Michael Hanselmann
:ref:`old result format <old-result-format>`. Only clients using the
331 9189c902 Michael Hanselmann
new calls described below will be able to make use of new features such
332 9189c902 Michael Hanselmann
as filters. Two new calls are introduced:
333 9189c902 Michael Hanselmann
334 9189c902 Michael Hanselmann
``Query``
335 9189c902 Michael Hanselmann
  Execute a query on items, optionally filtered. Takes a single
336 9189c902 Michael Hanselmann
  parameter, a :ref:`query object <data-query-request>` encoded as a
337 9189c902 Michael Hanselmann
  dictionary and returns a :ref:`data query response
338 9189c902 Michael Hanselmann
  <data-query-response`.
339 9189c902 Michael Hanselmann
``QueryFields``
340 9189c902 Michael Hanselmann
  Return list of supported fields as :ref:`field definitions
341 9189c902 Michael Hanselmann
  <field-def>`. Takes a single parameter, a :ref:`fields query object
342 9189c902 Michael Hanselmann
  <fields-query-request>` encoded as a dictionary and returns a
343 9189c902 Michael Hanselmann
  :ref:`fields query response <fields-query-response>`.
344 9189c902 Michael Hanselmann
345 e5a246df Michael Hanselmann
346 e5a246df Michael Hanselmann
Python
347 e5a246df Michael Hanselmann
++++++
348 e5a246df Michael Hanselmann
349 e5a246df Michael Hanselmann
The LUXI API is more or less mapped directly into Python. In addition to
350 e5a246df Michael Hanselmann
the existing stub functions new ones will be added for the new query
351 e5a246df Michael Hanselmann
requests.
352 e5a246df Michael Hanselmann
353 e5a246df Michael Hanselmann
RAPI
354 e5a246df Michael Hanselmann
++++
355 e5a246df Michael Hanselmann
356 e5a246df Michael Hanselmann
The RAPI interface already returns dictionaries for each item, but to
357 e5a246df Michael Hanselmann
not break compatibility no changes should be made to the structure (e.g.
358 e5a246df Michael Hanselmann
to include field definitions). The proposal here is to add a new
359 e5a246df Michael Hanselmann
parameter to allow clients to execute the requests described in this
360 e5a246df Michael Hanselmann
proposal directly and to receive the unmodified result. The new formats
361 e5a246df Michael Hanselmann
are a lot more verbose, flexible and extensible.
362 e5a246df Michael Hanselmann
363 9189c902 Michael Hanselmann
.. _cli-programs:
364 9189c902 Michael Hanselmann
365 9189c902 Michael Hanselmann
CLI programs
366 9189c902 Michael Hanselmann
++++++++++++
367 9189c902 Michael Hanselmann
368 9189c902 Michael Hanselmann
Command line programs might have difficulties to display the verbose
369 9189c902 Michael Hanselmann
status data to the user. There are several options:
370 9189c902 Michael Hanselmann
371 9189c902 Michael Hanselmann
- Use colours to indicate missing values
372 9189c902 Michael Hanselmann
- Display status as value in parentheses, e.g. "(unavailable)"
373 9189c902 Michael Hanselmann
- Hide unknown columns from the result table and print a warning
374 9189c902 Michael Hanselmann
- Exit with non-zero code to indicate failures and/or missing data
375 9189c902 Michael Hanselmann
376 9189c902 Michael Hanselmann
Some are better for interactive usage, some better for use by other
377 9189c902 Michael Hanselmann
programs. It is expected that a combination will be used. The column
378 9189c902 Michael Hanselmann
separator (``--separator=…``) can be used to differentiate between
379 9189c902 Michael Hanselmann
interactive and programmatic usage.
380 9189c902 Michael Hanselmann
381 e5a246df Michael Hanselmann
382 e5a246df Michael Hanselmann
Other discussed solutions
383 e5a246df Michael Hanselmann
-------------------------
384 e5a246df Michael Hanselmann
385 e5a246df Michael Hanselmann
Another solution discussed was to add an additional column for each
386 e5a246df Michael Hanselmann
non-static field containing the status. Clients interested in the status
387 e5a246df Michael Hanselmann
could explicitely query for it.
388 e5a246df Michael Hanselmann
389 e5a246df Michael Hanselmann
.. vim: set textwidth=72 :
390 e5a246df Michael Hanselmann
.. Local Variables:
391 e5a246df Michael Hanselmann
.. mode: rst
392 e5a246df Michael Hanselmann
.. fill-column: 72
393 e5a246df Michael Hanselmann
.. End: