deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From email4t...@gmail.com
Subject [PATCH 4/5] CIMI: Added volume image support for new cimi client
Date Fri, 02 Dec 2011 18:32:52 GMT
From: Tong Li <litong01@us.ibm.com>

---
 clients/cimi/app.rb                         |    1 +
 clients/cimi/lib/entities.rb                |    3 +-
 clients/cimi/lib/entities/volume_image.rb   |   30 +++++++++++++++++++++++++++
 clients/cimi/views/volume_images/index.haml |   20 ++++++++++++++++++
 clients/cimi/views/volume_images/show.haml  |   28 +++++++++++++++++++++++++
 5 files changed, 81 insertions(+), 1 deletions(-)
 create mode 100644 clients/cimi/lib/entities/volume_image.rb
 create mode 100644 clients/cimi/views/volume_images/index.haml
 create mode 100644 clients/cimi/views/volume_images/show.haml

diff --git a/clients/cimi/app.rb b/clients/cimi/app.rb
index 01927cb..9f91446 100644
--- a/clients/cimi/app.rb
+++ b/clients/cimi/app.rb
@@ -22,6 +22,7 @@ module CIMI::Frontend
     use CIMI::Frontend::Machine
     use CIMI::Frontend::MachineTemplate
     use CIMI::Frontend::VolumeConfiguration
+    use CIMI::Frontend::VolumeImage
 
     configure do
       enable :logging
diff --git a/clients/cimi/lib/entities.rb b/clients/cimi/lib/entities.rb
index 2605f26..8c686e0 100644
--- a/clients/cimi/lib/entities.rb
+++ b/clients/cimi/lib/entities.rb
@@ -24,4 +24,5 @@ require 'entities/machine_configuration'
 require 'entities/machine_image'
 require 'entities/machine'
 require 'entities/machine_template'
-require 'entities/volume_configuration'
\ No newline at end of file
+require 'entities/volume_configuration'
+require 'entities/volume_image'
diff --git a/clients/cimi/lib/entities/volume_image.rb b/clients/cimi/lib/entities/volume_image.rb
new file mode 100644
index 0000000..ccd1c49
--- /dev/null
+++ b/clients/cimi/lib/entities/volume_image.rb
@@ -0,0 +1,30 @@
+# 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::Frontend::VolumeImage < CIMI::Frontend::Entity
+
+  get '/cimi/volume_images/:id' do
+    volume_image_xml = CIMI::Frontend.get_entity('volume_images', params[:id], credentials)
+    @volume_image= CIMI::Model::VolumeImage.from_xml(volume_image_xml)
+    haml :'volume_images/show'
+  end
+
+  get '/cimi/volume_images' do
+    volume_images_xml = CIMI::Frontend.get_entity_collection('volume_images', credentials)
+    @volume_images = CIMI::Model::VolumeImageCollection.from_xml(volume_images_xml)
+    haml :'volume_images/index'
+  end
+
+end
\ No newline at end of file
diff --git a/clients/cimi/views/volume_images/index.haml b/clients/cimi/views/volume_images/index.haml
new file mode 100644
index 0000000..e7ab56f
--- /dev/null
+++ b/clients/cimi/views/volume_images/index.haml
@@ -0,0 +1,20 @@
+- @title=@volume_images.description
+
+- content_for :breadcrumb do
+  %ul.breadcrumb
+    %li
+      %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
+      %span.divider="/"
+    %li.active
+      VolumeImageCollection
+
+%blockquote
+  %p
+    A Volume Image Collection entity represents the collection of Volume Image
+    entities within a Provider. This entity can be used to locate and create
+    Volume Images.
+
+%ul
+  - @volume_images.volume_images.each do |image|
+    %li
+      %a{ :href => "/cimi/volume_images/#{image.href.split('/').last}"}=image.href.split('/').last
diff --git a/clients/cimi/views/volume_images/show.haml b/clients/cimi/views/volume_images/show.haml
new file mode 100644
index 0000000..ef396dc
--- /dev/null
+++ b/clients/cimi/views/volume_images/show.haml
@@ -0,0 +1,28 @@
+- @title="#{@volume_image.name}"
+
+- content_for :breadcrumb do
+  %ul.breadcrumb
+    %li
+      %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
+      %span.divider="/"
+    %li
+      %a{ :href => "/cimi/volume_images"} VolumeImageCollection
+      %span.divider="/"
+    %li.active
+      = @volume_image.name
+
+%blockquote
+  %p
+    This entity represents the information necessary for hardware virtualized
+    resources to create a Volume Instance
+
+%dl
+  %dt URI
+  %dd
+    %a{ :href => @volume_image.uri }=@volume_image.uri
+  %dt Description
+  %dd=@volume_image.description
+  %dt Created
+  %dd=@volume_image.created
+  %dt Details
+  %dd=@volume_image.inspect
\ No newline at end of file
-- 
1.7.4.1


Mime
View raw message