Package ganeti :: Package rapi :: Module baserlib
[hide private]
[frames] | no frames]

Module baserlib

source code

Remote API base resources library.

Classes [hide private]
  R_Generic
Generic class for resources.
Functions [hide private]
 
BuildUriList(ids, uri_format, uri_fields=("name","uri"))
Builds a URI list as used by index resources.
source code
 
ExtractField(sequence, index)
Creates a list containing one column out of a list of lists.
source code
 
MapFields(names, data)
Maps two lists into one dictionary.
source code
 
_Tags_GET(kind, name="")
Helper function to retrieve tags.
source code
 
_Tags_PUT(kind, tags, name="")
Helper function to set tags.
source code
 
_Tags_DELETE(kind, tags, name="")
Helper function to delete tags.
source code
 
MapBulkFields(itemslist, fields)
Map value to field name in to one dictionary.
source code
dict
MakeParamsDict(opts, params)
Makes params dictionary out of a option set.
source code
string
SubmitJob(op, cl=None)
Generic wrapper for submit job, for better http compatibility.
source code
 
GetClient()
Geric wrapper for luxi.Client(), for better http compatiblity.
source code
 
FeedbackFn(ts, log_type, log_msg)
Feedback logging function for http case.
source code

Imports: logging, luxi, rapi, http, ssconf, constants, opcodes, errors


Function Details [hide private]

BuildUriList(ids, uri_format, uri_fields=("name","uri"))

source code 

Builds a URI list as used by index resources.

Parameters:
  • ids - list of ids as strings
  • uri_format - format to be applied for URI
  • uri_fields - optional parameter for field IDs

ExtractField(sequence, index)

source code 

Creates a list containing one column out of a list of lists.

Parameters:
  • sequence - sequence of lists
  • index - index of field

MapFields(names, data)

source code 

Maps two lists into one dictionary.

Example:

   >>> MapFields(["a", "b"], ["foo", 123])
   {'a': 'foo', 'b': 123}
Parameters:
  • names - field names (list of strings)
  • data - field data (list)

MapBulkFields(itemslist, fields)

source code 

Map value to field name in to one dictionary.

Parameters:
  • itemslist - a list of items values
  • fields - a list of items names
Returns:
a list of mapped dictionaries

MakeParamsDict(opts, params)

source code 

Makes params dictionary out of a option set.

This function returns a dictionary needed for hv or be parameters. But only those fields which provided in the option set. Takes parameters frozensets from constants.

Parameters:
  • opts (dict) - selected options
  • params (frozenset) - subset of options
Returns: dict
dictionary of options, filtered by given subset.

SubmitJob(op, cl=None)

source code 

Generic wrapper for submit job, for better http compatibility.

Parameters:
  • op (list) - the list of opcodes for the job
  • cl (None or luxi.Client) - optional luxi client to use
Returns: string
the job ID

FeedbackFn(ts, log_type, log_msg)

source code 

Feedback logging function for http case.

We don't have a stdout for printing log messages, so log them to the http log at least.