You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by dk...@apache.org on 2013/07/09 08:25:12 UTC

[6/9] git commit: CIMI: replaced machine admin with credential and made its views consistent with others

CIMI: replaced machine admin with credential
and made its views consistent with others


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/cacd6552
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/cacd6552
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/cacd6552

Branch: refs/heads/master
Commit: cacd655270337a4d02bb0a944a87d857b2faa7ca
Parents: e3ce360
Author: Dies Koper <di...@fast.au.fujitsu.com>
Authored: Wed Jul 3 23:40:29 2013 +1000
Committer: Dies Koper <di...@fast.au.fujitsu.com>
Committed: Wed Jul 3 23:51:22 2013 +1000

----------------------------------------------------------------------
 clients/cimi/app.rb                          |  2 +-
 clients/cimi/lib/entities.rb                 |  2 +-
 clients/cimi/lib/entities/credential.rb      | 66 +++++++++++++++++++++++
 clients/cimi/lib/entities/machine.rb         | 10 ++--
 clients/cimi/lib/entities/machine_admin.rb   | 66 -----------------------
 clients/cimi/views/credentials/index.haml    | 53 ++++++++++++++++++
 clients/cimi/views/credentials/show.haml     | 35 ++++++++++++
 clients/cimi/views/machine_admins/index.haml | 54 -------------------
 clients/cimi/views/machine_admins/show.haml  | 35 ------------
 clients/cimi/views/machines/index.haml       | 12 ++---
 10 files changed, 167 insertions(+), 168 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/cacd6552/clients/cimi/app.rb
----------------------------------------------------------------------
diff --git a/clients/cimi/app.rb b/clients/cimi/app.rb
index 67c3f8f..ea6a3c7 100644
--- a/clients/cimi/app.rb
+++ b/clients/cimi/app.rb
@@ -22,12 +22,12 @@ module CIMI::Frontend
     use CIMI::Frontend::Address
     use CIMI::Frontend::AddressTemplate
     use CIMI::Frontend::CloudEntryPoint
+    use CIMI::Frontend::Credential
     use CIMI::Frontend::ForwardingGroup
     use CIMI::Frontend::ForwardingGroupTemplate
     use CIMI::Frontend::MachineConfiguration
     use CIMI::Frontend::MachineImage
     use CIMI::Frontend::Machine
-    use CIMI::Frontend::MachineAdmin
     use CIMI::Frontend::MachineTemplate
     use CIMI::Frontend::VolumeConfiguration
     use CIMI::Frontend::VolumeImage

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/cacd6552/clients/cimi/lib/entities.rb
----------------------------------------------------------------------
diff --git a/clients/cimi/lib/entities.rb b/clients/cimi/lib/entities.rb
index 522c10e..6099802 100644
--- a/clients/cimi/lib/entities.rb
+++ b/clients/cimi/lib/entities.rb
@@ -22,10 +22,10 @@ require 'entities/base_entity'
 require 'entities/cloud_entry_point'
 require 'entities/address'
 require 'entities/address_template'
+require 'entities/credential'
 require 'entities/forwarding_group'
 require 'entities/forwarding_group_template'
 require 'entities/machine_configuration'
