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.
- checksums.yaml +4 -4
- data/.fasterer.yml +3 -0
- data/.gitignore +9 -16
- data/.rspec +1 -1
- data/.rubocop.yml +69 -0
- data/.travis.yml +27 -0
- data/AUTHORS +8 -6
- data/CHANGELOG.md +0 -0
- data/Gemfile +1 -1
- data/LICENSE +1 -1
- data/README.md +25 -170
- data/Rakefile +25 -17
- data/examples/initialize_model.rb +10 -0
- data/examples/parse_action_instance_json.rb +15 -0
- data/examples/parse_action_instance_text.rb +15 -0
- data/examples/parse_categories_json.rb +15 -0
- data/examples/parse_categories_text.rb +15 -0
- data/examples/parse_instance_json.rb +15 -0
- data/examples/parse_instance_text.rb +15 -0
- data/examples/parse_model_json.rb +9 -0
- data/examples/parse_model_text.rb +9 -0
- data/examples/render_action_instance_json.rb +17 -0
- data/examples/render_action_instance_text.rb +17 -0
- data/examples/render_instance_json.rb +20 -0
- data/examples/render_instance_text.rb +20 -0
- data/examples/render_model_json.rb +12 -0
- data/examples/render_model_text.rb +12 -0
- data/examples/rendering/action_instance.json +6 -0
- data/examples/rendering/action_instance.txt +2 -0
- data/examples/rendering/categories.json +78 -0
- data/examples/rendering/categories.txt +4 -0
- data/examples/rendering/instance.json +70 -0
- data/examples/rendering/instance.txt +12 -0
- data/examples/rendering/model.alt.json +1716 -0
- data/examples/rendering/model.json +785 -0
- data/examples/rendering/model.txt +68 -0
- data/lib/occi/core/action.rb +12 -26
- data/lib/occi/core/action_instance.rb +109 -65
- data/lib/occi/core/attribute.rb +136 -0
- data/lib/occi/core/attribute_definition.rb +269 -0
- data/lib/occi/core/category.rb +110 -83
- data/lib/occi/core/collection.rb +255 -0
- data/lib/occi/core/constants.rb +14 -0
- data/lib/occi/core/entity.rb +301 -195
- data/lib/occi/core/errors/.gitkeep +0 -0
- data/lib/occi/core/errors/attribute_definition_error.rb +11 -0
- data/lib/occi/core/errors/attribute_validation_error.rb +13 -0
- data/lib/occi/core/errors/category_validation_error.rb +13 -0
- data/lib/occi/core/errors/collection_lookup_error.rb +11 -0
- data/lib/occi/core/errors/instance_validation_error.rb +13 -0
- data/lib/occi/core/errors/mandatory_argument_error.rb +11 -0
- data/lib/occi/core/errors/model_lookup_error.rb +11 -0
- data/lib/occi/core/errors/parser_error.rb +11 -0
- data/lib/occi/core/errors/parsing_error.rb +11 -0
- data/lib/occi/core/errors/renderer_error.rb +11 -0
- data/lib/occi/core/errors/rendering_error.rb +11 -0
- data/lib/occi/core/errors/validation_error.rb +11 -0
- data/lib/occi/core/errors.rb +9 -0
- data/lib/occi/core/helpers/.gitkeep +0 -0
- data/lib/occi/core/helpers/argument_validator.rb +27 -0
- data/lib/occi/core/helpers/attributes_accessor.rb +22 -0
- data/lib/occi/core/helpers/error_handler.rb +29 -0
- data/lib/occi/core/helpers/hash_dereferencer.rb +149 -0
- data/lib/occi/core/helpers/identifier_validator.rb +135 -0
- data/lib/occi/core/helpers/instance_attribute_resetter.rb +131 -0
- data/lib/occi/core/helpers/instance_attributes_accessor.rb +30 -0
- data/lib/occi/core/helpers/locatable.rb +40 -0
- data/lib/occi/core/helpers/parser_dereferencer.rb +96 -0
- data/lib/occi/core/helpers/raw_json_parser.rb +18 -0
- data/lib/occi/core/helpers/renderable.rb +93 -0
- data/lib/occi/core/helpers/yaml_summoner.rb +44 -0
- data/lib/occi/core/helpers.rb +13 -0
- data/lib/occi/core/instance_builder.rb +162 -0
- data/lib/occi/core/kind.rb +100 -132
- data/lib/occi/core/link.rb +47 -72
- data/lib/occi/core/mixin.rb +76 -61
- data/lib/occi/core/model.rb +341 -0
- data/lib/occi/core/parsers/.gitkeep +0 -0
- data/lib/occi/core/parsers/base_parser.rb +168 -0
- data/lib/occi/core/parsers/json/.gitkeep +0 -0
- data/lib/occi/core/parsers/json/action_instance.rb +36 -0
- data/lib/occi/core/parsers/json/category.rb +113 -0
- data/lib/occi/core/parsers/json/entity.rb +156 -0
- data/lib/occi/core/parsers/json/validator/.gitkeep +0 -0
- data/lib/occi/core/parsers/json/validator/action-instance.json +3 -0
- data/lib/occi/core/parsers/json/validator/entity-collection.json +3 -0
- data/lib/occi/core/parsers/json/validator/link-collection.json +3 -0
- data/lib/occi/core/parsers/json/validator/link.json +3 -0
- data/lib/occi/core/parsers/json/validator/locations.json +3 -0
- data/lib/occi/core/parsers/json/validator/mixin-collection.json +3 -0
- data/lib/occi/core/parsers/json/validator/model.json +3 -0
- data/lib/occi/core/parsers/json/validator/occi-schema.json +277 -0
- data/lib/occi/core/parsers/json/validator/resource-collection.json +3 -0
- data/lib/occi/core/parsers/json/validator/resource.json +3 -0
- data/lib/occi/core/parsers/json/validator.rb +87 -0
- data/lib/occi/core/parsers/json_parser.rb +128 -0
- data/lib/occi/core/parsers/text/.gitkeep +0 -0
- data/lib/occi/core/parsers/text/category.rb +183 -0
- data/lib/occi/core/parsers/text/constants.rb +89 -0
- data/lib/occi/core/parsers/text/entity.rb +257 -0
- data/lib/occi/core/parsers/text/location.rb +48 -0
- data/lib/occi/core/parsers/text_parser.rb +257 -0
- data/lib/occi/core/parsers.rb +18 -0
- data/lib/occi/core/renderer_factory.rb +213 -0
- data/lib/occi/core/renderers/.gitkeep +0 -0
- data/lib/occi/core/renderers/base_renderer.rb +81 -0
- data/lib/occi/core/renderers/json/.gitkeep +0 -0
- data/lib/occi/core/renderers/json/action_instance.rb +24 -0
- data/lib/occi/core/renderers/json/attributes.rb +50 -0
- data/lib/occi/core/renderers/json/base.rb +46 -0
- data/lib/occi/core/renderers/json/category.rb +85 -0
- data/lib/occi/core/renderers/json/collection.rb +52 -0
- data/lib/occi/core/renderers/json/instance.rb +39 -0
- data/lib/occi/core/renderers/json/link.rb +48 -0
- data/lib/occi/core/renderers/json/model.rb +26 -0
- data/lib/occi/core/renderers/json/resource.rb +27 -0
- data/lib/occi/core/renderers/json_renderer.rb +72 -0
- data/lib/occi/core/renderers/text/.gitkeep +0 -0
- data/lib/occi/core/renderers/text/action_instance.rb +36 -0
- data/lib/occi/core/renderers/text/attributes.rb +87 -0
- data/lib/occi/core/renderers/text/base.rb +82 -0
- data/lib/occi/core/renderers/text/category.rb +183 -0
- data/lib/occi/core/renderers/text/collection.rb +65 -0
- data/lib/occi/core/renderers/text/instance.rb +44 -0
- data/lib/occi/core/renderers/text/link.rb +40 -0
- data/lib/occi/core/renderers/text/model.rb +41 -0
- data/lib/occi/core/renderers/text/resource.rb +109 -0
- data/lib/occi/core/renderers/text_renderer.rb +72 -0
- data/lib/occi/core/renderers.rb +20 -0
- data/lib/occi/core/resource.rb +93 -57
- data/lib/occi/core/utils/.gitkeep +0 -0
- data/lib/occi/core/version.rb +17 -0
- data/lib/occi/core/warehouse/actions/.gitkeep +0 -0
- data/lib/occi/core/warehouse/actions/attributes/.gitkeep +0 -0
- data/lib/occi/core/warehouse/kinds/.gitkeep +0 -0
- data/lib/occi/core/warehouse/kinds/attributes/.gitkeep +0 -0
- data/lib/occi/core/warehouse/kinds/attributes/occi.core.id.yml +7 -0
- data/lib/occi/core/warehouse/kinds/attributes/occi.core.source.yml +7 -0
- data/lib/occi/core/warehouse/kinds/attributes/occi.core.summary.yml +7 -0
- data/lib/occi/core/warehouse/kinds/attributes/occi.core.target.yml +7 -0
- data/lib/occi/core/warehouse/kinds/attributes/occi.core.title.yml +7 -0
- data/lib/occi/core/warehouse/kinds/entity.yml +10 -0
- data/lib/occi/core/warehouse/kinds/link.yml +10 -0
- data/lib/occi/core/warehouse/kinds/resource.yml +9 -0
- data/lib/occi/core/warehouse/mixins/.gitkeep +0 -0
- data/lib/occi/core/warehouse/mixins/attributes/.gitkeep +0 -0
- data/lib/occi/core/warehouse.rb +115 -0
- data/lib/occi/core.rb +59 -23
- data/lib/occi/infrastructure/compute.rb +5 -122
- data/lib/occi/infrastructure/constants.rb +25 -0
- data/lib/occi/infrastructure/instance_builder.rb +24 -0
- data/lib/occi/infrastructure/mixins/.gitkeep +0 -0
- data/lib/occi/infrastructure/mixins/os_tpl.rb +19 -0
- data/lib/occi/infrastructure/mixins/resource_tpl.rb +19 -0
- data/lib/occi/infrastructure/mixins.rb +12 -0
- data/lib/occi/infrastructure/model.rb +27 -0
- data/lib/occi/infrastructure/network.rb +5 -104
- data/lib/occi/infrastructure/networkinterface.rb +5 -100
- data/lib/occi/infrastructure/storage.rb +5 -59
- data/lib/occi/infrastructure/storagelink.rb +5 -54
- data/lib/occi/infrastructure/version.rb +5 -0
- data/lib/occi/infrastructure/warehouse/actions/.gitkeep +0 -0
- data/lib/occi/infrastructure/warehouse/actions/attributes/.gitkeep +0 -0
- data/lib/occi/infrastructure/warehouse/actions/compute_restart.yml +12 -0
- data/lib/occi/infrastructure/warehouse/actions/compute_save.yml +19 -0
- data/lib/occi/infrastructure/warehouse/actions/compute_start.yml +4 -0
- data/lib/occi/infrastructure/warehouse/actions/compute_stop.yml +12 -0
- data/lib/occi/infrastructure/warehouse/actions/compute_suspend.yml +12 -0
- data/lib/occi/infrastructure/warehouse/actions/network_down.yml +4 -0
- data/lib/occi/infrastructure/warehouse/actions/network_up.yml +4 -0
- data/lib/occi/infrastructure/warehouse/actions/networkinterface_down.yml +4 -0
- data/lib/occi/infrastructure/warehouse/actions/networkinterface_up.yml +4 -0
- data/lib/occi/infrastructure/warehouse/actions/storage_backup.yml +4 -0
- data/lib/occi/infrastructure/warehouse/actions/storage_offline.yml +4 -0
- data/lib/occi/infrastructure/warehouse/actions/storage_online.yml +4 -0
- data/lib/occi/infrastructure/warehouse/actions/storage_resize.yml +12 -0
- data/lib/occi/infrastructure/warehouse/actions/storage_snapshot.yml +4 -0
- data/lib/occi/infrastructure/warehouse/actions/storagelink_offline.yml +4 -0
- data/lib/occi/infrastructure/warehouse/actions/storagelink_online.yml +4 -0
- data/lib/occi/infrastructure/warehouse/kinds/.gitkeep +0 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/.gitkeep +0 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.compute.architecture.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.compute.cores.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.compute.hostname.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.compute.memory.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.compute.speed.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.compute.state.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.network.label.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.network.state.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.network.vlan.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.networkinterface.interface.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.networkinterface.mac.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.networkinterface.state.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.storage.size.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.storage.state.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.storagelink.deviceid.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.storagelink.mountpoint.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.storagelink.state.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/compute.yml +19 -0
- data/lib/occi/infrastructure/warehouse/kinds/network.yml +13 -0
- data/lib/occi/infrastructure/warehouse/kinds/networkinterface.yml +13 -0
- data/lib/occi/infrastructure/warehouse/kinds/storage.yml +15 -0
- data/lib/occi/infrastructure/warehouse/kinds/storagelink.yml +13 -0
- data/lib/occi/infrastructure/warehouse/mixins/.gitkeep +0 -0
- data/lib/occi/infrastructure/warehouse/mixins/attributes/.gitkeep +0 -0
- data/lib/occi/infrastructure/warehouse/mixins/attributes/occi.network.address.yml +7 -0
- data/lib/occi/infrastructure/warehouse/mixins/attributes/occi.network.allocation.yml +7 -0
- data/lib/occi/infrastructure/warehouse/mixins/attributes/occi.network.gateway.yml +7 -0
- data/lib/occi/infrastructure/warehouse/mixins/attributes/occi.networkinterface.address.yml +7 -0
- data/lib/occi/infrastructure/warehouse/mixins/attributes/occi.networkinterface.allocation.yml +7 -0
- data/lib/occi/infrastructure/warehouse/mixins/attributes/occi.networkinterface.gateway.yml +7 -0
- data/lib/occi/infrastructure/warehouse/mixins/ipnetwork.yml +11 -0
- data/lib/occi/infrastructure/warehouse/mixins/ipnetworkinterface.yml +11 -0
- data/lib/occi/infrastructure/warehouse.rb +20 -0
- data/lib/occi/infrastructure-ext.rb +35 -0
- data/lib/occi/infrastructure.rb +34 -19
- data/lib/occi/infrastructure_ext/constants.rb +20 -0
- data/lib/occi/infrastructure_ext/instance_builder.rb +22 -0
- data/lib/occi/infrastructure_ext/ipreservation.rb +9 -0
- data/lib/occi/infrastructure_ext/mixins/.gitkeep +0 -0
- data/lib/occi/infrastructure_ext/mixins/availability_zone.rb +19 -0
- data/lib/occi/infrastructure_ext/mixins.rb +12 -0
- data/lib/occi/infrastructure_ext/model.rb +26 -0
- data/lib/occi/infrastructure_ext/securitygroup.rb +9 -0
- data/lib/occi/infrastructure_ext/securitygrouplink.rb +9 -0
- data/lib/occi/infrastructure_ext/version.rb +5 -0
- data/lib/occi/infrastructure_ext/warehouse/actions/.gitkeep +0 -0
- data/lib/occi/infrastructure_ext/warehouse/actions/attributes/.gitkeep +0 -0
- data/lib/occi/infrastructure_ext/warehouse/actions/ipreservation_down.yml +4 -0
- data/lib/occi/infrastructure_ext/warehouse/actions/ipreservation_up.yml +4 -0
- data/lib/occi/infrastructure_ext/warehouse/kinds/.gitkeep +0 -0
- data/lib/occi/infrastructure_ext/warehouse/kinds/attributes/.gitkeep +0 -0
- data/lib/occi/infrastructure_ext/warehouse/kinds/attributes/occi.ipreservation.address.yml +7 -0
- data/lib/occi/infrastructure_ext/warehouse/kinds/attributes/occi.ipreservation.state.yml +7 -0
- data/lib/occi/infrastructure_ext/warehouse/kinds/attributes/occi.ipreservation.used.yml +7 -0
- data/lib/occi/infrastructure_ext/warehouse/kinds/attributes/occi.securitygroup.rules.yml +7 -0
- data/lib/occi/infrastructure_ext/warehouse/kinds/attributes/occi.securitygroup.state.yml +7 -0
- data/lib/occi/infrastructure_ext/warehouse/kinds/attributes/occi.securitygrouplink.state.yml +7 -0
- data/lib/occi/infrastructure_ext/warehouse/kinds/ipreservation.yml +13 -0
- data/lib/occi/infrastructure_ext/warehouse/kinds/securitygroup.yml +9 -0
- data/lib/occi/infrastructure_ext/warehouse/kinds/securitygrouplink.yml +8 -0
- data/lib/occi/infrastructure_ext/warehouse/mixins/.gitkeep +0 -0
- data/lib/occi/infrastructure_ext/warehouse/mixins/attributes/.gitkeep +0 -0
- data/lib/occi/infrastructure_ext/warehouse.rb +20 -0
- data/lib/occi/monkey_island/boolean.rb +6 -0
- data/lib/occi/monkey_island/hash.rb +4 -0
- data/occi-core.gemspec +26 -26
- metadata +312 -243
- data/.yardopts +0 -1
- data/config/occi.yml +0 -4
- data/lib/occi/collection.rb +0 -265
- data/lib/occi/core/actions.rb +0 -21
- data/lib/occi/core/attributes.rb +0 -411
- data/lib/occi/core/categories.rb +0 -64
- data/lib/occi/core/dependencies.rb +0 -7
- data/lib/occi/core/entities.rb +0 -48
- data/lib/occi/core/kinds.rb +0 -22
- data/lib/occi/core/links.rb +0 -37
- data/lib/occi/core/mixins.rb +0 -37
- data/lib/occi/core/properties.rb +0 -108
- data/lib/occi/core/resources.rb +0 -14
- data/lib/occi/errors/attribute_definitions_converted_error.rb +0 -5
- data/lib/occi/errors/attribute_missing_error.rb +0 -5
- data/lib/occi/errors/attribute_name_invalid_error.rb +0 -5
- data/lib/occi/errors/attribute_not_defined_error.rb +0 -5
- data/lib/occi/errors/attribute_property_type_error.rb +0 -5
- data/lib/occi/errors/attribute_type_error.rb +0 -5
- data/lib/occi/errors/category_not_defined_error.rb +0 -5
- data/lib/occi/errors/kind_not_defined_error.rb +0 -5
- data/lib/occi/errors/parser_input_error.rb +0 -5
- data/lib/occi/errors/parser_type_error.rb +0 -5
- data/lib/occi/errors.rb +0 -1
- data/lib/occi/extensions/hashie.rb +0 -25
- data/lib/occi/helpers/comparators/action_instance.rb +0 -22
- data/lib/occi/helpers/comparators/attributes.rb +0 -22
- data/lib/occi/helpers/comparators/categories.rb +0 -22
- data/lib/occi/helpers/comparators/category.rb +0 -22
- data/lib/occi/helpers/comparators/collection.rb +0 -40
- data/lib/occi/helpers/comparators/entities.rb +0 -22
- data/lib/occi/helpers/comparators/entity.rb +0 -22
- data/lib/occi/helpers/comparators/properties.rb +0 -26
- data/lib/occi/helpers/comparators.rb +0 -1
- data/lib/occi/helpers/inspect.rb +0 -12
- data/lib/occi/infrastructure/network/ipnetwork.rb +0 -28
- data/lib/occi/infrastructure/networkinterface/ipnetworkinterface.rb +0 -28
- data/lib/occi/infrastructure/os_tpl.rb +0 -20
- data/lib/occi/infrastructure/resource_tpl.rb +0 -20
- data/lib/occi/log.rb +0 -71
- data/lib/occi/model.rb +0 -87
- data/lib/occi/parser/json.rb +0 -38
- data/lib/occi/parser/text/constants.rb +0 -89
- data/lib/occi/parser/text.rb +0 -280
- data/lib/occi/parser.rb +0 -144
- data/lib/occi/settings.rb +0 -10
- data/lib/occi/version.rb +0 -3
- data/lib/occi-core.rb +0 -53
- data/spec/helpers/to_plain.rb +0 -39
- data/spec/helpers/yaml_hash.rb +0 -32
- data/spec/occi/collection_samples/collection1.json +0 -1
- data/spec/occi/collection_samples/directory2/collection2.json +0 -1
- data/spec/occi/collection_spec.rb +0 -1003
- data/spec/occi/core/action_instance_spec.rb +0 -317
- data/spec/occi/core/action_spec.rb +0 -71
- data/spec/occi/core/attributes_spec.rb +0 -665
- data/spec/occi/core/categories_spec.rb +0 -28
- data/spec/occi/core/category_spec.rb +0 -216
- data/spec/occi/core/entities_spec.rb +0 -160
- data/spec/occi/core/entity_spec.rb +0 -374
- data/spec/occi/core/kind_spec.rb +0 -182
- data/spec/occi/core/link_spec.rb +0 -52
- data/spec/occi/core/links_spec.rb +0 -132
- data/spec/occi/core/mixin_spec.rb +0 -38
- data/spec/occi/core/mixins_spec.rb +0 -107
- data/spec/occi/core/properties_spec.rb +0 -171
- data/spec/occi/core/resource_spec.rb +0 -42
- data/spec/occi/core_spec.rb +0 -12
- data/spec/occi/infrastructure/compute_spec.rb +0 -229
- data/spec/occi/infrastructure/network_spec.rb +0 -96
- data/spec/occi/infrastructure/networkinterface_spec.rb +0 -96
- data/spec/occi/infrastructure/storage_spec.rb +0 -33
- data/spec/occi/infrastructure/storagelink_spec.rb +0 -45
- data/spec/occi/log_spec.rb +0 -117
- data/spec/occi/model_spec.rb +0 -256
- data/spec/occi/parser/json_samples/test.json +0 -49
- data/spec/occi/parser/text_samples/occi_categories.body_plain.expected +0 -2
- data/spec/occi/parser/text_samples/occi_categories.expected +0 -2
- data/spec/occi/parser/text_samples/occi_categories.parse_headers.expected +0 -2
- data/spec/occi/parser/text_samples/occi_categories.text +0 -2
- data/spec/occi/parser/text_samples/occi_compute_rocci_server.expected +0 -11
- data/spec/occi/parser/text_samples/occi_compute_rocci_server.text +0 -10
- data/spec/occi/parser/text_samples/occi_link_resource_instance.body_plain.expected +0 -7
- data/spec/occi/parser/text_samples/occi_link_resource_instance.expected +0 -7
- data/spec/occi/parser/text_samples/occi_link_resource_instance.parse.expected +0 -7
- data/spec/occi/parser/text_samples/occi_link_resource_instance.text +0 -7
- data/spec/occi/parser/text_samples/occi_link_simple.expected +0 -7
- data/spec/occi/parser/text_samples/occi_link_simple.text +0 -1
- data/spec/occi/parser/text_samples/occi_link_w_attributes.expected +0 -7
- data/spec/occi/parser/text_samples/occi_link_w_attributes.text +0 -7
- data/spec/occi/parser/text_samples/occi_link_w_category.expected +0 -7
- data/spec/occi/parser/text_samples/occi_link_w_category.text +0 -3
- data/spec/occi/parser/text_samples/occi_model_categories.expected +0 -3
- data/spec/occi/parser/text_samples/occi_model_rocci_server.text +0 -51
- data/spec/occi/parser/text_samples/occi_network_rocci_server.body_plain.expected +0 -11
- data/spec/occi/parser/text_samples/occi_network_rocci_server.expected +0 -11
- data/spec/occi/parser/text_samples/occi_network_rocci_server.resource.header.expected +0 -9
- data/spec/occi/parser/text_samples/occi_network_rocci_server.resource.rack.expected +0 -9
- data/spec/occi/parser/text_samples/occi_network_rocci_server.text +0 -11
- data/spec/occi/parser/text_samples/occi_resource_custom_class_w_attributes.parse.expected +0 -15
- data/spec/occi/parser/text_samples/occi_resource_custom_class_w_attributes.text +0 -15
- data/spec/occi/parser/text_samples/occi_resource_w_attributes.text +0 -11
- data/spec/occi/parser/text_samples/occi_resource_w_inline_links.expected +0 -1
- data/spec/occi/parser/text_samples/occi_resource_w_inline_links.text +0 -16
- data/spec/occi/parser/text_samples/occi_resource_w_inline_links_only.text +0 -13
- data/spec/occi/parser/text_samples/occi_storage_rocci_server.expected +0 -9
- data/spec/occi/parser/text_samples/occi_storage_rocci_server.text +0 -9
- data/spec/occi/parser/text_spec.rb +0 -320
- data/spec/occi/parser_spec.rb +0 -259
- data/spec/occi-core_spec.rb +0 -31
- data/spec/spec_helper.rb +0 -18
data/lib/occi/parser/text.rb
DELETED
@@ -1,280 +0,0 @@
|
|
1
|
-
Dir[File.join(File.dirname(__FILE__), 'text', '*.rb')].each { |file| require file.gsub('.rb', '') }
|
2
|
-
|
3
|
-
module Occi
|
4
|
-
module Parser
|
5
|
-
module Text
|
6
|
-
|
7
|
-
class << self
|
8
|
-
|
9
|
-
include Occi::Parser::Text::Constants
|
10
|
-
|
11
|
-
def categories(lines)
|
12
|
-
Occi::Log.debug "[#{self}] Parsing through Occi::Parser::Text.categories"
|
13
|
-
collection = Occi::Collection.new
|
14
|
-
|
15
|
-
block = Proc.new { |line|
|
16
|
-
line.strip!
|
17
|
-
category = category(line) if line.start_with? 'Category:'
|
18
|
-
collection << category if category.kind_of? Occi::Core::Category
|
19
|
-
}
|
20
|
-
|
21
|
-
lines.respond_to?(:each) ? lines.each(&block) : lines.each_line(&block)
|
22
|
-
collection
|
23
|
-
end
|
24
|
-
|
25
|
-
def resource(lines)
|
26
|
-
Occi::Log.debug "[#{self}] Parsing through Occi::Parser::Text.resource"
|
27
|
-
collection = Occi::Collection.new
|
28
|
-
resource = Occi::Core::Resource.new
|
29
|
-
resource.id = nil
|
30
|
-
links = []
|
31
|
-
|
32
|
-
block = Proc.new { |line|
|
33
|
-
line.strip!
|
34
|
-
case line
|
35
|
-
when /^Category:/
|
36
|
-
category = category(line)
|
37
|
-
|
38
|
-
if category.kind_of? Occi::Core::Kind
|
39
|
-
resource = Occi::Core::Resource.new category.type_identifier
|
40
|
-
resource.id = nil
|
41
|
-
resource.kind = category
|
42
|
-
end
|
43
|
-
|
44
|
-
resource.mixins << category if category.kind_of? Occi::Core::Mixin
|
45
|
-
when /^X-OCCI-Attribute:/
|
46
|
-
resource.attributes.merge! attribute(line)
|
47
|
-
when /^Link:/
|
48
|
-
link = link_string(line, resource)
|
49
|
-
|
50
|
-
if link.kind_of? Occi::Core::Link
|
51
|
-
resource.links << link
|
52
|
-
links << link
|
53
|
-
elsif link.kind_of? Occi::Core::Action
|
54
|
-
resource.actions << link
|
55
|
-
else
|
56
|
-
raise Occi::Errors::ParserInputError, "Could not recognize resource link! #{link.inspect}"
|
57
|
-
end
|
58
|
-
end
|
59
|
-
}
|
60
|
-
lines.respond_to?(:each) ? lines.each(&block) : lines.each_line(&block)
|
61
|
-
|
62
|
-
if resource.kind_of?(Occi::Core::Resource) && !resource.empty?
|
63
|
-
collection << resource
|
64
|
-
links.each { |link| collection << link }
|
65
|
-
end
|
66
|
-
|
67
|
-
collection
|
68
|
-
end
|
69
|
-
|
70
|
-
def link(lines)
|
71
|
-
Occi::Log.debug "[#{self}] Parsing through Occi::Parser::Text.link"
|
72
|
-
collection = Occi::Collection.new
|
73
|
-
link = Occi::Core::Link.new
|
74
|
-
link.id = nil
|
75
|
-
|
76
|
-
block = Proc.new { |line|
|
77
|
-
line.strip!
|
78
|
-
case line
|
79
|
-
when /^Category:/
|
80
|
-
category = category(line)
|
81
|
-
|
82
|
-
if category.kind_of? Occi::Core::Kind
|
83
|
-
link = Occi::Core::Link.new category.type_identifier
|
84
|
-
link.id = nil
|
85
|
-
link.kind = category
|
86
|
-
end
|
87
|
-
|
88
|
-
link.mixins << category if category.kind_of? Occi::Core::Mixin
|
89
|
-
when /^X-OCCI-Attribute:/
|
90
|
-
link.attributes.merge! attribute(line)
|
91
|
-
end
|
92
|
-
}
|
93
|
-
lines.respond_to?(:each) ? lines.each(&block) : lines.each_line(&block)
|
94
|
-
|
95
|
-
collection << link if link.kind_of?(Occi::Core::Link) && !link.empty?
|
96
|
-
collection
|
97
|
-
end
|
98
|
-
|
99
|
-
def locations(lines)
|
100
|
-
Occi::Log.debug "[#{self}] Parsing through Occi::Parser::Text.locations"
|
101
|
-
locations = []
|
102
|
-
|
103
|
-
block = Proc.new { |line|
|
104
|
-
line.strip!
|
105
|
-
locations << location(line) if line.start_with? 'X-OCCI-Location:'
|
106
|
-
}
|
107
|
-
lines.respond_to?(:each) ? lines.each(&block) : lines.each_line(&block)
|
108
|
-
|
109
|
-
locations
|
110
|
-
end
|
111
|
-
|
112
|
-
def category(string)
|
113
|
-
Occi::Log.debug "[#{self}] Parsing through Occi::Parser::Text.category"
|
114
|
-
# create regular expression from regexp string
|
115
|
-
regexp = Regexp.new( Occi::Settings.compatibility ? REGEXP_CATEGORY : REGEXP_CATEGORY_STRICT )
|
116
|
-
# match string to regular expression
|
117
|
-
match = regexp.match string
|
118
|
-
|
119
|
-
raise Occi::Errors::ParserInputError, "Could not match #{string.inspect}" unless match
|
120
|
-
|
121
|
-
term = match[:term].downcase
|
122
|
-
scheme = match[:scheme]
|
123
|
-
title = match[:title]
|
124
|
-
related = match[:rel].to_s.split(/\s+/)
|
125
|
-
|
126
|
-
attributes = category_attributes(match[:attributes])
|
127
|
-
actions = match[:actions].to_s.split
|
128
|
-
location = match[:location]
|
129
|
-
|
130
|
-
case match[:class]
|
131
|
-
when 'kind'
|
132
|
-
Occi::Log.debug "[#{self}] class #{match[:class].inspect} identified as kind"
|
133
|
-
Occi::Core::Kind.new scheme, term, title, attributes, related, actions, location
|
134
|
-
when 'mixin'
|
135
|
-
Occi::Log.debug "[#{self}] class #{match[:class].inspect} identified as mixin"
|
136
|
-
Occi::Core::Mixin.new scheme, term, title, attributes, related, actions, location
|
137
|
-
when 'action'
|
138
|
-
Occi::Log.debug "[#{self}] class #{match[:class].inspect} identified as action"
|
139
|
-
Occi::Core::Action.new scheme, term, title, attributes
|
140
|
-
else
|
141
|
-
raise Occi::Errors::ParserInputError, "Category with class #{match[:class].inspect} not recognized in string: #{string}"
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
def category_attributes(matched_attributes)
|
146
|
-
attributes = Occi::Core::Attributes.new
|
147
|
-
return attributes unless matched_attributes
|
148
|
-
|
149
|
-
# TODO: find a better approach to fixing split
|
150
|
-
matched_attributes.gsub! /\{(immutable|required)\s+(required|immutable)\}/, '{\1_\2}'
|
151
|
-
|
152
|
-
matched_attributes.split.each do |attribute|
|
153
|
-
attribute.gsub! /\{(immutable|required)_(required|immutable)\}/, '{\1 \2}'
|
154
|
-
property_string = attribute[/#{REGEXP_ATTRIBUTE_DEF}/, -2]
|
155
|
-
properties = Occi::Core::Properties.new
|
156
|
-
|
157
|
-
if property_string
|
158
|
-
properties.required = property_string.include?('required')
|
159
|
-
properties.mutable = !property_string.include?('immutable')
|
160
|
-
end
|
161
|
-
|
162
|
-
name = attribute[/#{REGEXP_ATTRIBUTE_DEF}/, 1]
|
163
|
-
attributes.merge! name.split('.').reverse.inject(properties) { |a, n| Occi::Core::Attributes.new(n => a) }
|
164
|
-
end
|
165
|
-
|
166
|
-
attributes
|
167
|
-
end
|
168
|
-
|
169
|
-
def attribute(string)
|
170
|
-
Occi::Log.debug "[#{self}] Parsing through Occi::Parser::Text.attribute"
|
171
|
-
# create regular expression from regexp string
|
172
|
-
regexp = Regexp.new(REGEXP_ATTRIBUTE)
|
173
|
-
# match string to regular expression
|
174
|
-
match = regexp.match string
|
175
|
-
|
176
|
-
raise Occi::Errors::ParserInputError, "Could not match #{string.inspect}" unless match
|
177
|
-
|
178
|
-
value = match[:string] if match[:string]
|
179
|
-
|
180
|
-
if match[:number]
|
181
|
-
match[:number].include?('.') ? value = match[:number].to_f : value = match[:number].to_i
|
182
|
-
end
|
183
|
-
|
184
|
-
value = match[:bool] == "true" if match[:bool]
|
185
|
-
Occi::Core::Attributes.split match[:name] => value
|
186
|
-
end
|
187
|
-
|
188
|
-
def link_string(string, source)
|
189
|
-
Occi::Log.debug "[#{self}] Parsing through Occi::Parser::Text.link_string"
|
190
|
-
# create regular expression from regexp string
|
191
|
-
regexp = Regexp.new( Occi::Settings.compatibility ? REGEXP_LINK : REGEXP_LINK_STRICT )
|
192
|
-
# match string to regular expression
|
193
|
-
match = regexp.match string
|
194
|
-
|
195
|
-
raise Occi::Errors::ParserInputError, "Could not match #{string.inspect}" unless match
|
196
|
-
|
197
|
-
if match[:uri].include?('?action=')
|
198
|
-
link_string_action match
|
199
|
-
else
|
200
|
-
link_string_link match, source
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
def link_string_action(match)
|
205
|
-
scheme, term = match[:rel].split('#')
|
206
|
-
Occi::Core::Action.new scheme, term
|
207
|
-
end
|
208
|
-
|
209
|
-
def link_string_link(match, source)
|
210
|
-
target = match[:uri]
|
211
|
-
rel = match[:rel]
|
212
|
-
|
213
|
-
if match[:category].blank?
|
214
|
-
kind = Occi::Core::Link.kind
|
215
|
-
else
|
216
|
-
categories = match[:category].split
|
217
|
-
kind = categories.shift
|
218
|
-
mixins = categories
|
219
|
-
end
|
220
|
-
actions = nil
|
221
|
-
location = match[:self]
|
222
|
-
|
223
|
-
# create an array of the list of attributes
|
224
|
-
attributes = []
|
225
|
-
regexp = Regexp.new '(\\s*'+REGEXP_ATTRIBUTE_REPR.to_s+')'
|
226
|
-
attr_line = match[:attributes].sub(/^\s*;\s*/, ' ')
|
227
|
-
attributes = attr_line.scan(regexp).collect {|matches| matches.first}
|
228
|
-
|
229
|
-
# parse each attribute and create an OCCI Attribute object from it
|
230
|
-
attributes = attributes.inject(Hashie::Mash.new) { |hsh, attribute|
|
231
|
-
hsh.merge!(Occi::Parser::Text.attribute("X-OCCI-Attribute: #{attribute}"))
|
232
|
-
}
|
233
|
-
|
234
|
-
Occi::Core::Link.new kind, mixins, attributes, actions, rel, target, source, location
|
235
|
-
end
|
236
|
-
|
237
|
-
def location(string)
|
238
|
-
Occi::Log.debug "[#{self}] Parsing through Occi::Parser::Text.location"
|
239
|
-
# create regular expression from regexp string
|
240
|
-
regexp = Regexp.new(REGEXP_LOCATION)
|
241
|
-
# match string to regular expression
|
242
|
-
match = regexp.match string
|
243
|
-
|
244
|
-
raise Occi::Errors::ParserInputError, "Could not match #{string.inspect}" unless match
|
245
|
-
|
246
|
-
match[:location]
|
247
|
-
end
|
248
|
-
|
249
|
-
def action(lines)
|
250
|
-
Occi::Log.debug "[#{self}] Parsing through Occi::Parser::Text.action"
|
251
|
-
collection = Occi::Collection.new
|
252
|
-
action_instance = nil
|
253
|
-
|
254
|
-
block = Proc.new { |line|
|
255
|
-
line.strip!
|
256
|
-
|
257
|
-
case line
|
258
|
-
when /^Category:/
|
259
|
-
action_instance = Occi::Core::ActionInstance.new
|
260
|
-
action_instance.action = category(line)
|
261
|
-
when /^X-OCCI-Attribute:/
|
262
|
-
raise Occi::Errors::ParserInputError,
|
263
|
-
"Line #{line.inspect} arrived out of order!" unless action_instance
|
264
|
-
action_instance.attributes.merge! attribute(line)
|
265
|
-
end
|
266
|
-
}
|
267
|
-
lines.respond_to?(:each) ? lines.each(&block) : lines.each_line(&block)
|
268
|
-
|
269
|
-
unless action_instance.blank?
|
270
|
-
collection << action_instance
|
271
|
-
end
|
272
|
-
|
273
|
-
collection
|
274
|
-
end
|
275
|
-
|
276
|
-
end
|
277
|
-
|
278
|
-
end
|
279
|
-
end
|
280
|
-
end
|
data/lib/occi/parser.rb
DELETED
@@ -1,144 +0,0 @@
|
|
1
|
-
Dir[File.join(File.dirname(__FILE__), 'parser', '*.rb')].each { |file| require file.gsub('.rb', '') }
|
2
|
-
|
3
|
-
module Occi
|
4
|
-
module Parser
|
5
|
-
|
6
|
-
class << self
|
7
|
-
|
8
|
-
OCCI_HEADERS = ['Category', 'Link', 'X-OCCI-Location', 'X-OCCI-Attribute', 'Location'].freeze
|
9
|
-
|
10
|
-
# Parses an OCCI message and extracts OCCI relevant information
|
11
|
-
# @param [String] media_type the media type of the OCCI message
|
12
|
-
# @param [String] body the body of the OCCI message
|
13
|
-
# @param [true, false] category for text/plain and text/occi media types information e.g. from the HTTP request location is needed to determine if the OCCI message includes a category or an entity
|
14
|
-
# @param [Occi::Core::Resource,Occi::Core::Link] entity_type entity type to use for parsing of text plain entities
|
15
|
-
# @param [Hash] header optional header of the OCCI message
|
16
|
-
# @return [Occi::Collection] list consisting of an array of locations and the OCCI object collection
|
17
|
-
def parse(media_type, body, category=false, entity_type=Occi::Core::Resource, header={})
|
18
|
-
Occi::Log.debug "[#{self}] Parsing request data to OCCI Collection"
|
19
|
-
header = headers_to_arys(header)
|
20
|
-
|
21
|
-
Occi::Log.debug "[#{self}] Parsing headers: #{header.inspect}"
|
22
|
-
collection = parse_headers(header, category, entity_type)
|
23
|
-
|
24
|
-
Occi::Log.debug "[#{self}] Parsing #{media_type} from body"
|
25
|
-
coll_body = parse_body(media_type, body || '', category, entity_type)
|
26
|
-
collection.merge! coll_body if coll_body && !coll_body.empty?
|
27
|
-
|
28
|
-
collection
|
29
|
-
end
|
30
|
-
|
31
|
-
def locations(media_type, body, header)
|
32
|
-
locations = []
|
33
|
-
locations << header['Location'] if header['Location'] && !header['Location'].blank?
|
34
|
-
header = headers_to_arys(header)
|
35
|
-
|
36
|
-
Occi::Log.debug "[#{self}] Parsing locations from request headers: #{header.inspect}"
|
37
|
-
locations << Occi::Parser::Text.locations(header)
|
38
|
-
|
39
|
-
Occi::Log.debug "[#{self}] Parsing #{media_type} locations from body"
|
40
|
-
case media_type
|
41
|
-
when 'text/uri-list'
|
42
|
-
locations << body.split("\n")
|
43
|
-
when 'text/plain', nil
|
44
|
-
locations << Occi::Parser::Text.locations(body.split "\n")
|
45
|
-
else
|
46
|
-
nil
|
47
|
-
end
|
48
|
-
|
49
|
-
locations.flatten
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
def parse_headers(header, category, entity_type)
|
55
|
-
if category
|
56
|
-
Occi::Log.debug "[#{self}] Parsing categories from headers"
|
57
|
-
collection = Occi::Parser::Text.categories(header)
|
58
|
-
else
|
59
|
-
if entity_type == Occi::Core::Resource
|
60
|
-
Occi::Log.debug "[#{self}] Parsing a resource from headers"
|
61
|
-
collection = Occi::Parser::Text.resource(header)
|
62
|
-
elsif entity_type == Occi::Core::Link
|
63
|
-
Occi::Log.debug "[#{self}] Parsing a link from headers"
|
64
|
-
collection = Occi::Parser::Text.link(header)
|
65
|
-
elsif entity_type == Occi::Core::ActionInstance
|
66
|
-
Occi::Log.debug "[#{self}] Parsing an action instance from headers"
|
67
|
-
collection = Occi::Parser::Text.action(header)
|
68
|
-
else
|
69
|
-
raise Occi::Errors::ParserTypeError, "Entity type '#{entity_type}' not supported"
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
collection
|
74
|
-
end
|
75
|
-
|
76
|
-
def parse_body(media_type, body, category, entity_type)
|
77
|
-
collection = Occi::Collection.new
|
78
|
-
|
79
|
-
case media_type
|
80
|
-
when 'text/uri-list'
|
81
|
-
raise Occi::Errors::ParserTypeError, "Type 'text/uri-list' not supported by parse(). Call method #{self}.locations() to parse URI lists"
|
82
|
-
when 'text/occi'
|
83
|
-
Occi::Log.warn "Input type text/occi was passed to the parser in request body. All text/occi content MUST be passed in headers. Request body was not processed. The unprocessed content follows\n#{body}" unless body.blank?
|
84
|
-
nil
|
85
|
-
when 'text/plain', nil
|
86
|
-
collection = parse_body_plain(body, category, entity_type)
|
87
|
-
when 'application/occi+json', 'application/json'
|
88
|
-
collection = Occi::Parser::Json.collection body
|
89
|
-
else
|
90
|
-
raise Occi::Errors::ParserTypeError, "Content type #{media_type} not supported"
|
91
|
-
end
|
92
|
-
|
93
|
-
collection
|
94
|
-
end
|
95
|
-
|
96
|
-
def parse_body_plain(body, category, entity_type)
|
97
|
-
if category
|
98
|
-
collection = Occi::Parser::Text.categories body.split("\n")
|
99
|
-
else
|
100
|
-
if entity_type == Occi::Core::Resource
|
101
|
-
collection = Occi::Parser::Text.resource body.split("\n")
|
102
|
-
elsif entity_type == Occi::Core::Link
|
103
|
-
collection = Occi::Parser::Text.link body.split("\n")
|
104
|
-
elsif entity_type == Occi::Core::ActionInstance
|
105
|
-
collection = Occi::Parser::Text.action body.split("\n")
|
106
|
-
else
|
107
|
-
raise Occi::Errors::ParserTypeError, "Entity type #{entity_type} not supported"
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
collection
|
112
|
-
end
|
113
|
-
|
114
|
-
def headers_to_arys(header)
|
115
|
-
# remove the HTTP_ prefix if present and capitalize keys
|
116
|
-
header = Hash[header.map { |k, v| [k.gsub('HTTP_', '').capitalize, v] }]
|
117
|
-
|
118
|
-
# normalize different header-passing mechanisms and representations
|
119
|
-
if header['X-OCCI-Location'].blank?
|
120
|
-
header['X-OCCI-Location'] = header['X_occi_location'] unless header['X_occi_location'].blank?
|
121
|
-
header['X-OCCI-Location'] = header['X-occi-location'] unless header['X-occi-location'].blank?
|
122
|
-
end
|
123
|
-
|
124
|
-
if header['X-OCCI-Attribute'].blank?
|
125
|
-
header['X-OCCI-Attribute'] = header['X_occi_attribute'] unless header['X_occi_attribute'].blank?
|
126
|
-
header['X-OCCI-Attribute'] = header['X-occi-attribute'] unless header['X-occi-attribute'].blank?
|
127
|
-
end
|
128
|
-
|
129
|
-
# clean-up
|
130
|
-
header.delete_if { |k, v| v.blank? || !OCCI_HEADERS.include?(k) }
|
131
|
-
|
132
|
-
header = header.map do |k, v|
|
133
|
-
# sometimes header values arrive as single-value arrays!
|
134
|
-
v = v.first if v.kind_of?(Array)
|
135
|
-
v.to_s.split(',').collect { |w| "#{k}: #{w}".strip }
|
136
|
-
end
|
137
|
-
|
138
|
-
header.flatten.sort
|
139
|
-
end
|
140
|
-
|
141
|
-
end
|
142
|
-
|
143
|
-
end
|
144
|
-
end
|
data/lib/occi/settings.rb
DELETED
data/lib/occi/version.rb
DELETED
data/lib/occi-core.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
|
3
|
-
require 'active_support'
|
4
|
-
require 'active_support/core_ext'
|
5
|
-
require 'active_support/json'
|
6
|
-
require 'active_support/inflector'
|
7
|
-
require 'active_support/notifications'
|
8
|
-
|
9
|
-
require 'set'
|
10
|
-
require 'uri'
|
11
|
-
require 'hashie/mash'
|
12
|
-
|
13
|
-
require 'logger'
|
14
|
-
require 'uuidtools'
|
15
|
-
require 'rubygems/package'
|
16
|
-
require 'zlib'
|
17
|
-
require 'tempfile'
|
18
|
-
require 'settingslogic'
|
19
|
-
|
20
|
-
require 'occi/extensions/hashie'
|
21
|
-
|
22
|
-
require 'occi/helpers/inspect'
|
23
|
-
require 'occi/helpers/comparators'
|
24
|
-
|
25
|
-
require 'occi/errors'
|
26
|
-
require 'occi/settings'
|
27
|
-
require 'occi/log'
|
28
|
-
require 'occi/version'
|
29
|
-
require 'occi/core'
|
30
|
-
require 'occi/infrastructure'
|
31
|
-
require 'occi/collection'
|
32
|
-
require 'occi/parser'
|
33
|
-
require 'occi/model'
|
34
|
-
|
35
|
-
module Occi
|
36
|
-
|
37
|
-
def kinds
|
38
|
-
Occi::Core::Kinds.new
|
39
|
-
end
|
40
|
-
|
41
|
-
def mixins
|
42
|
-
Occi::Core::Mixins.new
|
43
|
-
end
|
44
|
-
|
45
|
-
def actions
|
46
|
-
Occi::Core::Actions.new
|
47
|
-
end
|
48
|
-
|
49
|
-
# @return [Array] list of Occi::Core::Categories
|
50
|
-
def categories
|
51
|
-
self.kinds + self.mixins + self.actions
|
52
|
-
end
|
53
|
-
end
|
data/spec/helpers/to_plain.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'psych'
|
2
|
-
|
3
|
-
class ToPlain < Psych::Visitors::Visitor
|
4
|
-
|
5
|
-
# Scalars are just strings.
|
6
|
-
def visit_Psych_Nodes_Scalar o
|
7
|
-
o.value
|
8
|
-
end
|
9
|
-
|
10
|
-
# Sequences are arrays.
|
11
|
-
def visit_Psych_Nodes_Sequence o
|
12
|
-
o.children.each_with_object([]) do |child, list|
|
13
|
-
list << accept(child)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
# Mappings are hashes.
|
18
|
-
def visit_Psych_Nodes_Mapping o
|
19
|
-
o.children.each_slice(2).each_with_object({}) do |(k,v), h|
|
20
|
-
h[accept(k)] = accept(v)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# We also need to handle documents...
|
25
|
-
def visit_Psych_Nodes_Document o
|
26
|
-
accept o.root
|
27
|
-
end
|
28
|
-
|
29
|
-
# ... and streams.
|
30
|
-
def visit_Psych_Nodes_Stream o
|
31
|
-
o.children.map { |c| accept c }
|
32
|
-
end
|
33
|
-
|
34
|
-
# Aliases aren't handles here :-(
|
35
|
-
def visit_Psych_Nodes_Alias o
|
36
|
-
# Not implemented!
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
data/spec/helpers/yaml_hash.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'hashie'
|
2
|
-
|
3
|
-
class YAMLHash < Hashie::Mash
|
4
|
-
|
5
|
-
def load_file fs
|
6
|
-
f = File.open(fs, "rt")
|
7
|
-
self.load f.read
|
8
|
-
f.close
|
9
|
-
end
|
10
|
-
|
11
|
-
def load s
|
12
|
-
lin = s.lines
|
13
|
-
stack = Array.new
|
14
|
-
while (true) do
|
15
|
-
begin
|
16
|
-
line = lin.next
|
17
|
-
rescue
|
18
|
-
break
|
19
|
-
end
|
20
|
-
|
21
|
-
next if /^---/.match(line)
|
22
|
-
|
23
|
-
currentDepth = line.scan(/^\s*/).first.length / 2
|
24
|
-
while (currentDepth) < stack.length
|
25
|
-
stack.pop
|
26
|
-
end
|
27
|
-
|
28
|
-
stack.push(line.lstrip.chomp.gsub(/\s*$/, "").gsub(/[\*\&]\d+/, "Ptr-Emptied").gsub(/[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}/, "ID-Emptied").gsub(/ ! /, " "))
|
29
|
-
self[stack] = nil
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
{"kinds":[{"parent":"http://schemas.ogf.org/occi/core#resource","related":["http://schemas.ogf.org/occi/core#resource"],"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"],"location":"/compute/","scheme":"http://schemas.ogf.org/occi/infrastructure#","term":"compute","title":"compute resource","attributes":{"occi":{"core":{"id":{"type":"string","pattern":"[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"},"title":{"type":"string","mutable":true,"pattern":".*"},"summary":{"type":"string","mutable":true,"pattern":".*"}},"compute":{"architecture":{"type":"string","mutable":true,"pattern":"x86|x64"},"cores":{"type":"number","mutable":true,"pattern":".*"},"hostname":{"type":"string","mutable":true,"pattern":"(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*"},"memory":{"type":"number","mutable":true,"pattern":".*"},"speed":{"type":"number","mutable":true,"pattern":".*"},"state":{"type":"string","pattern":"inactive|active|suspended|error"}}}}}],"mixins":[{"location":"/mixins/my_mixin/","scheme":"http://example.com/occi/tags#","term":"my_mixin","attributes":{}}],"actions":[{"scheme":"http://schemas.ogf.org/occi/infrastructure/compute/action#","term":"start","attributes":{}}],"resources":[{"kind":"http://schemas.ogf.org/occi/core#resource","attributes":{"occi":{"core":{"id":"d51cc509-e1b7-4796-98a4-ccae05964ea8"}}},"id":"d51cc509-e1b7-4796-98a4-ccae05964ea8"}],"links":[{"kind":"http://schemas.ogf.org/occi/core#link","attributes":{"occi":{"core":{"id":"35e6f510-4617-465d-9f92-e1079b78f420"}}},"id":"35e6f510-4617-465d-9f92-e1079b78f420","rel":"http://schemas.ogf.org/occi/core#link"}],"action":{"action":"http://schemas.ogf.org/occi/core#action_instance"}}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"kinds":[{"parent":"http://schemas.ogf.org/occi/core#resource","related":["http://schemas.ogf.org/occi/core#resource"],"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"],"location":"/storage/","scheme":"http://schemas.ogf.org/occi/infrastructure#","term":"storage","title":"storage resource","attributes":{"occi":{"core":{"id":{"type":"string","pattern":"[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"},"title":{"type":"string","mutable":true,"pattern":".*"},"summary":{"type":"string","mutable":true,"pattern":".*"}},"storage":{"size":{"type":"number","mutable":true,"pattern":".*"},"state":{"type":"string","pattern":"online|offline|backup|snapshot|resize|degraded"}}}}}],"mixins":[{"location":"/mixins/another_mixin/","scheme":"http://example.com/occi/tags#","term":"another_mixin","attributes":{}}],"actions":[{"scheme":"http://schemas.ogf.org/occi/infrastructure/compute/action#","term":"stop","attributes":{}}],"resources":[{"kind":"http://schemas.ogf.org/occi/core#resource","attributes":{"occi":{"core":{"id":"556ed1b1-183d-4ece-8649-a2d1a0825cde"}}},"id":"556ed1b1-183d-4ece-8649-a2d1a0825cde"}],"links":[{"kind":"http://schemas.ogf.org/occi/core#link","attributes":{"occi":{"core":{"id":"3dbfbd1e-5fcd-4ad2-98a3-fd167838431d"}}},"id":"3dbfbd1e-5fcd-4ad2-98a3-fd167838431d","rel":"http://schemas.ogf.org/occi/core#link"}],"action":{"action":"http://schemas.ogf.org/occi/core/entity/action#testaction","attributes":{}}}
|