You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by ma...@apache.org on 2013/03/12 11:13:23 UTC

[3/3] git commit: CIMI Webapp create address

Updated Branches:
  refs/heads/master ea132e764 -> 61c88b621


CIMI Webapp create address


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

Branch: refs/heads/master
Commit: ab3811b6474d870a55f65a9b37779e4eb81680f4
Parents: ea132e7
Author: NjeriChelimo <ma...@gmail.com>
Authored: Wed Mar 6 18:08:33 2013 +0300
Committer: marios <ma...@redhat.com>
Committed: Tue Mar 12 12:12:50 2013 +0200

----------------------------------------------------------------------
 clients/cimi/lib/entities/address.rb    |   20 ++++++++++++++++++++
 clients/cimi/views/addresses/index.haml |   21 +++++++++++++++++++++
 clients/cimi/views/machines/index.haml  |    2 +-
 3 files changed, 42 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ab3811b6/clients/cimi/lib/entities/address.rb
----------------------------------------------------------------------
diff --git a/clients/cimi/lib/entities/address.rb b/clients/cimi/lib/entities/address.rb
index 31f5de9..5f7b5c8 100644
--- a/clients/cimi/lib/entities/address.rb
+++ b/clients/cimi/lib/entities/address.rb
@@ -22,9 +22,29 @@ class CIMI::Frontend::Address < CIMI::Frontend::Entity
   end
 
   get '/cimi/addresses' do
+    address_template_xml = get_entity_collection('address_templates', credentials)
+    @address_templates = CIMI::Model::AddressTemplateCollection.from_xml(address_template_xml)
     addresses_xml = get_entity_collection('addresses', credentials)
     @addresses = CIMI::Model::AddressCollection.from_xml(addresses_xml)
     haml :'addresses/index'
   end
 
+  post '/cimi/addresses' do
+    address_xml = Nokogiri::XML::Builder.new do |xml|
+      xml.Address(:xmlns => CIMI::Frontend::CMWG_NAMESPACE) {
+        xml.name params[:address][:name]
+        xml.description params[:address][:description]
+        xml.machineTemplate( :href => params[:address][:address_template] )
+      }
+    end.to_xml
+    begin
+      result = create_entity('addresses', address_xml, credentials)
+      address = CIMI::Model::AddressCollection.from_xml(result)
+      flash[:success] = "Address was successfully created."
+      redirect "/cimi/addresses/#{address.name}", 302
+    rescue => e
+      flash[:error] = "Address cannot be created: #{e.message}"
+    end
+  end
+
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ab3811b6/clients/cimi/views/addresses/index.haml
----------------------------------------------------------------------
diff --git a/clients/cimi/views/addresses/index.haml b/clients/cimi/views/addresses/index.haml
index 128ebef..6224291 100644
--- a/clients/cimi/views/addresses/index.haml
+++ b/clients/cimi/views/addresses/index.haml
@@ -10,6 +10,27 @@
 
 - content_for :actions do
   %p
+    %a{ :href => '#addressModal', :class => 'btn btn-primary', :'data-toggle' => :modal} New Address
+
+  %div{ :id => :addressModal, :class => 'modal hide fade' }
+    .modal-header
+      %h3 Create new Address entity
+    .modal-body
+      %form{ :action => "/cimi/addresses", :method => :post }
+        %fieldset
+          .control-group
+            %label.control-label{ :for => 'address[name]' } Address Name
+            .controls
+              %input{ :type => :text, :name => 'address[name]' }
+            %label.control-label{ :for => 'address[address_template]' } Address Image
+            .controls
+              %select{ :name => 'address[address_template]' }
+                - @address_templates.address_templates.each do |template|
+                  %option{ :value => template.id }=href_to_id(template.id)
+    .modal-footer
+      %a{ :href => '#', :class => 'btn btn-primary', :'data-loading-text' => 'Creating Address...', :onclick => "postModalForm(this, 'addressModal')"} Continue
+      %a{ :href => '#', :class => 'btn', :'data-dismiss' => 'modal'} Cancel
+  %p
     %a{ :href => "#{@addresses.id}?format=xml", :class => 'label warning' } XML
     %a{ :href => "#{@addresses.id}?format=json", :class => 'label warning' } JSON
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ab3811b6/clients/cimi/views/machines/index.haml
----------------------------------------------------------------------
diff --git a/clients/cimi/views/machines/index.haml b/clients/cimi/views/machines/index.haml
index cfe832f..85aaaf6 100644
--- a/clients/cimi/views/machines/index.haml
+++ b/clients/cimi/views/machines/index.haml
@@ -15,7 +15,7 @@
 
   %div{ :id => :machineModal, :class => 'modal hide fade' }
     .modal-header
-      %h3 Create mew Machine entity
+      %h3 Create new Machine entity
     .modal-body
       %form{ :action => "/cimi/machines", :method => :post }
         %fieldset