You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by ma...@redhat.com on 2013/03/20 18:02:52 UTC

[PATCH 3/4] Network API rev 2 (RFC) - Views

From: marios <ma...@redhat.com>


Signed-off-by: marios <ma...@redhat.com>
---
 server/views/instances/new.html.haml  |  9 +++++++++
 server/views/instances/show.html.haml |  9 +++++++++
 server/views/networks/index.html.haml | 10 ++++++++++
 server/views/networks/index.xml.haml  |  4 ++++
 server/views/networks/new.html.haml   | 10 ++++++++++
 server/views/networks/show.html.haml  | 24 ++++++++++++++++++++++++
 server/views/networks/show.xml.haml   | 15 +++++++++++++++
 server/views/subnets/index.html.haml  | 10 ++++++++++
 server/views/subnets/index.xml.haml   |  4 ++++
 server/views/subnets/new.html.haml    | 14 ++++++++++++++
 server/views/subnets/show.html.haml   | 24 ++++++++++++++++++++++++
 server/views/subnets/show.xml.haml    | 13 +++++++++++++
 12 files changed, 146 insertions(+)
 create mode 100644 server/views/networks/index.html.haml
 create mode 100644 server/views/networks/index.xml.haml
 create mode 100644 server/views/networks/new.html.haml
 create mode 100644 server/views/networks/show.html.haml
 create mode 100644 server/views/networks/show.xml.haml
 create mode 100644 server/views/subnets/index.html.haml
 create mode 100644 server/views/subnets/index.xml.haml
 create mode 100644 server/views/subnets/new.html.haml
 create mode 100644 server/views/subnets/show.html.haml
 create mode 100644 server/views/subnets/show.xml.haml

diff --git a/server/views/instances/new.html.haml b/server/views/instances/new.html.haml
index f6f674e..e22a110 100644
--- a/server/views/instances/new.html.haml
+++ b/server/views/instances/new.html.haml
@@ -84,6 +84,15 @@
               %input{ :type => :text, :id => "path#{i}", :name => "path#{i}", :value => ""} Path #{i}
               %input{ :type => "file", :name => "content#{i}", :size => 50 }
 
+        - if driver.has_capability? :networks
+          %div{ 'data-role' => :fieldcontain }
+            %label{ :for => :network, :class => 'ui-input-text'} Network to Launch Instance into:
+            %select{:name => 'network_id', :'data-native-menu' => "true" }
+              %option{ :value => ''} None
+              - @networks.each do |net|
+                - net.subnets.each do |sn|
+                  %option{ :value => "#{net.id}+#{sn}" } #{net.id}+#{sn}
+
     - if !@hardware_profiles.empty?
       %div{ 'data-role' => :fieldcontain }
         %h3 Instance profile
diff --git a/server/views/instances/show.html.haml b/server/views/instances/show.html.haml
index ae193aa..37446bf 100644
--- a/server/views/instances/show.html.haml
+++ b/server/views/instances/show.html.haml
@@ -56,6 +56,15 @@
       -@instance.storage_volumes.each do |vol|
         %li
           %a{ :href => storage_volume_url("#{vol.keys.first}"), :'data-ajax' => 'false'}=["#{vol.keys.first}", "#{vol.values.first}"].compact.reject{ |e| e.empty? }.join(' <---> ')
+    - if @instance.network_bindings
+      %li{ :'data-role' => 'list-divider'} Network Bindings
+      -@instance.network_bindings.each do |net_bind|
+        %li
+          %a{ :href => network_url("#{net_bind[:network]}"), :'data-ajax' => 'false'}="Network #{net_bind[:network]}"
+        %li
+          %a{ :href => subnet_url("#{net_bind[:subnet]}"), :'data-ajax' => 'false'}="Subnet #{net_bind[:subnet]}"
+        %li="Address #{net_bind[:ip_address]}"
+        %li
     %li{ :'data-role' => 'list-divider'} Actions
     %li
       %div{ :'data-role' => 'controlgroup', :'data-type' => "horizontal" }
