Skip to content

Instantly share code, notes, and snippets.

@ffeldhaus
Created November 5, 2012 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ffeldhaus/4018052 to your computer and use it in GitHub Desktop.
Save ffeldhaus/4018052 to your computer and use it in GitHub Desktop.
rOCCI parse text plain message
1.9.3p286 :001 > body=%Q|Category: storage;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind"
1.9.3p286 :002"> Category: storage;scheme="http://opennebula.org/occi/infrastructure#";class="mixin"
1.9.3p286 :003"> X-OCCI-Attribute: occi.core.id="e7db6669-d819-5e20-a7ee-90be46591490"
1.9.3p286 :004"> X-OCCI-Attribute: occi.core.title="debian6"
1.9.3p286 :005"> X-OCCI-Attribute: occi.core.summary="Debian6 sample image"
1.9.3p286 :006"> X-OCCI-Attribute: occi.storage.state="online"
1.9.3p286 :007"> X-OCCI-Attribute: org.opennebula.storage.id="31"
1.9.3p286 :008"> X-OCCI-Attribute: org.opennebula.storage.type="OS"
1.9.3p286 :009"> X-OCCI-Attribute: org.opennebula.storage.dev_prefix="xvd"
1.9.3p286 :010"> X-OCCI-Attribute: org.opennebula.storage.bus="ide"
1.9.3p286 :011"> X-OCCI-Attribute: org.opennebula.storage.persistent="NO"|
=> "Category: storage;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind"\nCategory: storage;scheme="http://opennebula.org/occi/infrastructure#";class="mixin"\nX-OCCI-Attribute: occi.core.id="e7db6669-d819-5e20-a7ee-90be46591490"\nX-OCCI-Attribute: occi.core.title="debian6"\nX-OCCI-Attribute: occi.core.summary="Debian6 sample image"\nX-OCCI-Attribute: occi.storage.state="online"\nX-OCCI-Attribute: org.opennebula.storage.id="31"\nX-OCCI-Attribute: org.opennebula.storage.type="OS"\nX-OCCI-Attribute: org.opennebula.storage.dev_prefix="xvd"\nX-OCCI-Attribute: org.opennebula.storage.bus="ide"\nX-OCCI-Attribute: org.opennebula.storage.persistent="NO""
1.9.3p286 :012 > require 'occi'
=> true
1.9.3p286 :013 > Occi::Parser.parse('text/plain',body)
=> [[], {
"kinds": [
],
"mixins": [
],
"actions": [
],
"resources": [
{
"kind": "http://schemas.ogf.org/occi/infrastructure#storage",
"mixins": [
"http://opennebula.org/occi/infrastructure#storage"
],
"attributes": {
"occi": {
"core": {
"id": "e7db6669-d819-5e20-a7ee-90be46591490",
"title": "debian6",
"summary": "Debian6 sample image"
},
"storage": {
"state": "online"
}
},
"org": {
"opennebula": {
"storage": {
"id": "31",
"type": "OS",
"dev_prefix": "xvd",
"bus": "ide",
"persistent": "NO"
}
}
}
},
"id": "e7db6669-d819-5e20-a7ee-90be46591490"
}
],
"links": [
],
"action": null
}]
1.9.3p286 :014 >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment