occi-core 4.3.6 → 5.0.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (359) hide show
  1. checksums.yaml +4 -4
  2. data/.fasterer.yml +3 -0
  3. data/.gitignore +9 -16
  4. data/.rspec +1 -1
  5. data/.rubocop.yml +69 -0
  6. data/.travis.yml +27 -0
  7. data/AUTHORS +8 -6
  8. data/CHANGELOG.md +0 -0
  9. data/Gemfile +1 -1
  10. data/LICENSE +1 -1
  11. data/README.md +25 -170
  12. data/Rakefile +25 -17
  13. data/examples/initialize_model.rb +10 -0
  14. data/examples/parse_action_instance_json.rb +15 -0
  15. data/examples/parse_action_instance_text.rb +15 -0
  16. data/examples/parse_categories_json.rb +15 -0
  17. data/examples/parse_categories_text.rb +15 -0
  18. data/examples/parse_instance_json.rb +15 -0
  19. data/examples/parse_instance_text.rb +15 -0
  20. data/examples/parse_model_json.rb +9 -0
  21. data/examples/parse_model_text.rb +9 -0
  22. data/examples/render_action_instance_json.rb +17 -0
  23. data/examples/render_action_instance_text.rb +17 -0
  24. data/examples/render_instance_json.rb +20 -0
  25. data/examples/render_instance_text.rb +20 -0
  26. data/examples/render_model_json.rb +12 -0
  27. data/examples/render_model_text.rb +12 -0
  28. data/examples/rendering/action_instance.json +6 -0
  29. data/examples/rendering/action_instance.txt +2 -0
  30. data/examples/rendering/categories.json +78 -0
  31. data/examples/rendering/categories.txt +4 -0
  32. data/examples/rendering/instance.json +70 -0
  33. data/examples/rendering/instance.txt +12 -0
  34. data/examples/rendering/model.alt.json +1716 -0
  35. data/examples/rendering/model.json +785 -0
  36. data/examples/rendering/model.txt +68 -0
  37. data/lib/occi/core/action.rb +12 -26
  38. data/lib/occi/core/action_instance.rb +109 -65
  39. data/lib/occi/core/attribute.rb +136 -0
  40. data/lib/occi/core/attribute_definition.rb +269 -0
  41. data/lib/occi/core/category.rb +110 -83
  42. data/lib/occi/core/collection.rb +255 -0
  43. data/lib/occi/core/constants.rb +14 -0
  44. data/lib/occi/core/entity.rb +301 -195
  45. data/lib/occi/core/errors/.gitkeep +0 -0
  46. data/lib/occi/core/errors/attribute_definition_error.rb +11 -0
  47. data/lib/occi/core/errors/attribute_validation_error.rb +13 -0
  48. data/lib/occi/core/errors/category_validation_error.rb +13 -0
  49. data/lib/occi/core/errors/collection_lookup_error.rb +11 -0
  50. data/lib/occi/core/errors/instance_validation_error.rb +13 -0
  51. data/lib/occi/core/errors/mandatory_argument_error.rb +11 -0
  52. data/lib/occi/core/errors/model_lookup_error.rb +11 -0
  53. data/lib/occi/core/errors/parser_error.rb +11 -0
  54. data/lib/occi/core/errors/parsing_error.rb +11 -0
  55. data/lib/occi/core/errors/renderer_error.rb +11 -0
  56. data/lib/occi/core/errors/rendering_error.rb +11 -0
  57. data/lib/occi/core/errors/validation_error.rb +11 -0
  58. data/lib/occi/core/errors.rb +9 -0
  59. data/lib/occi/core/helpers/.gitkeep +0 -0
  60. data/lib/occi/core/helpers/argument_validator.rb +27 -0
  61. data/lib/occi/core/helpers/attributes_accessor.rb +22 -0
  62. data/lib/occi/core/helpers/error_handler.rb +29 -0
  63. data/lib/occi/core/helpers/hash_dereferencer.rb +149 -0
  64. data/lib/occi/core/helpers/identifier_validator.rb +135 -0
  65. data/lib/occi/core/helpers/instance_attribute_resetter.rb +131 -0
  66. data/lib/occi/core/helpers/instance_attributes_accessor.rb +30 -0
  67. data/lib/occi/core/helpers/locatable.rb +40 -0
  68. data/lib/occi/core/helpers/parser_dereferencer.rb +96 -0
  69. data/lib/occi/core/helpers/raw_json_parser.rb +18 -0
  70. data/lib/occi/core/helpers/renderable.rb +93 -0
  71. data/lib/occi/core/helpers/yaml_summoner.rb +44 -0
  72. data/lib/occi/core/helpers.rb +13 -0
  73. data/lib/occi/core/instance_builder.rb +162 -0
  74. data/lib/occi/core/kind.rb +100 -132
  75. data/lib/occi/core/link.rb +47 -72
  76. data/lib/occi/core/mixin.rb +76 -61
  77. data/lib/occi/core/model.rb +341 -0
  78. data/lib/occi/core/parsers/.gitkeep +0 -0
  79. data/lib/occi/core/parsers/base_parser.rb +168 -0
  80. data/lib/occi/core/parsers/json/.gitkeep +0 -0
  81. data/lib/occi/core/parsers/json/action_instance.rb +36 -0
  82. data/lib/occi/core/parsers/json/category.rb +113 -0
  83. data/lib/occi/core/parsers/json/entity.rb +156 -0
  84. data/lib/occi/core/parsers/json/validator/.gitkeep +0 -0
  85. data/lib/occi/core/parsers/json/validator/action-instance.json +3 -0
  86. data/lib/occi/core/parsers/json/validator/entity-collection.json +3 -0
  87. data/lib/occi/core/parsers/json/validator/link-collection.json +3 -0
  88. data/lib/occi/core/parsers/json/validator/link.json +3 -0
  89. data/lib/occi/core/parsers/json/validator/locations.json +3 -0
  90. data/lib/occi/core/parsers/json/validator/mixin-collection.json +3 -0
  91. data/lib/occi/core/parsers/json/validator/model.json +3 -0
  92. data/lib/occi/core/parsers/json/validator/occi-schema.json +277 -0
  93. data/lib/occi/core/parsers/json/validator/resource-collection.json +3 -0
  94. data/lib/occi/core/parsers/json/validator/resource.json +3 -0
  95. data/lib/occi/core/parsers/json/validator.rb +87 -0
  96. data/lib/occi/core/parsers/json_parser.rb +128 -0
  97. data/lib/occi/core/parsers/text/.gitkeep +0 -0
  98. data/lib/occi/core/parsers/text/category.rb +183 -0
  99. data/lib/occi/core/parsers/text/constants.rb +89 -0
  100. data/lib/occi/core/parsers/text/entity.rb +257 -0
  101. data/lib/occi/core/parsers/text/location.rb +48 -0
  102. data/lib/occi/core/parsers/text_parser.rb +257 -0
  103. data/lib/occi/core/parsers.rb +18 -0
  104. data/lib/occi/core/renderer_factory.rb +213 -0
  105. data/lib/occi/core/renderers/.gitkeep +0 -0
  106. data/lib/occi/core/renderers/base_renderer.rb +81 -0
  107. data/lib/occi/core/renderers/json/.gitkeep +0 -0
  108. data/lib/occi/core/renderers/json/action_instance.rb +24 -0
  109. data/lib/occi/core/renderers/json/attributes.rb +50 -0
  110. data/lib/occi/core/renderers/json/base.rb +46 -0
  111. data/lib/occi/core/renderers/json/category.rb +85 -0
  112. data/lib/occi/core/renderers/json/collection.rb +52 -0
  113. data/lib/occi/core/renderers/json/instance.rb +39 -0
  114. data/lib/occi/core/renderers/json/link.rb +48 -0
  115. data/lib/occi/core/renderers/json/model.rb +26 -0
  116. data/lib/occi/core/renderers/json/resource.rb +27 -0
  117. data/lib/occi/core/renderers/json_renderer.rb +72 -0
  118. data/lib/occi/core/renderers/text/.gitkeep +0 -0
  119. data/lib/occi/core/renderers/text/action_instance.rb +36 -0
  120. data/lib/occi/core/renderers/text/attributes.rb +87 -0
  121. data/lib/occi/core/renderers/text/base.rb +82 -0
  122. data/lib/occi/core/renderers/text/category.rb +183 -0
  123. data/lib/occi/core/renderers/text/collection.rb +65 -0
  124. data/lib/occi/core/renderers/text/instance.rb +44 -0
  125. data/lib/occi/core/renderers/text/link.rb +40 -0
  126. data/lib/occi/core/renderers/text/model.rb +41 -0
  127. data/lib/occi/core/renderers/text/resource.rb +109 -0
  128. data/lib/occi/core/renderers/text_renderer.rb +72 -0
  129. data/lib/occi/core/renderers.rb +20 -0
  130. data/lib/occi/core/resource.rb +93 -57
  131. data/lib/occi/core/utils/.gitkeep +0 -0
  132. data/lib/occi/core/version.rb +17 -0
  133. data/lib/occi/core/warehouse/actions/.gitkeep +0 -0
  134. data/lib/occi/core/warehouse/actions/attributes/.gitkeep +0 -0
  135. data/lib/occi/core/warehouse/kinds/.gitkeep +0 -0
  136. data/lib/occi/core/warehouse/kinds/attributes/.gitkeep +0 -0
  137. data/lib/occi/core/warehouse/kinds/attributes/occi.core.id.yml +7 -0
  138. data/lib/occi/core/warehouse/kinds/attributes/occi.core.source.yml +7 -0
  139. data/lib/occi/core/warehouse/kinds/attributes/occi.core.summary.yml +7 -0
  140. data/lib/occi/core/warehouse/kinds/attributes/occi.core.target.yml +7 -0
  141. data/lib/occi/core/warehouse/kinds/attributes/occi.core.title.yml +7 -0
  142. data/lib/occi/core/warehouse/kinds/entity.yml +10 -0
  143. data/lib/occi/core/warehouse/kinds/link.yml +10 -0
  144. data/lib/occi/core/warehouse/kinds/resource.yml +9 -0
  145. data/lib/occi/core/warehouse/mixins/.gitkeep +0 -0
  146. data/lib/occi/core/warehouse/mixins/attributes/.gitkeep +0 -0
  147. data/lib/occi/core/warehouse.rb +115 -0
  148. data/lib/occi/core.rb +59 -23
  149. data/lib/occi/infrastructure/compute.rb +5 -122
  150. data/lib/occi/infrastructure/constants.rb +25 -0
  151. data/lib/occi/infrastructure/instance_builder.rb +24 -0
  152. data/lib/occi/infrastructure/mixins/.gitkeep +0 -0
  153. data/lib/occi/infrastructure/mixins/os_tpl.rb +19 -0
  154. data/lib/occi/infrastructure/mixins/resource_tpl.rb +19 -0
  155. data/lib/occi/infrastructure/mixins.rb +12 -0
  156. data/lib/occi/infrastructure/model.rb +27 -0
  157. data/lib/occi/infrastructure/network.rb +5 -104
  158. data/lib/occi/infrastructure/networkinterface.rb +5 -100
  159. data/lib/occi/infrastructure/storage.rb +5 -59
  160. data/lib/occi/infrastructure/storagelink.rb +5 -54
  161. data/lib/occi/infrastructure/version.rb +5 -0
  162. data/lib/occi/infrastructure/warehouse/actions/.gitkeep +0 -0
  163. data/lib/occi/infrastructure/warehouse/actions/attributes/.gitkeep +0 -0
  164. data/lib/occi/infrastructure/warehouse/actions/compute_restart.yml +12 -0
  165. data/lib/occi/infrastructure/warehouse/actions/compute_save.yml +19 -0
  166. data/lib/occi/infrastructure/warehouse/actions/compute_start.yml +4 -0
  167. data/lib/occi/infrastructure/warehouse/actions/compute_stop.yml +12 -0
  168. data/lib/occi/infrastructure/warehouse/actions/compute_suspend.yml +12 -0
  169. data/lib/occi/infrastructure/warehouse/actions/network_down.yml +4 -0
  170. data/lib/occi/infrastructure/warehouse/actions/network_up.yml +4 -0
  171. data/lib/occi/infrastructure/warehouse/actions/networkinterface_down.yml +4 -0
  172. data/lib/occi/infrastructure/warehouse/actions/networkinterface_up.yml +4 -0
  173. data/lib/occi/infrastructure/warehouse/actions/storage_backup.yml +4 -0
  174. data/lib/occi/infrastructure/warehouse/actions/storage_offline.yml +4 -0
  175. data/lib/occi/infrastructure/warehouse/actions/storage_online.yml +4 -0
  176. data/lib/occi/infrastructure/warehouse/actions/storage_resize.yml +12 -0
  177. data/lib/occi/infrastructure/warehouse/actions/storage_snapshot.yml +4 -0
  178. data/lib/occi/infrastructure/warehouse/actions/storagelink_offline.yml +4 -0
  179. data/lib/occi/infrastructure/warehouse/actions/storagelink_online.yml +4 -0
  180. data/lib/occi/infrastructure/warehouse/kinds/.gitkeep +0 -0
  181. data/lib/occi/infrastructure/warehouse/kinds/attributes/.gitkeep +0 -0
  182. data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.compute.architecture.yml +7 -0
  183. data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.compute.cores.yml +7 -0
  184. data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.compute.hostname.yml +7 -0
  185. data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.compute.memory.yml +7 -0
  186. data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.compute.speed.yml +7 -0
  187. data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.compute.state.yml +7 -0
  188. data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.network.label.yml +7 -0
  189. data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.network.state.yml +7 -0
  190. data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.network.vlan.yml +7 -0
  191. data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.networkinterface.interface.yml +7 -0
  192. data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.networkinterface.mac.yml +7 -0
  193. data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.networkinterface.state.yml +7 -0
  194. data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.storage.size.yml +7 -0
  195. data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.storage.state.yml +7 -0
  196. data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.storagelink.deviceid.yml +7 -0
  197. data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.storagelink.mountpoint.yml +7 -0
  198. data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.storagelink.state.yml +7 -0
  199. data/lib/occi/infrastructure/warehouse/kinds/compute.yml +19 -0
  200. data/lib/occi/infrastructure/warehouse/kinds/network.yml +13 -0
  201. data/lib/occi/infrastructure/warehouse/kinds/networkinterface.yml +13 -0
  202. data/lib/occi/infrastructure/warehouse/kinds/storage.yml +15 -0
  203. data/lib/occi/infrastructure/warehouse/kinds/storagelink.yml +13 -0
  204. data/lib/occi/infrastructure/warehouse/mixins/.gitkeep +0 -0
  205. data/lib/occi/infrastructure/warehouse/mixins/attributes/.gitkeep +0 -0
  206. data/lib/occi/infrastructure/warehouse/mixins/attributes/occi.network.address.yml +7 -0
  207. data/lib/occi/infrastructure/warehouse/mixins/attributes/occi.network.allocation.yml +7 -0
  208. data/lib/occi/infrastructure/warehouse/mixins/attributes/occi.network.gateway.yml +7 -0
  209. data/lib/occi/infrastructure/warehouse/mixins/attributes/occi.networkinterface.address.yml +7 -0
  210. data/lib/occi/infrastructure/warehouse/mixins/attributes/occi.networkinterface.allocation.yml +7 -0
  211. data/lib/occi/infrastructure/warehouse/mixins/attributes/occi.networkinterface.gateway.yml +7 -0
  212. data/lib/occi/infrastructure/warehouse/mixins/ipnetwork.yml +11 -0
  213. data/lib/occi/infrastructure/warehouse/mixins/ipnetworkinterface.yml +11 -0
  214. data/lib/occi/infrastructure/warehouse.rb +20 -0
  215. data/lib/occi/infrastructure-ext.rb +35 -0
  216. data/lib/occi/infrastructure.rb +34 -19
  217. data/lib/occi/infrastructure_ext/constants.rb +20 -0
  218. data/lib/occi/infrastructure_ext/instance_builder.rb +22 -0
  219. data/lib/occi/infrastructure_ext/ipreservation.rb +9 -0
  220. data/lib/occi/infrastructure_ext/mixins/.gitkeep +0 -0
  221. data/lib/occi/infrastructure_ext/mixins/availability_zone.rb +19 -0
  222. data/lib/occi/infrastructure_ext/mixins.rb +12 -0
  223. data/lib/occi/infrastructure_ext/model.rb +26 -0
  224. data/lib/occi/infrastructure_ext/securitygroup.rb +9 -0
  225. data/lib/occi/infrastructure_ext/securitygrouplink.rb +9 -0
  226. data/lib/occi/infrastructure_ext/version.rb +5 -0
  227. data/lib/occi/infrastructure_ext/warehouse/actions/.gitkeep +0 -0
  228. data/lib/occi/infrastructure_ext/warehouse/actions/attributes/.gitkeep +0 -0
  229. data/lib/occi/infrastructure_ext/warehouse/actions/ipreservation_down.yml +4 -0
  230. data/lib/occi/infrastructure_ext/warehouse/actions/ipreservation_up.yml +4 -0
  231. data/lib/occi/infrastructure_ext/warehouse/kinds/.gitkeep +0 -0
  232. data/lib/occi/infrastructure_ext/warehouse/kinds/attributes/.gitkeep +0 -0
  233. data/lib/occi/infrastructure_ext/warehouse/kinds/attributes/occi.ipreservation.address.yml +7 -0
  234. data/lib/occi/infrastructure_ext/warehouse/kinds/attributes/occi.ipreservation.state.yml +7 -0
  235. data/lib/occi/infrastructure_ext/warehouse/kinds/attributes/occi.ipreservation.used.yml +7 -0
  236. data/lib/occi/infrastructure_ext/warehouse/kinds/attributes/occi.securitygroup.rules.yml +7 -0
  237. data/lib/occi/infrastructure_ext/warehouse/kinds/attributes/occi.securitygroup.state.yml +7 -0
  238. data/lib/occi/infrastructure_ext/warehouse/kinds/attributes/occi.securitygrouplink.state.yml +7 -0
  239. data/lib/occi/infrastructure_ext/warehouse/kinds/ipreservation.yml +13 -0
  240. data/lib/occi/infrastructure_ext/warehouse/kinds/securitygroup.yml +9 -0
  241. data/lib/occi/infrastructure_ext/warehouse/kinds/securitygrouplink.yml +8 -0
  242. data/lib/occi/infrastructure_ext/warehouse/mixins/.gitkeep +0 -0
  243. data/lib/occi/infrastructure_ext/warehouse/mixins/attributes/.gitkeep +0 -0
  244. data/lib/occi/infrastructure_ext/warehouse.rb +20 -0
  245. data/lib/occi/monkey_island/boolean.rb +6 -0
  246. data/lib/occi/monkey_island/hash.rb +4 -0
  247. data/occi-core.gemspec +26 -26
  248. metadata +312 -243
  249. data/.yardopts +0 -1
  250. data/config/occi.yml +0 -4
  251. data/lib/occi/collection.rb +0 -265
  252. data/lib/occi/core/actions.rb +0 -21
  253. data/lib/occi/core/attributes.rb +0 -411
  254. data/lib/occi/core/categories.rb +0 -64
  255. data/lib/occi/core/dependencies.rb +0 -7
  256. data/lib/occi/core/entities.rb +0 -48
  257. data/lib/occi/core/kinds.rb +0 -22
  258. data/lib/occi/core/links.rb +0 -37
  259. data/lib/occi/core/mixins.rb +0 -37
  260. data/lib/occi/core/properties.rb +0 -108
  261. data/lib/occi/core/resources.rb +0 -14
  262. data/lib/occi/errors/attribute_definitions_converted_error.rb +0 -5
  263. data/lib/occi/errors/attribute_missing_error.rb +0 -5
  264. data/lib/occi/errors/attribute_name_invalid_error.rb +0 -5
  265. data/lib/occi/errors/attribute_not_defined_error.rb +0 -5
  266. data/lib/occi/errors/attribute_property_type_error.rb +0 -5
  267. data/lib/occi/errors/attribute_type_error.rb +0 -5
  268. data/lib/occi/errors/category_not_defined_error.rb +0 -5
  269. data/lib/occi/errors/kind_not_defined_error.rb +0 -5
  270. data/lib/occi/errors/parser_input_error.rb +0 -5
  271. data/lib/occi/errors/parser_type_error.rb +0 -5
  272. data/lib/occi/errors.rb +0 -1
  273. data/lib/occi/extensions/hashie.rb +0 -25
  274. data/lib/occi/helpers/comparators/action_instance.rb +0 -22
  275. data/lib/occi/helpers/comparators/attributes.rb +0 -22
  276. data/lib/occi/helpers/comparators/categories.rb +0 -22
  277. data/lib/occi/helpers/comparators/category.rb +0 -22
  278. data/lib/occi/helpers/comparators/collection.rb +0 -40
  279. data/lib/occi/helpers/comparators/entities.rb +0 -22
  280. data/lib/occi/helpers/comparators/entity.rb +0 -22
  281. data/lib/occi/helpers/comparators/properties.rb +0 -26
  282. data/lib/occi/helpers/comparators.rb +0 -1
  283. data/lib/occi/helpers/inspect.rb +0 -12
  284. data/lib/occi/infrastructure/network/ipnetwork.rb +0 -28
  285. data/lib/occi/infrastructure/networkinterface/ipnetworkinterface.rb +0 -28
  286. data/lib/occi/infrastructure/os_tpl.rb +0 -20
  287. data/lib/occi/infrastructure/resource_tpl.rb +0 -20
  288. data/lib/occi/log.rb +0 -71
  289. data/lib/occi/model.rb +0 -87
  290. data/lib/occi/parser/json.rb +0 -38
  291. data/lib/occi/parser/text/constants.rb +0 -89
  292. data/lib/occi/parser/text.rb +0 -280
  293. data/lib/occi/parser.rb +0 -144
  294. data/lib/occi/settings.rb +0 -10
  295. data/lib/occi/version.rb +0 -3
  296. data/lib/occi-core.rb +0 -53
  297. data/spec/helpers/to_plain.rb +0 -39
  298. data/spec/helpers/yaml_hash.rb +0 -32
  299. data/spec/occi/collection_samples/collection1.json +0 -1
  300. data/spec/occi/collection_samples/directory2/collection2.json +0 -1
  301. data/spec/occi/collection_spec.rb +0 -1003
  302. data/spec/occi/core/action_instance_spec.rb +0 -317
  303. data/spec/occi/core/action_spec.rb +0 -71
  304. data/spec/occi/core/attributes_spec.rb +0 -665
  305. data/spec/occi/core/categories_spec.rb +0 -28
  306. data/spec/occi/core/category_spec.rb +0 -216
  307. data/spec/occi/core/entities_spec.rb +0 -160
  308. data/spec/occi/core/entity_spec.rb +0 -374
  309. data/spec/occi/core/kind_spec.rb +0 -182
  310. data/spec/occi/core/link_spec.rb +0 -52
  311. data/spec/occi/core/links_spec.rb +0 -132
  312. data/spec/occi/core/mixin_spec.rb +0 -38
  313. data/spec/occi/core/mixins_spec.rb +0 -107
  314. data/spec/occi/core/properties_spec.rb +0 -171
  315. data/spec/occi/core/resource_spec.rb +0 -42
  316. data/spec/occi/core_spec.rb +0 -12
  317. data/spec/occi/infrastructure/compute_spec.rb +0 -229
  318. data/spec/occi/infrastructure/network_spec.rb +0 -96
  319. data/spec/occi/infrastructure/networkinterface_spec.rb +0 -96
  320. data/spec/occi/infrastructure/storage_spec.rb +0 -33
  321. data/spec/occi/infrastructure/storagelink_spec.rb +0 -45
  322. data/spec/occi/log_spec.rb +0 -117
  323. data/spec/occi/model_spec.rb +0 -256
  324. data/spec/occi/parser/json_samples/test.json +0 -49
  325. data/spec/occi/parser/text_samples/occi_categories.body_plain.expected +0 -2
  326. data/spec/occi/parser/text_samples/occi_categories.expected +0 -2
  327. data/spec/occi/parser/text_samples/occi_categories.parse_headers.expected +0 -2
  328. data/spec/occi/parser/text_samples/occi_categories.text +0 -2
  329. data/spec/occi/parser/text_samples/occi_compute_rocci_server.expected +0 -11
  330. data/spec/occi/parser/text_samples/occi_compute_rocci_server.text +0 -10
  331. data/spec/occi/parser/text_samples/occi_link_resource_instance.body_plain.expected +0 -7
  332. data/spec/occi/parser/text_samples/occi_link_resource_instance.expected +0 -7
  333. data/spec/occi/parser/text_samples/occi_link_resource_instance.parse.expected +0 -7
  334. data/spec/occi/parser/text_samples/occi_link_resource_instance.text +0 -7
  335. data/spec/occi/parser/text_samples/occi_link_simple.expected +0 -7
  336. data/spec/occi/parser/text_samples/occi_link_simple.text +0 -1
  337. data/spec/occi/parser/text_samples/occi_link_w_attributes.expected +0 -7
  338. data/spec/occi/parser/text_samples/occi_link_w_attributes.text +0 -7
  339. data/spec/occi/parser/text_samples/occi_link_w_category.expected +0 -7
  340. data/spec/occi/parser/text_samples/occi_link_w_category.text +0 -3
  341. data/spec/occi/parser/text_samples/occi_model_categories.expected +0 -3
  342. data/spec/occi/parser/text_samples/occi_model_rocci_server.text +0 -51
  343. data/spec/occi/parser/text_samples/occi_network_rocci_server.body_plain.expected +0 -11
  344. data/spec/occi/parser/text_samples/occi_network_rocci_server.expected +0 -11
  345. data/spec/occi/parser/text_samples/occi_network_rocci_server.resource.header.expected +0 -9
  346. data/spec/occi/parser/text_samples/occi_network_rocci_server.resource.rack.expected +0 -9
  347. data/spec/occi/parser/text_samples/occi_network_rocci_server.text +0 -11
  348. data/spec/occi/parser/text_samples/occi_resource_custom_class_w_attributes.parse.expected +0 -15
  349. data/spec/occi/parser/text_samples/occi_resource_custom_class_w_attributes.text +0 -15
  350. data/spec/occi/parser/text_samples/occi_resource_w_attributes.text +0 -11
  351. data/spec/occi/parser/text_samples/occi_resource_w_inline_links.expected +0 -1
  352. data/spec/occi/parser/text_samples/occi_resource_w_inline_links.text +0 -16
  353. data/spec/occi/parser/text_samples/occi_resource_w_inline_links_only.text +0 -13
  354. data/spec/occi/parser/text_samples/occi_storage_rocci_server.expected +0 -9
  355. data/spec/occi/parser/text_samples/occi_storage_rocci_server.text +0 -9
  356. data/spec/occi/parser/text_spec.rb +0 -320
  357. data/spec/occi/parser_spec.rb +0 -259
  358. data/spec/occi-core_spec.rb +0 -31
  359. data/spec/spec_helper.rb +0 -18
@@ -0,0 +1,68 @@
1
+ Category: entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="entity";location="/entity/";attributes="occi.core.id{immutable required} occi.core.title"
2
+ Category: resource;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="resource";rel="http://schemas.ogf.org/occi/core#entity";location="/resource/";attributes="occi.core.id{immutable required} occi.core.title occi.core.summary"
3
+ Category: link;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="link";rel="http://schemas.ogf.org/occi/core#entity";location="/link/";attributes="occi.core.id{immutable required} occi.core.title occi.core.target occi.core.source{required}"
4
+ Category: compute;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";title="compute resource";rel="http://schemas.ogf.org/occi/core#resource";location="/compute/";attributes="occi.core.id{immutable required} occi.core.title occi.core.summary occi.compute.architecture occi.compute.cores occi.compute.hostname occi.compute.memory occi.compute.speed occi.compute.state{immutable}";actions="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"
5
+ Category: storage;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";title="storage resource";rel="http://schemas.ogf.org/occi/core#resource";location="/storage/";attributes="occi.core.id{immutable required} occi.core.title occi.core.summary occi.storage.size occi.storage.state";actions="http://schemas.ogf.org/occi/infrastructure/storage/action#online http://schemas.ogf.org/occi/infrastructure/storage/action#offline http://schemas.ogf.org/occi/infrastructure/storage/action#backup http://schemas.ogf.org/occi/infrastructure/storage/action#snapshot http://schemas.ogf.org/occi/infrastructure/storage/action#resize"
6
+ Category: network;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";title="network resource";rel="http://schemas.ogf.org/occi/core#resource";location="/network/";attributes="occi.core.id{immutable required} occi.core.title occi.core.summary occi.network.vlan occi.network.label occi.network.state{immutable}";actions="http://schemas.ogf.org/occi/infrastructure/network/action#up http://schemas.ogf.org/occi/infrastructure/network/action#down"
7
+ Category: networkinterface;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";title="networkinterface link";rel="http://schemas.ogf.org/occi/core#link";location="/link/networkinterface/";attributes="occi.core.id{immutable required} occi.core.title occi.core.target occi.core.source{required} occi.networkinterface.interface{immutable} occi.networkinterface.mac occi.networkinterface.state{immutable}";actions="http://schemas.ogf.org/occi/infrastructure/networkinterface/action#up http://schemas.ogf.org/occi/infrastructure/networkinterface/action#down"
8
+ Category: storagelink;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";title="storage link";rel="http://schemas.ogf.org/occi/core#link";location="/link/storagelink/";attributes="occi.core.id{immutable required} occi.core.title occi.core.target occi.core.source{required} occi.storagelink.deviceid occi.storagelink.mountpoint occi.storagelink.state{immutable}";actions="http://schemas.ogf.org/occi/infrastructure/storagelink/action#online http://schemas.ogf.org/occi/infrastructure/storagelink/action#offline"
9
+ Category: resource_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";title="resource template";location="/mixin/resource_tpl/"
10
+ Category: os_tpl;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";title="operating system template";location="/mixin/os_tpl/"
11
+ Category: ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure/network#";class="mixin";title="IP network mixin";location="/mixin/ipnetwork/";attributes="occi.network.address occi.network.gateway occi.network.allocation"
12
+ Category: ipnetworkinterface;scheme="http://schemas.ogf.org/occi/infrastructure/networkinterface#";class="mixin";title="IP network interface mixin";location="/mixin/ipnetworkinterface/";attributes="occi.networkinterface.address occi.networkinterface.gateway occi.networkinterface.allocation"
13
+ Category: public_key;scheme="http://schemas.openstack.org/instance/credentials#";class="mixin";title="OpenStack's contextualization extension - credentials";location="/mixin/public_key/";attributes="org.openstack.credentials.publickey.name org.openstack.credentials.publickey.data"
14
+ Category: user_data;scheme="http://schemas.openstack.org/compute/instance#";class="mixin";title="OpenStack's contextualization extension - user_data";location="/mixin/user_data/";attributes="org.openstack.compute.user_data"
15
+ Category: availability_zone;scheme="http://fedcloud.egi.eu/occi/infrastructure#";class="mixin";title="Availablity zone within the target infrastructure";location="/mixin/availability_zone/"
16
+ Category: uuid_fedcloud_warg_101;scheme="http://occi.localhost/occi/infrastructure/availability_zone#";class="mixin";title="Availablity zone fedcloud-warg";rel="http://fedcloud.egi.eu/occi/infrastructure#availability_zone http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/availability_zone/uuid_fedcloud_warg_101/"
17
+ Category: uuid_fedcloud_cerit_sc_103;scheme="http://occi.localhost/occi/infrastructure/availability_zone#";class="mixin";title="Availablity zone fedcloud-cerit-sc";rel="http://fedcloud.egi.eu/occi/infrastructure#availability_zone http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/availability_zone/uuid_fedcloud_cerit_sc_103/"
18
+ Category: uuid_cernvm_3_3_0_40gb_fedcloud_dukan_80;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="CERNVM-3.3.0-40GB@fedcloud-dukan";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_cernvm_3_3_0_40gb_fedcloud_dukan_80/"
19
+ Category: uuid_scientific_linux_6_5_fedcloud_dukan_82;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="Scientific-Linux-6.5@fedcloud-dukan";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_scientific_linux_6_5_fedcloud_dukan_82/"
20
+ Category: uuid_dci_bridge_fedcloud_dukan_109;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="DCI-Bridge@fedcloud-dukan";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_dci_bridge_fedcloud_dukan_109/"
21
+ Category: uuid_egi_compss_lofar_debian_7_0_x86_64_0001_fedcloud_dukan_113;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="EGI-COMPSs-Lofar-Debian-7.0-x86_64-0001@fedcloud-dukan";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_egi_compss_lofar_debian_7_0_x86_64_0001_fedcloud_dukan_113/"
22
+ Category: uuid_egi_fedcloud_clients_fedcloud_warg_128;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="EGI-FedCloud-Clients@fedcloud-warg";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_egi_fedcloud_clients_fedcloud_warg_128/"
23
+ Category: uuid_egi_ubuntu_server_12_04_lts_fedcloud_warg_129;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="EGI-Ubuntu-Server-12.04-LTS@fedcloud-warg";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_egi_ubuntu_server_12_04_lts_fedcloud_warg_129/"
24
+ Category: uuid_egi_centos_6_fedcloud_warg_130;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="EGI-CentOS-6@fedcloud-warg";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_egi_centos_6_fedcloud_warg_130/"
25
+ Category: uuid_egi_ubuntu_server_14_04_lts_fedcloud_warg_131;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="EGI-Ubuntu-Server-14.04-LTS@fedcloud-warg";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_egi_ubuntu_server_14_04_lts_fedcloud_warg_131/"
26
+ Category: uuid_transplant_base_fedcloud_warg_132;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="transPLANT-Base@fedcloud-warg";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_transplant_base_fedcloud_warg_132/"
27
+ Category: uuid_gcubesmartexecutor_fedcloud_warg_139;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="GCubeSmartExecutor@fedcloud-warg";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_gcubesmartexecutor_fedcloud_warg_139/"
28
+ Category: uuid_egi_centos_7_fedcloud_warg_149;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="EGI-CentOS-7@fedcloud-warg";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_egi_centos_7_fedcloud_warg_149/"
29
+ Category: uuid_egi_docker_ubuntu_server_14_04_lts_fedcloud_warg_150;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="EGI-Docker-Ubuntu-Server-14.04-LTS@fedcloud-warg";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_egi_docker_ubuntu_server_14_04_lts_fedcloud_warg_150/"
30
+ Category: uuid_futuregateway_ubuntu_14_04_lts_fedcloud_warg_153;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="FutureGateway-Ubuntu-14.04-LTS@fedcloud-warg";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_futuregateway_ubuntu_14_04_lts_fedcloud_warg_153/"
31
+ Category: uuid_extras_wp4_ubuntu_14_04_lts_fedcloud_warg_155;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="Extras-WP4-Ubuntu-14.04-LTS@fedcloud-warg";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_extras_wp4_ubuntu_14_04_lts_fedcloud_warg_155/"
32
+ Category: uuid_hadoop_2_7_1_ubuntu_14_04_lts_fedcloud_warg_156;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="Hadoop-2.7.1-Ubuntu-14.04-LTS@fedcloud-warg";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_hadoop_2_7_1_ubuntu_14_04_lts_fedcloud_warg_156/"
33
+ Category: uuid_dataminer_ubuntu_12_04_lts_fedcloud_warg_164;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="DataMiner-Ubuntu-12.04-LTS@fedcloud-warg";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_dataminer_ubuntu_12_04_lts_fedcloud_warg_164/"
34
+ Category: uuid_egi_cernvm_3_fedcloud_warg_167;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="EGI-CernVM-3@fedcloud-warg";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_egi_cernvm_3_fedcloud_warg_167/"
35
+ Category: uuid_apache_hive_ubuntu_14_04_lts_fedcloud_warg_169;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="Apache-Hive-Ubuntu-14.04-LTS@fedcloud-warg";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_apache_hive_ubuntu_14_04_lts_fedcloud_warg_169/"
36
+ Category: uuid_bacterial_genomics_fedcloud_warg_177;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="Bacterial-Genomics@fedcloud-warg";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_bacterial_genomics_fedcloud_warg_177/"
37
+ Category: uuid_egi_ubuntu_server_16_04_lts_fedcloud_warg_178;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="EGI-Ubuntu-Server-16.04-LTS@fedcloud-warg";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_egi_ubuntu_server_16_04_lts_fedcloud_warg_178/"
38
+ Category: uuid_egi_compss_2_0_ubuntu_15_04_fedcloud_warg_179;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="EGI-COMPSs-2.0-Ubuntu-15.04@fedcloud-warg";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_egi_compss_2_0_ubuntu_15_04_fedcloud_warg_179/"
39
+ Category: uuid_egi_docker_ubuntu_server_16_04_lts_fedcloud_warg_186;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="EGI-Docker-Ubuntu-Server-16.04-LTS@fedcloud-warg";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_egi_docker_ubuntu_server_16_04_lts_fedcloud_warg_186/"
40
+ Category: uuid_egi_fedora_25_fedcloud_warg_189;scheme="http://occi.localhost/occi/infrastructure/os_tpl#";class="mixin";title="EGI-Fedora-25@fedcloud-warg";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/os_tpl/uuid_egi_fedora_25_fedcloud_warg_189/"
41
+ Category: universe;scheme="http://schemas.fedcloud.egi.eu/occi/infrastructure/resource_tpl#";class="mixin";title="Universe Instance - 40 cores and 232 GB RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/resource_tpl/universe/";attributes="occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable} occi.compute.ephemeral_storage.size{immutable}"
42
+ Category: goliath;scheme="http://schemas.fedcloud.egi.eu/occi/infrastructure/resource_tpl#";class="mixin";title="Goliath Instance - 16 cores and 64 GB RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/resource_tpl/goliath/";attributes="occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable} occi.compute.ephemeral_storage.size{immutable}"
43
+ Category: sym_mammoth;scheme="http://schemas.fedcloud.egi.eu/occi/infrastructure/resource_tpl#";class="mixin";title="Symmetric Mammoth Instance - 32 cores and 32 GB RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/resource_tpl/sym_mammoth/";attributes="occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable} occi.compute.ephemeral_storage.size{immutable}"
44
+ Category: mem_small;scheme="http://fedcloud.egi.eu/occi/compute/flavour/1.0#";class="mixin";title="Small Instance - 1 core and 4 GB RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/resource_tpl/mem_small/";attributes="occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable} occi.compute.ephemeral_storage.size{immutable}"
45
+ Category: extra_large;scheme="http://schemas.fedcloud.egi.eu/occi/infrastructure/resource_tpl#";class="mixin";title="Extra Large Instance - 8 cores and 8 GB RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/resource_tpl/extra_large/";attributes="occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable} occi.compute.ephemeral_storage.size{immutable}"
46
+ Category: mem_extra_large;scheme="http://schemas.fedcloud.egi.eu/occi/infrastructure/resource_tpl#";class="mixin";title="Extra Large Instance - 8 cores and 32 GB RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/resource_tpl/mem_extra_large/";attributes="occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable} occi.compute.ephemeral_storage.size{immutable}"
47
+ Category: medium;scheme="http://fedcloud.egi.eu/occi/compute/flavour/1.0#";class="mixin";title="Medium Instance - 2 cores and 2 GB RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/resource_tpl/medium/";attributes="occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable} occi.compute.ephemeral_storage.size{immutable}"
48
+ Category: mem_medium;scheme="http://fedcloud.egi.eu/occi/compute/flavour/1.0#";class="mixin";title="Medium Instance - 2 cores and 8 GB RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/resource_tpl/mem_medium/";attributes="occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable} occi.compute.ephemeral_storage.size{immutable}"
49
+ Category: mammoth;scheme="http://schemas.fedcloud.egi.eu/occi/infrastructure/resource_tpl#";class="mixin";title="Mammoth Instance - 16 cores and 32 GB RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/resource_tpl/mammoth/";attributes="occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable} occi.compute.ephemeral_storage.size{immutable}"
50
+ Category: small;scheme="http://fedcloud.egi.eu/occi/compute/flavour/1.0#";class="mixin";title="Small Instance - 1 core and 1 GB RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/resource_tpl/small/";attributes="occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable} occi.compute.ephemeral_storage.size{immutable}"
51
+ Category: large;scheme="http://fedcloud.egi.eu/occi/compute/flavour/1.0#";class="mixin";title="Large Instance - 4 cores and 4 GB RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/resource_tpl/large/";attributes="occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable} occi.compute.ephemeral_storage.size{immutable}"
52
+ Category: mem_large;scheme="http://fedcloud.egi.eu/occi/compute/flavour/1.0#";class="mixin";title="Large Instance - 4 cores and 16 GB RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/resource_tpl/mem_large/";attributes="occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable} occi.compute.ephemeral_storage.size{immutable}"
53
+ Category: atlas;scheme="http://schemas.fedcloud.egi.eu/occi/infrastructure/resource_tpl#";class="mixin";title="Atlas Instance - 32 cores and 64 GB RAM";rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl http://schemas.ogf.org/occi/infrastructure#compute";location="/mixin/resource_tpl/atlas/";attributes="occi.compute.architecture{immutable} occi.compute.cores{immutable} occi.compute.speed{immutable} occi.compute.memory{immutable} occi.compute.ephemeral_storage.size{immutable}"
54
+ Category: start;scheme="http://schemas.ogf.org/occi/infrastructure/compute/action#";class="action";title="start compute instance"
55
+ Category: stop;scheme="http://schemas.ogf.org/occi/infrastructure/compute/action#";class="action";title="stop compute instance";attributes="method"
56
+ Category: restart;scheme="http://schemas.ogf.org/occi/infrastructure/compute/action#";class="action";title="restart compute instance";attributes="method"
57
+ Category: suspend;scheme="http://schemas.ogf.org/occi/infrastructure/compute/action#";class="action";title="suspend compute instance";attributes="method"
58
+ Category: online;scheme="http://schemas.ogf.org/occi/infrastructure/storage/action#";class="action";title="activate storage"
59
+ Category: offline;scheme="http://schemas.ogf.org/occi/infrastructure/storage/action#";class="action";title="deactivate storage"
60
+ Category: backup;scheme="http://schemas.ogf.org/occi/infrastructure/storage/action#";class="action";title="backup storage"
61
+ Category: snapshot;scheme="http://schemas.ogf.org/occi/infrastructure/storage/action#";class="action";title="snapshot storage"
62
+ Category: resize;scheme="http://schemas.ogf.org/occi/infrastructure/storage/action#";class="action";title="resize storage";attributes="size{required}"
63
+ Category: up;scheme="http://schemas.ogf.org/occi/infrastructure/network/action#";class="action";title="activate network"
64
+ Category: down;scheme="http://schemas.ogf.org/occi/infrastructure/network/action#";class="action";title="deactivate network"
65
+ Category: up;scheme="http://schemas.ogf.org/occi/infrastructure/networkinterface/action#";class="action";title="activate networkinterface"
66
+ Category: down;scheme="http://schemas.ogf.org/occi/infrastructure/networkinterface/action#";class="action";title="deactivate networkinterface"
67
+ Category: online;scheme="http://schemas.ogf.org/occi/infrastructure/storagelink/action#";class="action";title="activate storagelink"
68
+ Category: offline;scheme="http://schemas.ogf.org/occi/infrastructure/storagelink/action#";class="action";title="deactivate storagelink"
@@ -1,32 +1,18 @@
1
1
  module Occi
2
2
  module Core
3
- class Action < Occi::Core::Category
4
-
5
- # @param [String] scheme
6
- # @param [String] term
7
- # @param [String] title
8
- # @param [Hash] attributes
9
- def initialize(scheme='http://schemas.ogf.org/occi/core#',
10
- term='action',
11
- title=nil,
12
- attributes=Occi::Core::Attributes.new)
13
- super(scheme, term, title, attributes)
3
+ # Class without internal logic semantically separating `Category` and
4
+ # `Action` instances for rendering purposes.
5
+ #
6
+ # @author Boris Parak <parak@cesnet.cz>
7
+ class Action < Category
8
+ class << self
9
+ # :nodoc:
10
+ def allowed_yaml_classes
11
+ # TODO: get rid of this with referenced (name-only) attributes in Action YAMLs
12
+ [String, Regexp, URI, IPAddr, Integer, Float].freeze
13
+ end
14
+ private :allowed_yaml_classes
14
15
  end
15
-
16
- # @return [String] text representation
17
- def to_text
18
- text = super
19
- text << "#{@attributes.to_string_short}"
20
- text
21
- end
22
-
23
- # @return [Hash] hash containing the HTTP headers of the text/occi rendering
24
- def to_header
25
- header = super
26
- header[:Category] << "#{@attributes.to_string_short}"
27
- header
28
- end
29
-
30
16
  end
