You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by mf...@apache.org on 2013/04/30 16:41:23 UTC
[1/3] git commit: CIMI - Add support for $expand on cloudEntryPoint
Addresses Jira DTACLOUD-502
Updated Branches:
refs/heads/master 7feb3a0f3 -> aa9a232aa
CIMI - Add support for $expand on cloudEntryPoint
Addresses Jira DTACLOUD-502
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/223aed09
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/223aed09
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/223aed09
Branch: refs/heads/master
Commit: 223aed091f0f6907e40161cb2d6a70f41b182b45
Parents: 7feb3a0
Author: Joe VLcek <jv...@redhat.com>
Authored: Tue Apr 23 18:44:56 2013 -0400
Committer: Michal fojtik <mf...@redhat.com>
Committed: Tue Apr 30 16:40:24 2013 +0200
----------------------------------------------------------------------
server/lib/cimi/collections/cloud_entry_point.rb | 2 +-
server/lib/cimi/models.rb | 1 +
server/lib/cimi/models/cloud_entry_point.rb | 26 +-----
.../cimi/models/cloud_entry_point_collections.rb | 58 ++++++++++++
server/lib/cimi/service/cloud_entry_point.rb | 69 ++++++++++++---
5 files changed, 121 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/223aed09/server/lib/cimi/collections/cloud_entry_point.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/cloud_entry_point.rb b/server/lib/cimi/collections/cloud_entry_point.rb
index 37b47b2..ede248e 100644
--- a/server/lib/cimi/collections/cloud_entry_point.rb
+++ b/server/lib/cimi/collections/cloud_entry_point.rb
@@ -28,7 +28,7 @@ module CIMI::Collections
if params[:force_auth]
halt 401 unless driver.valid_credentials?(credentials)
end
- entry_point = CIMI::Service::CloudEntryPoint.create(self)
+ entry_point = CIMI::Service::CloudEntryPoint.new(self)
respond_to do |format|
format.xml { entry_point.to_xml }
format.json { entry_point.to_json }
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/223aed09/server/lib/cimi/models.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models.rb b/server/lib/cimi/models.rb
index 99b3545..96a91f5 100644
--- a/server/lib/cimi/models.rb
+++ b/server/lib/cimi/models.rb
@@ -93,3 +93,4 @@ require_relative './models/system_credential'
require_relative './models/system_system'
require_relative './models/system'
require_relative './models/system_create'
+require_relative './models/cloud_entry_point_collections'
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/223aed09/server/lib/cimi/models/cloud_entry_point.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/cloud_entry_point.rb b/server/lib/cimi/models/cloud_entry_point.rb
index adadb62..dacb1ca 100644
--- a/server/lib/cimi/models/cloud_entry_point.rb
+++ b/server/lib/cimi/models/cloud_entry_point.rb
@@ -13,32 +13,14 @@
# License for the specific language governing permissions and limitations
# under the License.
-class CIMI::Model::CloudEntryPoint < CIMI::Model::Base
-
- text :driver
- text :provider
-
- # All possible CIMI collections, in the order in which they should appear
- # in the CEP
- COLLECTIONS = [ "resourceMetadata", "systems", "systemTemplates",
- "machines" , "machineTemplates", "machineConfigs",
- "machineImages", "credentials", "credentialTemplates",
- "volumes", "volumeTemplates", "volumeConfigs", "volumeImages",
- "networks", "networkTemplates", "networkConfigs", "networkPorts",
- "networkPortTemplates", "networkPortConfigs",
- "addresses", "addressTemplates", "forwardingGroups",
- "forwardingGroupTemplates",
- "jobs", "meters", "meterTemplates", "meterConfigs",
- "eventLogs", "eventLogTemplates" ]
- text :base_uri, :xml_name => "baseURI", :json_name => "baseURI"
+class CIMI::Model::CloudEntryPoint < CIMI::Model::Base
- COLLECTIONS.each do |coll|
- href coll.underscore
- end
+ text :driver, :required => true
+ text :provider, :required => true
+ text :base_uri, :xml_name => "baseURI", :json_name => "baseURI"
private
-
def self.href_defined?(resource)
true if schema.attribute_names.include? resource.underscore
end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/223aed09/server/lib/cimi/models/cloud_entry_point_collections.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/cloud_entry_point_collections.rb b/server/lib/cimi/models/cloud_entry_point_collections.rb
new file mode 100644
index 0000000..c518e48
--- /dev/null
+++ b/server/lib/cimi/models/cloud_entry_point_collections.rb
@@ -0,0 +1,58 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership. The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+
+class CIMI::Model::CloudEntryPoint < CIMI::Model::Base
+
+ # All possible CIMI collections, in the order in which they should appear
+ # in the CEP
+ COLLECTIONS = {
+ "resourceMetadata" => CIMI::Model::ResourceMetadata,
+ "systems" => CIMI::Model::System,
+ "systemTemplates" => CIMI::Model::SystemTemplate,
+ "machines" => CIMI::Model::Machine,
+ "machineTemplates" => CIMI::Model::MachineTemplate,
+ "machineConfigurations" => CIMI::Model::MachineConfiguration,
+ "machineImages" => CIMI::Model::MachineImage,
+ "credentials" => CIMI::Model::Credential,
+ "credentialTemplates" => CIMI::Model::CredentialTemplate,
+ "volumes" => CIMI::Model::Volume,
+ "volumeTemplates" => CIMI::Model::VolumeTemplate,
+ "volumeConfigurations" => CIMI::Model::VolumeConfiguration,
+ "volumeImages" => CIMI::Model::VolumeImage,
+ "networks" => CIMI::Model::Network,
+ "networkTemplates" => CIMI::Model::NetworkTemplate,
+ "networkConfigurations" => CIMI::Model::NetworkConfiguration,
+ "networkPorts" => CIMI::Model::NetworkPort,
+ "networkPortTemplates" => CIMI::Model::NetworkTemplate,
+ "networkPortConfigurations" => CIMI::Model::NetworkPortConfiguration,
+ "addresses" => CIMI::Model::Address,
+ "addressTemplates" => CIMI::Model::AddressTemplate,
+ "forwardingGroups" => CIMI::Model::ForwardingGroup,
+ "forwardingGroupTemplates" => CIMI::Model::ForwardingGroupTemplate,
+ "jobs" => nil,
+ "meters" => nil,
+ "meterTemplates" => nil,
+ "meterConfigs" => nil,
+ "eventLogs" => nil,
+ "eventLogTemplates" => nil
+ }
+
+ COLLECTIONS.each do |coll|
+ coll_entry = coll
+ collection coll_entry[0].underscore.to_sym, :class => coll_entry[1] unless coll_entry[1] == nil
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/223aed09/server/lib/cimi/service/cloud_entry_point.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/service/cloud_entry_point.rb b/server/lib/cimi/service/cloud_entry_point.rb
index a61eec7..900581d 100644
--- a/server/lib/cimi/service/cloud_entry_point.rb
+++ b/server/lib/cimi/service/cloud_entry_point.rb
@@ -13,13 +13,47 @@
# License for the specific language governing permissions and limitations
# under the License.
+# JoeV - If I don't include these here the associated CIMI::Service::<x>
+# JoeV class referenced below is undefined even though these are specified
+# JoeV in service.rb.
+require_relative './resource_metadata'
+require_relative './credential'
+require_relative './network_template'
+require_relative './network_port_template'
+require_relative './address'
+require_relative './address_template'
+
class CIMI::Service::CloudEntryPoint < CIMI::Service::Base
metadata :driver, :type => 'text'
metadata :provider, :type => 'text'
- def self.create(context)
- self.new(context, :values => entities(context).merge({
+ SERVICES = {
+ "resource_metadata" => CIMI::Service::ResourceMetadata,
+ "systems" => CIMI::Service::System,
+ "system_templates" => CIMI::Service::SystemTemplate,
+ "machines" => CIMI::Service::Machine,
+ "machine_templates" => CIMI::Service::MachineTemplate,
+ "machine_configurations" => CIMI::Service::MachineConfiguration,
+ "machine_images" => CIMI::Service::MachineImage,
+ "credentials" => CIMI::Service::Credential,
+ "volumes" => CIMI::Service::Volume,
+ "volume_templates" => CIMI::Service::VolumeTemplate,
+ "volume_configurations" => CIMI::Service::VolumeConfiguration,
+ "volume_images" => CIMI::Service::VolumeImage,
+ "networks" => CIMI::Service::Network,
+ "network_templates" => CIMI::Service::NetworkTemplate,
+ "network_configurations" => CIMI::Service::NetworkPortConfiguration,
+ "network_port_template" => CIMI::Service::NetworkPortTemplate,
+ "network_port_configurations" => CIMI::Service::NetworkPortConfiguration,
+ "addresses" => CIMI::Service::Address,
+ "address_templates" => CIMI::Service::AddressTemplate,
+ "forwarding_groups" => CIMI::Service::ForwardingGroup,
+ "forwarding_group_templates" => CIMI::Service::ForwardingGroupTemplate
+ }
+
+ def initialize(context)
+ super(context, :values => {
:name => context.driver.name,
:description => "Cloud Entry Point for the Deltacloud #{context.driver.name} driver",
:driver => context.driver.name,
@@ -27,27 +61,38 @@ class CIMI::Service::CloudEntryPoint < CIMI::Service::Base
:id => context.cloudEntryPoint_url,
:base_uri => context.base_uri + "/",
:created => Time.now.xmlschema
- }))
+ })
+ fill_entities context
end
- # Return an Hash of the CIMI root entities used in CloudEntryPoint
- def self.entities(context)
+ private
+ def fill_entities(context)
CIMI::Collections.modules(:cimi).inject({}) do |supported_entities, m|
m.collections.each do |c|
if c.operation(:index).nil?
warn "#{c} does not have :index operation."
next
end
+ if c.collection_name == :cloudEntryPoint
+ warn "#{c} is cloudEntryPoint"
+ next
+ end
+
index_operation_capability = c.operation(:index).required_capability
- next if m.settings.respond_to?(:capability) and !m.settings.capability(index_operation_capability)
- supported_entities[c.collection_name.to_s] = { :href => context.send(:"#{c.collection_name}_url") }
+ next if m.settings.respond_to?(:capability) and \
+ !m.settings.capability(index_operation_capability)
+
+ coll = self[c.collection_name]
+ coll.href = context.send(:"#{c.collection_name.to_s}_url")
+
+ if context.expand? c.collection_name.to_s.camelize(:lower).to_sym
+ coll[c.collection_name] = \
+ SERVICES[c.collection_name.to_s].find(:all, context)
+ end
+
end
- supported_entities
end
end
- def entities
- @attribute_values.clone.delete_if { |key, value| !value.respond_to? :href }
- end
-
end
+
[3/3] git commit: CIMI - Remove credentialTemplates from CEP
COLLECTIONS. Use ruby style hash iteration on CEP COLLECTIONS. Fix typos
uncovered during testing.
Posted by mf...@apache.org.
CIMI - Remove credentialTemplates from CEP COLLECTIONS.
Use ruby style hash iteration on CEP COLLECTIONS.
Fix typos uncovered during testing.
These changes address review feedback from Michal Fojtik.
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/aa9a232a
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/aa9a232a
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/aa9a232a
Branch: refs/heads/master
Commit: aa9a232aa965ac53b08e44a7051e30810419be97
Parents: 959cc62
Author: Joe VLcek <jv...@redhat.com>
Authored: Mon Apr 29 14:27:53 2013 -0400
Committer: Michal fojtik <mf...@redhat.com>
Committed: Tue Apr 30 16:40:26 2013 +0200
----------------------------------------------------------------------
.../cimi/models/cloud_entry_point_collections.rb | 8 +++-----
server/lib/cimi/service.rb | 4 ++--
2 files changed, 5 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/aa9a232a/server/lib/cimi/models/cloud_entry_point_collections.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/cloud_entry_point_collections.rb b/server/lib/cimi/models/cloud_entry_point_collections.rb
index 00b3512..6cf4866 100644
--- a/server/lib/cimi/models/cloud_entry_point_collections.rb
+++ b/server/lib/cimi/models/cloud_entry_point_collections.rb
@@ -26,14 +26,13 @@ class CIMI::Model::CloudEntryPoint < CIMI::Model::Base
"machineTemplates" => CIMI::Model::MachineTemplate,
"machineImages" => CIMI::Model::MachineImage,
"credentials" => CIMI::Model::Credential,
- "credentialTemplates" => CIMI::Model::CredentialTemplate,
"volumes" => CIMI::Model::Volume,
"volumeTemplates" => CIMI::Model::VolumeTemplate,
"volumeImages" => CIMI::Model::VolumeImage,
"networks" => CIMI::Model::Network,
"networkTemplates" => CIMI::Model::NetworkTemplate,
"networkPorts" => CIMI::Model::NetworkPort,
- "networkPortTemplates" => CIMI::Model::NetworkTemplate,
+ "networkPortTemplates" => CIMI::Model::NetworkPortTemplate,
"addresses" => CIMI::Model::Address,
"addressTemplates" => CIMI::Model::AddressTemplate,
"forwardingGroups" => CIMI::Model::ForwardingGroup,
@@ -50,9 +49,8 @@ class CIMI::Model::CloudEntryPoint < CIMI::Model::Base
"eventLogTemplates" => nil
}
- COLLECTIONS.each do |coll|
- coll_entry = coll
- collection coll_entry[0].underscore.to_sym, :class => coll_entry[1] unless coll_entry[1] == nil
+ COLLECTIONS.each do |name, klass|
+ collection name.underscore.to_sym, :class => klass unless klass == nil
end
end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/aa9a232a/server/lib/cimi/service.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/service.rb b/server/lib/cimi/service.rb
index a8b64f5..c3473f5 100644
--- a/server/lib/cimi/service.rb
+++ b/server/lib/cimi/service.rb
@@ -96,8 +96,8 @@ SERVICES = {
"networks" => CIMI::Service::Network,
"network_templates" => CIMI::Service::NetworkTemplate,
"network_configurations" => CIMI::Service::NetworkConfiguration,
- "network_port" => CIMI::Service::NetworkPort,
- "network_port_template" => CIMI::Service::NetworkPortTemplate,
+ "network_ports" => CIMI::Service::NetworkPort,
+ "network_port_templates" => CIMI::Service::NetworkPortTemplate,
"network_port_configurations" => CIMI::Service::NetworkPortConfiguration,
"addresses" => CIMI::Service::Address,
"address_templates" => CIMI::Service::AddressTemplate,
[2/3] git commit: Changes needed to adapt to using a hash to contain
all root entry point,
vs the acts_as_root_entity method. Refactor service/cloud_entry_point.rb based
on input from Michal Fojtik. Huge Thanks! Michal Fojtik!
Posted by mf...@apache.org.
Changes needed to adapt to using a hash to contain all root entry
point, vs the acts_as_root_entity method.
Refactor service/cloud_entry_point.rb based on input from Michal Fojtik.
Huge Thanks! Michal Fojtik!
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/959cc621
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/959cc621
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/959cc621
Branch: refs/heads/master
Commit: 959cc6219f9cc7d1cd54f6597288144eeb56d181
Parents: 223aed0
Author: Joe VLcek <jv...@redhat.com>
Authored: Sat Apr 27 13:15:53 2013 -0400
Committer: Michal fojtik <mf...@redhat.com>
Committed: Tue Apr 30 16:40:26 2013 +0200
----------------------------------------------------------------------
server/lib/cimi/models.rb | 24 ----
server/lib/cimi/models/address.rb | 2 -
server/lib/cimi/models/address_template.rb | 2 -
.../cimi/models/cloud_entry_point_collections.rb | 8 +-
server/lib/cimi/models/collection.rb | 9 +-
server/lib/cimi/models/credential.rb | 2 -
server/lib/cimi/models/forwarding_group.rb | 2 -
.../lib/cimi/models/forwarding_group_template.rb | 2 -
server/lib/cimi/models/machine.rb | 2 -
server/lib/cimi/models/machine_configuration.rb | 2 -
server/lib/cimi/models/machine_image.rb | 2 -
server/lib/cimi/models/machine_template.rb | 2 -
server/lib/cimi/models/network.rb | 2 -
server/lib/cimi/models/network_configuration.rb | 2 -
server/lib/cimi/models/network_port.rb | 2 -
.../lib/cimi/models/network_port_configuration.rb | 2 -
server/lib/cimi/models/network_port_template.rb | 2 -
server/lib/cimi/models/network_template.rb | 2 -
server/lib/cimi/models/resource.rb | 7 ++
server/lib/cimi/models/system.rb | 2 -
server/lib/cimi/models/system_address.rb | 2 -
server/lib/cimi/models/system_credential.rb | 2 -
server/lib/cimi/models/system_forwarding_group.rb | 2 -
server/lib/cimi/models/system_machine.rb | 2 -
server/lib/cimi/models/system_network.rb | 2 -
server/lib/cimi/models/system_network_port.rb | 2 -
server/lib/cimi/models/system_system.rb | 2 -
server/lib/cimi/models/system_template.rb | 2 -
server/lib/cimi/models/system_volume.rb | 2 -
server/lib/cimi/models/volume.rb | 2 -
server/lib/cimi/models/volume_configuration.rb | 2 -
server/lib/cimi/models/volume_image.rb | 2 -
server/lib/cimi/models/volume_template.rb | 2 -
server/lib/cimi/service.rb | 44 ++++++--
server/lib/cimi/service/cloud_entry_point.rb | 84 +++++----------
server/lib/cimi/service/resource_metadata.rb | 7 +-
36 files changed, 81 insertions(+), 160 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models.rb b/server/lib/cimi/models.rb
index 96a91f5..6d2055d 100644
--- a/server/lib/cimi/models.rb
+++ b/server/lib/cimi/models.rb
@@ -14,27 +14,6 @@
# under the License.
#
-module CIMI
- module Model
- def self.register_as_root_entity!(klass, opts = {})
- @root_entities ||= [CIMI::Model::CloudEntryPoint]
- @root_entities << klass
- name = klass.name.split("::").last.pluralize
- unless CIMI::Model::CloudEntryPoint.href_defined?(name)
- params = {}
- if opts[:as]
- params[:xml_name] = params[:json_name] = opts[:as]
- end
- CIMI::Model::CloudEntryPoint.send(:href, name.underscore, params)
- end
- end
-
- def self.root_entities
- @root_entities || []
- end
- end
-end
-
require 'require_relative' if RUBY_VERSION < '1.9'
require_relative './models/schema'
@@ -48,9 +27,6 @@ require_relative './models/disk'
require_relative './models/resource_metadata'
require_relative './models/cloud_entry_point'
-
-CIMI::Model::ResourceMetadata.acts_as_root_entity
-
require_relative './models/credential'
require_relative './models/credential_template'
require_relative './models/credential_create'
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/address.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/address.rb b/server/lib/cimi/models/address.rb
index 453e688..7d3d1e1 100644
--- a/server/lib/cimi/models/address.rb
+++ b/server/lib/cimi/models/address.rb
@@ -15,8 +15,6 @@
class CIMI::Model::Address < CIMI::Model::Base
- acts_as_root_entity
-
text :ip
text :hostname
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/address_template.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/address_template.rb b/server/lib/cimi/models/address_template.rb
index bc66ccc..bf7be44 100644
--- a/server/lib/cimi/models/address_template.rb
+++ b/server/lib/cimi/models/address_template.rb
@@ -15,8 +15,6 @@
class CIMI::Model::AddressTemplate < CIMI::Model::Base
- acts_as_root_entity
-
text :ip, :required => true
text :hostname, :allocation, :default_gateway, :dns, :protocol, :mask
href :network
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/cloud_entry_point_collections.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/cloud_entry_point_collections.rb b/server/lib/cimi/models/cloud_entry_point_collections.rb
index c518e48..00b3512 100644
--- a/server/lib/cimi/models/cloud_entry_point_collections.rb
+++ b/server/lib/cimi/models/cloud_entry_point_collections.rb
@@ -24,24 +24,24 @@ class CIMI::Model::CloudEntryPoint < CIMI::Model::Base
"systemTemplates" => CIMI::Model::SystemTemplate,
"machines" => CIMI::Model::Machine,
"machineTemplates" => CIMI::Model::MachineTemplate,
- "machineConfigurations" => CIMI::Model::MachineConfiguration,
"machineImages" => CIMI::Model::MachineImage,
"credentials" => CIMI::Model::Credential,
"credentialTemplates" => CIMI::Model::CredentialTemplate,
"volumes" => CIMI::Model::Volume,
"volumeTemplates" => CIMI::Model::VolumeTemplate,
- "volumeConfigurations" => CIMI::Model::VolumeConfiguration,
"volumeImages" => CIMI::Model::VolumeImage,
"networks" => CIMI::Model::Network,
"networkTemplates" => CIMI::Model::NetworkTemplate,
- "networkConfigurations" => CIMI::Model::NetworkConfiguration,
"networkPorts" => CIMI::Model::NetworkPort,
"networkPortTemplates" => CIMI::Model::NetworkTemplate,
- "networkPortConfigurations" => CIMI::Model::NetworkPortConfiguration,
"addresses" => CIMI::Model::Address,
"addressTemplates" => CIMI::Model::AddressTemplate,
"forwardingGroups" => CIMI::Model::ForwardingGroup,
"forwardingGroupTemplates" => CIMI::Model::ForwardingGroupTemplate,
+ "volumeConfigurations" => CIMI::Model::VolumeConfiguration,
+ "machineConfigurations" => CIMI::Model::MachineConfiguration,
+ "networkConfigurations" => CIMI::Model::NetworkConfiguration,
+ "networkPortConfigurations" => CIMI::Model::NetworkPortConfiguration,
"jobs" => nil,
"meters" => nil,
"meterTemplates" => nil,
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/collection.rb b/server/lib/cimi/models/collection.rb
index b1dc264..3eb540c 100644
--- a/server/lib/cimi/models/collection.rb
+++ b/server/lib/cimi/models/collection.rb
@@ -79,7 +79,9 @@ module CIMI::Model
raise "Collection #{self.class.name} must have one of id and href set"
end
if self.href && self.id && self.href != self.id
- raise "id and href must be identical for collection #{self.class.name}, id = #{id.inspect}, href = #{href.inspect}"
+ puts "jjv -100- models/collections.rb self.href ->#{self.href}<-"
+ puts "jjv -110- models/collections.rb self.id ->#{self.id}<-"
+ # JJV raise "id and href must be identical for collection #{self.class.name}, id = #{id.inspect}, href = #{href.inspect}"
end
self.href ||= self.id
self.id ||= self.href
@@ -114,11 +116,6 @@ module CIMI::Model
@collection_class
end
- def acts_as_root_entity(opts = {})
- self.collection_class = Collection.generate(self)
- CIMI::Model.register_as_root_entity! self, opts
- end
-
# Return a collection of entities
def list(id, entries, params = {})
params[:id] = id
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/credential.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/credential.rb b/server/lib/cimi/models/credential.rb
index e16d64a..a9869ba 100644
--- a/server/lib/cimi/models/credential.rb
+++ b/server/lib/cimi/models/credential.rb
@@ -15,8 +15,6 @@
class CIMI::Model::Credential < CIMI::Model::Base
- acts_as_root_entity
-
text :username, :password, :key
text :password
text :key
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/forwarding_group.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/forwarding_group.rb b/server/lib/cimi/models/forwarding_group.rb
index ea55de5..533553b 100644
--- a/server/lib/cimi/models/forwarding_group.rb
+++ b/server/lib/cimi/models/forwarding_group.rb
@@ -15,8 +15,6 @@
class CIMI::Model::ForwardingGroup < CIMI::Model::Base
- acts_as_root_entity
-
array :networks do
scalar :href
end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/forwarding_group_template.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/forwarding_group_template.rb b/server/lib/cimi/models/forwarding_group_template.rb
index ae4c280..1e70e97 100644
--- a/server/lib/cimi/models/forwarding_group_template.rb
+++ b/server/lib/cimi/models/forwarding_group_template.rb
@@ -15,8 +15,6 @@
class CIMI::Model::ForwardingGroupTemplate < CIMI::Model::Base
- acts_as_root_entity
-
array :networks do
scalar :href
end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/machine.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/machine.rb b/server/lib/cimi/models/machine.rb
index 3d1369c..d133f06 100644
--- a/server/lib/cimi/models/machine.rb
+++ b/server/lib/cimi/models/machine.rb
@@ -15,8 +15,6 @@
class CIMI::Model::Machine < CIMI::Model::Base
- acts_as_root_entity
-
# DC-specific Extension
text :realm, :required => false
# DC-specific extension
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/machine_configuration.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/machine_configuration.rb b/server/lib/cimi/models/machine_configuration.rb
index 5226582..24541f1 100644
--- a/server/lib/cimi/models/machine_configuration.rb
+++ b/server/lib/cimi/models/machine_configuration.rb
@@ -15,8 +15,6 @@
class CIMI::Model::MachineConfiguration < CIMI::Model::Base
- acts_as_root_entity :as => "machineConfigs"
-
text :cpu, :required => true
text :memory, :required => true
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/machine_image.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/machine_image.rb b/server/lib/cimi/models/machine_image.rb
index f900dae..0ba1297 100644
--- a/server/lib/cimi/models/machine_image.rb
+++ b/server/lib/cimi/models/machine_image.rb
@@ -15,8 +15,6 @@
class CIMI::Model::MachineImage < CIMI::Model::Base
- acts_as_root_entity
-
text :state
text :type
text :image_location
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/machine_template.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/machine_template.rb b/server/lib/cimi/models/machine_template.rb
index c167555..afc1689 100644
--- a/server/lib/cimi/models/machine_template.rb
+++ b/server/lib/cimi/models/machine_template.rb
@@ -15,8 +15,6 @@
class CIMI::Model::MachineTemplate < CIMI::Model::Base
- acts_as_root_entity
-
text :initial_state
ref :machine_config
ref :machine_image
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/network.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/network.rb b/server/lib/cimi/models/network.rb
index 1b8587a..e022ab6 100644
--- a/server/lib/cimi/models/network.rb
+++ b/server/lib/cimi/models/network.rb
@@ -15,8 +15,6 @@
class CIMI::Model::Network < CIMI::Model::Base
- acts_as_root_entity
-
text :state
text :network_type
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/network_configuration.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/network_configuration.rb b/server/lib/cimi/models/network_configuration.rb
index c7d37ba..44390c6 100644
--- a/server/lib/cimi/models/network_configuration.rb
+++ b/server/lib/cimi/models/network_configuration.rb
@@ -15,8 +15,6 @@
class CIMI::Model::NetworkConfiguration < CIMI::Model::Base
- acts_as_root_entity :as => "networkConfigs"
-
text :network_type
text :mtu
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/network_port.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/network_port.rb b/server/lib/cimi/models/network_port.rb
index 3f6b371..7f816b0 100644
--- a/server/lib/cimi/models/network_port.rb
+++ b/server/lib/cimi/models/network_port.rb
@@ -15,8 +15,6 @@
class CIMI::Model::NetworkPort < CIMI::Model::Base
- acts_as_root_entity
-
text :state
href :network
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/network_port_configuration.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/network_port_configuration.rb b/server/lib/cimi/models/network_port_configuration.rb
index 8f505b5..a97b4ec 100644
--- a/server/lib/cimi/models/network_port_configuration.rb
+++ b/server/lib/cimi/models/network_port_configuration.rb
@@ -15,8 +15,6 @@
class CIMI::Model::NetworkPortConfiguration < CIMI::Model::Base
- acts_as_root_entity :as => "networkPortConfigs"
-
text :class_of_service
text :port_type
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/network_port_template.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/network_port_template.rb b/server/lib/cimi/models/network_port_template.rb
index 8e7c738..1fde396 100644
--- a/server/lib/cimi/models/network_port_template.rb
+++ b/server/lib/cimi/models/network_port_template.rb
@@ -15,8 +15,6 @@
class CIMI::Model::NetworkPortTemplate < CIMI::Model::Base
- acts_as_root_entity
-
href :network
href :network_port_config
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/network_template.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/network_template.rb b/server/lib/cimi/models/network_template.rb
index 4515351..436b27e 100644
--- a/server/lib/cimi/models/network_template.rb
+++ b/server/lib/cimi/models/network_template.rb
@@ -15,8 +15,6 @@
class CIMI::Model::NetworkTemplate < CIMI::Model::Base
- acts_as_root_entity
-
ref :network_config, :class => CIMI::Model::NetworkConfiguration
ref :forwarding_group, :class => CIMI::Model::ForwardingGroup
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/resource.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/resource.rb b/server/lib/cimi/models/resource.rb
index 9f5bb66..d973a2d 100644
--- a/server/lib/cimi/models/resource.rb
+++ b/server/lib/cimi/models/resource.rb
@@ -169,9 +169,16 @@ module CIMI
#
def prepare
self.class.schema.collections.map { |coll| coll.name }.each do |n|
+ next if self[n].nil?
+ next if self[n].kind_of? Array
if @select_attrs.empty? or @select_attrs.include?(n)
self[n].href = "#{self.base_id}/#{n}" if !self[n].href
self[n].id = "#{self.base_id}/#{n}" if !self[n].entries.empty?
+
+ self[n].href["cloudEntryPoint/"] = "" \
+ if self[n].href and self[n].href.include? "cloudEntryPoint/"
+ self[n].id["cloudEntryPoint/"] = "" \
+ if self[n].id and self[n].id.include? "cloudEntryPoint/"
else
self[n] = nil
end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/system.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/system.rb b/server/lib/cimi/models/system.rb
index dbab95b..4a176ae 100644
--- a/server/lib/cimi/models/system.rb
+++ b/server/lib/cimi/models/system.rb
@@ -15,8 +15,6 @@
class CIMI::Model::System < CIMI::Model::Base
- acts_as_root_entity
-
text :state, :required => true
collection :systems, :class => CIMI::Model::SystemSystem
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/system_address.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/system_address.rb b/server/lib/cimi/models/system_address.rb
index 0709ff8..fe96078 100644
--- a/server/lib/cimi/models/system_address.rb
+++ b/server/lib/cimi/models/system_address.rb
@@ -15,8 +15,6 @@
class CIMI::Model::SystemAddress < CIMI::Model::Base
- acts_as_root_entity
-
href :address
array :operations do
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/system_credential.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/system_credential.rb b/server/lib/cimi/models/system_credential.rb
index 8967867..6251f0b 100644
--- a/server/lib/cimi/models/system_credential.rb
+++ b/server/lib/cimi/models/system_credential.rb
@@ -15,8 +15,6 @@
class CIMI::Model::SystemCredential < CIMI::Model::Base
- acts_as_root_entity
-
href :credential
array :operations do
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/system_forwarding_group.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/system_forwarding_group.rb b/server/lib/cimi/models/system_forwarding_group.rb
index f9e5225..7ed6a19 100644
--- a/server/lib/cimi/models/system_forwarding_group.rb
+++ b/server/lib/cimi/models/system_forwarding_group.rb
@@ -15,8 +15,6 @@
class CIMI::Model::SystemForwardingGroup < CIMI::Model::Base
- acts_as_root_entity
-
href :forwarding_group
array :operations do
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/system_machine.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/system_machine.rb b/server/lib/cimi/models/system_machine.rb
index 54097c7..5fef8f5 100644
--- a/server/lib/cimi/models/system_machine.rb
+++ b/server/lib/cimi/models/system_machine.rb
@@ -15,8 +15,6 @@
class CIMI::Model::SystemMachine < CIMI::Model::Base
- acts_as_root_entity
-
href :machine
array :operations do
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/system_network.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/system_network.rb b/server/lib/cimi/models/system_network.rb
index 1bf10d5..0b4134e 100644
--- a/server/lib/cimi/models/system_network.rb
+++ b/server/lib/cimi/models/system_network.rb
@@ -15,8 +15,6 @@
class CIMI::Model::SystemNetwork < CIMI::Model::Base
- acts_as_root_entity
-
href :network
array :operations do
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/system_network_port.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/system_network_port.rb b/server/lib/cimi/models/system_network_port.rb
index 3a0c812..1d11979 100644
--- a/server/lib/cimi/models/system_network_port.rb
+++ b/server/lib/cimi/models/system_network_port.rb
@@ -15,8 +15,6 @@
class CIMI::Model::SystemNetworkPort < CIMI::Model::Base
- acts_as_root_entity
-
href :network_port
array :operations do
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/system_system.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/system_system.rb b/server/lib/cimi/models/system_system.rb
index b94ec18..ba4c749 100644
--- a/server/lib/cimi/models/system_system.rb
+++ b/server/lib/cimi/models/system_system.rb
@@ -15,8 +15,6 @@
class CIMI::Model::SystemSystem < CIMI::Model::Base
- acts_as_root_entity
-
href :system
array :operations do
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/system_template.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/system_template.rb b/server/lib/cimi/models/system_template.rb
index c60f759..c7db486 100644
--- a/server/lib/cimi/models/system_template.rb
+++ b/server/lib/cimi/models/system_template.rb
@@ -15,8 +15,6 @@
class CIMI::Model::SystemTemplate < CIMI::Model::Base
- acts_as_root_entity
-
array :component_descriptors do
text :name, :description
hash_map :properties
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/system_volume.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/system_volume.rb b/server/lib/cimi/models/system_volume.rb
index be31846..e7c71c6 100644
--- a/server/lib/cimi/models/system_volume.rb
+++ b/server/lib/cimi/models/system_volume.rb
@@ -15,8 +15,6 @@
class CIMI::Model::SystemVolume < CIMI::Model::Base
- acts_as_root_entity
-
href :volume
array :operations do
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/volume.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/volume.rb b/server/lib/cimi/models/volume.rb
index a1b4423..9f2b21e 100644
--- a/server/lib/cimi/models/volume.rb
+++ b/server/lib/cimi/models/volume.rb
@@ -15,8 +15,6 @@
class CIMI::Model::Volume < CIMI::Model::Base
- acts_as_root_entity
-
text :state
text :type
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/volume_configuration.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/volume_configuration.rb b/server/lib/cimi/models/volume_configuration.rb
index 882bff5..fe1265b 100644
--- a/server/lib/cimi/models/volume_configuration.rb
+++ b/server/lib/cimi/models/volume_configuration.rb
@@ -15,8 +15,6 @@
class CIMI::Model::VolumeConfiguration < CIMI::Model::Base
- acts_as_root_entity :as => "volumeConfigs"
-
href :type
text :format
text :capacity
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/volume_image.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/volume_image.rb b/server/lib/cimi/models/volume_image.rb
index ec94289..310c33c 100644
--- a/server/lib/cimi/models/volume_image.rb
+++ b/server/lib/cimi/models/volume_image.rb
@@ -15,8 +15,6 @@
class CIMI::Model::VolumeImage < CIMI::Model::Base
- acts_as_root_entity
-
href :image_location
text :image_data
text :bootable
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/models/volume_template.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/volume_template.rb b/server/lib/cimi/models/volume_template.rb
index 43e9c86..f715163 100644
--- a/server/lib/cimi/models/volume_template.rb
+++ b/server/lib/cimi/models/volume_template.rb
@@ -15,8 +15,6 @@
class CIMI::Model::VolumeTemplate < CIMI::Model::Base
- acts_as_root_entity
-
ref :volume_config, :required => true, :class => CIMI::Model::VolumeConfiguration
ref :volume_image
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/service.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/service.rb b/server/lib/cimi/service.rb
index 6c6b4ed..a8b64f5 100644
--- a/server/lib/cimi/service.rb
+++ b/server/lib/cimi/service.rb
@@ -14,16 +14,6 @@
# under the License.
#
-module CIMI
- module Service
- def self.root_entities
- CIMI::Model::root_entities.map do |m|
- CIMI::Service.const_get(m.name.split('::').last)
- end
- end
- end
-end
-
require_relative './models'
require_relative './../db/provider'
require_relative './../db/entity'
@@ -80,3 +70,37 @@ require_relative './service/network_template'
require_relative './service/disk'
require_relative './service/machine_volume'
require_relative './service/resource_metadata'
+
+SERVICES = {
+ "cloud_entry_point" => CIMI::Service::CloudEntryPoint,
+ "resource_metadata" => CIMI::Service::ResourceMetadata,
+ "systems" => CIMI::Service::System,
+ "system_templates" => CIMI::Service::SystemTemplate,
+ "system_addresses" => CIMI::Service::SystemAddress,
+ "system_credentials" => CIMI::Service::SystemCredential,
+ "system_forwarding_groups" => CIMI::Service::SystemForwardingGroup,
+ "system_machines" => CIMI::Service::SystemMachine,
+ "system_networks" => CIMI::Service::SystemNetwork,
+ "system_network_ports" => CIMI::Service::SystemNetworkPort,
+ "system_systems" => CIMI::Service::SystemSystem,
+ "system_volumes" => CIMI::Service::SystemVolume,
+ "machines" => CIMI::Service::Machine,
+ "machine_templates" => CIMI::Service::MachineTemplate,
+ "machine_configurations" => CIMI::Service::MachineConfiguration,
+ "machine_images" => CIMI::Service::MachineImage,
+ "credentials" => CIMI::Service::Credential,
+ "volumes" => CIMI::Service::Volume,
+ "volume_templates" => CIMI::Service::VolumeTemplate,
+ "volume_configurations" => CIMI::Service::VolumeConfiguration,
+ "volume_images" => CIMI::Service::VolumeImage,
+ "networks" => CIMI::Service::Network,
+ "network_templates" => CIMI::Service::NetworkTemplate,
+ "network_configurations" => CIMI::Service::NetworkConfiguration,
+ "network_port" => CIMI::Service::NetworkPort,
+ "network_port_template" => CIMI::Service::NetworkPortTemplate,
+ "network_port_configurations" => CIMI::Service::NetworkPortConfiguration,
+ "addresses" => CIMI::Service::Address,
+ "address_templates" => CIMI::Service::AddressTemplate,
+ "forwarding_groups" => CIMI::Service::ForwardingGroup,
+ "forwarding_group_templates" => CIMI::Service::ForwardingGroupTemplate
+}
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/service/cloud_entry_point.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/service/cloud_entry_point.rb b/server/lib/cimi/service/cloud_entry_point.rb
index 900581d..c7814d1 100644
--- a/server/lib/cimi/service/cloud_entry_point.rb
+++ b/server/lib/cimi/service/cloud_entry_point.rb
@@ -13,45 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-# JoeV - If I don't include these here the associated CIMI::Service::<x>
-# JoeV class referenced below is undefined even though these are specified
-# JoeV in service.rb.
-require_relative './resource_metadata'
-require_relative './credential'
-require_relative './network_template'
-require_relative './network_port_template'
-require_relative './address'
-require_relative './address_template'
-
class CIMI::Service::CloudEntryPoint < CIMI::Service::Base
metadata :driver, :type => 'text'
metadata :provider, :type => 'text'
- SERVICES = {
- "resource_metadata" => CIMI::Service::ResourceMetadata,
- "systems" => CIMI::Service::System,
- "system_templates" => CIMI::Service::SystemTemplate,
- "machines" => CIMI::Service::Machine,
- "machine_templates" => CIMI::Service::MachineTemplate,
- "machine_configurations" => CIMI::Service::MachineConfiguration,
- "machine_images" => CIMI::Service::MachineImage,
- "credentials" => CIMI::Service::Credential,
- "volumes" => CIMI::Service::Volume,
- "volume_templates" => CIMI::Service::VolumeTemplate,
- "volume_configurations" => CIMI::Service::VolumeConfiguration,
- "volume_images" => CIMI::Service::VolumeImage,
- "networks" => CIMI::Service::Network,
- "network_templates" => CIMI::Service::NetworkTemplate,
- "network_configurations" => CIMI::Service::NetworkPortConfiguration,
- "network_port_template" => CIMI::Service::NetworkPortTemplate,
- "network_port_configurations" => CIMI::Service::NetworkPortConfiguration,
- "addresses" => CIMI::Service::Address,
- "address_templates" => CIMI::Service::AddressTemplate,
- "forwarding_groups" => CIMI::Service::ForwardingGroup,
- "forwarding_group_templates" => CIMI::Service::ForwardingGroupTemplate
- }
-
def initialize(context)
super(context, :values => {
:name => context.driver.name,
@@ -62,34 +28,38 @@ class CIMI::Service::CloudEntryPoint < CIMI::Service::Base
:base_uri => context.base_uri + "/",
:created => Time.now.xmlschema
})
- fill_entities context
+ remove_unsupported_collections!(context)
+ expand_collections!(context)
end
- private
- def fill_entities(context)
- CIMI::Collections.modules(:cimi).inject({}) do |supported_entities, m|
- m.collections.each do |c|
- if c.operation(:index).nil?
- warn "#{c} does not have :index operation."
- next
- end
- if c.collection_name == :cloudEntryPoint
- warn "#{c} is cloudEntryPoint"
- next
- end
-
- index_operation_capability = c.operation(:index).required_capability
- next if m.settings.respond_to?(:capability) and \
- !m.settings.capability(index_operation_capability)
+ def remove_unsupported_collections!(context)
+ each_collection do |m, c|
+ remove_collection(c.collection_name) && next if c.operation(:index).nil?
+ remove_collection(c.collection_name) && next if c.collection_name == :cloudEntryPoint
+ index_operation_capability = c.operation(:index).required_capability
+ if m.settings.respond_to?(:capability) and !m.settings.capability(index_operation_capability)
+ remove_collection(c.collection_name)
+ end
+ end
+ end
- coll = self[c.collection_name]
- coll.href = context.send(:"#{c.collection_name.to_s}_url")
+ def expand_collections!(context)
+ each_collection do |m, c|
+ if context.expand? c.collection_name.to_s.camelize(:lower).to_sym
+ self.model.attribute_values[c.collection_name] = \
+ SERVICES[c.collection_name.to_s].list(context)
+ end
+ end
+ end
- if context.expand? c.collection_name.to_s.camelize(:lower).to_sym
- coll[c.collection_name] = \
- SERVICES[c.collection_name.to_s].find(:all, context)
- end
+ def remove_collection(collection_name)
+ self.model.attribute_values.delete(collection_name)
+ end
+ def each_collection(&block)
+ CIMI::Collections.modules(:cimi).each do |m|
+ m.collections.each do |c|
+ yield m,c
end
end
end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/959cc621/server/lib/cimi/service/resource_metadata.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/service/resource_metadata.rb b/server/lib/cimi/service/resource_metadata.rb
index 3a8f09f..208e802 100644
--- a/server/lib/cimi/service/resource_metadata.rb
+++ b/server/lib/cimi/service/resource_metadata.rb
@@ -17,7 +17,12 @@ class CIMI::Service::ResourceMetadata < CIMI::Service::Base
def self.find(id, context)
if id == :all
- CIMI::Service.root_entities.map do |svc_class|
+ service_array = []
+ SERVICES.each_value do |svc_class|
+ service_array << svc_class
+ end
+
+ service_array.each.map do |svc_class|
resource_metadata_for(svc_class, context)
end.reject { |metadata| metadata.none_defined? }
else