-require 'entities/machine_admin'
 require 'entities/machine_image'
 require 'entities/machine'
 require 'entities/machine_template'

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/cacd6552/clients/cimi/lib/entities/credential.rb
----------------------------------------------------------------------
diff --git a/clients/cimi/lib/entities/credential.rb b/clients/cimi/lib/entities/credential.rb
new file mode 100644
index 0000000..3916704
--- /dev/null
+++ b/clients/cimi/lib/entities/credential.rb
@@ -0,0 +1,66 @@
+# 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::Credential < CIMI::Frontend::Entity
+
+  get '/cimi/credentials/new' do
+    haml :'credentials/new'
+  end
+
+  get '/cimi/credentials/:id' do
+    credentials_xml = get_entity('credentials', params[:id], credentials)
+    @cred = CIMI::Model::Credential.from_xml(credentials_xml)
+    haml :'credentials/show'
+  end
+
+  delete '/cimi/credentials/:id/delete' do
+    result = destroy_entity('credentials', params[:id], credentials)
+    if result.code == 200
+      flash[:success] = "Credential '#{params[:id]}' was successfully destroyed."
+      redirect '/cimi/credentials'
+    else
+      flash[:error] = "Unable to destroy Credential #{params[:id]}"
+    end
+  end
+
+  get '/cimi/credentials' do
+    credential_xml = get_entity_collection('credentials', credentials)
+    @creds = collection_class_for(:credential).from_xml(credential_xml)
+    haml :'credentials/index'
+  end
+
+  post '/cimi/credential' do
+    credential_xml = Nokogiri::XML::Builder.new do |xml|
+      xml.Credential(:xmlns => CIMI::Frontend::CMWG_NAMESPACE) {
+        xml.name params[:credential][:name]
+        xml.description params[:credential][:description]
+        xml.username params[:credential][:username]
+        xml.password params[:credential][:password]
+        xml.key params[:credential][:key]
+      }
+    end.to_xml
+    begin
+      result = create_entity('credentials', credential_xml, credentials)
+      cred = collection_class_for(:credential).from_xml(result)
+      flash[:success] = "Credential was successfully created."
+      redirect "/cimi/credentials/#{cred.name}", 302
+    rescue => e
+      flash[:error] = "Credential could not be created: #{e.message}"
+      redirect(back)
+    end
+  end
+
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/cacd6552/clients/cimi/lib/entities/machine.rb
----------------------------------------------------------------------
diff --git a/clients/cimi/lib/entities/machine.rb b/clients/cimi/lib/entities/machine.rb
index 72286d0..05f1e14 100644
--- a/clients/cimi/lib/entities/machine.rb
+++ b/clients/cimi/lib/entities/machine.rb
@@ -42,11 +42,11 @@ class CIMI::Frontend::Machine < CIMI::Frontend::Entity
     machine_conf_xml = get_entity_collection('machine_configurations', credentials)
     @machine_configurations = collection_class_for(:machine_configuration).from_xml(machine_conf_xml)
     begin
-      machine_admins_xml = get_entity_collection('machine_admins', credentials)
-      @machine_admins = collection_class_for(:machine_admin).from_xml(machine_admins_xml)
-      # In case backend does not support MachineAdmin collection
+      credentials_xml = get_entity_collection('credentials', credentials)
+      @creds = collection_class_for(:credential).from_xml(credentials_xml)
+      # In case backend does not support Credential collection
     rescue RestClient::ResourceNotFound
-      @machine_admins = []
+      @creds = []
     end
     machine_xml = get_entity_collection('machines', credentials)
     @machines = collection_class_for(:machine).from_xml(machine_xml)
@@ -104,7 +104,7 @@ class CIMI::Frontend::Machine < CIMI::Frontend::Entity
         xml.machineTemplate {
           xml.machineConfig( :href => params[:machine][:machine_configuration] )
           xml.machineImage( :href => params[:machine][:machine_image] )
-          xml.machineAdmin( :href => params[:machine][:machine_admin] ) unless params[:machine][:machine_admin].nil?
+          xml.credential( :href => params[:machine][:credential] ) unless params[:machine][:credential].nil?
         }
       }
     end.to_xml

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/cacd6552/clients/cimi/lib/entities/machine_admin.rb
----------------------------------------------------------------------
diff --git a/clients/cimi/lib/entities/machine_admin.rb b/clients/cimi/lib/entities/machine_admin.rb
deleted file mode 100644
index c7077cc..0000000
--- a/clients/cimi/lib/entities/machine_admin.rb
+++ /dev/null
@@ -1,66 +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::Frontend::MachineAdmin < CIMI::Frontend::Entity
-
-  get '/cimi/machine_admins/new' do
-    haml :'machine_admins/new'
-  end
-
-  get '/cimi/machine_admins/:id' do
-    machine_admins_xml = get_entity('machine_admins', params[:id], credentials)
-    @machine_admin = CIMI::Model::MachineAdmin.from_xml(machine_admins_xml)
-    haml :'machine_admins/show'
-  end
-
-  delete '/cimi/machine_admins/:id/delete' do
-    result = destroy_entity('machine_admins', params[:id], credentials)
-    if result.code == 200
-      flash[:success] = "MachineAdmin '#{params[:id]}' was successfully destroyed."
-      redirect '/cimi/machine_admins'
-    else
-      flash[:error] = "Unable to destroy Machine Admin #{params[:id]}"
-    end
-  end
-
-  get '/cimi/machine_admins' do
-    machine_admin_xml = get_entity_collection('machine_admins', credentials)
-    @machine_admins = collection_class_for(:machine_admin).from_xml(machine_admin_xml)
-    haml :'machine_admins/index'
-  end
-
-  post '/cimi/machine_admin' do
-    machine_admin_xml = Nokogiri::XML::Builder.new do |xml|
-      xml.MachineAdmin(:xmlns => CIMI::Frontend::CMWG_NAMESPACE) {
-        xml.name params[:machine_admin][:name]
-        xml.description params[:machine_admin][:description]
-        xml.username params[:machine_admin][:username]
-        xml.password params[:machine_admin][:password]
-        xml.key params[:machine_admin][:key]
-      }
-    end.to_xml
-    begin
-      result = create_entity('machine_admins', machine_admin_xml, credentials)
-      machine_admin = collection_class_for(:machine_admin).from_xml(result)
-      flash[:success] = "MachineAdmin was successfully created."
-      redirect "/cimi/machine_admins/#{machine_admin.name}", 302
-    rescue => e
-      flash[:error] = "Machine Admin could not be created: #{e.message}"
-      redirect(back)
-    end
-  end
-
-
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/cacd6552/clients/cimi/views/credentials/index.haml
----------------------------------------------------------------------
diff --git a/clients/cimi/views/credentials/index.haml b/clients/cimi/views/credentials/index.haml
new file mode 100644
index 0000000..e737447
--- /dev/null
+++ b/clients/cimi/views/credentials/index.haml
@@ -0,0 +1,53 @@
+- @title=collection_name @creds
+
+- content_for :breadcrumb do
+  %ul.breadcrumb
+    %li
+      %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
+      %span.divider="/"
+    %li.active
+      CredentialCollection
+
+- content_for :actions do
+  %p
+    %a{ :href => "#{@creds.id}?format=xml", :class => 'label warning' } XML
+    %a{ :href => "#{@creds.id}?format=json", :class => 'label warning' } JSON
+  %p
+    %a{ :href => '#credModal', :class => 'btn btn-primary', :'data-toggle' => :modal } New Credential
+
+  %div{ :id => :credModal, :class => 'modal hide fade' }
+    .modal-header
+      %h3 Create mew Credential entity
+    .modal-body
+      %form{ :action => "/cimi/credential", :method => :post }
+        %fieldset
+          .control-group
+            %label.control-label{ :for => 'credential[name]' } Key Name
+            .controls
+              %input{ :type => :text, :name => 'credential[name]' }
+            %label.control-label{ :for => 'credential[description]' } Key Description
+            .controls
+              %input{ :type => :text, :name => 'credential[description]' }
+            %label.control-label{ :for => 'credential[key]' } PEM data
+            .controls
+              %textarea{:name => 'credential[key]', :class => 'input-xlarge', :rows => 3}
+    .modal-footer
+      %a{ :href => '#', :class => 'btn btn-primary', :'data-loading-text' => 'Creating Credential...', :onclick => "postModalForm(this, 'credModal')"} Continue
+      %a{ :href => '#', :class => 'btn', :'data-dismiss' => 'modal'} Cancel
+
+%blockquote
+  %p
+    A Credential Collection entity represents the collection of Credential
+    entities within a Provider. This entity can be used to locate and create
+    Credentials.
+
+%h3 CredentialCollection
+
+%ul
+  - @creds.credentials.each do |conf|
+    %li
+      %a{ :href => "/cimi/credentials/#{conf.id.split('/').last}"}=conf.id.split('/').last
+
+- details 'Collection details' do
+  - row 'ID', @creds.id
+  - row 'Count', @creds.count

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/cacd6552/clients/cimi/views/credentials/show.haml
----------------------------------------------------------------------
diff --git a/clients/cimi/views/credentials/show.haml b/clients/cimi/views/credentials/show.haml
new file mode 100644
index 0000000..6a9ac76
--- /dev/null
+++ b/clients/cimi/views/credentials/show.haml
@@ -0,0 +1,35 @@
+- @title="#{@cred.name}"
+
+- content_for :breadcrumb do
+  %ul.breadcrumb
+    %li
+      %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
+      %span.divider="/"
+    %li
+      %a{ :href => "/cimi/credentials"} CredentialCollection
+      %span.divider="/"
+    %li.active
+      = @cred.name
+
+- content_for :actions do
+  %p
+    %a{ :href => "#{@cred.id}?format=xml", :class => 'label warning' } XML
+    %a{ :href => "#{@cred.id}?format=json", :class => 'label warning' } JSON
+  %p
+    %form{ :action => "/cimi/credentials/#{@cred.name}/delete", :method => :post, :style => 'display:inline'}
+      %input{ :type => :hidden, :name => '_method', :value => 'delete'}
+      %button{ :class => 'btn btn-danger'} Destroy
+
+%blockquote
+  %p
+    A Credential entity contains the information required to create the
+    initial administrative super-user of a newly created Machine
+
+- details 'Credential Details' do
+  - row 'ID', @cred.id
+  - row 'Description', @cred.description
+  - row 'Created', @cred.created
+  - row 'Username', boolean_span_for(@cred.username)
+  - row 'Password', boolean_span_for(@cred.password)
+  - row 'Key', '<pre>'+boolean_span_for(@cred.key)+'</pre>'
+

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/cacd6552/clients/cimi/views/machine_admins/index.haml
----------------------------------------------------------------------
diff --git a/clients/cimi/views/machine_admins/index.haml b/clients/cimi/views/machine_admins/index.haml
deleted file mode 100644
index 3b0e1ae..0000000
--- a/clients/cimi/views/machine_admins/index.haml
+++ /dev/null
@@ -1,54 +0,0 @@
-- @title=@machine_admins.name
-
-- content_for :breadcrumb do
-  %ul.breadcrumb
-    %li
-      %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
-      %span.divider="/"
-    %li.active
-      MachineAdminCollection
-
-- content_for :actions do
-  %p
-    %a{ :href => "#{@machine_admins.id}?format=xml", :class => 'label warning' } XML
-    %a{ :href => "#{@machine_admins.id}?format=json", :class => 'label warning' } JSON
-  %p
-    %a{ :href => '#adminModal', :class => 'btn btn-primary', :'data-toggle' => :modal } New Machine Admin
-
-  %div{ :id => :adminModal, :class => 'modal hide fade' }
-    .modal-header
-      %h3 Create mew MachineAdmin entity
-    .modal-body
-      %form{ :action => "/cimi/machine_admin", :method => :post }
-        %fieldset
-          .control-group
-            %label.control-label{ :for => 'machine_admin[name]' } Key Name
-            .controls
-              %input{ :type => :text, :name => 'machine_admin[name]' }
-            %label.control-label{ :for => 'machine_admin[description]' } Key Description
-            .controls
-              %input{ :type => :text, :name => 'machine_admin[description]' }
-            %label.control-label{ :for => 'machine_admin[key]' } PEM data
-            .controls
-              %textarea{:name => 'machine_admin[key]', :class => 'input-xlarge', :rows => 3}
-    .modal-footer
-      %a{ :href => '#', :class => 'btn btn-primary', :'data-loading-text' => 'Creating MachineAdmin...', :onclick => "postModalForm(this, 'adminModal')"} Continue
-      %a{ :href => '#', :class => 'btn', :'data-dismiss' => 'modal'} Cancel
-
-%blockquote
-  %p
-    A Machine Admin Collection entity represents the collection of Machine Admin
-    entities within a Provider. This entity can be used to locate and create
-    MachineAdmins.
-
-%h3 MachineAdminCollection
-
-%ul
-  - @machine_admins.machine_admins.each do |conf|
-    %li
-      %a{ :href => "/cimi/machine_admins/#{conf.href.split('/').last}"}=conf.href.split('/').last
-
-- details 'Collection details' do
-  - row 'ID', @machine_admins.id
-  - row 'Description', @machine_admins.description
-  - row 'Created', @machine_admins.created

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/cacd6552/clients/cimi/views/machine_admins/show.haml
----------------------------------------------------------------------
diff --git a/clients/cimi/views/machine_admins/show.haml b/clients/cimi/views/machine_admins/show.haml
deleted file mode 100644
index 2e95ea7..0000000
--- a/clients/cimi/views/machine_admins/show.haml
+++ /dev/null
@@ -1,35 +0,0 @@
-- @title="#{@machine_admin.name}"
-
-- content_for :breadcrumb do
-  %ul.breadcrumb
-    %li
-      %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
-      %span.divider="/"
-    %li
-      %a{ :href => "/cimi/machine_admins"} MachineAdminCollection
-      %span.divider="/"
-    %li.active
-      = @machine_admin.name
-
-- content_for :actions do
-  %p
-    %a{ :href => "#{@machine_admin.id}?format=xml", :class => 'label warning' } XML
-    %a{ :href => "#{@machine_admin.id}?format=json", :class => 'label warning' } JSON
-  %p
-    %form{ :action => "/cimi/machine_admins/#{@machine_admin.name}/delete", :method => :post, :style => 'display:inline'}
-      %input{ :type => :hidden, :name => '_method', :value => 'delete'}
-      %button{ :class => 'btn btn-danger'} Destroy
-
-%blockquote
-  %p
-    A Machine Admin entity contains the information required to create the
-    initial administrative super- user of a newly created Machine
-
-- details 'MachineAdmin Details' do
-  - row 'ID', @machine_admin.id
-  - row 'Description', @machine_admin.description
-  - row 'Created', @machine_admin.created
-  - row 'Username', boolean_span_for(@machine_admin.username)
-  - row 'Password', boolean_span_for(@machine_admin.password)
-  - row 'Key', '<pre>'+boolean_span_for(@machine_admin.key)+'</pre>'
-

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/cacd6552/clients/cimi/views/machines/index.haml
----------------------------------------------------------------------
diff --git a/clients/cimi/views/machines/index.haml b/clients/cimi/views/machines/index.haml
index 85aaaf6..aa195ab 100644
--- a/clients/cimi/views/machines/index.haml
+++ b/clients/cimi/views/machines/index.haml
@@ -33,14 +33,14 @@
               %select{ :name => 'machine[machine_configuration]' }
                 - @machine_configurations.machine_configurations.each do |configuration|
                   %option{ :value => configuration.id }=href_to_id(configuration.id)
-            - unless @machine_admins.kind_of?(Array)
-              %label.control-label{ :for => 'machine[machine_admin]' } Machine Admin
+            - unless @creds.kind_of?(Array)
+              %label.control-label{ :for => 'machine[credential]' } Credential
               .controls
-                %select{ :name => 'machine[machine_admin]' }
-                  - @machine_admins.machine_admins.each do |admin|
-                    %option{ :value => admin.id }=href_to_id(admin.id)
+                %select{ :name => 'machine[credential]' }
+                  - @creds.credentials.each do |cred|
+                    %option{ :value => cred.id }=href_to_id(cred.id)
     .modal-footer
-      %a{ :href => '#', :class => 'btn btn-primary', :'data-loading-text' => 'Creating MachineAdmin...', :onclick => "postModalForm(this, 'machineModal')"} Continue
+      %a{ :href => '#', :class => 'btn btn-primary', :'data-loading-text' => 'Creating Credential...', :onclick => "postModalForm(this, 'machineModal')"} Continue
       %a{ :href => '#', :class => 'btn', :'data-dismiss' => 'modal'} Cancel
   %p{:style => 'text-align:right;'}
     %a{ :href => "#{@machines.id}?format=xml", :class => 'label warning' } XML