CORE

occi

class pOCCI.occi.Attribute

OCCI Attribute Instance

Variables:
  • name (string) – attribute name
  • value – attribute value (any type)
  • type (string) – ‘string’, ‘number’, ‘boolean’, ‘enum’ [string]
classmethod equals(a1, a2)

Compare two OCCI Attribute Values

:param occi.Attribute self :param {} a1: attribute value :param {} a2: attribute value :return: attributes equals :rtype: bool

validate()
class pOCCI.occi.AttributeDefinition

OCCI Attribute Definition

Variables:
  • immutable (bool) – attribute can’t be changed [false]
  • required (bool) – attribute is required [false]
  • type (string) – ‘string’, ‘number’, ‘boolean’, ‘enum’ [string]
  • default – default value
  • description (string) – description
isimmutable()
isrequired()
class pOCCI.occi.Category

OCCI Category

Variables:
  • term (string) – term
  • scheme (string) – scheme
  • class (string) – class
  • ... – other fields (location, actions, attributes, ...)
validate()
exception pOCCI.occi.Error

Base class for pOCCI exceptions.

class pOCCI.occi.Generic

Generic OCCI object in python.

validate()

Validate OCCI object.

Returns:OCCI object is valid
Return type:bool

OCCI Link

Variables:
  • uri (string) – URI
  • string[] (rel) – resource types
  • string (self) – self URI
  • category[] (string) – types
  • attributes{} (string) – attributes
validate()
exception pOCCI.occi.ParseError(value, body=None)

Parse exception.

exception pOCCI.occi.RenderError

Render exception.

exception pOCCI.occi.TransportError

Transport exception.

occi_libs

render

pOCCI.render.create_renderer(req_mimetype)

Create OCCI Renderer.

Parameters:req_mimetype (string) – requested mimetype
Returns:renderer or None
Return type:RenderBase
pOCCI.render.parse_mimetype(mimetype)

Parse mimetype name string.

Example::
text/plain; charset=iso-8859-1
Parameters:mimetype (string) – mimetype
Result :(mimetype, charset) tuple
Return type:(string, string)

render_base

class pOCCI.render_base.Renderer

OCCI Renderer base skeleton.

parse_categories(body, headers)

Parse OCCI Category Collection

Parameters:
  • body[] (string) – text to parse
  • headers[] (string) – headers to parse
Returns:

Array of OCCI Categories

Return type:

occi.Category[]

parse_locations(body, headers)

Parse OCCI Entity collection

Parameters:
  • body[] (string) – text to parse
  • headers[] (string) – headers to parse
Returns:

array of renderer-specific strings

Return type:

string[]

parse_resource(body, header)

Parse OCCI Resource instance

Parameters:
  • body[] (string) – text to parse
  • headers[] (string) – headers to parse
Returns:

categories, links, and attributes

Return type:

[occi.Category categories[], occi.Link links[], occi.Attribute attributes[]]

render_categories(categories)

Render OCCI Category collection

Parameters:category[] (occi.Category) – OCCI Category array
Returns:render result
Return type:[string, string[]]
render_category(category)

Render OCCI Category

Parameters:category (occi.Category) – OCCI Category object
Returns:render result
Return type:[string, string[]]
render_resource(categories, links=None, attributes=None)

Render OCCI Resource instance

Parameters:
  • categories[] (occi.Category) – OCCI Category array
  • links[] (occi.Link) – OCCI Link array
  • attributes[] (occi.Attribute) – OCCI Attribute array
Returns:

render result

Return type:

[string, string[]]

pOCCI.render_base.check_url(body, scheme=False, host=False, path=False)

Check validity of URL.

Parameters:
  • body (string) – validated URL
  • scheme (bool) – scheme required
  • host (bool) – hostname required
  • path (bool) – local path required
Returns:

URL validity, empty string considered as not valid

Return type:

bool

render_http

class pOCCI.render_http.HTTPHeadersRenderer

HTTP Headers OCCI Renderer

RFC 7230 http://www.ietf.org/rfc/rfc7230.txt.

Empty string is always returned as body during rendering.

Beware of HTTP Headers size limitations. It is better to not use ‘text/occi’ mimetype for transfering OCCI Category Collection.

