You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2012/09/25 01:52:48 UTC
[7/10] git commit: CIMI models: declare acts_as_root_entity on the
model itself
CIMI models: declare acts_as_root_entity on the model itself
That way, we do not need to have lots of explicit collection classes. The
acts_as_root_entity' generates the collection class.
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/302f67e8
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/302f67e8
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/302f67e8
Branch: refs/heads/master
Commit: 302f67e8962b1adb31691ad0f45c6c7537e14b45
Parents: eeaf1c6
Author: David Lutterkort <lu...@redhat.com>
Authored: Thu Sep 13 10:12:31 2012 -0700
Committer: David Lutterkort <lu...@redhat.com>
Committed: Mon Sep 24 16:33:40 2012 -0700
----------------------------------------------------------------------
server/lib/cimi/collections/address_templates.rb | 2 +-
server/lib/cimi/collections/addresses.rb | 2 +-
server/lib/cimi/collections/machine_admins.rb | 2 +-
.../lib/cimi/collections/machine_configurations.rb | 2 +-
server/lib/cimi/collections/machine_images.rb | 2 +-
server/lib/cimi/collections/machines.rb | 2 +-
.../lib/cimi/collections/network_configurations.rb | 2 +-
.../collections/network_port_configurations.rb | 2 +-
.../lib/cimi/collections/network_port_templates.rb | 2 +-
server/lib/cimi/collections/network_ports.rb | 2 +-
server/lib/cimi/collections/network_templates.rb | 2 +-
server/lib/cimi/collections/networks.rb | 2 +-
.../cimi/collections/routing_group_templates.rb | 2 +-
server/lib/cimi/collections/routing_groups.rb | 2 +-
.../lib/cimi/collections/volume_configurations.rb | 2 +-
server/lib/cimi/collections/volume_images.rb | 2 +-
server/lib/cimi/collections/volumes.rb | 2 +-
server/lib/cimi/models.rb | 22 +---
server/lib/cimi/models/address.rb | 2 +
server/lib/cimi/models/address_collection.rb | 34 -----
server/lib/cimi/models/address_template.rb | 2 +
.../lib/cimi/models/address_template_collection.rb | 34 -----
server/lib/cimi/models/base.rb | 2 +-
server/lib/cimi/models/collection.rb | 99 +++++++++++++++
.../lib/cimi/models/entity_metadata_collection.rb | 31 -----
server/lib/cimi/models/machine.rb | 2 +
server/lib/cimi/models/machine_admin.rb | 2 +
server/lib/cimi/models/machine_admin_collection.rb | 34 -----
server/lib/cimi/models/machine_collection.rb | 37 ------
server/lib/cimi/models/machine_configuration.rb | 2 +
.../models/machine_configuration_collection.rb | 34 -----
server/lib/cimi/models/machine_image.rb | 2 +
server/lib/cimi/models/machine_image_collection.rb | 36 ------
server/lib/cimi/models/machine_template.rb | 2 +
.../lib/cimi/models/machine_template_collection.rb | 34 -----
server/lib/cimi/models/network.rb | 2 +
server/lib/cimi/models/network_collection.rb | 35 -----
server/lib/cimi/models/network_configuration.rb | 2 +
.../models/network_configuration_collection.rb | 38 ------
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 +
.../lib/cimi/models/network_template_collection.rb | 38 ------
server/lib/cimi/models/routing_group.rb | 2 +
server/lib/cimi/models/routing_group_collection.rb | 34 -----
server/lib/cimi/models/routing_group_template.rb | 2 +
.../models/routing_group_template_collection.rb | 35 -----
server/lib/cimi/models/schema.rb | 21 +++-
server/lib/cimi/models/volume.rb | 2 +
server/lib/cimi/models/volume_collection.rb | 36 ------
server/lib/cimi/models/volume_configuration.rb | 2 +
.../cimi/models/volume_configuration_collection.rb | 36 ------
server/lib/cimi/models/volume_image.rb | 2 +
server/lib/cimi/models/volume_image_collection.rb | 36 ------
server/lib/cimi/models/volume_template.rb | 2 +
.../lib/cimi/models/volume_template_collection.rb | 36 ------
.../tests/cimi/collections/machine_images_test.rb | 2 +-
58 files changed, 176 insertions(+), 640 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/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
index 809fc82..42cd82d 100644
--- a/server/lib/cimi/collections/address_templates.rb
+++ b/server/lib/cimi/collections/address_templates.rb
@@ -24,7 +24,7 @@ module CIMI::Collections
description 'List all AddressTemplates in the AddressTemplateCollection'
param :CIMISelect, :string, :optional
control do
- address_templates = AddressTemplateCollection.default(self).filter_by(params[:CIMISelect])
+ address_templates = AddressTemplate.list(self).filter_by(params[:CIMISelect])
respond_to do |format|
format.xml {address_templates.to_xml}
format.json {address_templates.to_json}
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/collections/addresses.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/addresses.rb b/server/lib/cimi/collections/addresses.rb
index ca2959e..c3d3239 100644
--- a/server/lib/cimi/collections/addresses.rb
+++ b/server/lib/cimi/collections/addresses.rb
@@ -26,7 +26,7 @@ module CIMI::Collections
description 'List all Addresses in the AddressCollection'
param :CIMISelect, :string, :optional
control do
- addresses = AddressCollection.default(self).filter_by(params[:CIMISelect])
+ addresses = Address.find(self).filter_by(params[:CIMISelect])
respond_to do |format|
format.xml {addresses.to_xml}
format.json {addresses.to_json}
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/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
index d2cf3b4..e6bac61 100644
--- a/server/lib/cimi/collections/machine_admins.rb
+++ b/server/lib/cimi/collections/machine_admins.rb
@@ -25,7 +25,7 @@ module CIMI::Collections
description "List all machine admins"
param :CIMISelect, :string, :optional
control do
- machine_admins = MachineAdminCollection.default(self).filter_by(params[:CIMISelect])
+ machine_admins = MachineAdmin.list(self).filter_by(params[:CIMISelect])
respond_to do |format|
format.xml { machine_admins.to_xml }
format.json { machine_admins.to_json }
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/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
index e24d1aa..30471ac 100644
--- a/server/lib/cimi/collections/machine_configurations.rb
+++ b/server/lib/cimi/collections/machine_configurations.rb
@@ -25,7 +25,7 @@ module CIMI::Collections
param :CIMISelect, :string, :optional
description "List all machine configurations"
control do
- machine_configs = MachineConfigurationCollection.default(self).filter_by(params[:CIMISelect])
+ machine_configs = MachineConfiguration.list(self).filter_by(params[:CIMISelect])
respond_to do |format|
format.xml { machine_configs.to_xml }
format.json { machine_configs.to_json }
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/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
index f43fe9b..1fb81e2 100644
--- a/server/lib/cimi/collections/machine_images.rb
+++ b/server/lib/cimi/collections/machine_images.rb
@@ -25,7 +25,7 @@ module CIMI::Collections
description "List all machine configurations"
param :CIMISelect, :string, :optional
control do
- machine_images = MachineImageCollection.default(self).filter_by(params[:CIMISelect])
+ machine_images = MachineImage.list(self).filter_by(params[:CIMISelect])
respond_to do |format|
format.xml { machine_images.to_xml }
format.json { machine_images.to_json }
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/collections/machines.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/machines.rb b/server/lib/cimi/collections/machines.rb
index 74a31dc..92bee1a 100644
--- a/server/lib/cimi/collections/machines.rb
+++ b/server/lib/cimi/collections/machines.rb
@@ -25,7 +25,7 @@ module CIMI::Collections
param :CIMISelect, :string, :optional
description "List all machines"
control do
- machines = MachineCollection.default(self).filter_by(params[:CIMISelect])
+ machines = Machine.list(self).filter_by(params[:CIMISelect])
respond_to do |format|
format.xml { machines.to_xml }
format.json { machines.to_json }
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/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
index cab28ca..5fb1d3d 100644
--- a/server/lib/cimi/collections/network_configurations.rb
+++ b/server/lib/cimi/collections/network_configurations.rb
@@ -24,7 +24,7 @@ module CIMI::Collections
description 'List all NetworkConfigurations'
param :CIMISelect, :string, :optional
control do
- network_configurations = NetworkConfigurationCollection.default(self).filter_by(params[:CIMISelect])
+ network_configurations = NetworkConfiguration.list(self).filter_by(params[:CIMISelect])
respond_to do |format|
format.xml { network_configurations.to_xml }
format.json { network_configurations.to_json }
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/collections/network_port_configurations.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/network_port_configurations.rb b/server/lib/cimi/collections/network_port_configurations.rb
index 8a1c17d..5848134 100644
--- a/server/lib/cimi/collections/network_port_configurations.rb
+++ b/server/lib/cimi/collections/network_port_configurations.rb
@@ -24,7 +24,7 @@ module CIMI::Collections
description 'List all NetworkPortConfigurations in the NetworkPortConfigurationCollection'
param :CIMISelect, :string, :optional
control do
- net_port_configs = NetworkPortConfigurationCollection.default(self).filter_by(params[:CIMISelect])
+ net_port_configs = NetworkPortConfiguration.list(self).filter_by(params[:CIMISelect])
respond_to do |format|
format.xml {net_port_configs.to_xml}
format.json {net_port_configs.to_json}
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/collections/network_port_templates.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/network_port_templates.rb b/server/lib/cimi/collections/network_port_templates.rb
index 1995e56..f588813 100644
--- a/server/lib/cimi/collections/network_port_templates.rb
+++ b/server/lib/cimi/collections/network_port_templates.rb
@@ -26,7 +26,7 @@ module CIMI::Collections
description 'List all NetworkPortTemplates in the NetworkPortTemplateCollection'
param :CIMISelect, :string, :optional
control do
- network_port_templates = NetworkPortTemplateCollection.default(self).filter_by(params[:CIMISelect])
+ network_port_templates = NetworkPortTemplate.list(self).filter_by(params[:CIMISelect])
respond_to do |format|
format.xml {network_port_templates.to_xml}
format.json {network_port_templates.to_json}
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/collections/network_ports.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/network_ports.rb b/server/lib/cimi/collections/network_ports.rb
index ef6e240..ec46bb4 100644
--- a/server/lib/cimi/collections/network_ports.rb
+++ b/server/lib/cimi/collections/network_ports.rb
@@ -26,7 +26,7 @@ module CIMI::Collections
description 'List all NetworkPorts in the NetworkPortCollection'
param :CIMISelect, :string, :optional
control do
- network_ports = NetworkPortCollection.default(self).filter_by(params[:CIMISelect])
+ network_ports = NetworkPort.list(self).filter_by(params[:CIMISelect])
respond_to do |format|
format.xml {network_ports.to_xml}
format.json {network_ports.to_json}
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/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
index 9fff8ff..3aae129 100644
--- a/server/lib/cimi/collections/network_templates.rb
+++ b/server/lib/cimi/collections/network_templates.rb
@@ -24,7 +24,7 @@ module CIMI::Collections
description 'List all Network Templates in the NetworkTemplateCollection'
param :CIMISelect, :string, :optional
control do
- network_templates = NetworkTemplateCollection.default(self).filter_by(params[:CIMISelect])
+ network_templates = NetworkTemplate.list(self).filter_by(params[:CIMISelect])
respond_to do |format|
format.xml {network_templates.to_xml}
format.json {network_templates.to_json}
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/collections/networks.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/networks.rb b/server/lib/cimi/collections/networks.rb
index c11e188..b399ae8 100644
--- a/server/lib/cimi/collections/networks.rb
+++ b/server/lib/cimi/collections/networks.rb
@@ -25,7 +25,7 @@ module CIMI::Collections
description "List all Networks"
param :CIMISelect, :string, :optional
control do
- networks = NetworkCollection.default(self).filter_by(params[:CIMISelect])
+ networks = Network.list(self).filter_by(params[:CIMISelect])
respond_to do |format|
format.xml { networks.to_xml }
format.json { networks.to_json }
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/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
index d320d28..464b262 100644
--- a/server/lib/cimi/collections/routing_group_templates.rb
+++ b/server/lib/cimi/collections/routing_group_templates.rb
@@ -24,7 +24,7 @@ module CIMI::Collections
description 'List all RoutingGroupTemplates in the RoutingGroupTemplateCollection'
param :CIMISelect, :string, :optional
control do
- routing_group_templates = RoutingGroupTemplateCollection.default(self).filter_by(params[:CIMISelect])
+ routing_group_templates = RoutingGroupTemplate.list(self).filter_by(params[:CIMISelect])
respond_to do |format|
format.xml {routing_group_templates.to_xml}
format.json {routing_group_templates.to_json}
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/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
index 751290c..52a1fcf 100644
--- a/server/lib/cimi/collections/routing_groups.rb
+++ b/server/lib/cimi/collections/routing_groups.rb
@@ -24,7 +24,7 @@ module CIMI::Collections
description 'List all RoutingGroups in the RoutingGroupsCollection'
param :CIMISelect, :string, :optional
control do
- routing_groups = RoutingGroupCollection.default(self).filter_by(params[:CIMISelect])
+ routing_groups = RoutingGroup.list(self).filter_by(params[:CIMISelect])
respond_to do |format|
format.xml {routing_groups.to_xml}
format.json {routing_groups.to_json}
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/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
index 0887462..7195570 100644
--- a/server/lib/cimi/collections/volume_configurations.rb
+++ b/server/lib/cimi/collections/volume_configurations.rb
@@ -24,7 +24,7 @@ module CIMI::Collections
description "Get list all VolumeConfigurations"
param :CIMISelect, :string, :optional
control do
- volume_configuration = VolumeConfigurationCollection.default(self).filter_by(params[:CIMISelect])
+ volume_configuration = VolumeConfiguration.list(self).filter_by(params[:CIMISelect])
respond_to do |format|
format.xml { volume_configuration.to_xml }
format.json { volume_configuration.to_json }
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/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
index 64db9ae..77040b4 100644
--- a/server/lib/cimi/collections/volume_images.rb
+++ b/server/lib/cimi/collections/volume_images.rb
@@ -25,7 +25,7 @@ module CIMI::Collections
description "List all volumes images"
param :CIMISelect, :string, :optional
control do
- volume_images = VolumeImageCollection.default(self).filter_by(params[:CIMISelect])
+ volume_images = VolumeImage.list(self).filter_by(params[:CIMISelect])
respond_to do |format|
format.xml { volume_images.to_xml }
format.json { volume_images.to_json }
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/collections/volumes.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/volumes.rb b/server/lib/cimi/collections/volumes.rb
index 80350de..9e7041c 100644
--- a/server/lib/cimi/collections/volumes.rb
+++ b/server/lib/cimi/collections/volumes.rb
@@ -24,7 +24,7 @@ module CIMI::Collections
description "List all volumes"
param :CIMISelect, :string, :optional
control do
- volumes = VolumeCollection.default(self).filter_by(params[:CIMISelect])
+ volumes = Volume.list(self).filter_by(params[:CIMISelect])
respond_to do |format|
format.xml { volumes.to_xml }
format.json { volumes.to_json }
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models.rb b/server/lib/cimi/models.rb
index 333f5bd..5b01e49 100644
--- a/server/lib/cimi/models.rb
+++ b/server/lib/cimi/models.rb
@@ -21,6 +21,7 @@ require 'require_relative' if RUBY_VERSION < '1.9'
require_relative './models/schema'
require_relative './models/base'
+require_relative './models/collection'
require_relative './models/errors'
require_relative './models/entity_metadata'
require_relative './models/entity_metadata_collection'
@@ -35,35 +36,16 @@ require_relative './models/machine_admin'
require_relative './models/volume_configuration'
require_relative './models/volume_image'
require_relative './models/volume_template'
-require_relative './models/machine_template_collection'
-require_relative './models/machine_image_collection'
-require_relative './models/machine_configuration_collection'
-require_relative './models/machine_collection'
-require_relative './models/volume_collection'
-require_relative './models/machine_admin_collection'
-require_relative './models/volume_configuration_collection'
-require_relative './models/volume_image_collection'
-require_relative './models/volume_template_collection'
require_relative './models/network'
-require_relative './models/network_collection'
require_relative './models/network_configuration'
-require_relative './models/network_configuration_collection'
require_relative './models/network_template'
-require_relative './models/network_template_collection'
require_relative './models/routing_group'
-require_relative './models/routing_group_collection'
require_relative './models/routing_group_template'
-require_relative './models/routing_group_template_collection'
require_relative './models/network_port'
-require_relative './models/network_port_collection'
-require_relative './models/network_port_configuration'
-require_relative './models/network_port_configuration_collection'
require_relative './models/network_port_template'
-require_relative './models/network_port_template_collection'
+require_relative './models/network_port_configuration'
require_relative './models/address'
-require_relative './models/address_collection'
require_relative './models/address_template'
-require_relative './models/address_template_collection'
require_relative './models/disk'
require_relative './models/disk_collection'
require_relative './models/machine_volume'
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/address.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/address.rb b/server/lib/cimi/models/address.rb
index f9e10a1..1704933 100644
--- a/server/lib/cimi/models/address.rb
+++ b/server/lib/cimi/models/address.rb
@@ -15,6 +15,8 @@
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/302f67e8/server/lib/cimi/models/address_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/address_collection.rb b/server/lib/cimi/models/address_collection.rb
deleted file mode 100644
index eef6c51..0000000
--- a/server/lib/cimi/models/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/302f67e8/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 9d2c409..9d7c36b 100644
--- a/server/lib/cimi/models/address_template.rb
+++ b/server/lib/cimi/models/address_template.rb
@@ -15,6 +15,8 @@
class CIMI::Model::AddressTemplate < CIMI::Model::Base
+ acts_as_root_entity
+
text :ip
text :hostname
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/address_template_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/address_template_collection.rb b/server/lib/cimi/models/address_template_collection.rb
deleted file mode 100644
index 3bb95cd..0000000
--- a/server/lib/cimi/models/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 => CIMI::Model::AddressTemplate.all(context).map { |addr| { :href => addr.id } }
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/base.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/base.rb b/server/lib/cimi/models/base.rb
index b627b82..92ad07b 100644
--- a/server/lib/cimi/models/base.rb
+++ b/server/lib/cimi/models/base.rb
@@ -225,7 +225,7 @@ class CIMI::Model::Base
hash :property
- def self.act_as_root_entity(name=nil)
+ def self.acts_as_root_entity(name=nil)
if name
name = name.to_s.camelize.pluralize
else
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/collection.rb b/server/lib/cimi/models/collection.rb
new file mode 100644
index 0000000..a6e1e36
--- /dev/null
+++ b/server/lib/cimi/models/collection.rb
@@ -0,0 +1,99 @@
+# 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::Model
+ class Collection < Base
+
+ class << self
+ attr_accessor :entry_name
+ end
+
+ # Make sure the base schema gets cloned
+ self.schema
+
+ def initialize(values = {})
+ if values[:entries]
+ values[self.class.entry_name] = values.delete(:entries)
+ end
+ super(values)
+ end
+
+ def entries
+ self[entry_name]
+ end
+
+ def [](a)
+ a = entry_name if a == :entries
+ super(a)
+ end
+
+ def []=(a, v)
+ a = entry_name if a == :entries
+ super(a, v)
+ end
+
+ def self.xml_tag_name
+ "Collection"
+ end
+
+ def self.generate(model_class)
+ model_name = model_class.name.split("::").last
+ coll_class = Class.new(CIMI::Model::Collection)
+ CIMI::Model.const_set(:"#{model_name}Collection", coll_class)
+ coll_class.entry_name = model_name.underscore.pluralize.to_sym
+ entry_schema = model_class.schema
+ coll_class.instance_eval do
+ text :count
+ array self.entry_name, :schema => entry_schema, :xml_name => model_name
+ array :operations do
+ scalar :rel, :href
+ end
+ end
+ coll_class
+ end
+ end
+
+ #
+ # We need to reopen Base and add some stuff to avoid circular dependencies
+ #
+ class Base
+ #
+ # Toplevel collections
+ #
+
+ class << self
+
+ attr_accessor :collection_class
+
+ def acts_as_root_entity
+ self.collection_class = Collection.generate(self)
+ CIMI::Model.register_as_root_entity! collection_class.entry_name.to_s.camelize
+ end
+
+ # Return a collection of entities
+ def list(context)
+ entries = find(:all, context)
+ desc = "#{self.name.split("::").last} Collection for the #{context.driver.name.capitalize} driver"
+ collection_class.new(:count => entries.size,
+ :entries => entries,
+ :description => desc)
+ end
+ end
+
+ def self.all(context)
+ find(:all, context)
+ end
+ end
+end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/entity_metadata_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/entity_metadata_collection.rb b/server/lib/cimi/models/entity_metadata_collection.rb
deleted file mode 100644
index 595b502..0000000
--- a/server/lib/cimi/models/entity_metadata_collection.rb
+++ /dev/null
@@ -1,31 +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::EntityMetadataCollection < CIMI::Model::Base
-
- array :entity_metadata do
- scalar :href
- end
-
- def self.default(context)
- self.new(
- :id => context.entity_metadata_url,
- :name => 'default',
- :created => Time.now,
- :entity_metadata => CIMI::Model::EntityMetadata.all_uri(context)
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/machine.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/machine.rb b/server/lib/cimi/models/machine.rb
index 7cc659a..a5d3302 100644
--- a/server/lib/cimi/models/machine.rb
+++ b/server/lib/cimi/models/machine.rb
@@ -15,6 +15,8 @@
class CIMI::Model::Machine < CIMI::Model::Base
+ acts_as_root_entity
+
text :state
text :cpu
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/machine_admin.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/machine_admin.rb b/server/lib/cimi/models/machine_admin.rb
index 6cf4462..fd435a1 100644
--- a/server/lib/cimi/models/machine_admin.rb
+++ b/server/lib/cimi/models/machine_admin.rb
@@ -15,6 +15,8 @@
class CIMI::Model::MachineAdmin < CIMI::Model::Base
+ acts_as_root_entity
+
text :username
text :password
text :key
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/machine_admin_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/machine_admin_collection.rb b/server/lib/cimi/models/machine_admin_collection.rb
deleted file mode 100644
index 08c1559..0000000
--- a/server/lib/cimi/models/machine_admin_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::MachineAdminCollection < CIMI::Model::Base
-
- act_as_root_entity :machine_admin
-
- array :machine_admins do
- scalar :href
- end
-
- def self.default(context)
- self.new(
- :id => context.machine_admins_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} MachineAdminCollection",
- :machine_admins => CIMI::Model::MachineAdmin.all_uri(context)
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/machine_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/machine_collection.rb b/server/lib/cimi/models/machine_collection.rb
deleted file mode 100644
index 9c57301..0000000
--- a/server/lib/cimi/models/machine_collection.rb
+++ /dev/null
@@ -1,37 +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::MachineCollection < CIMI::Model::Base
-
- act_as_root_entity :machine
-
- text :count
-
- #add machines array:
- self << CIMI::Model::Machine
-
- def self.default(context)
- machines = CIMI::Model::Machine.all(context)
- self.new(
- :id => context.machines_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} MachineCollection",
- :count => machines.size,
- :machines => machines
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/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 6ea92dd..41a140c 100644
--- a/server/lib/cimi/models/machine_configuration.rb
+++ b/server/lib/cimi/models/machine_configuration.rb
@@ -15,6 +15,8 @@
class CIMI::Model::MachineConfiguration < CIMI::Model::Base
+ acts_as_root_entity
+
text :memory
text :cpu
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/machine_configuration_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/machine_configuration_collection.rb b/server/lib/cimi/models/machine_configuration_collection.rb
deleted file mode 100644
index 051e1b9..0000000
--- a/server/lib/cimi/models/machine_configuration_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::MachineConfigurationCollection < CIMI::Model::Base
-
- text :count
-
- self << CIMI::Model::MachineConfiguration
-
- def self.default(context)
- machine_configurations = CIMI::Model::MachineConfiguration.all(context)
- self.new(
- :id => context.machine_configurations_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} MachineConfigurationCollection",
- :count => machine_configurations.count,
- :machine_configurations => machine_configurations
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/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 7389475..eeaff0a 100644
--- a/server/lib/cimi/models/machine_image.rb
+++ b/server/lib/cimi/models/machine_image.rb
@@ -15,6 +15,8 @@
class CIMI::Model::MachineImage < CIMI::Model::Base
+ acts_as_root_entity
+
href :image_location
text :image_data
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/machine_image_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/machine_image_collection.rb b/server/lib/cimi/models/machine_image_collection.rb
deleted file mode 100644
index cd4b5b4..0000000
--- a/server/lib/cimi/models/machine_image_collection.rb
+++ /dev/null
@@ -1,36 +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::MachineImageCollection < CIMI::Model::Base
-
- act_as_root_entity :machine_image
-
- text :count
-
- self << CIMI::Model::MachineImage
-
- def self.default(context)
- machine_images = CIMI::Model::MachineImage.all(context)
- self.new(
- :id => context.machine_images_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} MachineImageCollection",
- :count => machine_images.count,
- :machine_images => machine_images
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/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 8a88052..b09cc40 100644
--- a/server/lib/cimi/models/machine_template.rb
+++ b/server/lib/cimi/models/machine_template.rb
@@ -15,6 +15,8 @@
class CIMI::Model::MachineTemplate < CIMI::Model::Base
+ acts_as_root_entity
+
href :machine_config
href :machine_image
href :machine_admin
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/machine_template_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/machine_template_collection.rb b/server/lib/cimi/models/machine_template_collection.rb
deleted file mode 100644
index 289c984..0000000
--- a/server/lib/cimi/models/machine_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::MachineTemplateCollection < CIMI::Model::Base
-
- text :count
-
- self << CIMI::Model::MachineTemplate
-
- def self.default(context)
- machine_templates = CIMI::Model::MachineTemplate.all(context)
- self.new(
- :id => context.machine_template_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} MachineTemplateCollection",
- :count => machine_templates.size,
- :machine_templates => machine_templates
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/network.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/network.rb b/server/lib/cimi/models/network.rb
index cc8e4df..4e783ea 100644
--- a/server/lib/cimi/models/network.rb
+++ b/server/lib/cimi/models/network.rb
@@ -15,6 +15,8 @@
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/302f67e8/server/lib/cimi/models/network_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/network_collection.rb b/server/lib/cimi/models/network_collection.rb
deleted file mode 100644
index 7c746b4..0000000
--- a/server/lib/cimi/models/network_collection.rb
+++ /dev/null
@@ -1,35 +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::NetworkCollection < CIMI::Model::Base
-
- act_as_root_entity :network
- text :count
-
- #add networks Array:
- self << CIMI::Model::Network
-
- def self.default(context)
- networks = CIMI::Model::Network.all(context)
- self.new(
- :id => context.networks_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} NetworkCollection",
- :count => networks.size,
- :networks => networks
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/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 479f5cb..007beb5 100644
--- a/server/lib/cimi/models/network_configuration.rb
+++ b/server/lib/cimi/models/network_configuration.rb
@@ -15,6 +15,8 @@
class CIMI::Model::NetworkConfiguration < CIMI::Model::Base
+ acts_as_root_entity
+
text :network_type
text :mtu
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/network_configuration_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/network_configuration_collection.rb b/server/lib/cimi/models/network_configuration_collection.rb
deleted file mode 100644
index edad20f..0000000
--- a/server/lib/cimi/models/network_configuration_collection.rb
+++ /dev/null
@@ -1,38 +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::NetworkConfigurationCollection < CIMI::Model::Base
-
- act_as_root_entity :network_configuration
-
- text :count
-
-#add members Array:
- self << CIMI::Model::NetworkConfiguration
-
-
- def self.default(context)
- network_configurations = CIMI::Model::NetworkConfiguration.all(context)
- self.new(
- :id => context.network_configurations_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} NetworkConfigurationCollection",
- :count => network_configurations.size,
- :network_configurations => network_configurations
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/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 92415ca..6905f5a 100644
--- a/server/lib/cimi/models/network_port.rb
+++ b/server/lib/cimi/models/network_port.rb
@@ -15,6 +15,8 @@
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/302f67e8/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 88f431a..1c3ae4f 100644
--- a/server/lib/cimi/models/network_port_configuration.rb
+++ b/server/lib/cimi/models/network_port_configuration.rb
@@ -15,6 +15,8 @@
class CIMI::Model::NetworkPortConfiguration < CIMI::Model::Base
+ acts_as_root_entity
+
text :class_of_service
text :port_type
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/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 8fb7ef1..774d6e9 100644
--- a/server/lib/cimi/models/network_port_template.rb
+++ b/server/lib/cimi/models/network_port_template.rb
@@ -15,6 +15,8 @@
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/302f67e8/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 edb0837..09eadd0 100644
--- a/server/lib/cimi/models/network_template.rb
+++ b/server/lib/cimi/models/network_template.rb
@@ -15,6 +15,8 @@
class CIMI::Model::NetworkTemplate < CIMI::Model::Base
+ acts_as_root_entity
+
href :network_config
href :forwarding_group
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/network_template_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/network_template_collection.rb b/server/lib/cimi/models/network_template_collection.rb
deleted file mode 100644
index adb3e7d..0000000
--- a/server/lib/cimi/models/network_template_collection.rb
+++ /dev/null
@@ -1,38 +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::NetworkTemplateCollection < CIMI::Model::Base
-
- act_as_root_entity :network_template
-
- text :count
-
- #add member array:
- self << CIMI::Model::NetworkTemplate
-
- def self.default(context)
- network_templates = CIMI::Model::NetworkTemplate.all(context)
- self.new(
- :id => context.network_templates_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} NetworkTemplateCollection",
- :count => network_templates.size,
- :network_templates => network_templates
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/routing_group.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/routing_group.rb b/server/lib/cimi/models/routing_group.rb
index d26f4d7..fd87607 100644
--- a/server/lib/cimi/models/routing_group.rb
+++ b/server/lib/cimi/models/routing_group.rb
@@ -15,6 +15,8 @@
class CIMI::Model::RoutingGroup < CIMI::Model::Base
+ acts_as_root_entity
+
array :networks do
scalar :href
end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/routing_group_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/routing_group_collection.rb b/server/lib/cimi/models/routing_group_collection.rb
deleted file mode 100644
index 285e164..0000000
--- a/server/lib/cimi/models/routing_group_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::RoutingGroupCollection < CIMI::Model::Base
-
- act_as_root_entity :routing_group
-
- array :routing_groups do
- scalar :href
- end
-
- def self.default(context)
- self.new(
- :id => context.routing_groups_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} RoutingGroupCollection",
- :routing_groups => CIMI::Model::RoutingGroup.all_uri(context)
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/routing_group_template.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/routing_group_template.rb b/server/lib/cimi/models/routing_group_template.rb
index 204a353..c673c9d 100644
--- a/server/lib/cimi/models/routing_group_template.rb
+++ b/server/lib/cimi/models/routing_group_template.rb
@@ -15,6 +15,8 @@
class CIMI::Model::RoutingGroupTemplate < CIMI::Model::Base
+ acts_as_root_entity
+
array :networks do
scalar :href
end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/routing_group_template_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/routing_group_template_collection.rb b/server/lib/cimi/models/routing_group_template_collection.rb
deleted file mode 100644
index 61a4a68..0000000
--- a/server/lib/cimi/models/routing_group_template_collection.rb
+++ /dev/null
@@ -1,35 +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::RoutingGroupTemplateCollection < CIMI::Model::Base
-
- act_as_root_entity :routing_group_template
-
- array :routing_group_templates do
- scalar :href
- end
-
- def self.default(context)
- self.new(
- :id => context.routing_group_templates_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} RoutingGroupTemplateCollection",
- :routing_group_templates => CIMI::Model::RoutingGroupTemplate.all_uri(context)
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/schema.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/schema.rb b/server/lib/cimi/models/schema.rb
index 03914b6..a02b5a6 100644
--- a/server/lib/cimi/models/schema.rb
+++ b/server/lib/cimi/models/schema.rb
@@ -87,9 +87,16 @@ class CIMI::Model::Schema
def initialize(name, opts, &block)
content = opts[:content]
super(name, opts)
- @schema = CIMI::Model::Schema.new
- @schema.instance_eval(&block) if block_given?
- @schema.scalar(content, :text => :direct) if content
+ if opts[:schema]
+ if block_given?
+ raise "Cannot provide :schema option and a block"
+ end
+ @schema = opts[:schema]
+ else
+ @schema = CIMI::Model::Schema.new
+ @schema.instance_eval(&block) if block_given?
+ @schema.scalar(content, :text => :direct) if content
+ end
end
def from_xml(xml, model)
@@ -282,6 +289,14 @@ class CIMI::Model::Schema
def hash(name)
add_attributes!([name, {}], Hash)
end
+
+ def collection(name, opts={})
+ text :count
+
+ array :operations do
+ scalar :rel, :href
+ end
+ end
end
include DSL
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/volume.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/volume.rb b/server/lib/cimi/models/volume.rb
index 111a4e5..8d32c66 100644
--- a/server/lib/cimi/models/volume.rb
+++ b/server/lib/cimi/models/volume.rb
@@ -15,6 +15,8 @@
class CIMI::Model::Volume < CIMI::Model::Base
+ acts_as_root_entity
+
struct :capacity do
scalar :quantity
scalar :units
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/volume_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/volume_collection.rb b/server/lib/cimi/models/volume_collection.rb
deleted file mode 100644
index e780845..0000000
--- a/server/lib/cimi/models/volume_collection.rb
+++ /dev/null
@@ -1,36 +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::VolumeCollection < CIMI::Model::Base
-
- act_as_root_entity :volume
-
- text :count
-
- self << CIMI::Model::Volume
-
- def self.default(context)
- volumes = CIMI::Model::Volume.all(context)
- self.new(
- :id => context.volumes_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} VolumeCollection",
- :count => volumes.count,
- :volumes => volumes
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/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 75b37ea..55f3d3a 100644
--- a/server/lib/cimi/models/volume_configuration.rb
+++ b/server/lib/cimi/models/volume_configuration.rb
@@ -15,6 +15,8 @@
class CIMI::Model::VolumeConfiguration < CIMI::Model::Base
+ acts_as_root_entity
+
text :format
struct :capacity do
scalar :quantity
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/volume_configuration_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/volume_configuration_collection.rb b/server/lib/cimi/models/volume_configuration_collection.rb
deleted file mode 100644
index d8ac229..0000000
--- a/server/lib/cimi/models/volume_configuration_collection.rb
+++ /dev/null
@@ -1,36 +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::VolumeConfigurationCollection < CIMI::Model::Base
-
- act_as_root_entity :volume_configuration
-
- text :count
-
- self << CIMI::Model::VolumeConfiguration
-
- def self.default(context)
- volume_configurations = CIMI::Model::VolumeConfiguration.all(context)
- self.new(
- :id => context.volume_configurations_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} VolumeConfigurationCollection",
- :count => volume_configurations.size,
- :volume_configurations => volume_configurations
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/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 ae72ea6..ff65ff5 100644
--- a/server/lib/cimi/models/volume_image.rb
+++ b/server/lib/cimi/models/volume_image.rb
@@ -15,6 +15,8 @@
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/302f67e8/server/lib/cimi/models/volume_image_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/volume_image_collection.rb b/server/lib/cimi/models/volume_image_collection.rb
deleted file mode 100644
index d411431..0000000
--- a/server/lib/cimi/models/volume_image_collection.rb
+++ /dev/null
@@ -1,36 +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::VolumeImageCollection < CIMI::Model::Base
-
- act_as_root_entity :volume_image
-
- text :count
-
- self << CIMI::Model::VolumeImage
-
- def self.default(context)
- volume_images = CIMI::Model::VolumeImage.all(context)
- self.new(
- :id => context.volume_images_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} VolumeImageCollection",
- :count => volume_images.count,
- :volume_images => volume_images
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/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 b9c82db..b2ac323 100644
--- a/server/lib/cimi/models/volume_template.rb
+++ b/server/lib/cimi/models/volume_template.rb
@@ -15,6 +15,8 @@
class CIMI::Model::VolumeTemplate < CIMI::Model::Base
+ acts_as_root_entity
+
href :volume_config
href :volume_image
array :operations do
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/lib/cimi/models/volume_template_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/volume_template_collection.rb b/server/lib/cimi/models/volume_template_collection.rb
deleted file mode 100644
index 90462a0..0000000
--- a/server/lib/cimi/models/volume_template_collection.rb
+++ /dev/null
@@ -1,36 +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::VolumeTemplateCollection < CIMI::Model::Base
-
- act_as_root_entity :volume_template
-
- text :count
-
- self << CIMI::Model::VolumeTemplate
-
- def self.default(context)
- volume_templates = CIMI::Model::VolumeTemplate.all(context)
- self.new(
- :id => context.volume_template_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} VolumeTemplateCollection",
- :count => volume_templates.size,
- :volume_templates => volume_templates
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/302f67e8/server/tests/cimi/collections/machine_images_test.rb
----------------------------------------------------------------------
diff --git a/server/tests/cimi/collections/machine_images_test.rb b/server/tests/cimi/collections/machine_images_test.rb
index d65212d..7a085f1 100644
--- a/server/tests/cimi/collections/machine_images_test.rb
+++ b/server/tests/cimi/collections/machine_images_test.rb
@@ -36,7 +36,7 @@ describe CIMI::Collections::MachineImages do
it 'should allow to filter using CIMISelect' do
get root_url '/machine_images?CIMISelect=description'
status.must_equal 200
- xml.root.name.must_equal 'MachineImageCollection'
+ xml.root.name.must_equal 'Collection'
(xml/'description').wont_be_empty
(xml/'id').must_be_empty
end