deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [45/50] [abbrv] 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
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/models/volume.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/volume.rb b/server/lib/cimi/models/volume.rb
new file mode 100644
index 0000000..9c106e2
--- /dev/null
+++ b/server/lib/cimi/models/volume.rb
@@ -0,0 +1,103 @@
+# 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::Volume < CIMI::Model::Base
+
+  struct :capacity do
+    scalar :quantity
+    scalar :units
+  end
+  text :bootable
+  text :supports_snapshots
+  array :snapshots do
+    scalar :ref
+  end
+  text :guest_interface
+  array :meters do
+    scalar :ref
+  end
+  href :eventlog
+  array :operations do
+    scalar :rel, :href
+  end
+
+  def self.find(id, context)
+    volumes = []
+    opts = ( id == :all ) ? {} : { :id => id }
+    volumes = context.driver.storage_volumes(context.credentials, opts)
+    volumes.collect!{ |volume| from_storage_volume(volume, context) }
+    return volumes.first unless volumes.length > 1
+    return volumes
+  end
+
+  def self.all(context); find(:all, context); end
+
+  def self.create_from_json(json_in, context)
+    json = JSON.parse(json_in)
+    volume_config_id = json["volumeTemplate"]["volumeConfig"]["href"].split("/").last
+    volume_image_id = (json["volumeTemplate"].has_key?("volumeImage") ?
+                json["volumeTemplate"]["volumeImage"]["href"].split("/").last  : nil)
+    create_volume({:volume_config_id=>volume_config_id, :volume_image_id=>volume_image_id}, context)
+  end
+
+  def self.create_from_xml(xml_in, context)
+    xml = XmlSimple.xml_in(xml_in)
+    volume_config_id = xml["volumeTemplate"][0]["volumeConfig"][0]["href"].split("/").last
+    volume_image_id = (xml["volumeTemplate"][0].has_key?("volumeImage") ?
+             xml["volumeTemplate"][0]["volumeImage"][0]["href"].split("/").last  : nil)
+    create_volume({:volume_config_id=>volume_config_id, :volume_image_id=>volume_image_id}, context)
+  end
+
+  def self.delete!(id, context)
+    context.driver.destroy_storage_volume(context.credentials, {:id=>id} )
+  end
+
+  def self.find_to_attach_from_json(json_in, context)
+    json = JSON.parse(json_in)
+    volumes = json["volumes"].map{|v| {:volume=>self.find(v["volume"]["href"].split("/volumes/").last, context),
+                                       :attachment_point=>v["attachmentPoint"]  }}
+  end
+
+  def self.find_to_attach_from_xml(xml_in, context)
+    xml = XmlSimple.xml_in(xml_in)
+    volumes = xml["volume"].map{|v| {:volume => self.find(v["href"].split("/volumes/").last, context),
+                                      :attachment_point=>v["attachmentPoint"] }}
+  end
+
+  private
+
+  def self.create_volume(params, context)
+    volume_config = CIMI::Model::VolumeConfiguration.find(params[:volume_config_id], context)
+    opts = {:capacity=>volume_config.capacity[:quantity], :snapshot_id=>params[:volume_image_id] }
+    storage_volume = self.driver.create_storage_volume(context.credentials, opts)
+    from_storage_volume(storage_volume, context)
+  end
+
+  def self.from_storage_volume(volume, context)
+    self.new( { :name => volume.id,
+                :description => volume.id,
+                :created => volume.created,
+                :id => context.volume_url(volume.id),
+                :capacity => { :quantity=>volume.capacity, :units=>"gibibyte"  }, #FIXME... units will vary
+                :bootable => "false", #fixme ... will vary... ec2 doesn't expose this
+                :supports_snapshots => "true", #fixme, will vary (true for ec2)
+                :snapshots => [], #fixme...
+                :guest_interface => "",
+                :eventlog => {:href=> "http://eventlogs"},#FIXME
+                :meters => []
+            } )
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/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
new file mode 100644
index 0000000..1f4152e
--- /dev/null
+++ b/server/lib/cimi/models/volume_collection.rb
@@ -0,0 +1,34 @@
+# 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
+
+  array :volumes do
+    scalar :href
+  end
+
+  def self.default(context)
+    self.new(
+      :id => context.volumes_url,
+      :name => 'default',
+      :created => Time.now,
+      :description => "#{context.driver.name.capitalize} VolumeCollection",
+      :volumes => CIMI::Model::Volume.all_uri(context)
+    )
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/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
new file mode 100644
index 0000000..75b37ea
--- /dev/null
+++ b/server/lib/cimi/models/volume_configuration.rb
@@ -0,0 +1,60 @@
+# 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::VolumeConfiguration < CIMI::Model::Base
+
+  text :format
+  struct :capacity do
+    scalar :quantity
+    scalar :units
+  end
+  text :supports_snapshots
+  text :guest_interface
+  array :operations do
+    scalar :rel, :href
+  end
+
+  def self.find(id, context)
+    volume_configs = []
+    if id == :all
+      #ec2 ebs volumes can 1gb..1tb
+      (1..1000).each do |size|
+        volume_configs << create(size, context)
+      end
+    else
+      volume_configs << create(id, context)
+      return volume_configs.first
+    end
+    return volume_configs
+  end
+
+
+  def self.all(context); find(:all, context); end
+
+  private
+
+  def self.create(size, context)
+    self.new( {
+                :id => context.volume_configuration_url(size),
+                :name => size,
+                :description => "volume configuration with #{size} GiB",
+                :created => Time.now.to_s,
+                :capacity => {:quantity=>size, :units=>"gibibytes"},
+                :supports_snapshots => "true"
+                # FIXME :guest_interface => "NFS"
+            } )
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/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
new file mode 100644
index 0000000..2120ae6
--- /dev/null
+++ b/server/lib/cimi/models/volume_configuration_collection.rb
@@ -0,0 +1,34 @@
+# 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
+
+  array :volume_configurations do
+    scalar :href
+  end
+
+  def self.default(context)
+    self.new(
+      :id => context.volume_configurations_url,
+      :name => 'default',
+      :created => Time.now,
+      :description => "#{context.driver.name.capitalize} VolumeConfigurationCollection",
+      :volume_configurations => CIMI::Model::VolumeConfiguration.all_uri(context)
+    )
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/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
new file mode 100644
index 0000000..03cc7fd
--- /dev/null
+++ b/server/lib/cimi/models/volume_image.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.
+
+class CIMI::Model::VolumeImage < CIMI::Model::Base
+
+  href :image_location
+  text :image_data
+  text :bootable
+  array :operations do
+    scalar :rel, :href
+  end
+
+  def self.find(id, context)
+    storage_snapshots = []
+    opts = ( id==:all  ) ? {}  : { :id=>id }
+    storage_snapshots = self.driver.storage_snapshots(context.credentials, opts)
+    storage_snapshots.collect!{ |snapshot| from_storage_snapshot(snapshot, context) }
+    return storage_snapshots.first unless storage_snapshots.length > 1
+    return storage_snapshots
+  end
+
+  def self.all(context); find(:all, context); end
+
+  private
+
+  def self.from_storage_snapshot(snapshot, context)
+    self.new( {
+               :name => snapshot.id,
+               :description => snapshot.id,
+               :created => snapshot.created,
+               :id => context.volume_image_url(snapshot.id),
+               :image_location => {:href=>context.volume_url(snapshot.storage_volume_id)},
+               :bootable => "false"  #FIXME
+            } )
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/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
new file mode 100644
index 0000000..f3da877
--- /dev/null
+++ b/server/lib/cimi/models/volume_image_collection.rb
@@ -0,0 +1,34 @@
+# 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
+
+  array :volume_images do
+    scalar :href
+  end
+
+  def self.default(context)
+    self.new(
+      :id => context.volume_images_url,
+      :name => 'default',
+      :created => Time.now,
+      :description => "#{context.driver.name.capitalize} VolumeImageCollection",
+      :volume_images => CIMI::Model::VolumeImage.all_uri(context)
+    )
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/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
new file mode 100644
index 0000000..b9c82db
--- /dev/null
+++ b/server/lib/cimi/models/volume_template.rb
@@ -0,0 +1,23 @@
+# 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::VolumeTemplate < CIMI::Model::Base
+
+  href :volume_config
+  href :volume_image
+  array :operations do
+    scalar :rel, :href
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/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
new file mode 100644
index 0000000..f53547c
--- /dev/null
+++ b/server/lib/cimi/models/volume_template_collection.rb
@@ -0,0 +1,34 @@
+# 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
+
+  array :volume_templates do
+    scalar :href
+  end
+
+  def self.default(context)
+    self.new(
+      :id => context.volume_template_url,
+      :name => 'default',
+      :created => Time.now,
+      :description => "#{context.driver.name.capitalize} VolumeTemplateCollection",
+      :volume_templates => CIMI::Model::VolumeTemplate.all_uri(context)
+    )
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/models/vsp.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/vsp.rb b/server/lib/cimi/models/vsp.rb
new file mode 100644
index 0000000..b8b27f5
--- /dev/null
+++ b/server/lib/cimi/models/vsp.rb
@@ -0,0 +1,102 @@
+# 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::VSP < CIMI::Model::Base
+
+  text :state
+
+  href :network
+
+  text :bandwidth_reservation
+
+  text :traffic_priority
+
+  text :max_traffic_delay
+
+  text :max_traffic_loss
+
+  text :max_traffic_jitter
+
+  href :event_log
+
+  array :meters do
+    scalar :href
+  end
+
+  array :operations do
+    scalar :rel, :href
+  end
+
+  def self.find(id, context)
+    if id==:all
+      context.driver.vsps(context.credentials, {:env=>context})
+    else
+      context.driver.vsps(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["vspTemplate"]["href"] #template by reference
+      vsp_config, network = get_by_reference(input, context)
+    else
+      if input["vspTemplate"]["vspConfig"]["href"] # configuration by reference
+        vsp_config = CIMI::Model::VSPConfiguration.find(context.href_id(input["vspTemplate"]["vspConfig"]["href"],:vsp_configurations), context)
+      else #configuration by value
+        vsp_config = get_by_value(request_body, type)
+      end
+      network = CIMI::Model::Network.find(context.href_id(input["vspTemplate"]["network"]["href"], :networks), context)
+    end
+    params = {:vsp_config => vsp_config, :network => network, :name=>input["name"], :description=>input["description"], :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_vsp(context.credentials, params)
+  end
+
+  def self.delete!(id, context)
+    context.driver.delete_vsp(context.credentials, id)
+  end
+
+  def perform(action, context, &block)
+    begin
+      if context.driver.send(:"#{action.name}_vsp", context.credentials, self.name)
+        block.callback :success
+      else
+        raise "Operation #{action.name} failed to execute on the VSP #{self.name} "
+      end
+    rescue => e
+      block.callback :failure, e.message
+    end
+  end
+
+
+  private
+
+  def self.get_by_reference(input, context)
+    vsp_template = CIMI::Model::VSPTemplate.find(context.href_id(input["vspTemplate"]["href"], :vsp_templates), context)
+    vsp_config = CIMI::Model::VSPConfiguration.find(context.href_id(vsp_template.vsp_config.href, :vsp_configurations), context)
+    network = CIMI::Model::Network.find(context.href_id(vsp_template.network.href, :networks), context)
+    return vsp_config, network
+  end
+
+  def self.get_by_value(request_body, type)
+    if type == :xml
+      xml_arrays = XmlSimple.xml_in(request_body, {"NormaliseSpace"=>2})
+      vsp_config = CIMI::Model::VSPConfiguration.from_xml(XmlSimple.xml_out(xml_arrays["vspTemplate"][0]["vspConfig"][0]))
+    else
+     json = JSON.parse(request_body)
+      vsp_config = CIMI::Model::VSPConfiguration.from_json(JSON.generate(json["vspTemplate"]["vspConfig"]))
+    end
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/models/vsp_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/vsp_collection.rb b/server/lib/cimi/models/vsp_collection.rb
new file mode 100644
index 0000000..fc72024
--- /dev/null
+++ b/server/lib/cimi/models/vsp_collection.rb
@@ -0,0 +1,34 @@
+# 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::VSPCollection < CIMI::Model::Base
+
+  CIMI::Model.register_as_root_entity! "VSPs"
+
+  array :vsps do
+    scalar :href
+  end
+
+  def self.default(context)
+    self.new(
+      :id => context.vsps_url,
+      :name => 'default',
+      :created => Time.now,
+      :description => "#{context.driver.name.capitalize} VSPCollection",
+      :vsps => CIMI::Model::VSP.all_uri(context)
+    )
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/models/vsp_configuration.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/vsp_configuration.rb b/server/lib/cimi/models/vsp_configuration.rb
new file mode 100644
index 0000000..c9a9bf3
--- /dev/null
+++ b/server/lib/cimi/models/vsp_configuration.rb
@@ -0,0 +1,40 @@
+# 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::VSPConfiguration < CIMI::Model::Base
+
+  text :bandwidth_reservation
+
+  text :traffic_priority
+
+  text :max_traffic_delay
+
+  text :max_traffic_loss
+
+  text :max_traffic_jitter
+
+  array :operations do
+    scalar :rel, :href
+  end
+
+  def self.find(id, context)
+    if id==:all
+      context.driver.vsp_configurations(context.credentials, {:env=>context})
+    else
+      context.driver.vsp_configurations(context.credentials, {:env=>context, :id=>id})
+    end
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/models/vsp_configuration_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/vsp_configuration_collection.rb b/server/lib/cimi/models/vsp_configuration_collection.rb
new file mode 100644
index 0000000..d4927e7
--- /dev/null
+++ b/server/lib/cimi/models/vsp_configuration_collection.rb
@@ -0,0 +1,34 @@
+# 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::VSPConfigurationCollection < CIMI::Model::Base
+
+  CIMI::Model.register_as_root_entity! "VSPConfigurations"
+
+  array :vsp_configurations do
+    scalar :href
+  end
+
+  def self.default(context)
+    self.new(
+      :id => context.vsp_configurations_url,
+      :name => 'default',
+      :created => Time.now,
+      :description => "#{context.driver.name.capitalize} VSPConfigurationCollection",
+      :vsp_configurations => CIMI::Model::VSPConfiguration.all_uri(context)
+    )
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/models/vsp_template.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/vsp_template.rb b/server/lib/cimi/models/vsp_template.rb
new file mode 100644
index 0000000..f1b8078
--- /dev/null
+++ b/server/lib/cimi/models/vsp_template.rb
@@ -0,0 +1,34 @@
+# 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::VSPTemplate < CIMI::Model::Base
+
+  href :network
+
+  href :vsp_config
+
+  array :operations do
+    scalar :rel, :href
+  end
+
+  def self.find(id, context)
+    if id==:all
+      context.driver.vsp_templates(context.credentials, {:env=>context})
+    else
+      context.driver.vsp_templates(context.credentials, {:env=>context, :id=>id})
+    end
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/models/vsp_template_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/vsp_template_collection.rb b/server/lib/cimi/models/vsp_template_collection.rb
new file mode 100644
index 0000000..61d5311
--- /dev/null
+++ b/server/lib/cimi/models/vsp_template_collection.rb
@@ -0,0 +1,34 @@
+# 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::VSPTemplateCollection < CIMI::Model::Base
+
+  CIMI::Model.register_as_root_entity! "VSPTemplates"
+
+  array :vsp_templates do
+    scalar :href
+  end
+
+  def self.default(context)
+    self.new(
+      :id => context.vsp_templates_url,
+      :name => 'default',
+      :created => Time.now,
+      :description => "#{context.driver.name.capitalize} VSPTemplateCollection",
+      :vsp_templates => CIMI::Model::VSPTemplate.all_uri(context)
+    )
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/server.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/server.rb b/server/lib/cimi/server.rb
index 60f9a3b..a1c7ef9 100644
--- a/server/lib/cimi/server.rb
+++ b/server/lib/cimi/server.rb
@@ -13,947 +13,48 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
-require 'cimi/dependencies'
-require 'cimi/helpers/cimi_helper'
-require 'cimi/model'
+require 'rubygems'
+require 'crack'
+require 'json'
+require 'yaml'
+require 'haml'
+require 'sinatra/base'
+require 'sinatra/rabbit'
+require_relative '../sinatra'
 
-set :version, '0.1.0'
+require_relative './helpers'
+require_relative './collections'
 
-include Deltacloud::Drivers
-include CIMI::Model
+CMWG_NAMESPACE = "http://www.dmtf.org/cimi"
 
-set :drivers, Proc.new { driver_config }
+module CIMI
+  class API < Collections::Base
 
-Sinatra::Application.register Rack::RespondTo
+    # Enable logging
+    use Rack::CommonLogger
+    use Rack::Date
+    use Rack::ETag
+    use Rack::MatrixParams
+    use Rack::DriverSelect
+    use Rack::Accept
+    use Rack::MediaType
 
-use Rack::ETag
-use Rack::Runtime
-use Rack::MatrixParams
-use Rack::DriverSelect
-use Rack::MediaType
-use Rack::Date
-use Rack::CIMI
+    helpers CIMIHelper
 
-configure do
-  set :root_url, "/cimi"
-  set :views, File::join($top_srcdir, 'views', 'cimi')
-  set :public_folder, File::join($top_srcdir, 'public')
-  driver
-end
-
-configure :production do
-  use Rack::SyslogLogger
-  disable :logging
-  enable :show_errors
-  set :dump_errors, false
-  $stdout = SyslogFile.new
-  $stderr = $stdout
-end
-
-configure :development do
-  set :raise_errors => false
-  set :show_exceptions, false
-  $stdout.sync = true
-  $stderr.sync = true
-end
-
-# You could use $API_HOST environment variable to change your hostname to
-# whatever you want (eg. if you running API behind NAT)
-HOSTNAME=ENV['API_HOST'] ? ENV['API_HOST'] : nil
-
-error do
-  report_error
-end
-
-get "/" do
-  redirect settings.root_url
-end
-
-get "#{settings.root_url}\/?" do
-  halt 401 if params[:force_auth] and not driver.valid_credentials?(credentials)
-  redirect cloudEntryPoint_url, 301
-end
+    include Deltacloud::Helpers
+    include CIMI::Collections
+    include CIMI::Model
 
-global_collection  :cloudEntryPoint do
-  description 'Cloud entry point'
-  operation :index do
-    description "list all resources of the cloud"
-    control do
-      entry_point = CloudEntryPoint.create(self)
+    get API_ROOT_URL do
+      if params[:force_auth]
+        return [401, 'Authentication failed'] unless driver.valid_credentials?(credentials)
+      end
+      entry_point = CIMI::Model::CloudEntryPoint.create(self)
       respond_to do |format|
         format.xml { entry_point.to_xml }
         format.json { entry_point.to_json }
       end
     end
-  end
-end
-
-global_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
-
-    description "The Machine Configuration entity represents the set of configuration values "+
-      "that define the (virtual) hardware resources of a to-be-realized Machine Instance.."
-
-    param :id, :string, :required
-
-    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
-
-global_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."
-    param :id,          :string,    :required
-    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
-
-global_collection :machine_admins do
-  description 'Machine Admin entity'
-
-  operation :index do
-    description "List all machine admins"
-    param :CIMISelect,  :string,  :optional
-    with_capability :keys
-    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"
-    param :id,          :string,    :required
-    with_capability :key
-    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"
-    with_capability :create_key
-    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, :method => :delete, :member => true do
-    description "Delete specified MachineAdmin entity"
-    param :id,          :string,    :required
-    control do
-      MachineAdmin.delete!(params[:id], self)
-      no_content_with_status(200)
-    end
-  end
-
-end
-
-global_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."
-    param :id,          :string,    :required
-    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
-
-  operation :stop, :method => :post, :member => true do
-    description "Stop specific machine."
-    param :id,          :string,    :required
-    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, :method => :post, :member => true do
-    description "Start specific machine."
-    param :id,          :string,    :required
-    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, :method => :post, :member => true do
-    description "Start specific machine."
-    param :id,          :string,    :required
-    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
-  operation :attach_volume, :method => :put, :member => true do
-    description "Attach CIMI Volume(s) to a machine."
-    param :id, :string, :required
-    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
-
-  operation :detach_volume, :method => :put, :member => true do
-    description "Detach CIMI Volume(s) from a machine."
-    param :id, :string, :required
-    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
-
-global_collection :volumes do
-  description "Volume represents storage at either the block or file-system level. Volumes can be attached to Machines. Once attached, Volumes can be accessed by processes on that Machine"
-
-  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."
-    param :id, :string, :required
-    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
-
-global_collection :volume_configurations do
-  description "The Volume Configuration entity represents the set of configuration values needed to create a Volume with certain characteristics. Volume Configurations are created by Providers and MAY, at the Providers discretion, be created by Consumers"
-
-  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"
-    param :id, :required, :string
-    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
-
-global_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"
-    param :id, :string, :required
-    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
-
-
-global_collection :entity_metadata do
-  description 'This allows for the discovery of Provider defined constraints on the CIMI defined attributes as well as discovery of any new extension attributes that the Provider may have defined.'
-
-  operation :index do
-    description "List all entity metadata defined for this provider"
-    control do
-      entity_metadata = 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"
-    param :id, :required, :string
-    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
-
-global_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"
-    param :id, :string, :required
-    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
-
-  operation :start, :method => :post, :member => true do
-    description "Start specific network."
-    param :id,          :string,    :required
-    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
-
-  operation :stop, :method => :post, :member => true do
-    description "Stop specific network."
-    param :id,          :string,    :required
-    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
-
-  operation :suspend, :method => :post, :member => true do
-    description "Suspend specific network."
-    param :id,          :string,    :required
-    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
-
-global_collection :network_configurations do
-  description 'Network Configurations contain the set of configuration values representing the information needed to create a Network with certain characteristics'
-
-  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'
-    param :id, :string, :required
-    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
-
-global_collection :network_templates do
-
-  description 'Network Template is a set of configuration values for realizing a Network. An instance of Network Template may be used to create multiple Networks'
-
-  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'
-    param :id, :string, :required
-    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
-
-
-global_collection :routing_groups do
-
-  description 'Routing Groups represent a collection of Networks that route to each other. Providers shall not allow two Networks to be routable to each other unless they are explicitly connected by being part of a common RoutingGroup.'
-
-  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'
-    param :id, :string, :required
-    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
-
-
-global_collection :routing_group_templates do
-
-  description 'Routing Groups Templates capture the configuration values for realizing a RoutingGroup. A Routing Group Template may be used to create multiple RoutingGroups'
-
-  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'
-    param :id, :string, :required
-    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
-
-
-global_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'
-    param :id, :string, :required
-    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"
-    param :id, :string, :required
-    control do
-      CIMI::Model::VSP.delete!(params[:id], self)
-      no_content_with_status(200)
-    end
-  end
-
-  operation :start, :method => :post, :member => true 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
-
-  operation :stop, :method => :post, :member => true do
-    description "Stop 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
-
-end
-
-global_collection :vsp_configurations do
-
-  description 'A VSP Configuration is the set of configuration values representing the information needed to create a VSP with certain characteristics'
-
-  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'
-    param :id, :string, :required
-    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
-
-
-global_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'
-    param :id, :string, :required
-    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
-
-global_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'
-    param :id, :string, :required
-    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
-
-
-global_collection :address_templates do
-
-  description 'An AddressTemplate captures the configuration values for realizing an Address. An Address Template may be used to create multiple Addresses.'
-
-  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'
-    param :id, :string, :required
-    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


Mime
View raw message