31
17
  end
32
18
  end
@@ -1,97 +1,141 @@
1
1
  module Occi
2
2
  module Core
3
+ # Class representing executable instances of actions. Every instance carries the original
4
+ # action definition (instance of `Action`) together with attributes chosen for this
5
+ # invocation of the action. Validity of `ActionInstance` instances is determined by
6
+ # the validity of included `Action` instance and validity of provided attribute values.
7
+ #
8
+ # @attr action [Action] original action definition
9
+ # @attr attributes [Hash] attributes for this action instance
10
+ #
11
+ # @author Boris Parak <parak@cesnet.cz>
3
12
  class ActionInstance
13
+ include Yell::Loggable
14
+ include Helpers::Renderable
15
+ include Helpers::InstanceAttributesAccessor
16
+ include Helpers::ArgumentValidator
17
+ include Helpers::InstanceAttributeResetter
4
18
 
5
- include Occi::Helpers::Inspect
6
- include Occi::Helpers::Comparators::ActionInstance
19
+ attr_accessor :action, :attributes
7
20
 
8
- attr_accessor :action, :attributes, :model
21
+ ERRORS = [
22
+ Occi::Core::Errors::AttributeValidationError,
23
+ Occi::Core::Errors::AttributeDefinitionError,
24
+ Occi::Core::Errors::InstanceValidationError
25
+ ].freeze
9
26
 
10
- class_attribute :action, :attributes
27
+ def initialize(args = {})
28
+ default_args! args
11
29
 
12
- self.attributes = Occi::Core::Attributes.new
30
+ @action = args.fetch(:action)
31
+ @attributes = args.fetch(:attributes)
13
32
 
14
- self.action = Occi::Core::Action.new scheme='http://schemas.ogf.org/occi/core#',
15
- term='action_instance',
16
- title='action',
17
- attributes=Occi::Core::Attributes.new(self.attributes)
33
+ reset_attributes
34
+ end
18
35
 
19
- def initialize(action = self.action, attributes=self.attributes)
20
- raise ArgumentError, 'action cannot be nil' unless action
36
+ # Short-hand for accessing the identifier of assigned `Action`
37
+ # instance.
38
+ #
39
+ # @return [String] identifier of the included `Action` instance
40
+ # @return [NilClass] if no action is present
41
+ def action_identifier
42
+ action ? action.identifier : nil
43
+ end
21
44
 
22
- if action.kind_of? String
23
- scheme, term = action.split '#'
24
- action = Occi::Core::Action.new(scheme, term)
45
+ # Assigns new action instance to this action instance. This
46
+ # method will trigger a complete reset on all previously
47
+ # set attributes, for the sake of consistency.
48
+ #
49
+ # @param action [Occi::Core::Action] action to be assigned
50
+ # @return [Occi::Core::Action] assigned action
51
+ def action=(action)
52
+ unless action
53
+ raise Occi::Core::Errors::InstanceValidationError,
54
+ 'Missing valid action'
25
55
  end
