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...@gmail.com on 2013/01/10 10:29:03 UTC

[PATCH 1/2] added network port entity

From: NjeriChelimo <ma...@gmail.com>

---
 clients/cimi/lib/entities/network_port.rb |   30 +++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 clients/cimi/lib/entities/network_port.rb

diff --git a/clients/cimi/lib/entities/network_port.rb b/clients/cimi/lib/entities/network_port.rb
new file mode 100644
index 0000000..16923ee
--- /dev/null
+++ b/clients/cimi/lib/entities/network_port.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::NetworkPort < CIMI::Frontend::Entity
+
+  get '/cimi/network_ports/:id' do
+    network_port_xml = get_entity('network_ports', params[:id], credentials)
+    @network_port = CIMI::Model::NetworkPort.from_xml(network_port_xml)
+    haml :'network_ports/show'
+  end
+
+  get '/cimi/network_templates' do
+    network_port_xml = get_entity_collection('network_ports', credentials)
+    @network_ports = CIMI::Model::NetworkPortCollection.from_xml(network_port_xml)
+    haml :'network_ports/index'
+   end
+
+                                end
-- 
1.7.9.5


Re: [PATCH 2/2] Added network port routes and index.haml file

Posted by "marios@redhat.com" <ma...@redhat.com>.
Hey Martha -  ok as we discussed this morning... the patches were
basically fine - I tracked the issue down to the haml file. Haml is very
particular about syntax and especially the spacing - which is a bit of a
pita to get right sometimes.

I attach the diff here (you can apply this on top of your second patch)
- so you can see what the view file should look like. Since the
attachment may not show up on the mailing list, I include it inline at
the end of this e-mail.

Can you also add the show view (i.e. show.haml as well as the
index.haml) before you send the patches out. Also, can you remove the
Gemfile.lock from the committed files. If you need any help
squashing/rebasing and getting these into shape just ask,

marios



>From 8cc360e4bfa03892c8a7777b06315400ea9aeb10 Mon Sep 17 00:00:00 2001
From: marios <ma...@redhat.com>
Date: Thu, 10 Jan 2013 15:46:15 +0200
Subject: [PATCH 3/3] DIFF for Martha


Signed-off-by: marios <ma...@redhat.com>
---
 clients/cimi/views/network_ports/index.haml | 42
++++++++++++++---------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/clients/cimi/views/network_ports/index.haml
b/clients/cimi/views/network_ports/index.haml
index bfa34d4..2deb64d 100644
--- a/clients/cimi/views/network_ports/index.haml
+++ b/clients/cimi/views/network_ports/index.haml
@@ -1,23 +1,23 @@
 - @title=collection_name @network_ports
