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
@@ -1,317 +0,0 @@
|
|
1
|
-
module Occi
|
2
|
-
module Core
|
3
|
-
describe ActionInstance do
|
4
|
-
|
5
|
-
let(:ai){ Occi::Core::ActionInstance.new }
|
6
|
-
let(:action){ Occi::Core::Action.new }
|
7
|
-
|
8
|
-
let(:attributes){ Occi::Core::Attributes.new }
|
9
|
-
let(:attributes_one){
|
10
|
-
attrs = Occi::Core::Attributes.new
|
11
|
-
attrs["occi.core.title"] = "test"
|
12
|
-
|
13
|
-
attrs
|
14
|
-
}
|
15
|
-
let(:attributes_wnil){
|
16
|
-
attrs = Occi::Core::Attributes.new
|
17
|
-
attrs["occi.core.title"] = nil
|
18
|
-
|
19
|
-
attrs
|
20
|
-
}
|
21
|
-
let(:attributes_multi){
|
22
|
-
attrs = Occi::Core::Attributes.new
|
23
|
-
attrs["occi.core.title"] = "test"
|
24
|
-
attrs["occi.core.id"] = "1"
|
25
|
-
attrs["org.opennebula.network.id"] = 1
|
26
|
-
|
27
|
-
attrs
|
28
|
-
}
|
29
|
-
let(:attributes_unconvertable){ { "not" => "convertable" } }
|
30
|
-
|
31
|
-
let(:action_string){ 'http://rspec.rocci.cesnet.cz/occi/core#action' }
|
32
|
-
let(:action_string_invalid){ 'http://rspec.rocci.cesnet.cz/occi/core_action' }
|
33
|
-
|
34
|
-
context '#new' do
|
35
|
-
it 'with defaults' do
|
36
|
-
expect { ai }.not_to raise_error
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'fails without an action' do
|
40
|
-
expect { Occi::Core::ActionInstance.new nil }.to raise_error(ArgumentError)
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'does not fail without attributes' do
|
44
|
-
expect { Occi::Core::ActionInstance.new action, nil }.not_to raise_error
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'does not fail with an Occi::Core::Action instance' do
|
48
|
-
expect { Occi::Core::ActionInstance.new action }.not_to raise_error
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'does not fail with a valid action type identifier' do
|
52
|
-
expect { Occi::Core::ActionInstance.new action_string }.not_to raise_error
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'fails with an invalid action type identifier' do
|
56
|
-
expect { Occi::Core::ActionInstance.new action_string_invalid }.to raise_error(ArgumentError)
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'does not fail with an Occi::Core::Attributes instance' do
|
60
|
-
expect { Occi::Core::ActionInstance.new action, attributes }.not_to raise_error
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'does not fail with un-convertable attribute values' do
|
64
|
-
expect { Occi::Core::ActionInstance.new action, attributes_unconvertable}.not_to raise_error
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
context '#action' do
|
69
|
-
it 'exposes associated action as Occi::Core::Action' do
|
70
|
-
expect(ai.action).to be_a(Occi::Core::Action)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
context '#attributes' do
|
75
|
-
it 'exposes associated attributes as Occi::Core::Attributes' do
|
76
|
-
expect(ai.attributes).to be_a(Occi::Core::Attributes)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
context '#model' do
|
81
|
-
# TODO: should ActionInstance have an associated model?
|
82
|
-
it 'exposes associated model as Occi::Model (??)' #do
|
83
|
-
#expect(ai.model).to be_a(Occi::Model)
|
84
|
-
#end
|
85
|
-
end
|
86
|
-
|
87
|
-
context '#to_text' do
|
88
|
-
it 'renders default to text' do
|
89
|
-
expected = "Category: action_instance;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"action\""
|
90
|
-
expect(ai.to_text).to eq(expected)
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'renders to text w/ an attribute' do
|
94
|
-
expected = %Q|Category: action;scheme="http://schemas.ogf.org/occi/core#";class="action"
|
95
|
-
X-OCCI-Attribute: occi.core.title="test"|
|
96
|
-
expect(Occi::Core::ActionInstance.new(action, attributes_one.to_hash).to_text).to eq(expected)
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'renders to text w/ attributes' do
|
100
|
-
expected = %Q|Category: action;scheme="http://schemas.ogf.org/occi/core#";class="action"
|
101
|
-
X-OCCI-Attribute: occi.core.title="test"
|
102
|
-
X-OCCI-Attribute: occi.core.id="1"
|
103
|
-
X-OCCI-Attribute: org.opennebula.network.id=1|
|
104
|
-
expect(Occi::Core::ActionInstance.new(action, attributes_multi.to_hash).to_text).to eq(expected)
|
105
|
-
end
|
106
|
-
|
107
|
-
it 'renders to text w/ a nil attribute' do
|
108
|
-
expected = "Category: action;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"action\""
|
109
|
-
expect(Occi::Core::ActionInstance.new(action, attributes_wnil.to_hash).to_text).to eq(expected)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
context '#to_header' do
|
114
|
-
it 'renders default to hash' do
|
115
|
-
expected = {"Category" => "action_instance;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"action\""}
|
116
|
-
expect(ai.to_header).to eq(expected)
|
117
|
-
end
|
118
|
-
|
119
|
-
it 'renders to hash w/ an attribute' do
|
120
|
-
expected = {
|
121
|
-
"Category" => "action;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"action\"",
|
122
|
-
"X-OCCI-Attribute" => "occi.core.title=\"test\""
|
123
|
-
}
|
124
|
-
expect(Occi::Core::ActionInstance.new(action, attributes_one.to_hash).to_header).to eq(expected)
|
125
|
-
end
|
126
|
-
|
127
|
-
it 'renders to hash w/ attributes' do
|
128
|
-
expected = {
|
129
|
-
"Category" => "action;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"action\"",
|
130
|
-
"X-OCCI-Attribute" => "occi.core.title=\"test\",occi.core.id=\"1\",org.opennebula.network.id=1"
|
131
|
-
}
|
132
|
-
expect(Occi::Core::ActionInstance.new(action, attributes_multi.to_hash).to_header).to eq(expected)
|
133
|
-
end
|
134
|
-
|
135
|
-
it 'renders to hash w/ a nil attribute' do
|
136
|
-
expected = {"Category" => "action;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"action\""}
|
137
|
-
expect(Occi::Core::ActionInstance.new(action, attributes_wnil.to_hash).to_header).to eq(expected)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
context '#to_json' do
|
142
|
-
let(:actioninstance){ Occi::Core::ActionInstance.new }
|
143
|
-
it 'renders default to JSON' do
|
144
|
-
expected = '{"action":"http://schemas.ogf.org/occi/core#action_instance","attributes":{}}'
|
145
|
-
expect(actioninstance.to_json).to eql expected
|
146
|
-
end
|
147
|
-
|
148
|
-
it 'renders to JSON w/ an attribute' do
|
149
|
-
actioninstance.attributes.testattr = 'test'
|
150
|
-
expected = '{"action":"http://schemas.ogf.org/occi/core#action_instance","attributes":{"testattr":"test"}}'
|
151
|
-
expect(actioninstance.to_json).to eql expected
|
152
|
-
end
|
153
|
-
|
154
|
-
it 'renders to JSON w/ multiple attributes' do
|
155
|
-
actioninstance.attributes.testattr = 'test'
|
156
|
-
actioninstance.attributes.anotherattr = 42
|
157
|
-
expected = '{"action":"http://schemas.ogf.org/occi/core#action_instance","attributes":{"testattr":"test","anotherattr":42}}'
|
158
|
-
expect(actioninstance.to_json).to eql expected
|
159
|
-
end
|
160
|
-
|
161
|
-
it 'renders to JSON w/ a nil attribute' do
|
162
|
-
actioninstance.attributes.testattr = nil
|
163
|
-
expected = '{"action":"http://schemas.ogf.org/occi/core#action_instance","attributes":{}}'
|
164
|
-
expect(actioninstance.to_json).to eql expected
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
context '#as_json' do
|
169
|
-
it 'renders default to Hashie::Mash' do
|
170
|
-
expected = Hashie::Mash.new({"action" => "http://schemas.ogf.org/occi/core#action_instance", "attributes" => {}})
|
171
|
-
expect(ai.as_json).to eq(expected)
|
172
|
-
end
|
173
|
-
|
174
|
-
it 'renders to Hashie::Mash w/ an attribute' do
|
175
|
-
expected = Hashie::Mash.new
|
176
|
-
expected.action = "http://schemas.ogf.org/occi/core#action"
|
177
|
-
expected.attributes = {"occi" => {"core" => {"title" => "test"}}}
|
178
|
-
|
179
|
-
expect(Occi::Core::ActionInstance.new(action, attributes_one.to_hash).as_json).to eq(expected)
|
180
|
-
end
|
181
|
-
|
182
|
-
it 'renders to Hashie::Mash w/ attributes' do
|
183
|
-
expected = Hashie::Mash.new
|
184
|
-
expected.action = "http://schemas.ogf.org/occi/core#action"
|
185
|
-
expected.attributes = {
|
186
|
-
"occi" => {"core" => {"title" => "test", "id" => "1"}},
|
187
|
-
"org" => {"opennebula" => {"network" => {"id" => 1}}}
|
188
|
-
}
|
189
|
-
|
190
|
-
expect(Occi::Core::ActionInstance.new(action, attributes_multi.to_hash).as_json).to eq(expected)
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
context '#==' do
|
195
|
-
|
196
|
-
it 'matches the same instance' do
|
197
|
-
expect(ai).to eq ai
|
198
|
-
end
|
199
|
-
|
200
|
-
it 'matches a clone' do
|
201
|
-
expect(ai).to eq ai.clone
|
202
|
-
end
|
203
|
-
|
204
|
-
it 'does not match with a different action' do
|
205
|
-
changed = ai.clone
|
206
|
-
changed.action = Occi::Core::Action.new(action_string)
|
207
|
-
|
208
|
-
expect(ai).not_to eq changed
|
209
|
-
end
|
210
|
-
|
211
|
-
it 'does not match with different attributes' do
|
212
|
-
changed = ai.clone
|
213
|
-
changed.attributes = attributes_one
|
214
|
-
|
215
|
-
expect(ai).not_to eq changed
|
216
|
-
end
|
217
|
-
|
218
|
-
it 'does not match a nil' do
|
219
|
-
expect(ai).not_to eq nil
|
220
|
-
end
|
221
|
-
|
222
|
-
end
|
223
|
-
|
224
|
-
context '#eql?' do
|
225
|
-
|
226
|
-
it 'matches the same instance' do
|
227
|
-
expect(ai).to eql ai
|
228
|
-
end
|
229
|
-
|
230
|
-
it 'matches a clone' do
|
231
|
-
expect(ai).to eql ai.clone
|
232
|
-
end
|
233
|
-
|
234
|
-
it 'does not match with a different action' do
|
235
|
-
changed = ai.clone
|
236
|
-
changed.action = Occi::Core::Action.new(action_string)
|
237
|
-
|
238
|
-
expect(ai).not_to eql changed
|
239
|
-
end
|
240
|
-
|
241
|
-
it 'does not match with different attributes' do
|
242
|
-
changed = ai.clone
|
243
|
-
changed.attributes = attributes_one
|
244
|
-
|
245
|
-
expect(ai).not_to eql changed
|
246
|
-
end
|
247
|
-
|
248
|
-
it 'does not match a nil' do
|
249
|
-
expect(ai).not_to eql nil
|
250
|
-
end
|
251
|
-
|
252
|
-
end
|
253
|
-
|
254
|
-
context '#equal?' do
|
255
|
-
|
256
|
-
it 'matches the same instance' do
|
257
|
-
expect(ai).to equal ai
|
258
|
-
end
|
259
|
-
|
260
|
-
it 'does not match clones' do
|
261
|
-
expect(ai).not_to equal ai.clone
|
262
|
-
end
|
263
|
-
|
264
|
-
end
|
265
|
-
|
266
|
-
context '#hash' do
|
267
|
-
|
268
|
-
it 'matches for clones' do
|
269
|
-
expect(ai.hash).to eq ai.clone.hash
|
270
|
-
end
|
271
|
-
|
272
|
-
it 'matches for the same instance' do
|
273
|
-
expect(ai.hash).to eq ai.hash
|
274
|
-
end
|
275
|
-
|
276
|
-
it 'does not match when action is different' do
|
277
|
-
ai_changed = ai.clone
|
278
|
-
ai_changed.action = Occi::Core::Action.new action_string
|
279
|
-
|
280
|
-
expect(ai.hash).not_to eq ai_changed.hash
|
281
|
-
end
|
282
|
-
|
283
|
-
it 'does not match when attributes are different' do
|
284
|
-
ai_changed = ai.clone
|
285
|
-
ai_changed.attributes = attributes_one
|
286
|
-
|
287
|
-
expect(ai.hash).not_to eq ai_changed.hash
|
288
|
-
end
|
289
|
-
|
290
|
-
end
|
291
|
-
|
292
|
-
context '#empty?' do
|
293
|
-
|
294
|
-
it 'returns false for a new instance with defaults' do
|
295
|
-
expect(ai.empty?).to be false
|
296
|
-
end
|
297
|
-
|
298
|
-
it 'returns true for an instance without an action' do
|
299
|
-
ai_changed = ai.clone
|
300
|
-
ai_changed.action = nil
|
301
|
-
|
302
|
-
expect(ai_changed.empty?).to be true
|
303
|
-
end
|
304
|
-
|
305
|
-
it 'returns true for an instance with an empty action' do
|
306
|
-
ai_changed = ai.clone
|
307
|
-
ai_changed.action = Occi::Core::Action.new
|
308
|
-
ai_changed.action.term = nil
|
309
|
-
|
310
|
-
expect(ai_changed.empty?).to be true
|
311
|
-
end
|
312
|
-
|
313
|
-
end
|
314
|
-
|
315
|
-
end
|
316
|
-
end
|
317
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
module Occi
|
2
|
-
module Core
|
3
|
-
describe Action do
|
4
|
-
let(:action){ Occi::Core::Action.new scheme='http://schemas.ogf.org/occi/core/entity/action#', term='testaction', title='testaction action' }
|
5
|
-
|
6
|
-
it 'can be instantiated' do
|
7
|
-
expect(action).to be_an_instance_of(Occi::Core::Action)
|
8
|
-
end
|
9
|
-
|
10
|
-
context '#term' do
|
11
|
-
it 'has correct term' do
|
12
|
-
expect(action.term).to eql 'testaction'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context '#title' do
|
17
|
-
it 'has correct title' do
|
18
|
-
expect(action.title).to eql 'testaction action'
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context '#scheme' do
|
23
|
-
it 'has correct scheme' do
|
24
|
-
expect(action.scheme).to eql 'http://schemas.ogf.org/occi/core/entity/action#'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context '#to_text' do
|
29
|
-
it 'renders text correctly' do
|
30
|
-
action.attributes = Occi::Core::Attributes.new
|
31
|
-
action.attributes['numbertype'] = { :type => 'number',
|
32
|
-
:default => 42,
|
33
|
-
:mutable => true }
|
34
|
-
action.attributes['stringtype'] = { :type => 'string',
|
35
|
-
:pattern => '[adefltuv]+',
|
36
|
-
:default => 'defaultvalue',
|
37
|
-
:mutable => true }
|
38
|
-
action.attributes['booleantype'] = { :type => 'boolean',
|
39
|
-
:default => true,
|
40
|
-
:mutable => true }
|
41
|
-
|
42
|
-
expected = 'Category: testaction;scheme="http://schemas.ogf.org/occi/core/entity/action#";class="action";title="testaction action";attributes="numbertype stringtype booleantype"'
|
43
|
-
|
44
|
-
expect(action.to_text).to eql expected
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context '#to_header' do
|
49
|
-
it 'renders text correctly' do
|
50
|
-
action.attributes = Occi::Core::Attributes.new
|
51
|
-
action.attributes['numbertype'] = { :type => 'number',
|
52
|
-
:default => 42,
|
53
|
-
:mutable => true }
|
54
|
-
action.attributes['stringtype'] = { :type => 'string',
|
55
|
-
:pattern => '[adefltuv]+',
|
56
|
-
:default => 'defaultvalue',
|
57
|
-
:mutable => true }
|
58
|
-
action.attributes['booleantype'] = { :type => 'boolean',
|
59
|
-
:default => true,
|
60
|
-
:mutable => true }
|
61
|
-
|
62
|
-
expected = {:Category => "testaction;scheme=\"http://schemas.ogf.org/occi/core/entity/action#\";class=\"action\";title=\"testaction action\";attributes=\"numbertype stringtype booleantype\""}
|
63
|
-
expect(action.to_header).to eql expected
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|