parse_categories(body, headers)

Parse OCCI Category Collection

Beware of HTTP Headers size limitations. It is better to not use ‘text/occi’ mimetype for transfering OCCI Category Collection.

Parameters:
  • body[] (string) – text to parse (unused in plain/occi)
  • headers[] (string) – headers to parse
Returns:

Array of OCCI Categories

Return type:

occi.Category[]

parse_header_values(body)

Helper generator method to split values in HTTP Header.

Parameters:body (string) – parsed text
Returns:result values
Return type:string
parse_locations(body, headers)

Parse OCCI Entity collection

Parameters:
  • body[] (string) – text to parse (unused in text/occi)
  • headers[] (string) – headers to parse
Returns:

Array of links

Return type:

string[]

parse_resource(body, headers)

Parse OCCI Resource instance

Parameters:
  • body[] (string) – text to parse (unused in text/occi)
  • headers[] (string) – headers to parse
Returns:

categories, links, and attributes

Return type:

[occi.Category categories[], occi.Link links[], occi.Attribute attributes[]]

render_attributes(attributes)

Render Attributes

Parameters:attribute[] (occi.Attribute) – OCCI Attribute object
Returns:render result
Return type:string[]
render_categories(categories)

Render OCCI Category collection

Parameters:category[] (occi.Category) – OCCI Category array
Returns:render result
Return type:[string, string[]]
render_category(category)

Render OCCI Category

Parameters:category (occi.Category) – OCCI Category object
Returns:render result
Return type:[string, string[]]

Render OCCI Links

Parameters:link[] (occi.Link) – OCCI Link array
Returns:render result
Return type:string[]
render_locations(locations)

Render Locations

Parameters:location (string) – location URI
Returns:render result
Return type:[string, string[]]
render_resource(categories, links=None, attributes=None)

Render OCCI Resource instance

Parameters:
  • category (occi.Category) – OCCI Category object
  • links[] (occi.Link) – OCCI Link array
  • attributes[] (occi.Attribute) – OCCI Attribute array
Returns:

render result

Return type:

[string, string[]]

render_json

class pOCCI.render_json.JSONRenderer

JSON OCCI Renderer

render_text

class pOCCI.render_text.TextRenderer

Plain Text OCCI Renderer

Empty array is always returned as headers during rendering.

parse_actions(body)

Parse OCCI Actions.

Example:

http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop http://schemas.ogf.org/occi/infrastructure/compute/action#restart http://schemas.ogf.org/occi/infrastructure/compute/action#suspend
Parameters:body (string) – text to parse
Returns:array of string
Return type:string[]
parse_attribute_body(body)

Parse OCCI Attribute body

Parameters:body (string) – text to parse
Returns:attribute type and value
Return type:occi.Attribute
parse_attribute_defs(body)

Parse OCCI Attribute Definitions.

Example:

occi.core.id{immutable required} occi.core.title occi.core.target occi.core.source{required}
Parameters:body (string) – text to parse
Returns:array of OCCI Attribute Definition
Return type:occi.AttributeDefinition[]
parse_attribute_value(body)

Parse OCCI Attribute value and detect its type

string, number, and boolean types are detected, enum is returned as string.

Parameters:body (string) – text to parse
Returns:attribute type and value
Return type:[string, any]
parse_categories(body, headers)

Parse OCCI Category Collection

Parameters:
  • body[] (string) – text to parse
  • headers[] (string) – headers to parse (unused in plain/text)
Returns:

Array of OCCI Categories

Return type:

occi.Category[]

parse_category_body(body)

Parse OCCI Category body

Example:

entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="entity";location="/entity/";attributes="occi.core.id{immutable required} occi.core.title"
Parameters:body (string) – text to parse
Returns:OCCI Category
Return type:occi.Category

Parse OCCI Link body

Example:

</storage/0>;rel="http://schemas.ogf.org/occi/infrastructure#storage";self="/link/storagelink/compute_103_disk_0";category="http://schemas.ogf.org/occi/infrastructure#storagelink http://opennebula.org/occi/infrastructure#storagelink";occi.core.id="compute_103_disk_0";occi.core.title="ttylinux";occi.core.target="/storage/0";occi.core.source="/compute/103";occi.storagelink.deviceid="/dev/hda";occi.storagelink.state="active"
Parameters:body (string) – text to parse
Returns:OCCI Link
Return type:occi.Link
parse_locations(body, headers)

Parse OCCI Entity collection

Parameters:
  • body[] (string) – text to parse
  • headers[] (string) – headers to parse (unused in text/plain)
Returns:

Array of links

Return type:

string[]

parse_resource(body, header)

Parse OCCI Resource instance

Parameters:
  • body[] (string) – text to parse
  • headers[] (string) – headers to parse (unused in text/plain)
Returns:

categories, links, and attributes

Return type:

[occi.Category categories[], occi.Link links[], occi.Attribute attributes[]]

render_attribute(attribute)

Render Attribute

Parameters:attribute (occi.Attribute) – OCCI Attribute object
Returns:render result
Return type:string
render_categories(categories)

Render OCCI Category collection

Parameters:category[] (occi.Category) – OCCI Category array
Returns:render result
Return type:[string, string[]]
render_category(category)

Render OCCI Category

Parameters:category (occi.Category) – OCCI Category object
Returns:render result
Return type:[string, string[]]

Render OCCI Link

Parameters:link (occi.Link) – OCCI Link object
Returns:render result
Return type:string
render_locations(locations)

Render Locations

Parameters:location[] (string) – location URI
Returns:render result
Return type:[string, string[]]
render_resource(categories, links=None, attributes=None)

Render OCCI Resource instance

Parameters:
  • category (occi.Category) – OCCI Category object
  • links[] (occi.Link) – OCCI Link array
  • attributes[] (occi.Attribute) – OCCI Attribute array
Returns:

render result

Return type:

[string, string[]]

Returns:

render result

pOCCI.render_text.text_actions(actions=None)
pOCCI.render_text.text_attribute_def(ad=None)
pOCCI.render_text.text_attribute_defs(ads=None)
pOCCI.render_text.text_attribute_repr(attribute)

Render one OCCI Attribute.

pOCCI.render_text.text_attribute_value(attribute)

Render OCCI Attribute value.

Parameters:attribute (occi.Attribute) – attribute with a value to render
Returns:attribute value rendering
Return type:string
pOCCI.render_text.text_category(category=None)

Render Link Attribute

render_uri

class pOCCI.render_uri.URIListRenderer

URI list OCCI Renderer

Empty array is always returned as headers during rendering.

parse_categories(body, headers)

Parse OCCI Category Collection

This method can’t be used in URI list rendering.

Parameters:
  • body[] (string) – text to parse
  • headers[] (string) – headers to parse
Returns:

Array of OCCI Categories

Return type:

occi.Category[]

parse_locations(body, headers)

Parse OCCI Entity collection

Parameters:
  • body[] (string) – text to parse
  • headers[] (string) – headers to parse
Returns:

array of renderer-specific strings

Return type:

string[]

parse_resource(body, header)

Parse OCCI Resource instance

This method can’t be used in URI list rendering.

Parameters:
  • body[] (string) – text to parse
  • headers[] (string) – headers to parse
Returns:

categories, links, and attributes

Return type:

[occi.Category categories[], occi.Link links[], occi.Attribute attributes[]]

render_categories(categories)

Render OCCI Category collection

This method can’t be used in URI list rendering.

Parameters:category[] (occi.Category) – OCCI Category array
Returns:render result
Return type:[string, string[]]
render_locations(locations)

Render Locations

Parameters:location[] (string) – location URI
Returns:render result
Return type:[string, string[]]
render_resource(categories, links=None, attributes=None)

Render OCCI Resource instance

This method can’t be used in URI list rendering.

Parameters:
  • categories[] (occi.Category) – OCCI Category array
  • links[] (occi.Link) – OCCI Link array
  • attributes[] (occi.Attribute) – OCCI Attribute array
Returns:

render result

Return type:

[string, string[]]

transport

version

Table Of Contents

Previous topic

OCCI Compliance Tests Matrix

Next topic

Python versions

This Page