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 2012/03/19 17:28:27 UTC

[PATCH 2/4] CIMI: Adds VSP entity and views to CIMI Client

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


Signed-off-by: marios <ma...@redhat.com>
---
 clients/cimi/app.rb                |    1 +
 clients/cimi/lib/entities.rb       |    1 +
 clients/cimi/lib/entities/vsp.rb   |   31 +++++++++++++++++++++++++++++++
 clients/cimi/views/vsps/index.haml |   30 ++++++++++++++++++++++++++++++
 clients/cimi/views/vsps/show.haml  |   33 +++++++++++++++++++++++++++++++++
 5 files changed, 96 insertions(+), 0 deletions(-)
 create mode 100644 clients/cimi/lib/entities/vsp.rb
 create mode 100644 clients/cimi/views/vsps/index.haml
 create mode 100644 clients/cimi/views/vsps/show.haml

diff --git a/clients/cimi/app.rb b/clients/cimi/app.rb
index 5064712..3d32cc5 100644
--- a/clients/cimi/app.rb
+++ b/clients/cimi/app.rb
@@ -33,6 +33,7 @@ module CIMI::Frontend
     use CIMI::Frontend::NetworkTemplate
     use CIMI::Frontend::RoutingGroup
     use CIMI::Frontend::RoutingGroupTemplate
+    use CIMI::Frontend::VSP
     use Rack::Session::Cookie
 
     helpers CIMI::Frontend::Helper
diff --git a/clients/cimi/lib/entities.rb b/clients/cimi/lib/entities.rb
index 5f9ed53..53ab6bf 100644
--- a/clients/cimi/lib/entities.rb
+++ b/clients/cimi/lib/entities.rb
@@ -33,3 +33,4 @@ require 'entities/network_configuration'
 require 'entities/network_template'
 require 'entities/routing_group'
 require 'entities/routing_group_template'
+require 'entities/vsp'
diff --git a/clients/cimi/lib/entities/vsp.rb b/clients/cimi/lib/entities/vsp.rb
new file mode 100644
index 0000000..13c90bd
--- /dev/null
+++ b/clients/cimi/lib/entities/vsp.rb
@@ -0,0 +1,31 @@
+
+# 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::VSP < CIMI::Frontend::Entity
+
+  get '/cimi/vsps/:id' do
+    vsp_xml = get_entity('vsps', params[:id], credentials)
+    @vsp = CIMI::Model::VSP.from_xml(vsp_xml)
+    haml :'vsps/show'
+  end
+
+  get '/cimi/vsps' do
+    vsps_xml = get_entity_collection('vsps', credentials)
+    @vsps = CIMI::Model::VSPCollection.from_xml(vsps_xml)
+    haml :'vsps/index'
+  end
+
+end
diff --git a/clients/cimi/views/vsps/index.haml b/clients/cimi/views/vsps/index.haml
new file mode 100644
index 0000000..163f777
--- /dev/null
+++ b/clients/cimi/views/vsps/index.haml
@@ -0,0 +1,30 @@
+- @title=@vsps.description
+
+- content_for :breadcrumb do
+  %ul.breadcrumb
+    %li
+      %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
+      %span.divider="/"
+    %li.active
+      VSPCollection
+
+- content_for :actions do
+  %p
+    %a{ :href => "#{@vsps.id}?format=xml", :class => 'label warning' } XML
+    %a{ :href => "#{@vsps.id}?format=json", :class => 'label warning' } JSON
+
+%blockquote
+  %p
+    A VSP Collection entity represents the collection of VSPs within a Provider.
+    This entity can be used to locate and create VSPs.
+
+%h3 VSPCollection
+%ul
+  - @vsps.vsps.each do |vsp|
+    %li
+      %a{ :href => "/cimi/vsps/#{vsp.href.split('/').last}"}=vsp.href.split('/').last
+
+-details 'VSPCollection details' do
+  -row 'ID', @vsps.id
+  -row 'Description', @vsps.description
+  -row 'Created', @vsps.created
diff --git a/clients/cimi/views/vsps/show.haml b/clients/cimi/views/vsps/show.haml
new file mode 100644
index 0000000..432b45e
--- /dev/null
+++ b/clients/cimi/views/vsps/show.haml
@@ -0,0 +1,33 @@
+- @title="#{@vsp.name}"
+
+- content_for :breadcrumb do
+  %ul.breadcrumb
+    %li
+      %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
+      %span.divider="/"
+    %li
+      %a{ :href => "/cimi/vsps"} VSPCollection
+      %span.divider="/"
+    %li.active
+      = @vsp.name
+
+- content_for :actions do
+  %p
+    %a{ :href => "#{@vsp.id}?format=xml", :class => 'label warning' } XML
+    %a{ :href => "#{@vsp.id}?format=json", :class => 'label warning' } JSON
+
+%blockquote
+  %p
+    A VSP represents the connection parameters of a network port.
+
+-details 'VSP details' do
+  -row 'ID', @vsp.id
+  -row 'Description', @vsp.description
+  -row 'Created', @vsp.created
+  -row 'State', @vsp.state
+  -row 'Network', @vsp.network.href
+  -row 'Bandwidth Reservation', @vsp.bandwidth_reservation
+  -row 'Traffic Priority', @vsp.traffic_priority
+  -row 'Maximum Traffic Delay', @vsp.max_traffic_delay
+  -row 'Maximum Traffic Loss', @vsp.max_traffic_loss
+  -row 'Maximum Traffic Jitter', @vsp.max_traffic_jitter
-- 
1.7.6.5