diff --git a/server/views/networks/index.html.haml b/server/views/networks/index.html.haml
new file mode 100644
index 0000000..aa0050b
--- /dev/null
+++ b/server/views/networks/index.html.haml
@@ -0,0 +1,10 @@
+=header "Networks" do
+  %a{ :href => url_for('networks/new'), :'data-icon' => :plus, :'data-role' => :button, :class => 'ui-btn-right'} Create new network
+
+%div{ :'data-role' => :content, :'data-theme' => 'c'}
+  %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'a'}
+    - @elements.each do |net|
+      %li
+        %a{ :href => network_url(net.id), :'data-ajax' => 'false'}
+          %img{ :class => 'ui-link-thumb', :src => '/images/cloud.png'}
+          %h3=net.id
diff --git a/server/views/networks/index.xml.haml b/server/views/networks/index.xml.haml
new file mode 100644
index 0000000..f2eaac6
--- /dev/null
+++ b/server/views/networks/index.xml.haml
@@ -0,0 +1,4 @@
+!!!XML
+%networks
+  - @elements.each do |c|
+    = haml :'networks/show', :locals => { :@network => c, :partial => true }
diff --git a/server/views/networks/new.html.haml b/server/views/networks/new.html.haml
new file mode 100644
index 0000000..0087259
--- /dev/null
+++ b/server/views/networks/new.html.haml
@@ -0,0 +1,10 @@
+=header "Create new network"
+
+%div{ :'data-role' => :content, :'data-theme' => 'c', :class => 'middle-dialog'}
+  %form{ :action => networks_url, :method => :post}
+    %div{ 'data-role' => :fieldcontain }
+      %p
+        %label{ :for => :address_block} CIDR Address block (optional):
+      %p
+        %input{ :type => :text, :id => :address_block, :name => :address_block, :value => '' }
+    %button{ :type => :submit} Create network
diff --git a/server/views/networks/show.html.haml b/server/views/networks/show.html.haml
new file mode 100644
index 0000000..18fef78
--- /dev/null
+++ b/server/views/networks/show.html.haml
@@ -0,0 +1,24 @@
+=header "Network"
+=subheader @network.id
+
+%div{ :'data-role' => :content, :'data-theme' => 'c'}
+  %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'd'}
+    %li{ :'data-role' => 'list-divider'} Identifier
+    %li
+      %p{ :'data-role' => 'fieldcontain'}=@network.id
+    %li{ :'data-role' => 'list-divider'} Name
+    %li
+      %p{ :'data-role' => 'fieldcontain'}=@network.name
+    %li{ :'data-role' => 'list-divider'} State
+    %li
+      %p{ :'data-role' => 'fieldcontain'}=@network.state
+    %li{ :'data-role' => 'list-divider'} Address Blocks
+    %li
+      %p{ :'data-role' => 'fieldcontain'}=(@network.address_blocks ? @network.address_blocks.join(",") : nil)
+    %li{ :'data-role' => 'list-divider'} Subnets
+    %li
+      %p{ :'data-role' => 'fieldcontain'}= (@network.subnets ? @network.subnets.join(",") : nil)
+    %li{ :'data-role' => 'list-divider'} Actions
+    %li
+      %div{ :'data-role' => 'controlgroup', :'data-type' => "horizontal" }
+        =link_to_action "Destroy", destroy_network_url(@network.id), :delete
diff --git a/server/views/networks/show.xml.haml b/server/views/networks/show.xml.haml
new file mode 100644
index 0000000..0ebb170
--- /dev/null
+++ b/server/views/networks/show.xml.haml
@@ -0,0 +1,15 @@
+- unless defined?(partial)
+  !!! XML
+%network{ :href => network_url(@network.id), :id => @network.id }
+  %name=@network.name
+  %state<
+    =@network.state
+  %address_blocks
+    - @network.address_blocks.each do |addr_block|
+      %address_block=addr_block
+  %subnets
+    - (@network.subnets || []).each do |subnet|
+      %subnet{:href => subnet_url(subnet), :id=>subnet}
+  %actions
+    - if driver.respond_to?(:destroy_network)
+      %link{ :rel => "destroy", :method => "delete", :href => destroy_network_url(@network.id)}
diff --git a/server/views/subnets/index.html.haml b/server/views/subnets/index.html.haml
new file mode 100644
index 0000000..5442c17
--- /dev/null
+++ b/server/views/subnets/index.html.haml
@@ -0,0 +1,10 @@
+=header "Subnets" do
+  %a{ :href => url_for('subnets/new'), :'data-icon' => :plus, :'data-role' => :button, :class => 'ui-btn-right'} Create new subnet
+
+%div{ :'data-role' => :content, :'data-theme' => 'c'}
+  %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'a'}
+    - @elements.each do |subnet|
+      %li
+        %a{ :href => subnet_url(subnet.id), :'data-ajax' => 'false'}
+          %img{ :class => 'ui-link-thumb', :src => '/images/cloud.png'}
+          %h3=subnet.id
diff --git a/server/views/subnets/index.xml.haml b/server/views/subnets/index.xml.haml
new file mode 100644
index 0000000..17f66b4
--- /dev/null
+++ b/server/views/subnets/index.xml.haml
@@ -0,0 +1,4 @@
+!!!XML
+%subnets
+  - @elements.each do |c|
+    = haml :'subnets/show', :locals => { :@subnet => c, :partial => true }
diff --git a/server/views/subnets/new.html.haml b/server/views/subnets/new.html.haml
new file mode 100644
index 0000000..c542d8e
--- /dev/null
+++ b/server/views/subnets/new.html.haml
@@ -0,0 +1,14 @@
+=header "Create new subnet"
+
+%div{ :'data-role' => :content, :'data-theme' => 'c', :class => 'middle-dialog'}
+  %form{ :action => subnets_url, :method => :post}
+    %div{ 'data-role' => :fieldcontain }
+      %p
+        %label{ :for => :network_id} Network ID:
+      %p
+        %input{ :type => :text, :id => :network_id, :name => :network_id, :value => '' }
+      %p
+        %label{ :for => :address_block} CIDR Address block:
+      %p
+        %input{ :type => :text, :id => :address_block, :name => :address_block, :value => '' }
+    %button{ :type => :submit} Create subnet
diff --git a/server/views/subnets/show.html.haml b/server/views/subnets/show.html.haml
new file mode 100644
index 0000000..e9cfadb
--- /dev/null
+++ b/server/views/subnets/show.html.haml
@@ -0,0 +1,24 @@
+=header "Subnet"
+=subheader @subnet.id
+
+%div{ :'data-role' => :content, :'data-theme' => 'c'}
+  %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'd'}
+    %li{ :'data-role' => 'list-divider'} Identifier
+    %li
+      %p{ :'data-role' => 'fieldcontain'}=@subnet.id
+    %li{ :'data-role' => 'list-divider'} Name
+    %li
+      %p{ :'data-role' => 'fieldcontain'}=@subnet.name
+    %li{ :'data-role' => 'list-divider'} Network
+    %li
+      %a{ :href => network_url(@subnet.network), :'data-ajax'=>'false' }=@subnet.network
+    %li{ :'data-role' => 'list-divider'} State
+    %li
+      %p{ :'data-role' => 'fieldcontain'}=@subnet.state
+    %li{ :'data-role' => 'list-divider'} Address Block
+    %li
+      %p{ :'data-role' => 'fieldcontain'}=(@subnet.address_block ? @subnet.address_block : nil)
+    %li{ :'data-role' => 'list-divider'} Actions
+    %li
+      %div{ :'data-role' => 'controlgroup', :'data-type' => "horizontal" }
+        =link_to_action "Destroy", destroy_subnet_url(@subnet.id), :delete
diff --git a/server/views/subnets/show.xml.haml b/server/views/subnets/show.xml.haml
new file mode 100644
index 0000000..3c47e59
--- /dev/null
+++ b/server/views/subnets/show.xml.haml
@@ -0,0 +1,13 @@
+- unless defined?(partial)
+  !!! XML
+%subnet{ :href => subnet_url(@subnet.id), :id => @subnet.id }
+  %name=@subnet.name
+  %state<
+    =@subnet.state
+  %address_block
+    =@subnet.address_block
+  %network
+    =@subnet.network
+  %actions
+    - if driver.respond_to?(:destroy_subnet)
+      %link{ :rel => "destroy", :method => "delete", :href => destroy_subnet_url(@subnet.id)}
-- 
1.8.1.4