deltacloud-dev mailing list archives

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

---
 clients/cimi/app.rb                             |    1 +
 clients/cimi/lib/entities.rb                    |    3 +-
 clients/cimi/lib/entities/machine_template.rb   |   30 +++++++++++++++++++++++
 clients/cimi/views/machine_templates/index.haml |   21 ++++++++++++++++
 clients/cimi/views/machine_templates/show.haml  |   28 +++++++++++++++++++++
 5 files changed, 82 insertions(+), 1 deletions(-)
 create mode 100644 clients/cimi/lib/entities/machine_template.rb
 create mode 100644 clients/cimi/views/machine_templates/index.haml
 create mode 100644 clients/cimi/views/machine_templates/show.haml

diff --git a/clients/cimi/app.rb b/clients/cimi/app.rb
index 33d187f..0c15495 100644
--- a/clients/cimi/app.rb
+++ b/clients/cimi/app.rb
@@ -20,6 +20,7 @@ module CIMI::Frontend
     use CIMI::Frontend::MachineConfiguration
     use CIMI::Frontend::MachineImage
     use CIMI::Frontend::Machine
+    use CIMI::Frontend::MachineTemplate
 
     configure do
       enable :logging
diff --git a/clients/cimi/lib/entities.rb b/clients/cimi/lib/entities.rb
index 7b77be0..88e13a9 100644
--- a/clients/cimi/lib/entities.rb
+++ b/clients/cimi/lib/entities.rb
@@ -22,4 +22,5 @@ require 'entities/base_entity'
 require 'entities/cloud_entry_point'
 require 'entities/machine_configuration'
 require 'entities/machine_image'
-require 'entities/machine'
\ No newline at end of file
+require 'entities/machine'
+require 'entities/machine_template'
\ No newline at end of file
diff --git a/clients/cimi/lib/entities/machine_template.rb b/clients/cimi/lib/entities/machine_template.rb
new file mode 100644
index 0000000..41b8938
--- /dev/null
+++ b/clients/cimi/lib/entities/machine_template.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::MachineTemplate < CIMI::Frontend::Entity
+
+  get '/cimi/machine_templates/:id' do
+    machine_templates_xml = CIMI::Frontend.get_entity('machine_templates', params[:id], credentials)
+    @machine_template = CIMI::Model::MachineTemplate.from_xml(machine_templates_xml)
+    haml :'machine_templates/show'
+  end
+
+  get '/cimi/machine_templates' do
+    machine_template_xml = CIMI::Frontend.get_entity_collection('machine_templates', credentials)
+    @machine_templates = CIMI::Model::MachineTemplateCollection.from_xml(machine_template_xml)
+    haml :'machine_templates/index'
+  end
+
+end
\ No newline at end of file
diff --git a/clients/cimi/views/machine_templates/index.haml b/clients/cimi/views/machine_templates/index.haml
new file mode 100644
index 0000000..f61126d
--- /dev/null
+++ b/clients/cimi/views/machine_templates/index.haml
@@ -0,0 +1,21 @@
+- @title=@machine_templates.description
+
+- content_for :breadcrumb do
+  %ul.breadcrumb
+    %li
+      %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
+      %span.divider="/"
+    %li.active
+      MachineTemplateCollection
+
+
+%blockquote
+  %p
+    A Machine Template Collection entity represents the collection of
+    Machine Template entities within a Provider. This entity can be used to
+    locate and create Machine Templates.
+
+%ul
+  - @machine_templates.machine_templates.each do |temp|
+    %li
+      %a{ :href => "/cimi/machine_templates/#{temp.href.split('/').last}"}=temp.href.split('/').last
diff --git a/clients/cimi/views/machine_templates/show.haml b/clients/cimi/views/machine_templates/show.haml
new file mode 100644
index 0000000..9386437
--- /dev/null
+++ b/clients/cimi/views/machine_templates/show.haml
@@ -0,0 +1,28 @@
+- @title="#{@machine_template.name}"
+
+- content_for :breadcrumb do
+  %ul.breadcrumb
+    %li
+      %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
+      %span.divider="/"
+    %li
+      %a{ :href => "/cimi/machine_templates"} MachineConfigurationCollection
+      %span.divider="/"
+    %li.active
+      = @machine_template.name
+
+%blockquote
+  %p
+    The Machine Configuration entity represents the set of configuration values
+    that define the (virtual) hardware resources of a to-be-realized Machine
+    Instance. Machine Configurations are created by Providers and MAY, at the
+    Providers discretion, be created by Consumers.
+
+%dl
+  %dt URI
+  %dd
+    %a{ :href => @machine_template.uri }=@machine_template.uri
+  %dt Description
+  %dd=@machine_template.description
+  %dt Created
+  %dd #{@machine_template.created}&nbsp;
\ No newline at end of file
-- 
1.7.4.1


Mime
View raw message