-
-  - content_for :breadcrumb do
-    %ul.breadcrumb
-      %li
-        %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
-        %span.divider="/"
-      %li.active
-         NetworkPortCollection
-  - content_for :actions do
-    %p
-      %a{ :href => "#{@network_ports.id}?format=xml", :class => 'label
warning' } XML
-      %a{ :href => "#{@network_ports.id}?format=json", :class => 'label
warning' } JSON
-
-  %ul
-    - @network_ports.network_ports.each do |port|
-      %li
-        %a{ :href =>
"/cimi/network_ports/#{href_to_id(port.id)}"}=href_to_id(port.id)
-
-  -details do
-    -row 'ID', @network_ports.id
-    -row 'Count', @network_ports.count

+- content_for :breadcrumb do
+  %ul.breadcrumb
+    %li
+      %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
+      %span.divider="/"
+    %li.active
+      NetworkPortCollection
+
+- content_for :actions do
+  %p
+    %a{ :href => "#{@network_ports.id}?format=xml", :class => 'label
warning' } XML
+    %a{ :href => "#{@network_ports.id}?format=json", :class => 'label
warning' } JSON
+
+%ul
+  - @network_ports.network_ports.each do |port|
+    %li
+      %a{ :href =>
"/cimi/network_ports/#{href_to_id(port.id)}"}=href_to_id(port.id)
+
+-details do
+  -row 'ID', @network_ports.id
+  -row 'Count', @network_ports.count
-- 
1.7.11.7





On 10/01/13 11:29, martha.c.chumo@gmail.com wrote:
> From: NjeriChelimo <ma...@gmail.com>
> 
> NOTE: When I do a curl, it works fine, but returns a 404 in the browser.
> ---
>  clients/cimi/Gemfile.lock                   |   12 ------------
>  clients/cimi/app.rb                         |    1 +
>  clients/cimi/lib/entities.rb                |    1 +
>  clients/cimi/lib/entities/network_port.rb   |    4 ++--
>  clients/cimi/views/network_ports/index.haml |   23 +++++++++++++++++++++++
>  5 files changed, 27 insertions(+), 14 deletions(-)
>  create mode 100644 clients/cimi/views/network_ports/index.haml
> 
> diff --git a/clients/cimi/Gemfile.lock b/clients/cimi/Gemfile.lock
> index 5ce2c94..93cb338 100644
> --- a/clients/cimi/Gemfile.lock
> +++ b/clients/cimi/Gemfile.lock
> @@ -1,8 +1,6 @@
>  GEM
>    remote: http://rubygems.org/
>    specs:
> -    backports (2.6.4)
> -    eventmachine (1.0.0)
>      haml (3.1.7)
>      json (1.7.5)
>      mime-types (1.19)
> @@ -12,21 +10,12 @@ GEM
>        rack (>= 0.4)
>      rack-protection (1.2.0)
>        rack
> -    rack-test (0.6.1)
> -      rack (>= 1.0)
>      rest-client (1.6.7)
>        mime-types (>= 1.16)
>      sinatra (1.3.3)
>        rack (~> 1.3, >= 1.3.6)
>        rack-protection (~> 1.2)
>        tilt (~> 1.3, >= 1.3.3)
> -    sinatra-contrib (1.3.1)
> -      backports (>= 2.0)
> -      eventmachine
> -      rack-protection
> -      rack-test
> -      sinatra (~> 1.3.0)
> -      tilt (~> 1.3)
>      tilt (1.3.3)
>  
>  PLATFORMS
> @@ -39,4 +28,3 @@ DEPENDENCIES
>    rack-accept
>    rest-client
>    sinatra
> -  sinatra-contrib
> diff --git a/clients/cimi/app.rb b/clients/cimi/app.rb
> index e26f2b9..d6702d7 100644
> --- a/clients/cimi/app.rb
> +++ b/clients/cimi/app.rb
> @@ -25,6 +25,7 @@ module CIMI::Frontend
>      use CIMI::Frontend::Machine
>      use CIMI::Frontend::MachineAdmin
>      use CIMI::Frontend::MachineTemplate
> +    use CIMI::Frontend::NetworkPort
>      use CIMI::Frontend::VolumeConfiguration
>      use CIMI::Frontend::VolumeImage
>      use CIMI::Frontend::Volume
> diff --git a/clients/cimi/lib/entities.rb b/clients/cimi/lib/entities.rb
> index 3442360..75bd6bd 100644
> --- a/clients/cimi/lib/entities.rb
> +++ b/clients/cimi/lib/entities.rb
> @@ -31,6 +31,7 @@ require 'entities/volume'
>  require 'entities/network'
>  require 'entities/network_configuration'
>  require 'entities/network_template'
> +require 'entities/network_port'
>  require 'entities/routing_group'
>  require 'entities/routing_group_template'
>  require 'entities/vsp'
> diff --git a/clients/cimi/lib/entities/network_port.rb b/clients/cimi/lib/entities/network_port.rb
> index 16923ee..3f3da2c 100644
> --- a/clients/cimi/lib/entities/network_port.rb
> +++ b/clients/cimi/lib/entities/network_port.rb
> @@ -21,10 +21,10 @@ class CIMI::Frontend::NetworkPort < CIMI::Frontend::Entity
>      haml :'network_ports/show'
>    end
>  
> -  get '/cimi/network_templates' do
> +  get '/cimi/network_ports' do
>      network_port_xml = get_entity_collection('network_ports', credentials)
>      @network_ports = CIMI::Model::NetworkPortCollection.from_xml(network_port_xml)
>      haml :'network_ports/index'
>     end
>  
> -                                end
> +end
> diff --git a/clients/cimi/views/network_ports/index.haml b/clients/cimi/views/network_ports/index.haml
> new file mode 100644
> index 0000000..bfa34d4
> --- /dev/null
> +++ b/clients/cimi/views/network_ports/index.haml
> @@ -0,0 +1,23 @@
> +- @title=collection_name @network_ports
> +  
> +  - content_for :breadcrumb do
> +    %ul.breadcrumb
> +      %li
> +        %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
> +        %span.divider="/"
> +      %li.active
> +         NetworkPortCollection
> +  - content_for :actions do
> +    %p
> +      %a{ :href => "#{@network_ports.id}?format=xml", :class => 'label warning' } XML
> +      %a{ :href => "#{@network_ports.id}?format=json", :class => 'label warning' } JSON
> +    
> +  %ul
> +    - @network_ports.network_ports.each do |port|
> +      %li
> +        %a{ :href => "/cimi/network_ports/#{href_to_id(port.id)}"}=href_to_id(port.id)
> +    
> +  -details do
> +    -row 'ID', @network_ports.id
> +    -row 'Count', @network_ports.count
> +
> 


[PATCH 2/2] Added network port routes and index.haml file

Posted by ma...@gmail.com.
From: NjeriChelimo <ma...@gmail.com>

NOTE: When I do a curl, it works fine, but returns a 404 in the browser.
---
 clients/cimi/Gemfile.lock                   |   12 ------------
 clients/cimi/app.rb                         |    1 +
 clients/cimi/lib/entities.rb                |    1 +
 clients/cimi/lib/entities/network_port.rb   |    4 ++--
 clients/cimi/views/network_ports/index.haml |   23 +++++++++++++++++++++++
 5 files changed, 27 insertions(+), 14 deletions(-)
 create mode 100644 clients/cimi/views/network_ports/index.haml

diff --git a/clients/cimi/Gemfile.lock b/clients/cimi/Gemfile.lock
index 5ce2c94..93cb338 100644
--- a/clients/cimi/Gemfile.lock
+++ b/clients/cimi/Gemfile.lock
@@ -1,8 +1,6 @@
 GEM
   remote: http://rubygems.org/
   specs:
-    backports (2.6.4)
-    eventmachine (1.0.0)
     haml (3.1.7)
     json (1.7.5)
     mime-types (1.19)
@@ -12,21 +10,12 @@ GEM
       rack (>= 0.4)
     rack-protection (1.2.0)
       rack
-    rack-test (0.6.1)
-      rack (>= 1.0)
     rest-client (1.6.7)
       mime-types (>= 1.16)
     sinatra (1.3.3)
       rack (~> 1.3, >= 1.3.6)
       rack-protection (~> 1.2)
       tilt (~> 1.3, >= 1.3.3)
-    sinatra-contrib (1.3.1)
-      backports (>= 2.0)
-      eventmachine
-      rack-protection
-      rack-test
-      sinatra (~> 1.3.0)
-      tilt (~> 1.3)
     tilt (1.3.3)
 
 PLATFORMS
@@ -39,4 +28,3 @@ DEPENDENCIES
   rack-accept
   rest-client
   sinatra
-  sinatra-contrib
diff --git a/clients/cimi/app.rb b/clients/cimi/app.rb
index e26f2b9..d6702d7 100644
--- a/clients/cimi/app.rb
+++ b/clients/cimi/app.rb
@@ -25,6 +25,7 @@ module CIMI::Frontend
     use CIMI::Frontend::Machine
     use CIMI::Frontend::MachineAdmin
     use CIMI::Frontend::MachineTemplate
+    use CIMI::Frontend::NetworkPort
     use CIMI::Frontend::VolumeConfiguration
     use CIMI::Frontend::VolumeImage
     use CIMI::Frontend::Volume
diff --git a/clients/cimi/lib/entities.rb b/clients/cimi/lib/entities.rb
index 3442360..75bd6bd 100644
--- a/clients/cimi/lib/entities.rb
+++ b/clients/cimi/lib/entities.rb
@@ -31,6 +31,7 @@ require 'entities/volume'
 require 'entities/network'
 require 'entities/network_configuration'
 require 'entities/network_template'
+require 'entities/network_port'
 require 'entities/routing_group'
 require 'entities/routing_group_template'
 require 'entities/vsp'
diff --git a/clients/cimi/lib/entities/network_port.rb b/clients/cimi/lib/entities/network_port.rb
index 16923ee..3f3da2c 100644
--- a/clients/cimi/lib/entities/network_port.rb
+++ b/clients/cimi/lib/entities/network_port.rb
@@ -21,10 +21,10 @@ class CIMI::Frontend::NetworkPort < CIMI::Frontend::Entity
     haml :'network_ports/show'
   end
 
-  get '/cimi/network_templates' do
+  get '/cimi/network_ports' do
     network_port_xml = get_entity_collection('network_ports', credentials)
     @network_ports = CIMI::Model::NetworkPortCollection.from_xml(network_port_xml)
     haml :'network_ports/index'
    end
 
-                                end
+end
diff --git a/clients/cimi/views/network_ports/index.haml b/clients/cimi/views/network_ports/index.haml
new file mode 100644
index 0000000..bfa34d4
--- /dev/null
+++ b/clients/cimi/views/network_ports/index.haml
@@ -0,0 +1,23 @@
+- @title=collection_name @network_ports
+  
+  - content_for :breadcrumb do
+    %ul.breadcrumb
+      %li
+        %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
+        %span.divider="/"
+      %li.active
+         NetworkPortCollection
+  - content_for :actions do
+    %p
+      %a{ :href => "#{@network_ports.id}?format=xml", :class => 'label warning' } XML
+      %a{ :href => "#{@network_ports.id}?format=json", :class => 'label warning' } JSON
+    
+  %ul
+    - @network_ports.network_ports.each do |port|
+      %li
+        %a{ :href => "/cimi/network_ports/#{href_to_id(port.id)}"}=href_to_id(port.id)
+    
+  -details do
+    -row 'ID', @network_ports.id
+    -row 'Count', @network_ports.count
+
-- 
1.7.9.5