Created
November 5, 2012 16:15
-
-
Save ffeldhaus/4018052 to your computer and use it in GitHub Desktop.
rOCCI parse text plain message
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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