CORE

class pOCCI.CORE.CORE_CREATE001[source]

Create an OCCI Resource

Unsupported test: Creating compute instances without os_tpl is not supported.

It can be called by::
pOCCI -t ‘CORE/CREATE/001’
objective = 'Create an OCCI Resource'
classmethod test()[source]
class pOCCI.CORE.CORE_CREATE006[source]

Add an OCCI Mixin definition

Unsupported test: Not implemented.

It can be called by::
pOCCI -t ‘CORE/CREATE/006’
objective = 'Add an OCCI mixin definition'
classmethod test()[source]
class pOCCI.CORE.CORE_DELETE001[source]
objective = 'Delete an OCCI Entity'
classmethod test()[source]
class pOCCI.CORE.CORE_DISCOVERY001[source]
objective = 'Retrieving all OCCI Categories supported by the OCCI Server'
classmethod test()[source]
class pOCCI.CORE.CORE_DISCOVERY002[source]
objective = 'Retrieving the OCCI Categories with an OCCI Category filter from the OCCI Server'
classmethod test()[source]
class pOCCI.CORE.CORE_MISC001[source]
objective = 'Trigger OCCI Action on existing OCCI Entity'
classmethod test()[source]
class pOCCI.CORE.CORE_READ001[source]
objective = 'Retrieve the URLs of all OCCI Entities belonging to an OCCI Kind or OCCI Mixin'
classmethod test()[source]
class pOCCI.CORE.CORE_READ002[source]
objective = 'Retrieve the URLs of the OCCI Entities belonging to an OCCI Kind or OCCI Mixin and related to an OCCI Category filter'
classmethod test()[source]
pOCCI.CORE.CORE_READ002_COMMON(category, links=[])[source]
class pOCCI.CORE.CORE_READ007[source]
objective = 'Retrieve the description of an OCCI Entity'
classmethod test()[source]
pOCCI.CORE.CORE_READ_DESCRIPTION(filter=None)[source]

Read OCCI Entity Description

Parameters:filter{} (string) – required attribute names and values
Returns:status, err_msg, url, entity description
Return type:[bool, string[], string, occi.Category[], occi.Link[], occi.Attribute[]]
pOCCI.CORE.CORE_READ_URL(filter)[source]
class pOCCI.CORE.CORE_UPDATE001[source]

Full update of a specific OCCI Entity

Requires existing compute machine.

OpenNebula issues:

objective = 'Full update of a specific OCCI Entity'
classmethod test()[source]
class pOCCI.CORE.INFRA_CREATE001[source]
objective = 'Create an OCCI Compute Resource'
classmethod test()[source]
class pOCCI.CORE.INFRA_CREATE002[source]
objective = 'Create an OCCI Storage Resource'
classmethod test()[source]
class pOCCI.CORE.INFRA_CREATE003[source]
objective = 'Create an OCCI Network Resource'
classmethod test()[source]
class pOCCI.CORE.INFRA_CREATE004[source]
objective = 'Create an OCCI Compute Resource using an OS and resource template'
classmethod test()[source]
class pOCCI.CORE.INFRA_CREATE005[source]

Unsupported test, os_tpl required.

It can be called by pOCCI -t ‘INFRA/CREATE/005’

objective = 'Create an OCCI Compute Resource with an OCCI Storagelink and an OCCI Networkinterface'
classmethod test()[source]
class pOCCI.CORE.INFRA_CREATE006[source]

Opennebula requires running compute instance.

objective = 'Create an OCCI Storagelink between an existing OCCI Compute and OCCI Storage Resource'
classmethod test()[source]
class pOCCI.CORE.INFRA_CREATE007[source]

Opennebula requires running compute instance.

objective = 'Create an OCCI Networkinterface between an existing OCCI Compute and OCCI Network Resource'
classmethod test()[source]
pOCCI.CORE.INFRA_CREATE_COMMON(resource, categories, additional_attributes, err_msg)[source]

Generic help function to create OCCI Infrastructure resources.

HTTP Headers renderer is always used.

Parameters:
  • resource (string) – OCCI Category term (compute, storage, network)
  • categories[] (occi.Category) – OCCI Categories to add to rendering
  • additional_attributes[] (occi.AttributeDefinition) – additional attributes to set from example defaults
  • err_msg[] (string) – error messages list to append
Returns:

status and error message list

Return type:

[bool, string[]]

Opennebula requires running compute instance.

Parameters:
  • resource_name (string) – Resource Name (storage, network)
  • resource_type (string) – Resource Type (link, interface)
Returns:

status, err_msg

Return type:

[bool, string[]]

class pOCCI.CORE.Test[source]

Base class for OCCI compliance tests

categories = []
classmethod clear_categories()[source]
classmethod fetch_categories(err_msg)[source]
classmethod get_category(uri)[source]
objective = None
classmethod pretest_http_status(http_ok_status, err_msg, force=False)[source]
classmethod search_category(filter)[source]
classmethod test()[source]
pOCCI.CORE.check_body_entities(body, headers, err_msg=[])[source]
pOCCI.CORE.check_content_type(content_type)[source]
pOCCI.CORE.check_http_status(http_expected_status, http_status)[source]
pOCCI.CORE.check_requested_content_type(content_type, big=False, headers=False)[source]
pOCCI.CORE.gen_id(prefix)[source]
pOCCI.CORE.get_attributes(attribute_definitions, attributes, err_msg)[source]

Fill attribute values from example_attributes for all required attributes.

Parameters:
  • attribute_definitions[] (occi.AttributeDefinition) – attribute definitions
  • attributes{} (occi.Attribute) – result attributes dictionary
  • err_msg[] (string) – list of errors to append
Returns:

all required attributes has a value

Return type:

bool

pOCCI.CORE.match_category(category, filter)[source]
pOCCI.CORE.match_entity(attributes, filter)[source]
pOCCI.CORE.testsuite_init()[source]

Initialize OCCI testsuite

Renderers from occi_libs needs to be initialized first.

occi

class pOCCI.occi.Attribute[source]

OCCI Attribute Instance

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

Compare two OCCI Attribute Values

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

validate()[source]
class pOCCI.occi.AttributeDefinition[source]

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()[source]
isrequired()[source]
class pOCCI.occi.Category[source]

OCCI Category

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

Base class for pOCCI exceptions.

class pOCCI.occi.Generic[source]

Generic OCCI object in python.

validate()[source]

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()[source]
exception pOCCI.occi.ParseError(value, body=None)[source]

Parse exception.

exception pOCCI.occi.RenderError[source]

Render exception.

exception pOCCI.occi.TransportError[source]

Transport exception.

occi_libs

pOCCI.occi_libs.html_escape(s)[source]
pOCCI.occi_libs.occi_config_init()[source]

Initialize pOCCI configuration.

Reads the configuration file: /etc/pOCCI.cfg, ~/.pOCCI.cfg.

pOCCI.occi_libs.occi_format(results)[source]
pOCCI.occi_libs.occi_init()[source]

Initialize pOCCI.

pOCCI.occi_libs.occi_print(results, outputformat)[source]
pOCCI.occi_libs.occi_render_init()[source]

Initialize pOCCI renderers.

Limitations:
  • For HTTP GET requests ‘text/occi’ is always needed
  • For bigger data ‘text/occi’ should not be used (using ‘text/plain’)
pOCCI.occi_libs.occi_test(name, objective, status, err_msg, running_time=None)[source]
pOCCI.occi_libs.result2str(result)[source]

render

pOCCI.render.create_renderer(req_mimetype)[source]

Create OCCI Renderer.

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

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[source]

OCCI Renderer base skeleton.

parse_categories(body, headers)[source]

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)[source]

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)[source]

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)[source]

Render OCCI Category collection

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

Render OCCI Category

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

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)[source]

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[source]

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)[source]

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)[source]

Helper generator method to split values in HTTP Header.

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

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)[source]

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[]]

reHeaderChunk = <_sre.SRE_Pattern object at 0x21a2d10>
render_attributes(attributes)[source]

Render Attributes

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

Render OCCI Category collection

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

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)[source]

Render Locations

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

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[source]

JSON OCCI Renderer

render_text

class pOCCI.render_text.TextRenderer[source]

Plain Text OCCI Renderer

Empty array is always returned as headers during rendering.

parse_actions(body)[source]

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)[source]

Parse OCCI Attribute body

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

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)[source]

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)[source]

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)[source]

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)[source]

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)[source]

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[]]

reAttribute = <_sre.SRE_Pattern object at 0x21722a0>
reAttributes = <_sre.SRE_Pattern object at 0x1f67330>
reBool = <_sre.SRE_Pattern object at 0x1beecc8>
reCategory = <_sre.SRE_Pattern object at 0x1ec0dc8>
reChunks = <_sre.SRE_Pattern object at 0x1ebd5b0>
reIntNumber = <_sre.SRE_Pattern object at 0x1e127c8>
reKeyCheck = <_sre.SRE_Pattern object at 0x1f34420>
reKeyValue = <_sre.SRE_Pattern object at 0x1db2e40>
reLocation = <_sre.SRE_Pattern object at 0x1f669b0>
reNumber = <_sre.SRE_Pattern object at 0x1e126f0>
reQuoted = <_sre.SRE_Pattern object at 0x1df0bb0>
reSP = <_sre.SRE_Pattern object at 0x1e2dd40>
reStringUnescape = <_sre.SRE_Pattern object at 0x213d490>
render_attribute(attribute)[source]

Render Attribute

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

Render OCCI Category collection

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

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)[source]

Render Locations

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

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)[source]
pOCCI.render_text.text_attribute_def(ad=None)[source]
pOCCI.render_text.text_attribute_defs(ads=None)[source]
pOCCI.render_text.text_attribute_repr(attribute)[source]

Render one OCCI Attribute.

pOCCI.render_text.text_attribute_value(attribute)[source]

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)[source]

Render Link Attribute

render_uri

class pOCCI.render_uri.URIListRenderer[source]

URI list OCCI Renderer

Empty array is always returned as headers during rendering.

parse_categories(body, headers)[source]

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)[source]

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)[source]

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)[source]

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)[source]

Render Locations

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

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

class pOCCI.transport.Transport(config)[source]

Transport base class. Curl is used, keystone authentication supported.

Available methods: delete(), get(), post(), put().

auth_keystone(url, tenants=True)[source]
clean()[source]
delete(url=None, mimetype=None, headers=[], body=None)[source]

Send HTTP DELETE request

Parameters:
  • base_url (string) – OCCI server URL (default: from config)
  • url (string) – URL
  • mimetype (string) – accepted mimetype (empty string=’*/*’)
  • headers[] (string) – HTTP Headers
Returns:

[body, header, HTTP status, content type]

Return type:

[string[], string[], string, string]

dprint(s)[source]
get(url=None, mimetype=None, headers=[])[source]

Send HTTP GET request

Parameters:
  • base_url (string) – OCCI server URL (default: from config)
  • url (string) – URL
  • mimetype (string) – accepted mimetype (empty string=’*/*’)
  • headers[] (string) – HTTP Headers
Returns:

[body, header, HTTP status, content type]

Return type:

[string[], string[], string, string]

perform()[source]
post(url=None, mimetype=None, headers=[], body='OK')[source]

Send HTTP POST request

Parameters:
  • base_url (string) – OCCI server URL (default: from config)
  • url (string) – URL
  • mimetype (string) – accepted mimetype (empty string=’*/*’)
  • headers[] (string) – HTTP Headers
  • post (string) – HTTP Body
Returns:

[body, header, HTTP status, content type]

Return type:

[string[], string[], string, string]

put(url=None, mimetype=None, headers=[], body='OK')[source]

Send HTTP POST request

Parameters:
  • base_url (string) – OCCI server URL (default: from config)
  • url (string) – URL
  • mimetype (string) – accepted mimetype (empty string=’*/*’)
  • headers[] (string) – HTTP Headers
  • post (string) – HTTP Body
Returns:

[body, header, HTTP status, content type]

Return type:

[string[], string[], string, string]

reEncoding = <_sre.SRE_Pattern object at 0x217c4e0>
reHeader = <_sre.SRE_Pattern object at 0x21719a0>
reStatus = <_sre.SRE_Pattern object at 0x1e2df08>
request(url=None, mimetype=None, headers=[])[source]
pOCCI.transport.get_header2(buff)[source]
pOCCI.transport.get_header3(buff)[source]

version

Table Of Contents

Previous topic

OCCI Compliance Tests Matrix

Next topic

Python versions

This Page