deltacloud-dev mailing list archives

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

---
 clients/cimi/app.rb                   |    1 +
 clients/cimi/lib/entities.rb          |    1 +
 clients/cimi/lib/entities/volume.rb   |   30 ++++++++++++++++++++++++++++++
 clients/cimi/views/volumes/index.haml |   21 +++++++++++++++++++++
 clients/cimi/views/volumes/show.haml  |   28 ++++++++++++++++++++++++++++
 5 files changed, 81 insertions(+), 0 deletions(-)
 create mode 100644 clients/cimi/lib/entities/volume.rb
 create mode 100644 clients/cimi/views/volumes/index.haml
 create mode 100644 clients/cimi/views/volumes/show.haml

diff --git a/clients/cimi/app.rb b/clients/cimi/app.rb
index 9f91446..618746e 100644
--- a/clients/cimi/app.rb
+++ b/clients/cimi/app.rb
@@ -23,6 +23,7 @@ module CIMI::Frontend
     use CIMI::Frontend::MachineTemplate
     use CIMI::Frontend::VolumeConfiguration
     use CIMI::Frontend::VolumeImage
+    use CIMI::Frontend::Volume
 
     configure do
       enable :logging
diff --git a/clients/cimi/lib/entities.rb b/clients/cimi/lib/entities.rb
index 8c686e0..d351488 100644
--- a/clients/cimi/lib/entities.rb
+++ b/clients/cimi/lib/entities.rb
@@ -26,3 +26,4 @@ require 'entities/machine'
 require 'entities/machine_template'
 require 'entities/volume_configuration'
 require 'entities/volume_image'
+require 'entities/volume'
diff --git a/clients/cimi/lib/entities/volume.rb b/clients/cimi/lib/entities/volume.rb
new file mode 100644
index 0000000..54ab3ba
--- /dev/null
+++ b/clients/cimi/lib/entities/volume.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::Volume < CIMI::Frontend::Entity
+
+  get '/cimi/volumes/:id' do
+    volume_xml = CIMI::Frontend.get_entity('volumes', params[:id], credentials)
+    @volume = CIMI::Model::Volume.from_xml(volume_xml)
+    haml :'volumes/show'
+  end
+
+  get '/cimi/volumes' do
+    volumes_xml = CIMI::Frontend.get_entity_collection('volumes', credentials)
+    @volumes = CIMI::Model::VolumeCollection.from_xml(volumes_xml)
+    haml :'volumes/index'
+  end
+
+end
\ No newline at end of file
diff --git a/clients/cimi/views/volumes/index.haml b/clients/cimi/views/volumes/index.haml
new file mode 100644
index 0000000..e9bd529
--- /dev/null
+++ b/clients/cimi/views/volumes/index.haml
@@ -0,0 +1,21 @@
+- @title=@volumes.description
+
+- content_for :breadcrumb do
+  %ul.breadcrumb
+    %li
+      %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
+      %span.divider="/"
+    %li.active
+      VolumeCollection
+
+
+%blockquote
+  %p
+    A Volume Collection entity represents the collection of Volume
+    entities within a Provider. This entity can be used to locate and create
+    volumes.
+
+%ul
+  - @volumes.volumes.each do |volume|
+    %li
+      %a{ :href => "/cimi/volumes/#{volume.href.split('/').last}"}=volume.href.split('/').last
diff --git a/clients/cimi/views/volumes/show.haml b/clients/cimi/views/volumes/show.haml
new file mode 100644
index 0000000..85a73f7
--- /dev/null
+++ b/clients/cimi/views/volumes/show.haml
@@ -0,0 +1,28 @@
+- @title="#{@volume.name}"
+
+- content_for :breadcrumb do
+  %ul.breadcrumb
+    %li
+      %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
+      %span.divider="/"
+    %li
+      %a{ :href => "/cimi/volumes"} VolumeCollection
+      %span.divider="/"
+    %li.active
+      = @volume.name
+
+%blockquote
+  %p
+    This entity represents a
+    volume Instance
+
+%dl
+  %dt URI
+  %dd
+    %a{ :href => @volume.uri }=@volume.uri
+  %dt Description
+  %dd=@volume.description
+  %dt Created
+  %dd #{@volume.created}&nbsp;
+  %dt Details
+  %dd=@volume.inspect
\ No newline at end of file
-- 
1.7.4.1


Mime
View raw message