26
- @action = action
27
56
 
28
- if attributes.kind_of? Occi::Core::Attributes
29
- @attributes = attributes.convert
30
- else
31
- @attributes = Occi::Core::Attributes.new(attributes || {})
32
- end
33
- end
57
+ @action = action
58
+ reset_attributes!
34
59
 
35
- # @param [Hash] options
36
- # @return [Hashie::Mash] json representation
37
- def as_json(options={})
38
- action = Hashie::Mash.new
39
- action.action = @action.to_s if @action
40
- action.attributes = @attributes.any? ? @attributes.as_json : Occi::Core::Attributes.new.as_json
41
60
  action
42
61
  end
43
-
44
- # @return [String] text representation
45
- def to_text
46
- text = "Category: #{@action.to_string_short}"
47
- @attributes.names.each_pair do |name, value|
48
- value = value.to_s.inspect unless value && value.is_a?(Numeric)
49
- text << "\nX-OCCI-Attribute: #{name}=#{value}"
62
+ alias kind action
63
+ alias kind= action=
64
+
65
+ # Checks whether this action instance is valid. Validity
66
+ # is determined by the validity of the included action
67
+ # object and attribute value(s).
68
+ #
69
+ # @return [TrueClass] if valid
70
+ # @return [FalseClass] if invalid
71
+ def valid?
72
+ begin
73
+ valid!
74
+ rescue *ERRORS => ex
75
+ logger.warn "ActionInstance invalid: #{ex.message}"
76
+ return false
50
77
  end
51
78
 
52
- text
79
+ true
53
80
  end
54
81
 
55
- # @return [String] JSON representation
56
- def to_json
57
- as_json.to_json
82
+ # Checks whether this action instance is valid. Validity
83
+ # is determined by the validity of the included action
84
+ # object and attribute value(s). This method will raise
85
+ # an error when the validation fails.
86
+ #
87
+ # @raise [Errors::AttributeValidationError] if attribute(s) are invalid
88
+ # @raise [Errors::AttributeDefinitionError] if attribute defs are missing
89
+ # @raise [Occi::Core::Errors::InstanceValidationError] if this instance is invalid
90
+ def valid!
91
+ raise Occi::Core::Errors::InstanceValidationError, 'Missing valid action object' unless action
92
+ raise Occi::Core::Errors::InstanceValidationError, 'Missing valid attributes object' unless attributes
93
+
94
+ attributes.each_pair { |name, attribute| valid_attribute!(name, attribute) }
58
95
  end
59
96
 
60
- # @return [Hash] hash containing the HTTP headers of the text/occi rendering
61
- def to_header
62
- header = Hashie::Mash.new
63
- header['Category'] = @action.to_string_short
97
+ private
64
98
 
65
- attributes = []
66
- @attributes.names.each_pair do |name, value|
67
- value = value.to_s.inspect unless value && value.is_a?(Numeric)
68
- attributes << "#{name}=#{value}"
69
- end
70
- header['X-OCCI-Attribute'] = attributes.join(',') if attributes.any?
71
-
72
- header
99
+ # Returns all base attributes for this instance in the
100
+ # form of the original hash.
101
+ #
102
+ # @return [Hash] hash with base attributes
103
+ def base_attributes
104
+ action.attributes
73
105
  end
74
106
 
