deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject [4/6] git commit: CIMI Webapp creating a Network
Date Mon, 25 Feb 2013 21:08:27 GMT
CIMI Webapp creating a Network


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

Branch: refs/heads/master
Commit: 177cf1cd84237f2cef216dcfc1016f7583f6cdd5
Parents: 9053875
Author: NjeriChelimo <martha.c.chumo@gmail.com>
Authored: Mon Feb 25 12:29:42 2013 +0300
Committer: David Lutterkort <lutter@redhat.com>
Committed: Mon Feb 25 13:05:58 2013 -0800

----------------------------------------------------------------------
 clients/cimi/lib/entities/network.rb   |   25 ++++++++++++++++++++++++
 clients/cimi/views/networks/index.haml |   28 +++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/177cf1cd/clients/cimi/lib/entities/network.rb
----------------------------------------------------------------------
diff --git a/clients/cimi/lib/entities/network.rb b/clients/cimi/lib/entities/network.rb
index 8ce9942..db1f011 100644
--- a/clients/cimi/lib/entities/network.rb
+++ b/clients/cimi/lib/entities/network.rb
@@ -22,9 +22,34 @@ class CIMI::Frontend::Network < CIMI::Frontend::Entity
   end
 
   get '/cimi/networks' do
+    forwarding_groups_xml = get_entity_collection('forwarding_groups', credentials)
+    @forwarding_groups = CIMI::Model::ForwardingGroupCollection.from_xml(forwarding_groups_xml)
+    network_config_xml = get_entity_collection('network_configurations', credentials)
+    @network_configurations = CIMI::Model::NetworkConfigurationCollection.from_xml(network_config_xml)
     networks_xml = get_entity_collection('networks', credentials)
     @networks = CIMI::Model::NetworkCollection.from_xml(networks_xml)
     haml :'networks/index'
   end
 
+  post '/cimi/networks' do
+    network_xml = Nokogiri::XML::Builder.new do |xml|
+      xml.Network(:xmlns => CIMI::Frontend::CMWG_NAMESPACE) {
+        xml.name params[:network][:name]
+        xml.description params[:network][:description]
+        xml.networkTemplate {
+          xml.networkConfig( :href => params[:network][:network_configuration] )
+          xml.forwardingGroup( :href => params[:network][:forwarding_group] )
+        }
+      }
+    end.to_xml
+    begin
+      result = create_entity('networks', network_xml, credentials)
+      network = CIMI::Model::NetworkCollection.from_xml(result)
+      flash[:success] = "Network was successfully created."
+      redirect "/cimi/networks/#{network.name}", 302
+    rescue => e
+      flash[:error] = "Network cannot be created: #{e.message}"
+    end
+  end
+
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/177cf1cd/clients/cimi/views/networks/index.haml
----------------------------------------------------------------------
diff --git a/clients/cimi/views/networks/index.haml b/clients/cimi/views/networks/index.haml
index 2ebd23f..405cd11 100644
--- a/clients/cimi/views/networks/index.haml
+++ b/clients/cimi/views/networks/index.haml
@@ -6,9 +6,37 @@
       %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
       %span.divider="/"
     %li.active
+
       NetworkCollection
 
 - content_for :actions do
+
+  %p
+    %a{ :href => '#networkModal', :class => 'btn btn-primary', :'data-toggle' =>
:modal} New Network
+
+  %div{ :id => :networkModal, :class => 'modal hide fade' }
+    .modal-header
+      %h3 Create new Network entity
+    .modal-body
+      %form{ :action => "/cimi/networks", :method => :post }
+        %fieldset
+          .control-group
+            %label.control-label{ :for => 'network[name]' } Network Name
+            .controls
+              %input{ :type => :text, :name => 'network[name]' }
+            %label.control-label{ :for => 'network[forwarding_group]' } Forwarding Group
+            .controls
+              %select{ :name => 'network[forwarding_group]' }
+                - @forwarding_groups.forwarding_groups.each do |group|
+                  %option{ :value => group.id }=href_to_id(group.id)
+            %label.control-label{ :for => 'network[network_configuration]' } Network Configuration
+            .controls
+              %select{ :name => 'network[network_configuration]' }
+                - @network_configurations.network_configurations.each do |configuration|
+                  %option{ :value => configuration.id }=href_to_id(configuration.id)
+    .modal-footer
+      %a{ :href => '#', :class => 'btn btn-primary', :'data-loading-text' => 'Creating
Network...', :onclick => "postModalForm(this, 'networkModal')"} Continue
+      %a{ :href => '#', :class => 'btn', :'data-dismiss' => 'modal'} Cancel
   %p
     %a{ :href => "#{@networks.id}?format=xml", :class => 'label warning' } XML
     %a{ :href => "#{@networks.id}?format=json", :class => 'label warning' } JSON


Mime
View raw message