deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [42/50] [abbrv] git commit: CIMI: Moved code from CIMI server.rb and split it to smaller collections like in Deltacloud
Date Tue, 22 May 2012 20:19:38 GMT
CIMI: Moved code from CIMI server.rb and split it to smaller collections like in Deltacloud


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/a8a53bc6
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/a8a53bc6
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/a8a53bc6

Branch: refs/heads/master
Commit: a8a53bc6f418be536b6467b302335e8f944078df
Parents: fd07fdd
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Tue Apr 17 15:25:26 2012 +0200
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Tue May 22 22:17:35 2012 +0200

----------------------------------------------------------------------
 server/lib/cimi/collections.rb                     |   58 +
 server/lib/cimi/collections/address_templates.rb   |   49 +
 server/lib/cimi/collections/addresses.rb           |   74 ++
 server/lib/cimi/collections/cloud_entry_point.rb   |   32 +
 server/lib/cimi/collections/entity_metadata.rb     |   48 +
 server/lib/cimi/collections/machine_admins.rb      |   74 ++
 .../lib/cimi/collections/machine_configurations.rb |   49 +
 server/lib/cimi/collections/machine_images.rb      |   50 +
 server/lib/cimi/collections/machines.rb            |  157 +++
 .../lib/cimi/collections/network_configurations.rb |   47 +
 server/lib/cimi/collections/network_templates.rb   |   48 +
 server/lib/cimi/collections/networks.rb            |  125 ++
 .../cimi/collections/routing_group_templates.rb    |   47 +
 server/lib/cimi/collections/routing_groups.rb      |   48 +
 .../lib/cimi/collections/volume_configurations.rb  |   48 +
 server/lib/cimi/collections/volume_images.rb       |   50 +
 server/lib/cimi/collections/volumes.rb             |   80 ++
 server/lib/cimi/collections/vsp_configurations.rb  |   48 +
 server/lib/cimi/collections/vsp_templates.rb       |   50 +
 server/lib/cimi/collections/vsps.rb                |  108 ++
 server/lib/cimi/helpers.rb                         |  104 ++
 server/lib/cimi/model.rb                           |   67 -
 server/lib/cimi/model/action.rb                    |   24 -
 server/lib/cimi/model/address.rb                   |   72 --
 server/lib/cimi/model/address_collection.rb        |   34 -
 server/lib/cimi/model/address_template.rb          |   54 -
 .../lib/cimi/model/address_template_collection.rb  |   34 -
 server/lib/cimi/model/base.rb                      |  249 ----
 server/lib/cimi/model/cloud_entry_point.rb         |   48 -
 server/lib/cimi/model/entity_metadata.rb           |   83 --
 .../lib/cimi/model/entity_metadata_collection.rb   |   31 -
 server/lib/cimi/model/errors.rb                    |   48 -
 server/lib/cimi/model/machine.rb                   |  229 ----
 server/lib/cimi/model/machine_admin.rb             |   59 -
 server/lib/cimi/model/machine_admin_collection.rb  |   34 -
 server/lib/cimi/model/machine_collection.rb        |   34 -
 server/lib/cimi/model/machine_configuration.rb     |   70 --
 .../cimi/model/machine_configuration_collection.rb |   34 -
 server/lib/cimi/model/machine_image.rb             |   46 -
 server/lib/cimi/model/machine_image_collection.rb  |   34 -
 server/lib/cimi/model/machine_template.rb          |   41 -
 .../lib/cimi/model/machine_template_collection.rb  |   34 -
 server/lib/cimi/model/network.rb                   |  106 --
 server/lib/cimi/model/network_collection.rb        |   34 -
 server/lib/cimi/model/network_configuration.rb     |   49 -
 .../cimi/model/network_configuration_collection.rb |   34 -
 server/lib/cimi/model/network_template.rb          |   36 -
 .../lib/cimi/model/network_template_collection.rb  |   35 -
 server/lib/cimi/model/routing_group.rb             |   34 -
 server/lib/cimi/model/routing_group_collection.rb  |   34 -
 server/lib/cimi/model/routing_group_template.rb    |   34 -
 .../model/routing_group_template_collection.rb     |   35 -
 server/lib/cimi/model/schema.rb                    |  277 -----
 server/lib/cimi/model/volume.rb                    |  103 --
 server/lib/cimi/model/volume_collection.rb         |   34 -
 server/lib/cimi/model/volume_configuration.rb      |   60 -
 .../cimi/model/volume_configuration_collection.rb  |   34 -
 server/lib/cimi/model/volume_image.rb              |   49 -
 server/lib/cimi/model/volume_image_collection.rb   |   34 -
 server/lib/cimi/model/volume_template.rb           |   23 -
 .../lib/cimi/model/volume_template_collection.rb   |   34 -
 server/lib/cimi/model/vsp.rb                       |  102 --
 server/lib/cimi/model/vsp_collection.rb            |   34 -
 server/lib/cimi/model/vsp_configuration.rb         |   40 -
 .../lib/cimi/model/vsp_configuration_collection.rb |   34 -
 server/lib/cimi/model/vsp_template.rb              |   34 -
 server/lib/cimi/model/vsp_template_collection.rb   |   34 -
 server/lib/cimi/models.rb                          |   75 ++
 server/lib/cimi/models/action.rb                   |   24 +
 server/lib/cimi/models/address.rb                  |   72 ++
 server/lib/cimi/models/address_collection.rb       |   34 +
 server/lib/cimi/models/address_template.rb         |   54 +
 .../lib/cimi/models/address_template_collection.rb |   34 +
 server/lib/cimi/models/base.rb                     |  249 ++++
 server/lib/cimi/models/cloud_entry_point.rb        |   46 +
 server/lib/cimi/models/entity_metadata.rb          |   84 ++
 .../lib/cimi/models/entity_metadata_collection.rb  |   31 +
 server/lib/cimi/models/errors.rb                   |   48 +
 server/lib/cimi/models/machine.rb                  |  227 ++++
 server/lib/cimi/models/machine_admin.rb            |   59 +
 server/lib/cimi/models/machine_admin_collection.rb |   34 +
 server/lib/cimi/models/machine_collection.rb       |   34 +
 server/lib/cimi/models/machine_configuration.rb    |   70 ++
 .../models/machine_configuration_collection.rb     |   34 +
 server/lib/cimi/models/machine_image.rb            |   46 +
 server/lib/cimi/models/machine_image_collection.rb |   34 +
 server/lib/cimi/models/machine_template.rb         |   41 +
 .../lib/cimi/models/machine_template_collection.rb |   34 +
 server/lib/cimi/models/network.rb                  |  109 ++
 server/lib/cimi/models/network_collection.rb       |   34 +
 server/lib/cimi/models/network_configuration.rb    |   49 +
 .../models/network_configuration_collection.rb     |   34 +
 server/lib/cimi/models/network_template.rb         |   36 +
 .../lib/cimi/models/network_template_collection.rb |   35 +
 server/lib/cimi/models/routing_group.rb            |   34 +
 server/lib/cimi/models/routing_group_collection.rb |   34 +
 server/lib/cimi/models/routing_group_template.rb   |   34 +
 .../models/routing_group_template_collection.rb    |   35 +
 server/lib/cimi/models/schema.rb                   |  277 +++++
 server/lib/cimi/models/volume.rb                   |  103 ++
 server/lib/cimi/models/volume_collection.rb        |   34 +
 server/lib/cimi/models/volume_configuration.rb     |   60 +
 .../cimi/models/volume_configuration_collection.rb |   34 +
 server/lib/cimi/models/volume_image.rb             |   49 +
 server/lib/cimi/models/volume_image_collection.rb  |   34 +
 server/lib/cimi/models/volume_template.rb          |   23 +
 .../lib/cimi/models/volume_template_collection.rb  |   34 +
 server/lib/cimi/models/vsp.rb                      |  102 ++
 server/lib/cimi/models/vsp_collection.rb           |   34 +
 server/lib/cimi/models/vsp_configuration.rb        |   40 +
 .../cimi/models/vsp_configuration_collection.rb    |   34 +
 server/lib/cimi/models/vsp_template.rb             |   34 +
 server/lib/cimi/models/vsp_template_collection.rb  |   34 +
 server/lib/cimi/server.rb                          |  959 +--------------
 114 files changed, 4148 insertions(+), 3645 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/collections.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections.rb b/server/lib/cimi/collections.rb