75
- # @return [Boolean] Indicating whether this action instance is "empty", i.e. required attributes are blank
76
- def empty?
77
- action.nil? || action.empty?
107
+ # Collects all available additional attributes for this
108
+ # instance and returns them as an array.
109
+ #
110
+ # @return [Array] array with added attribute hashes
111
+ def added_attributes
112
+ []
78
113
  end
79
114
 
80
- # @param [Boolean] set default values for all empty attributes
81
- # @return [Boolean] Result of the validation process
82
- def check(set_defaults = false)
83
- raise ArgumentError, 'No model has been assigned to this action instance' unless @model
84
-
85
- action = @model.get_by_id(@action.type_identifier, true)
86
- raise Occi::Errors::CategoryNotDefinedError,
87
- "Action not found for action instance #{self.class.name}[#{self.to_s.inspect}]!" unless action
88
-
89
- definitions = Occi::Core::Attributes.new
90
- definitions.merge! action.attributes
115
+ # :nodoc:
116
+ def sufficient_args!(args)
117
+ %i[action attributes].each do |attr|
118
+ unless args[attr]
119
+ raise Occi::Core::Errors::MandatoryArgumentError, "#{attr} is a mandatory " \
120
+ "argument for #{self.class}"
121
+ end
122
+ end
123
+ end
91
124
 
92
- @attributes.check!(definitions, set_defaults)
125
+ # :nodoc:
126
+ def defaults
127
+ {
128
+ action: nil,
129
+ attributes: {}
130
+ }
93
131
  end
94
132
 
133
+ # :nodoc:
134
+ def valid_attribute!(name, attribute)
135
+ attribute.valid!
136
+ rescue => ex
137
+ raise ex, "Attribute #{name.inspect} invalid: #{ex}", ex.backtrace
138
+ end
95
139
  end
96
140
  end
97
141
  end
@@ -0,0 +1,136 @@
1
+ module Occi
2
+ module Core
3
+ # Represents an attribute commonly used in instances based on
4
+ # `Entity` or `ActionInstance`. In most cases, instances of this
5
+ # class will carry the attribute `value` and the `attribute_definition`
6
+ # used for validation purposes. Attributes without `value` will default
7
+ # to the value specified by `attribute_definition.default`, if present.
8
+ # Attributes without `attribute_definition` are considered invalid.
9
+ #
10
+ # @attr value [Object] value of this attribute instance
11
+ # @attr attribute_definition [AttributeDefinition] definition of this attribute instance
12
+ #
13
+ # @author Boris Parak <parak@cesnet.cz>
14
+ class Attribute < Struct.new(:value, :attribute_definition)
15
+ include Yell::Loggable
16
+
17
+ # Checks whether the `value` assigned to this instance
18
+ # does not violate restrictions defined in `attribute_definition`.
19
+ # Attributes without `attribute_definition` are considered
20
+ # invalid. Attributes without `value` may be considered valid
21
+ # depending on the content on `attribute_definition`.
22
+ #
23
+ # @return [TrueClass, FalseClass] validation result
24
+ def valid?
25
+ begin
26
+ valid!
27
+ rescue Occi::Core::Errors::AttributeValidationError, Occi::Core::Errors::AttributeDefinitionError => ex
28
+ logger.warn "Attribute invalid: #{ex.message}"
29
+ return false
30
+ end
31
+
32
+ true
33
+ end
34
+
35
+ # Checks whether the `value` assigned to this instance
36
+ # does not violate restrictions defined in `attribute_definition`.
37
+ # Attributes without `attribute_definition` are considered
38
+ # invalid. Attributes without `value` may be considered valid
39
+ # depending on the content on `attribute_definition`.
40
+ # This method will raise an `Occi::Core::Errors::AttributeValidationError`
41
+ # error on failure.
42
+ #
43
+ # @raise [Occi::Core::Errors::AttributeDefinitionError] if there are problems with the definition
44
+ # @raise [Occi::Core::Errors::AttributeValidationError] if this instance is not valid
45
+ def valid!
46
+ unless definition?
47
+ raise Occi::Core::Errors::AttributeValidationError,
48
+ 'Attribute is missing a definition'
49
+ end
50
+ unless attribute_definition.respond_to?(:valid!)
51
+ raise Occi::Core::Errors::AttributeDefinitionError,
52
+ 'Attribute definition is not capable of validation'
53
+ end
54
+
55
+ attribute_definition.valid! value
56
+ end
57
+
58
+ # Checks whether this instance has `attribute_definition` assigned.
59
+ #
60
+ # @return [TrueClass, FalseClass] flag indicating the presence of `attribute_definition`
61
+ def definition?
62
+ !attribute_definition.nil?
63
+ end
64
+ alias attribute_definition? definition?
65
+
66
+ # Checks whether this instance has `value` assigned. Attributes in which
67
+ # `nil` is an acceptable value will still be considered valueless, although
68
+ # the validation may pass, see `#valid?` or `#valid!`.
69
+ #
70
+ # @return [TrueClass, FalseClass] flag indicating the presence of `value`
71
+ def value?
72
+ !value.nil?
73
+ end
74
+
75
+ # Checks whether this instance has both `value` and `attribute_definition` assigned.
76
+ # For details, see `#definition?` and `#value?`.
77
+ #
78
+ # @return [TrueClass, FalseClass] flag indicating the presence of `attribute_definition` and `value`
79
+ def full?
80
+ definition? && value?
81
+ end
82
+
83
+ # Checks whether this instance is missing both `value` and `attribute_definition`.
84
+ #
85
+ # @return [TrueClass, FalseClass] flag indicating emptiness
86
+ def empty?
87
+ !(definition? || value?)
88
+ end
89
+
90
+ # Gracefully sets `value` for this instance from the default value specified
91
+ # in `attribute_definition`. Only `value` set to `nil` will be replaced, other
92
+ # values will be kept. In case `nil` is the default value, it will be set
93
+ # and reported as a new value. An attempt to change the value will be made only
94
+ # if there is no current value (instance with a `value` but no `attribute_definition`
95
+ # will pass this method without raising an error).
96
+ #
97
+ # @raise [Occi::Core::Errors::AttributeDefinitionError] if there is no `attribute_definition`
98
+ # @return [Object] new value, if changed
99
+ # @return [NilClass] if nothing changed
100
+ def default
101
+ value? ? nil : default!
102
+ end
103
+
104
+ # Sets `value` for this instance from the default value specified
105
+ # in `attribute_definition`. This method will OVERWRITE any previous
106
+ # `value` present in this instance. See `#default` for the graceful
107
+ # version.
108
+ #
109
+ # @raise [Occi::Core::Errors::AttributeDefinitionError] if there is no `attribute_definition`
110
+ # @return [Object] new value
111
+ def default!
112
+ unless definition?
113
+ raise Occi::Core::Errors::AttributeDefinitionError,
114
+ 'There is no definition for this attribute'
115
+ end
116
+ self.value = attribute_definition.default
117
+ end
118
+
119
+ # Resets the value of this attribute instance to `nil`.
120
+ #
121
+ # @return [NilClass] always `nil`
122
+ def reset!
123
+ self.value = nil
124
+ end
125
+
126
+ # Reports whether attribute value is absent (`nil`) but the attribute is
127
+ # optional and this fact can be safely ignored. Helps with rendering
128
+ # decisions.
129
+ #
130
+ # @return [TrueClass, FalseClass] flag indicating "safe" valuelessness
131
+ def optionally_valueless?
132
+ !value? && definition? && attribute_definition.optional?
133
+ end
134
+ end
135
+ end
136
+ end