new file mode 100644
index 0000000..b675fc4
--- /dev/null
+++ b/server/lib/cimi/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.
+
+module CIMI
+
+  def self.collection_names
+    @collections.map { |c| c.collection_name }
+  end
+
+  def self.collections
+    @collections ||= []
+  end
+
+  module Collections
+
+    def self.collection(name)
+      CIMI.collections.find { |c| c.collection_name == name }
+    end
+
+    def self.cimi_modules
+      @cimi_modules ||= []
+    end
+
+    Dir[File.join(File::dirname(__FILE__), "collections", "*.rb")].each do |collection|
+      require collection
+      base_collection_name = File.basename(collection).gsub('.rb', '')
+      cimi_module_class = CIMI::Collections.const_get(base_collection_name.camelize)
+      cimi_modules << cimi_module_class
+      unless cimi_module_class.collections.nil?
+        cimi_module_class.collections.each do |c|
+          CIMI.collections << c
+        end
+      else
+        warn "WARNING: File %s placed in collections directory but does not have any collections defined" % base_collection_name
+      end
+    end
+
+    def self.included(klass)
+      klass.class_eval do
+        CIMI::Collections.cimi_modules.each { |c| use c }
+      end
+    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/collections/address_templates.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/address_templates.rb b/server/lib/cimi/collections/address_templates.rb
new file mode 100644
index 0000000..db59507
--- /dev/null
+++ b/server/lib/cimi/collections/address_templates.rb
@@ -0,0 +1,49 @@
+# 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.
+
+module CIMI::Collections
+  class AddressTemplates < Base
+
+    check_capability :for => lambda { |m| driver.respond_to? m }
+
+    collection :address_templates do
+
+      operation :index do
+        description 'List all AddressTemplates in the AddressTemplateCollection'
+        param :CIMISelect, :string, :optional
+        control do
+          address_templates = AddressTemplateCollection.default(self).filter_by(params[:CIMISelect])
+          respond_to do |format|
+            format.xml {address_templates.to_xml}
+            format.json {address_templates.to_json}
+          end
+        end
+      end
+
+      operation :show do
+        description 'Show a specific AddressTemplate'
+        control do
+          address_template = CIMI::Model::AddressTemplate.find(params[:id], self)
+          respond_to do |format|
+            format.xml {address_template.to_xml}
+            format.json {address_template.to_json}
+          end
+        end
+      end
+
+    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/collections/addresses.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/addresses.rb b/server/lib/cimi/collections/addresses.rb
new file mode 100644
index 0000000..96871c1
--- /dev/null
+++ b/server/lib/cimi/collections/addresses.rb
@@ -0,0 +1,74 @@
+# 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.
+
+module CIMI::Collections
+  class Addresses < Base
+
+    check_capability :for => lambda { |m| driver.respond_to? m }
+    collection :addresses do
+
+      description 'An Address represents an IP address, and its associated metdata, for a particular Network.'
+
+      operation :index do
+        description 'List all Addresses in the AddressCollection'
+        param :CIMISelect, :string, :optional
+        control do
+          addresses = AddressCollection.default(self).filter_by(params[:CIMISelect])
+          respond_to do |format|
+            format.xml {addresses.to_xml}
+            format.json {addresses.to_json}
+          end
+        end
+      end
+
+      operation :show do
+        description 'Show a specific Address'
+        control do
+          address = CIMI::Model::Address.find(params[:id], self)
+          respond_to do |format|
+            format.xml {address.to_xml}
+            format.json {address.to_json}
+          end
+        end
+      end
+
+      operation :create do
+        description "Create a new Address"
+        control do
+          if request.content_type.end_with?("json")
+            address = CIMI::Model::Address.create(request.body.read, self, :json)
+          else
+            address = CIMI::Model::Address.create(request.body.read, self, :xml)
+          end
+          respond_to do |format|
+            format.xml { address.to_xml }
+            format.json { address.to_json }
+          end
+        end
+      end
+
+      operation :destroy do
+        description "Delete a specified Address"
+        param :id, :string, :required
+        control do
+          CIMI::Model::Address.delete!(params[:id], self)
+          no_content_with_status(200)
+        end
+      end
+
+    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/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
new file mode 100644
index 0000000..79454f3
--- /dev/null
+++ b/server/lib/cimi/collections/cloud_entry_point.rb
@@ -0,0 +1,32 @@
+# 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.
+
+module CIMI::Collections
+  class CloudEntryPoint < Base
+
+    check_capability :for => lambda { |m| driver.respond_to? m }
+
+    collection  :cloudEntryPoint do
+      description 'Cloud entry point'
+      operation :index do
+        description "list all resources of the cloud"
+        control do
+          redirect API_ROOT_URL
+        end
+      end
+    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/collections/entity_metadata.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/entity_metadata.rb b/server/lib/cimi/collections/entity_metadata.rb
new file mode 100644
index 0000000..84e1fec
--- /dev/null
+++ b/server/lib/cimi/collections/entity_metadata.rb
@@ -0,0 +1,48 @@
+# 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.
+
+module CIMI::Collections
+  class EntityMetadata < Base
+
+    check_capability :for => lambda { |m| driver.respond_to? m }
+
+    collection :entity_metadata do
+
+      operation :index do
+        description "List all entity metadata defined for this provider"
+        control do
+          entity_metadata = CIMI::Model::EntityMetadataCollection.default(self)
+          respond_to do |format|
+            format.xml{entity_metadata.to_xml}
+            format.json{entity_metadata.to_json}
+          end
+        end
+      end
+
+      operation :show do
+        description "Get the entity metadata for a specific collection"
+        control do
+          entity_metadata = EntityMetadata.find(params[:id], self)
+          respond_to do |format|
+            format.xml{entity_metadata.to_xml}
+            format.json{entity_metadata.to_json}
+          end
+        end
+      end
+
+    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/collections/machine_admins.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/machine_admins.rb b/server/lib/cimi/collections/machine_admins.rb
new file mode 100644
index 0000000..c413cc9
--- /dev/null
+++ b/server/lib/cimi/collections/machine_admins.rb
@@ -0,0 +1,74 @@
+# 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.
+
+module CIMI::Collections
+  class MachineAdmins < Base
+
+    check_capability :for => lambda { |m| driver.respond_to? m }
+
+    collection :machine_admins do
+      description 'Machine Admin entity'
+
+      operation :index do
+        description "List all machine admins"
+        param :CIMISelect,  :string,  :optional
+        control do
+          machine_admins = MachineAdminCollection.default(self).filter_by(params[:CIMISelect])
+          respond_to do |format|
+            format.xml { machine_admins.to_xml }
+            format.json { machine_admins.to_json }
+          end
+        end
+      end
+
+      operation :show do
+        description "Show specific machine admin"
+        control do
+          machine_admin = MachineAdmin.find(params[:id], self)
+          respond_to do |format|
+            format.xml { machine_admin.to_xml }
+            format.json { machine_admin.to_json }
+          end
+        end
+      end
+
+      operation :create do
+        description "Show specific machine admin"
+        control do
+          if request.content_type.end_with?("+json")
+            new_admin = MachineAdmin.create_from_json(request.body.read, self)
+          else
+            new_admin = MachineAdmin.create_from_xml(request.body.read, self)
+          end
+          status 201 # Created
+          respond_to do |format|
+            format.json { new_admin.to_json }
+            format.xml { new_admin.to_xml }
+          end
+        end
+      end
+
+      operation :delete do
+        description "Delete specified MachineAdmin entity"
+        control do
+          MachineAdmin.delete!(params[:id], self)
+          no_content_with_status(200)
+        end
+      end
+
+    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/collections/machine_configurations.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/machine_configurations.rb b/server/lib/cimi/collections/machine_configurations.rb
new file mode 100644
index 0000000..5b09e6a
--- /dev/null
+++ b/server/lib/cimi/collections/machine_configurations.rb
@@ -0,0 +1,49 @@
+# 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.
+
+module CIMI::Collections
+  class MachineConfigurations < Base
+
+    check_capability :for => lambda { |m| driver.respond_to? m }
+
+    collection :machine_configurations do
+      description 'List all machine configurations'
+
+      operation :index do
+        param :CIMISelect,  :string,  :optional
+        description "List all machine configurations"
+        control do
+          machine_configs = MachineConfigurationCollection.default(self).filter_by(params[:CIMISelect])
+          respond_to do |format|
+            format.xml { machine_configs.to_xml }
+            format.json { machine_configs.to_json }
+          end
+        end
+      end
+
+      operation :show do
+        control do
+          machine_conf = MachineConfiguration.find(params[:id], self)
+          respond_to do |format|
+            format.xml { machine_conf.to_xml }
+            format.json { machine_conf.to_json }
+          end
+        end
+
+      end
+    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/collections/machine_images.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/machine_images.rb b/server/lib/cimi/collections/machine_images.rb
new file mode 100644
index 0000000..1296279
--- /dev/null
+++ b/server/lib/cimi/collections/machine_images.rb
@@ -0,0 +1,50 @@
+# 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.
+
+module CIMI::Collections
+  class MachineImages < Base
+
+    check_capability :for => lambda { |m| driver.respond_to? m }
+
+    collection :machine_images do
+      description 'List all machine images'
+
+      operation :index do
+        description "List all machine configurations"
+        param :CIMISelect,  :string,  :optional
+        control do
+          machine_images = MachineImageCollection.default(self).filter_by(params[:CIMISelect])
+          respond_to do |format|
+            format.xml { machine_images.to_xml }
+            format.json { machine_images.to_json }
+          end
+        end
+      end
+
+      operation :show do
+        description "Show specific machine image."
+        control do
+          machine_image = MachineImage.find(params[:id], self)
+          respond_to do |format|
+            format.xml { machine_image.to_xml }
+            format.json { machine_image.to_json }
+          end
+        end
+      end
+
+    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/collections/machines.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/machines.rb b/server/lib/cimi/collections/machines.rb
new file mode 100644
index 0000000..0abf63a
--- /dev/null
+++ b/server/lib/cimi/collections/machines.rb
@@ -0,0 +1,157 @@
+# 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.
+
+module CIMI::Collections
+  class Machines < Base
+
+    check_capability :for => lambda { |m| driver.respond_to? m }
+
+    collection :machines do
+      description 'List all machine'
+
+      operation :index do
+        param :CIMISelect,  :string,  :optional
+        description "List all machines"
+        control do
+          machines = MachineCollection.default(self).filter_by(params[:CIMISelect])
+          respond_to do |format|
+            format.xml { machines.to_xml }
+            format.json { machines.to_json }
+          end
+        end
+      end
+
+      operation :show do
+        description "Show specific machine."
+        control do
+          machine = Machine.find(params[:id], self)
+          respond_to do |format|
+            format.xml { machine.to_xml }
+            format.json { machine.to_json }
+          end
+        end
+      end
+
+      operation :create do
+        description "Create a new Machine entity."
+        control do
+          if request.content_type.end_with?("+json")
+            new_machine = Machine.create_from_json(request.body.read, self)
+          else
+            new_machine = Machine.create_from_xml(request.body.read, self)
+          end
+          status 201 # Created
+          respond_to do |format|
+            format.json { new_machine.to_json }
+            format.xml { new_machine.to_xml }
+          end
+        end
+      end
+
+      operation :destroy do
+        description "Delete a specified machine."
+        param :id,          :string,    :required
+        control do
+          Machine.delete!(params[:id], self)
+          no_content_with_status(200)
+        end
+      end
+
+      action :stop do
+        description "Stop specific machine."
+        control do
+          machine = Machine.find(params[:id], self)
+          if request.content_type.end_with?("+json")
+            action = Action.from_json(request.body.read)
+          else
+            action = Action.from_xml(request.body.read)
+          end
+          machine.perform(action, self) do |operation|
+            no_content_with_status(202) if operation.success?
+            # Handle errors using operation.failure?
+          end
+        end
+      end
+
+      operation :restart do
+        description "Start specific machine."
+        control do
+          machine = Machine.find(params[:id], self)
+          if request.content_type.end_with?("+json")
+            action = Action.from_json(request.body.read)
+          else
+            action = Action.from_xml(request.body.read)
+          end
+          machine.perform(action, self) do |operation|
+            no_content_with_status(202) if operation.success?
+            # Handle errors using operation.failure?
+          end
+        end
+      end
+
+      operation :start do
+        description "Start specific machine."
+        control do
+          machine = Machine.find(params[:id], self)
+          if request.content_type.end_with?("+json")
+            action = Action.from_json(request.body.read)
+          else
+            action = Action.from_xml(request.body.read)
+          end
+          machine.perform(action, self) do |operation|
+            no_content_with_status(202) if operation.success?
+            # Handle errors using operation.failure?
+          end
+        end
+      end
+
+      #NOTE: The routes for attach/detach used here are NOT as specified by CIMI
+      #will likely move later. CIMI specifies PUT of the whole Machine description
+      #with inclusion/ommission of the volumes you want [att|det]ached
+      action :attach_volume, :http_method => :put do
+        description "Attach CIMI Volume(s) to a machine."
+        control do
+          if request.content_type.end_with?("+json")
+            volumes_to_attach = Volume.find_to_attach_from_json(request.body.read, self)
+          else
+            volumes_to_attach = Volume.find_to_attach_from_xml(request.body.read, self)
+          end
+          machine = Machine.attach_volumes(volumes_to_attach, self)
+          respond_to do |format|
+            format.json{ machine.to_json}
+            format.xml{machine.to_xml}
+          end
+        end
+      end
+
+      action :detach_volume, :http_method => :put do
+        description "Detach CIMI Volume(s) from a machine."
+        control do
+          if request.content_type.end_with?("+json")
+            volumes_to_detach = Volume.find_to_attach_from_json(request.body.read, self)
+          else
+            volumes_to_detach = Volume.find_to_attach_from_xml(request.body.read, self)
+          end
+          machine = Machine.detach_volumes(volumes_to_detach, self)
+          respond_to do |format|
+            format.json{ machine.to_json}
+            format.xml{machine.to_xml}
+          end
+        end
+      end
+    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/collections/network_configurations.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/network_configurations.rb b/server/lib/cimi/collections/network_configurations.rb
new file mode 100644
index 0000000..02452a8
--- /dev/null
+++ b/server/lib/cimi/collections/network_configurations.rb
@@ -0,0 +1,47 @@
+# 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.
+
+module CIMI::Collections
+  class NetworkConfigurations < Base
+
+    check_capability :for => lambda { |m| driver.respond_to? m }
+    collection :network_configurations do
+
+      operation :index do
+        description 'List all NetworkConfigurations'
+        param :CIMISelect, :string, :optional
+        control do
+          network_configurations = NetworkConfigurationCollection.default(self).filter_by(params[:CIMISelect])
+          respond_to do |format|
+            format.xml { network_configurations.to_xml  }
+            format.json { network_configurations.to_json }
+          end
+        end
+      end
+
+      operation :show do
+        description 'Show a specific NetworkConfiguration'
+        control do
+          network_config = NetworkConfiguration.find(params[:id], self)
+          respond_to do |format|
+            format.xml { network_config.to_xml }
+            format.json { network_config.to_json }
+          end
+        end
+      end
+    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/collections/network_templates.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/network_templates.rb b/server/lib/cimi/collections/network_templates.rb
new file mode 100644
index 0000000..0ff82b2
--- /dev/null
+++ b/server/lib/cimi/collections/network_templates.rb
@@ -0,0 +1,48 @@
+# 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.
+
+module CIMI::Collections
+  class NetworkTemplates < Base
+
+    check_capability :for => lambda { |m| driver.respond_to? m }
+    collection :network_templates do
+
+      operation :index do
+        description 'List all Network Templates in the NetworkTemplateCollection'
+        param :CIMISelect, :string, :optional
+        control do
+          network_templates = NetworkTemplateCollection.default(self).filter_by(params[:CIMISelect])
+          respond_to do |format|
+            format.xml {network_templates.to_xml}
+            format.json {network_templates.to_json}
+          end
+        end
+      end
+
+      operation :show do
+        description 'Show a specific Network Template'
+        control do
+          network_template = NetworkTemplate.find(params[:id], self)
+          respond_to do |format|
+            format.xml {network_template.to_xml}
+            format.json {network_template.to_json}
+          end
+        end
+      end
+
+    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/collections/networks.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/networks.rb b/server/lib/cimi/collections/networks.rb
new file mode 100644
index 0000000..0aa21e8
--- /dev/null
+++ b/server/lib/cimi/collections/networks.rb
@@ -0,0 +1,125 @@
+# 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.
+
+module CIMI::Collections
+  class Networks < Base
+
+    check_capability :for => lambda { |m| driver.respond_to? m }
+
+    collection :networks do
+      description 'A Network represents an abstraction of a layer 2 broadcast domain'
+
+      operation :index do
+        description "List all Networks"
+        param :CIMISelect,  :string,  :optional
+        control do
+          networks = NetworkCollection.default(self).filter_by(params[:CIMISelect])
+          respond_to do |format|
+            format.xml { networks.to_xml }
+            format.json { networks.to_json }
+          end
+        end
+      end
+
+      operation :show do
+        description "Show a specific Network"
+        control do
+          network = Network.find(params[:id], self)
+          respond_to do |format|
+            format.xml { network.to_xml }
+            format.json { network.to_json }
+          end
+        end
+      end
+
+      operation :create do
+        description "Create a new Network"
+        control do
+          if request.content_type.end_with?("json")
+            network = Network.create(request.body.read, self, :json)
+          else
+            network = Network.create(request.body.read, self, :xml)
+          end
+          respond_to do |format|
+            format.xml { network.to_xml}
+            format.json { network.to_json }
+          end
+        end
+      end
+
+      operation :destroy do
+        description "Delete a specified Network"
+        param :id, :string, :required
+        control do
+          Network.delete!(params[:id], self)
+          no_content_with_status(200)
+        end
+      end
+
+      action :start do
+        description "Start specific network."
+        control do
+          network = Network.find(params[:id], self)
+          report_error(404) unless network
+          if request.content_type.end_with?("json")
+            action = Action.from_json(request.body.read)
+          else
+            action = Action.from_xml(request.body.read)
+          end
+          network.perform(action, self) do |operation|
+            no_content_with_status(202) if operation.success?
+            # Handle errors using operation.failure?
+          end
+        end
+      end
+
+      action :stop do
+        description "Stop specific network."
+        control do
+          network = Network.find(params[:id], self)
+          report_error(404) unless network
+          if request.content_type.end_with?("json")
+            action = Action.from_json(request.body.read)
+          else
+            action = Action.from_xml(request.body.read)
+          end
+          network.perform(action, self) do |operation|
+            no_content_with_status(202) if operation.success?
+            # Handle errors using operation.failure?
+          end
+        end
+      end
+
+      action :suspend do
+        description "Suspend specific network."
+        control do
+          network = Network.find(params[:id], self)
+          report_error(404) unless network
+          if request.content_type.end_with?("json")
+            action = Action.from_json(request.body.read)
+          else
+            action = Action.from_xml(request.body.read)
+          end
+          network.perform(action, self) do |operation|
+            no_content_with_status(202) if operation.success?
+            # Handle errors using operation.failure?
+          end
+        end
+      end
+
+    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/collections/routing_group_templates.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/routing_group_templates.rb b/server/lib/cimi/collections/routing_group_templates.rb
new file mode 100644
index 0000000..995b1f8
--- /dev/null
+++ b/server/lib/cimi/collections/routing_group_templates.rb
@@ -0,0 +1,47 @@
+# 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.
+
+module CIMI::Collections
+  class RoutingGroupTemplates < Base
+
+    check_capability :for => lambda { |m| driver.respond_to? m }
+    collection :routing_group_templates do
+
+      operation :index do
+        description 'List all RoutingGroupTemplates in the RoutingGroupTemplateCollection'
+        param :CIMISelect, :string, :optional
+        control do
+          routing_group_templates = RoutingGroupTemplateCollection.default(self).filter_by(params[:CIMISelect])
+          respond_to do |format|
+            format.xml {routing_group_templates.to_xml}
+            format.json {routing_group_templates.to_json}
+          end
+        end
+      end
+
+      operation :show do
+        description 'Show a specific RoutingGroupTemplate'
+        control do
+          routing_group_template = RoutingGroupTemplate.find(params[:id], self)
+          respond_to do |format|
+            format.xml {routing_group_template.to_xml}
+            format.json {routing_group_template.to_json}
+          end
+        end
+      end
+    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/collections/routing_groups.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/routing_groups.rb b/server/lib/cimi/collections/routing_groups.rb
new file mode 100644
index 0000000..5e7ccc5
--- /dev/null
+++ b/server/lib/cimi/collections/routing_groups.rb
@@ -0,0 +1,48 @@
+# 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.
+
+module CIMI::Collections
+  class RoutingGroups < Base
+
+    check_capability :for => lambda { |m| driver.respond_to? m }
+    collection :routing_groups do
+
+      operation :index do
+        description 'List all RoutingGroups in the RoutingGroupsCollection'
+        param :CIMISelect, :string, :optional
+        control do
+          routing_groups = RoutingGroupCollection.default(self).filter_by(params[:CIMISelect])
+          respond_to do |format|
+            format.xml {routing_groups.to_xml}
+            format.json {routing_groups.to_json}
+          end
+        end
+      end
+
+      operation :show do
+        description 'Show a specific RoutingGroup'
+        control do
+          routing_group = RoutingGroup.find(params[:id], self)
+          respond_to do |format|
+            format.xml {routing_group.to_xml}
+            format.json {routing_group.to_json}
+          end
+        end
+      end
+
+    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/collections/volume_configurations.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/volume_configurations.rb b/server/lib/cimi/collections/volume_configurations.rb
new file mode 100644
index 0000000..055e28c
--- /dev/null
+++ b/server/lib/cimi/collections/volume_configurations.rb
@@ -0,0 +1,48 @@
+# 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.
+
+module CIMI::Collections
+  class VolumeConfigurations < Base
+
+    check_capability :for => lambda { |m| driver.respond_to? m }
+
+    collection :volume_configurations do
+
+      operation :index do
+        description "Get list all VolumeConfigurations"
+        param :CIMISelect,  :string,  :optional
+        control do
+          volume_configuration = VolumeConfigurationCollection.default(self).filter_by(params[:CIMISelect])
+          respond_to do |format|
+            format.xml { volume_configuration.to_xml }
+            format.json { volume_configuration.to_json }
+          end
+        end
+      end
+
+      operation :show do
+        description "Get a specific VolumeConfiguration"
+        control do
+          volume_config = VolumeConfiguration.find(params[:id], self)
+          respond_to do |format|
+            format.xml { volume_config.to_xml }
+            format.json { volume_config.json }
+          end
+        end
+      end
+    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/collections/volume_images.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/volume_images.rb b/server/lib/cimi/collections/volume_images.rb
new file mode 100644
index 0000000..78432b1
--- /dev/null
+++ b/server/lib/cimi/collections/volume_images.rb
@@ -0,0 +1,50 @@
+# 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.
+
+module CIMI::Collections
+  class VolumeImages < Base
+
+    check_capability :for => lambda { |m| driver.respond_to? m }
+
+    collection :volume_images do
+      description 'This entity represents an image that could be place on a pre-loaded volume.'
+
+      operation :index do
+        description "List all volumes images"
+        param :CIMISelect,  :string,  :optional
+        control do
+          volume_images = VolumeImageCollection.default(self).filter_by(params[:CIMISelect])
+          respond_to do |format|
+            format.xml { volume_images.to_xml }
+            format.json { volume_images.to_json }
+          end
+        end
+      end
+
+      operation :show do
+        description "Show a specific volume image"
+        control do
+          volume_image = VolumeImage.find(params[:id], self)
+          respond_to do |format|
+            format.xml { volume_image.to_xml }
+            format.json { volume_image.to_json }
+          end
+        end
+      end
+    end
+
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/collections/volumes.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/volumes.rb b/server/lib/cimi/collections/volumes.rb
new file mode 100644
index 0000000..1c45c9e
--- /dev/null
+++ b/server/lib/cimi/collections/volumes.rb
@@ -0,0 +1,80 @@
+# 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.
+
+module CIMI::Collections
+  class Volumes < Base
+
+    check_capability :for => lambda { |m| driver.respond_to? m }
+    collection :volumes do
+
+      operation :index do
+        description "List all volumes"
+        param :CIMISelect,  :string,  :optional
+        control do
+          volumes = VolumeCollection.default(self).filter_by(params[:CIMISelect])
+          respond_to do |format|
+            format.xml { volumes.to_xml }
+            format.json { volumes.to_json }
+          end
+        end
+      end
+
+      operation :show do
+        description "Show specific Volume."
+        control do
+          volume = Volume.find(params[:id], self)
+          if volume
+            respond_to do |format|
+              format.xml  { volume.to_xml  }
+              format.json { volume.to_json }
+            end
+          else
+            report_error(404)
+          end
+        end
+      end
+
+      operation :create do
+        description "Create a new Volume."
+        control do
+          content_type = (request.content_type.end_with?("+json") ? :json  : :xml)
+          #((request.content_type.end_with?("+xml")) ? :xml : report_error(415) ) FIXME
+          case content_type
+          when :json
+            new_volume = Volume.create_from_json(request.body.read, self)
+          when :xml
+            new_volume = Volume.create_from_xml(request.body.read, self)
+          end
+          respond_to do |format|
+            format.json { new_volume.to_json }
+            format.xml { new_volume.to_xml }
+          end
+        end
+      end
+
+      operation :destroy do
+        description "Delete a specified Volume"
+        param :id, :string, :required
+        control do
+          Volume.delete!(params[:id], self)
+          no_content_with_status(200)
+        end
+      end
+
+    end
+
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/collections/vsp_configurations.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/vsp_configurations.rb b/server/lib/cimi/collections/vsp_configurations.rb
new file mode 100644
index 0000000..31acceb
--- /dev/null
+++ b/server/lib/cimi/collections/vsp_configurations.rb
@@ -0,0 +1,48 @@
+# 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.
+
+module CIMI::Collections
+  class VspConfigurations < Base
+
+    check_capability :for => lambda { |m| driver.respond_to? m }
+    collection :vsp_configurations do
+
+      operation :index do
+        description 'List all VSPConfigurations in the VSPConfigurationCollection'
+        param :CIMISelect, :string, :optional
+        control do
+          vsp_configs = VSPConfigurationCollection.default(self).filter_by(params[:CIMISelect])
+          respond_to do |format|
+            format.xml {vsp_configs.to_xml}
+            format.json {vsp_configs.to_json}
+          end
+        end
+      end
+
+      operation :show do
+        description 'Show a specific VSPConfiguration'
+        control do
+          vsp_config = VSPConfiguration.find(params[:id], self)
+          respond_to do |format|
+            format.xml {vsp_config.to_xml}
+            format.json {vsp_config.to_json}
+          end
+        end
+      end
+
+    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/collections/vsp_templates.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/vsp_templates.rb b/server/lib/cimi/collections/vsp_templates.rb
new file mode 100644
index 0000000..503de50
--- /dev/null
+++ b/server/lib/cimi/collections/vsp_templates.rb
@@ -0,0 +1,50 @@
+# 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.
+
+module CIMI::Collections
+  class VspTemplates < Base
+
+    check_capability :for => lambda { |m| driver.respond_to? m }
+    collection :vsp_templates do
+
+      description 'The VSP Template is a set of Configuration values for realizing a VSP. A VSP Template may be used to create multiple VSPs'
+
+      operation :index do
+        description 'List all VSPTemplates in the VSPTemplateCollection'
+        param :CIMISelect, :string, :optional
+        control do
+          vsp_templates = VSPTemplateCollection.default(self).filter_by(params[:CIMISelect])
+          respond_to do |format|
+            format.xml {vsp_templates.to_xml}
+            format.json {vsp_templates.to_json}
+          end
+        end
+      end
+
+      operation :show do
+        description 'Show a specific VSPTemplate'
+        control do
+          vsp_template = VSPTemplate.find(params[:id], self)
+          respond_to do |format|
+            format.xml {vsp_template.to_xml}
+            format.json {vsp_template.to_json}
+          end
+        end
+      end
+
+    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/collections/vsps.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/vsps.rb b/server/lib/cimi/collections/vsps.rb
new file mode 100644
index 0000000..52b1a5a
--- /dev/null
+++ b/server/lib/cimi/collections/vsps.rb
@@ -0,0 +1,108 @@
+# 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.
+
+module CIMI::Collections
+  class Vsps < Base
+
+    check_capability :for => lambda { |m| driver.respond_to? m }
+    collection :vsps do
+
+      description 'A VSP represents the connection parameters of a network port'
+
+      operation :index do
+        description 'List all VSPs in the VSPCollection'
+        param :CIMISelect, :string, :optional
+        control do
+          vsps = VSPCollection.default(self).filter_by(params[:CIMISelect])
+          respond_to do |format|
+            format.xml {vsps.to_xml}
+            format.json {vsps.to_json}
+          end
+        end
+      end
+
+      operation :show do
+        description 'Show a specific VSP'
+        control do
+          vsp = VSP.find(params[:id], self)
+          respond_to do |format|
+            format.xml {vsp.to_xml}
+            format.json {vsp.to_json}
+          end
+        end
+      end
+
+      operation :create do
+        description "Create a new VSP"
+        control do
+          if request.content_type.end_with?("json")
+            vsp = CIMI::Model::VSP.create(request.body.read, self, :json)
+          else
+            vsp = CIMI::Model::VSP.create(request.body.read, self, :xml)
+          end
+          respond_to do |format|
+            format.xml { vsp.to_xml }
+            format.json { vsp.to_json }
+          end
+        end
+      end
+
+      operation :destroy do
+        description "Delete a specified VSP"
+        control do
+          CIMI::Model::VSP.delete!(params[:id], self)
+          no_content_with_status(200)
+        end
+      end
+
+      action :start do
+        description "Start specific VSP."
+        param :id,          :string,    :required
+        control do
+          vsp = VSP.find(params[:id], self)
+          report_error(404) unless vsp
+          if request.content_type.end_with?("json")
+            action = Action.from_json(request.body.read)
+          else
+            action = Action.from_xml(request.body.read)
+          end
+          vsp.perform(action, self) do |operation|
+            no_content_with_status(202) if operation.success?
+            # Handle errors using operation.failure?
+          end
+        end
+      end
+
+      action :stop do
+        description "Stop specific VSP."
+        control do
+          vsp = VSP.find(params[:id], self)
+          report_error(404) unless vsp
+          if request.content_type.end_with?("json")
+            action = Action.from_json(request.body.read)
+          else
+            action = Action.from_xml(request.body.read)
+          end
+          vsp.perform(action, self) do |operation|
+            no_content_with_status(202) if operation.success?
+            # Handle errors using operation.failure?
+          end
+        end
+      end
+
+    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/helpers.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/helpers.rb b/server/lib/cimi/helpers.rb
new file mode 100644
index 0000000..4535c39
--- /dev/null
+++ b/server/lib/cimi/helpers.rb
@@ -0,0 +1,104 @@
+# 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.
+
+module Deltacloud; end
+module CIMI; end
+
+require_relative '../deltacloud/drivers'
+require_relative '../deltacloud/models'
+require_relative '../deltacloud/helpers/driver_helper'
+require_relative '../deltacloud/helpers/auth_helper'
+require_relative '../deltacloud/helpers/url_helper'
+require_relative '../deltacloud/helpers/assets_helper'
+require_relative '../deltacloud/helpers/deltacloud_helper'
+require_relative '../deltacloud/helpers/rabbit_helper'
+require_relative '../deltacloud/helpers/rabbit_helper'
+require_relative '../deltacloud/core_ext/string'
+require_relative '../deltacloud/core_ext/array'
+require_relative '../deltacloud/core_ext/hash'
+require_relative '../deltacloud/core_ext/integer'
+require_relative '../deltacloud/core_ext/proc'
+require_relative './helpers/cimi_helper'
+require_relative './models'
+
+module CIMI::Collections
+  class Base < Sinatra::Base
+
+    extend Deltacloud::Helpers::Drivers
+    include Sinatra::Rabbit::Features
+    include CIMI::Model
+
+    helpers Deltacloud::Helpers::Drivers
+    helpers Sinatra::AuthHelper
+    helpers Sinatra::UrlForHelper
+    helpers Sinatra::StaticAssets::Helpers
+    helpers Rack::RespondTo::Helpers
+    helpers Deltacloud::Helpers::Application
+
+    register Rack::RespondTo
+
+    enable :xhtml
+    enable :dump_errors
+    enable :show_errors
+    disable :show_exceptions
+
+    set :root_url, API_ROOT_URL
+    set :version, API_VERSION
+    set :root, File.join(File.dirname(__FILE__), '..', '..')
+    set :views, root + '/views/cimi'
+    set :public_folder, root + '/public'
+
+    error do
+      report_error
+    end
+
+    error Deltacloud::ExceptionHandler::ValidationFailure do
+      report_error
+    end
+
+    before do
+      # Respond with 400, If we don't get a http Host header,
+      halt 400, "Unable to find HTTP Host header" if @env['HTTP_HOST'] == nil
+    end
+
+    after do
+      headers 'X-CIMI-Specification-Version' => API_VERSION
+    end
+
+    def self.new_route_for(route, &block)
+      get route_for('/' + route.to_s + '/new') do
+        instance_eval(&block) if block_given?
+        respond_to do |format|
+          format.html do
+            haml :"#{route}/new"
+          end
+        end
+      end
+    end
+
+    def self.check_capability(opts={})
+      Sinatra::Rabbit.set :check_capability, opts[:for]
+    end
+
+    def self.check_features(opts={})
+      Sinatra::Rabbit.set :check_features, opts[:for]
+    end
+
+    def self.route_for(url)
+      "#{settings.root_url}#{url}"
+    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model.rb b/server/lib/cimi/model.rb
deleted file mode 100644
index fa3c771..0000000
--- a/server/lib/cimi/model.rb
+++ /dev/null
@@ -1,67 +0,0 @@
-# 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.
-#
-
-# Declare namespace for CIMI model
-#
-module CIMI
-  module Model; end
-end
-
-require 'cimi/model/schema'
-require 'cimi/model/base'
-require 'cimi/model/errors'
-require 'cimi/model/cloud_entry_point'
-require 'cimi/model/machine_template'
-require 'cimi/model/machine_image'
-require 'cimi/model/machine_configuration'
-require 'cimi/model/action'
-require 'cimi/model/machine'
-require 'cimi/model/volume'
-require 'cimi/model/machine_admin'
-require 'cimi/model/volume_configuration'
-require 'cimi/model/volume_image'
-require 'cimi/model/volume_template'
-require 'cimi/model/machine_template_collection'
-require 'cimi/model/machine_image_collection'
-require 'cimi/model/machine_configuration_collection'
-require 'cimi/model/machine_collection'
-require 'cimi/model/volume_collection'
-require 'cimi/model/machine_admin_collection'
-require 'cimi/model/volume_configuration_collection'
-require 'cimi/model/volume_image_collection'
-require 'cimi/model/volume_template_collection'
-require 'cimi/model/entity_metadata'
-require 'cimi/model/entity_metadata_collection'
-require 'cimi/model/network'
-require 'cimi/model/network_collection'
-require 'cimi/model/network_configuration'
-require 'cimi/model/network_configuration_collection'
-require 'cimi/model/network_template'
-require 'cimi/model/network_template_collection'
-require 'cimi/model/routing_group'
-require 'cimi/model/routing_group_collection'
-require 'cimi/model/routing_group_template'
-require 'cimi/model/routing_group_template_collection'
-require 'cimi/model/vsp'
-require 'cimi/model/vsp_collection'
-require 'cimi/model/vsp_configuration'
-require 'cimi/model/vsp_configuration_collection'
-require 'cimi/model/vsp_template'
-require 'cimi/model/vsp_template_collection'
-require 'cimi/model/address'
-require 'cimi/model/address_collection'
-require 'cimi/model/address_template'
-require 'cimi/model/address_template_collection'

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/action.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/action.rb b/server/lib/cimi/model/action.rb
deleted file mode 100644
index c1c9908..0000000
--- a/server/lib/cimi/model/action.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# 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::Action < CIMI::Model::Base
-
-  text :action
-
-  def name
-    action.split('/').last.strip.intern
-  end
-
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/address.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/address.rb b/server/lib/cimi/model/address.rb
deleted file mode 100644
index 8838331..0000000
--- a/server/lib/cimi/model/address.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-# 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::Address < CIMI::Model::Base
-
-  text :ip
-
-  text :hostname
-
-  text :allocation
-
-  text :default_gateway
-
-  text :dns
-
-  text :mac_address
-
-  text :protocol
-
-  text :mask
-
-  href :network
-
-  href :resource
-
-  array :operations do
-    scalar :rel, :href
-  end
-
-  def self.find(id, context)
-    if id==:all
-      context.driver.addresses(context.credentials, {:env=>context})
-    else
-      context.driver.addresses(context.credentials, {:id=>id, :env=>context})
-    end
-  end
-
-  def self.create(request_body, context, type)
-    input = (type == :xml)? XmlSimple.xml_in(request_body, {"ForceArray"=>false, "NormaliseSpace"=>2}) : JSON.parse(request_body)
-    if input["addressTemplate"]["href"] #by reference
-      address_template = AddressTemplate.find(context.href_id(input["addressTemplate"]["href"], :address_templates), context)
-    else
-      case type
-        when :json
-          address_template = AddressTemplate.from_json(JSON.generate(input["addressTemplate"]))
-        when :xml
-          xml = XmlSimple.xml_in(request_body, {"NormaliseSpace"=>2})
-          address_template = AddressTemplate.from_xml(XmlSimple.xml_out(xml["addressTemplate"][0]))
-      end
-    end
-    params = {:name=>input["name"], :description=>input["description"], :address_template=>address_template, :env=>context }
-    raise CIMI::Model::BadRequest.new("Bad request - missing required parameters. Client sent: #{request_body} which produced #{params.inspect}")  if params.has_value?(nil)
-    context.driver.create_address(context.credentials, params)
-  end
-
-  def self.delete!(id, context)
-    context.driver.delete_address(context.credentials, id)
-  end
-
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/address_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/address_collection.rb b/server/lib/cimi/model/address_collection.rb
deleted file mode 100644
index eef6c51..0000000
--- a/server/lib/cimi/model/address_collection.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# 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::AddressCollection < CIMI::Model::Base
-
-  act_as_root_entity :address
-
-  array :addresses do
-    scalar :href
-  end
-
-  def self.default(context)
-    self.new(
-      :id => context.addresses_url,
-      :name => 'default',
-      :created => Time.now,
-      :description => "#{context.driver.name.capitalize} AddressCollection",
-      :addresses => CIMI::Model::Address.all(context).map { |addr| { :href => addr.id } }
-    )
-  end
-
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/address_template.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/address_template.rb b/server/lib/cimi/model/address_template.rb
deleted file mode 100644
index 9d2c409..0000000
--- a/server/lib/cimi/model/address_template.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-# 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::AddressTemplate < CIMI::Model::Base
-
-  text :ip
-
-  text :hostname
-
-  text :allocation
-
-  text :default_gateway
-
-  text :dns
-
-  text :mac_address
-
-  text :protocol
-
-  text :mask
-
-  href :network
-
-  array :operations do
-    scalar :rel, :href
-  end
-
-  def self.find(id, context)
-    if id==:all
-      context.driver.address_templates(context.credentials, {:env=>context})
-    else
-      context.driver.address_templates(context.credentials, {:id=>id, :env=>context})
-    end
-  end
-
-  def self.create(request_body, context, type)
-  end
-
-  def self.delete!(id, context)
-  end
-
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/address_template_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/address_template_collection.rb b/server/lib/cimi/model/address_template_collection.rb
deleted file mode 100644
index e973252..0000000
--- a/server/lib/cimi/model/address_template_collection.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# 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::AddressTemplateCollection < CIMI::Model::Base
-
-  act_as_root_entity :address_template
-
-  array :address_templates do
-    scalar :href
-  end
-
-  def self.default(context)
-    self.new(
-      :id => context.address_templates_url,
-      :name => 'default',
-      :created => Time.now,
-      :description => "#{context.driver.name.capitalize} AddressTemplateCollection",
-      :address_templates => AddressTemplate.all(context).map { |addr| { :href => addr.id } }
-    )
-  end
-
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/base.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/base.rb b/server/lib/cimi/model/base.rb
deleted file mode 100644
index 16812ac..0000000
--- a/server/lib/cimi/model/base.rb
+++ /dev/null
@@ -1,249 +0,0 @@
-# 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.
-
-require 'xmlsimple'
-require 'json'
-
-# The base class for any CIMI object that we either read from a request or
-# write as a response. This class handles serializing/deserializing XML and
-# JSON into a common form.
-#
-# == Defining the schema
-#
-# The conversion of XML and JSON into internal objects is based on a schema
-# that is defined through a DSL:
-#
-#   class Machine < CIMI::Model::Base
-#     text :status
-#     href :meter
-#     array :volumes do
-#       scalar :href, :attachment_point, :protocol
-#     end
-#   end
-#
-# The DSL automatically takes care of converting identifiers from their
-# underscored form to the camel-cased form used by CIMI. The above class
-# can be used in the following way:
-#
-#   machine = Machine.from_xml(some_xml)
-#   if machine.status == "UP"
-#     ...
-#   end
-#   sda = machine.volumes.find { |v| v.attachment_point == "/dev/sda" }
-#   handle_meter(machine.meter.href)
-#
-# The keywords for the DSL are
-#   [scalar(names, ...)]
-#     Define a scalar attribute; in JSON, this is represented as a string
-#     property. In XML, this can be represented in a number of ways,
-#     depending on whether the option :text is set:
-#       * :text not set: attribute on the enclosing element
-#       * :text == :direct: the text content of the enclosing element
-#       * :text == :nested: the text content of an element +<name>...</name>+
-#   [text(names)]
-#     A shorthand for +scalar(names, :text => :nested)+, i.e., for
-#     attributes that in XML are represented by their own tags
-#   [href(name)]
-#     A shorthand for +struct name { scalar :href }+; in JSON, this is
-#     represented as +{ name: { "href": string } }+, and in XML as +<name
-#     href="..."/>+
-#   [struct(name, opts, &block)]
-#     A structured subobject; the block defines the schema of the
-#     subobject. The +:content+ option can be used to specify the attribute
-#     that should receive the content of hte corresponding XML element
-#   [array(name, opts, &block)]
-#     An array of structured subobjects; the block defines the schema of
-#     the subobjects.
-
-module CIMI::Model
-
-  def self.register_as_root_entity!(name)
-    @root_entities ||= []
-    @root_entities << name
-    unless CIMI::Model::CloudEntryPoint.href_defined?(name)
-      CIMI::Model::CloudEntryPoint.send(:href, name.underscore)
-    end
-  end
-
-  def self.root_entities
-    @root_entities || []
-  end
-
-end
-
-class CIMI::Model::Base
-
-  #
-  # We keep the values of the attributes in a hash
-  #
-  attr_reader :attribute_values
-
-  # Keep the list of all attributes in an array +attributes+; for each
-  # attribute, we also define a getter and a setter to access/change the
-  # value for that attribute
-  class << self
-    def base_schema
-      @schema ||= CIMI::Model::Schema.new
-    end
-
-    def clone_base_schema
-      @schema_duped = true
-      @schema = Marshal::load(Marshal.dump(superclass.base_schema))
-    end
-
-    def base_schema_cloned?
-      @schema_duped
-    end
-
-    private :'clone_base_schema', :'base_schema_cloned?'
-
-    def inherited(child)
-      child.instance_eval do
-        def schema
-          base_schema_cloned? ? @schema : clone_base_schema
-        end
-      end
-    end
-
-    def add_attributes!(names, attr_klass, &block)
-      if self.respond_to? :schema
-        schema.add_attributes!(names, attr_klass, &block)
-      else
-        base_schema.add_attributes!(names, attr_klass, &block)
-      end
-      names.each do |name|
-        define_method(name) { @attribute_values[name] }
-        define_method(:"#{name}=") { |newval| @attribute_values[name] = newval }
-      end
-    end
-
-    # Return Array of links to current CIMI object
-    def all_uri(context)
-      self.all(context).map { |e| { :href => e.id } }
-    end
-  end
-
-  extend CIMI::Model::Schema::DSL
-
-  def [](a)
-    @attribute_values[a]
-  end
-
-  def []=(a, v)
-    @attribute_values[a] = v
-  end
-
-  #
-  # Factory methods
-  #
-  def initialize(values = {})
-    @attribute_values = values
-  end
-
-  # Construct a new object from the XML representation +xml+
-  def self.from_xml(text)
-    xml = XmlSimple.xml_in(text, :force_content => true)
-    model = self.new
-    @schema.from_xml(xml, model)
-    model
-  end
-
-  # Construct a new object
-  def self.from_json(text)
-    json = JSON::parse(text)
-    model = self.new
-    @schema.from_json(json, model)
-    model
-  end
-
-  #
-  # Serialize
-  #
-
-  def self.xml_tag_name
-    self.name.split("::").last
-  end
-
-  def self.to_json(model)
-    JSON::unparse(@schema.to_json(model))
-  end
-
-  def self.to_xml(model)
-    xml = @schema.to_xml(model)
-    xml["xmlns"] = "http://www.dmtf.org/cimi"
-    XmlSimple.xml_out(xml, :root_name => xml_tag_name)
-  end
-
-  def to_json
-    self.class.to_json(self)
-  end
-
-  def to_xml
-    self.class.to_xml(self)
-  end
-
-  #
-  # Common attributes for all resources
-  #
-  text :id, :name, :description, :created
-
-  # FIXME: this doesn't match with JSON
-  hash :property, :content => :value do
-    scalar :name
-  end
-
-  def self.act_as_root_entity(name=nil)
-    if name
-      name = name.to_s.camelize.pluralize
-    else
-      name = xml_tag_name.pluralize.uncapitalize
-    end
-    CIMI::Model.register_as_root_entity! name
-  end
-
-  def self.all(_self); find(:all, _self); end
-
-  def filter_by(filter_opts)
-    return self if filter_opts.nil?
-    return filter_attributes(filter_opts.split(',').map{ |a| a.intern }) if filter_opts.include? ','
-    case filter_opts
-      when /^([\w\_]+)$/ then filter_attributes([$1.intern])
-      when /^([\w\_]+)\[(\d+\-\d+)\]$/ then filter_by_arr_range($1.intern, $2)
-      when /^([\w\_]+)\[(\d+)\]$/ then filter_by_arr_index($1.intern, $2)
-      else self
-    end
-  end
-
-  private
-
-  def filter_attributes(attr_list)
-    attrs = attr_list.inject({}) do |result, attr|
-      result[attr] = self.send(attr) if self.respond_to?(attr)
-      result
-    end
-    self.class.new(attrs)
-  end
-
-  def filter_by_arr_index(attr, filter)
-    return self unless self.respond_to?(attr)
-    self.class.new(attr => [self.send(attr)[filter.to_i]])
-  end
-
-  def filter_by_arr_range(attr, filter)
-    return self unless self.respond_to?(attr)
-    filter = filter.split('-').inject { |s,e| s.to_i..e.to_i }
-    self.class.new(attr => self.send(attr)[filter])
-  end
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/cloud_entry_point.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/cloud_entry_point.rb b/server/lib/cimi/model/cloud_entry_point.rb
deleted file mode 100644
index 5db94df..0000000
--- a/server/lib/cimi/model/cloud_entry_point.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# 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
-
-  array :entity_metadata do
-    scalar :href
-  end
-
-  def self.create(context)
-    self.new(entities(context).merge({
-      :name => context.driver.name,
-      :description => "Cloud Entry Point for the Deltacloud #{context.driver.name} driver",
-      :id => context.cloudEntryPoint_url,
-      :created => Time.now,
-      :entity_metadata => EntityMetadata.all_uri(context)
-    }))
-  end
-
-  # Return an Hash of the CIMI root entities used in CloudEntryPoint
-  def self.entities(context)
-    CIMI::Model.root_entities.inject({}) do |result, entity|
-      if context.respond_to? :"#{entity.underscore}_url"
-        result[entity.underscore] = { :href => context.send(:"#{entity.underscore}_url") }
-      end
-      result
-    end
-  end
-
-  private
-
-  def self.href_defined?(entity)
-    true if schema.attribute_names.include? entity.underscore
-  end
-
-end


Mime
View raw message