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/02/13 11:08:05 UTC
[PATCH] CIMI webapp: creating new volume configs
From: NjeriChelimo <ma...@gmail.com>
---
clients/cimi/lib/entities/volume_configuration.rb | 20 ++++++++++++++
clients/cimi/views/machine_templates/index.haml | 12 --------
.../cimi/views/volume_configurations/index.haml | 29 ++++++++++++++++++++
3 files changed, 49 insertions(+), 12 deletions(-)
diff --git a/clients/cimi/lib/entities/volume_configuration.rb b/clients/cimi/lib/entities/volume_configuration.rb
index 7008696..8e2db78 100644
--- a/clients/cimi/lib/entities/volume_configuration.rb
+++ b/clients/cimi/lib/entities/volume_configuration.rb
@@ -27,4 +27,24 @@ class CIMI::Frontend::VolumeConfiguration < CIMI::Frontend::Entity
haml :'volume_configurations/index'
end
+ post '/cimi/volume_configurations' do
+ volume_configuration_xml = Nokogiri::XML::Builder.new do |xml|
+ xml.VolumeConfigurations(:xmlns => CIMI::Frontend::CMWG_NAMESPACE) {
+ xml.name params[:volume_configuration][:name]
+ xml.description params[:volume_configuration][:description]
+ xml.format params[:volume_configuration][:format]
+ xml.capacity params[:volume_configuration][:capacity]
+ }
+ end.to_xml
+ begin
+ result = create_entity('volume_configurations', volume_configuration_xml, credentials)
+ volume_configuration = CIMI::Model::VolumeConfigurationCollection.from_xml(result)
+ flash[:success] = "Volume Configuration was successfully created."
+ redirect "/cimi/volume_configurations/#{volume_configuration.name}", 302
+ rescue => e
+ flash[:error] = "Volume Configuration cannot be created: #{e.message}"
+ redirect :back
+ end
+ end
+
end
diff --git a/clients/cimi/views/machine_templates/index.haml b/clients/cimi/views/machine_templates/index.haml
index 3077bf7..6bcbd24 100644
--- a/clients/cimi/views/machine_templates/index.haml
+++ b/clients/cimi/views/machine_templates/index.haml
@@ -8,10 +8,6 @@
%li.active
MachineTemplateCollection
-
-
-
-
- content_for :actions do
%p
@@ -44,14 +40,6 @@
%a{ :href => "#{@machine_templates.id}?format=xml", :class => 'label warning' } XML
%a{ :href => "#{@machine_templates.id}?format=json", :class => 'label warning' } JSON
-
-
-
-
-
-
-
-
%blockquote
%p
A Machine Template Collection entity represents the collection of
diff --git a/clients/cimi/views/volume_configurations/index.haml b/clients/cimi/views/volume_configurations/index.haml
index 376a112..f284b8b 100644
--- a/clients/cimi/views/volume_configurations/index.haml
+++ b/clients/cimi/views/volume_configurations/index.haml
@@ -9,6 +9,35 @@
VolumeConfigurationCollection
- content_for :actions do
+
+ %p
+ %a{ :href => '#volumeConfigurationModal', :class => 'btn btn-primary', :'data-toggle' => :modal} New Volume Configuration
+
+ %div{ :id => :volumeConfigurationModal, :class => 'modal hide fade' }
+ .modal-header
+ %h3 Create new Volume Configuration
+ .modal-body
+ %form{ :action => "/cimi/volume_configurations", :method => :post }
+ %fieldset
+ .control-group
+ %label.control-label{ :for => 'volume_configuration[name]' } Volume Configuration Name
+ .controls
+ %input{ :type => :text, :name => 'volume_configuration[name]' }
+ %label.control-label{ :for => 'volume_configuration[description]' } Volume Configuration Description
+ .controls
+ %input{ :type => :text, :description => 'volume_configuration[description]' }
+ %label.control-label{ :for => 'volume_configuration[format]' } Volume Configuration Format
+ .controls
+ %input{ :type => :text, :format => 'volume_configuration[format]' }
+ %label.control-label{ :for => 'volume_configuration[capacity]' } Volume Configuration Capacity
+ .controls
+ %input{ :type => :text, :capacity => 'volume_configuration[capacity]' }
+
+ .modal-footer
+ %a{ :href => '#', :class => 'btn btn-primary', :'data-loading-text' => 'Creating Volume Configuration...', :onclick => "postModalForm(this, 'volumeConfigurationModal')"} Continue
+ %a{ :href => '#', :class => 'btn', :'data-dismiss' => 'modal'} Cancel
+ %p{:style => 'text-align:right;'}
+
%p
%a{ :href => "#{@volume_configurations.id}?format=xml", :class => 'label warning' } XML
%a{ :href => "#{@volume_configurations.id}?format=json", :class => 'label warning' } JSON
--
1.7.9.5
Re: [PATCH] routes and view files for forwarding_groups and
forwarding_group_templates
Posted by David Lutterkort <lu...@redhat.com>.
On Wed, 2013-02-13 at 13:08 +0300, martha.c.chumo@gmail.com wrote:
> From: NjeriChelimo <ma...@gmail.com>
This seems to be mostly the same as the 3 patches you sent previously
(and that we neglected to commit); if there is anything that you'd like
to commit on top of them, please rebase/resend the patch.
David
[PATCH] routes and view files for forwarding_groups and forwarding_group_templates
Posted by ma...@gmail.com.
From: NjeriChelimo <ma...@gmail.com>
---
clients/cimi/app.rb | 4 +--
clients/cimi/lib/entities.rb | 4 +--
clients/cimi/lib/entities/forwarding_group.rb | 30 +++++++++++++++++++
.../cimi/lib/entities/forwarding_group_template.rb | 30 +++++++++++++++++++
.../views/forwarding_group_templates/index.haml | 29 ++++++++++++++++++
.../views/forwarding_group_templates/show.haml | 31 ++++++++++++++++++++
clients/cimi/views/forwarding_groups/index.haml | 28 ++++++++++++++++++
clients/cimi/views/forwarding_groups/show.haml | 29 ++++++++++++++++++
8 files changed, 181 insertions(+), 4 deletions(-)
create mode 100644 clients/cimi/lib/entities/forwarding_group.rb
create mode 100644 clients/cimi/lib/entities/forwarding_group_template.rb
create mode 100644 clients/cimi/views/forwarding_group_templates/index.haml
create mode 100644 clients/cimi/views/forwarding_group_templates/show.haml
create mode 100644 clients/cimi/views/forwarding_groups/index.haml
create mode 100644 clients/cimi/views/forwarding_groups/show.haml
diff --git a/clients/cimi/app.rb b/clients/cimi/app.rb
index 3809425..bf763d7 100644
--- a/clients/cimi/app.rb
+++ b/clients/cimi/app.rb
@@ -36,11 +36,11 @@ module CIMI::Frontend
use CIMI::Frontend::NetworkPortTemplate
use CIMI::Frontend::NetworkTemplate
use CIMI::Frontend::NetworkPort
- use CIMI::Frontend::RoutingGroup
- use CIMI::Frontend::RoutingGroupTemplate
use CIMI::Frontend::VSP
use CIMI::Frontend::VSPConfiguration
use CIMI::Frontend::VSPTemplate
+ use CIMI::Frontend::ForwardingGroup
+ use CIMI::Frontend::ForwardingGroupTemplate
use Rack::Session::Cookie
helpers CIMI::Frontend::Helper
diff --git a/clients/cimi/lib/entities.rb b/clients/cimi/lib/entities.rb
index c5c40df..0f54ca6 100644
--- a/clients/cimi/lib/entities.rb
+++ b/clients/cimi/lib/entities.rb
@@ -22,6 +22,8 @@ require 'entities/base_entity'
require 'entities/cloud_entry_point'
require 'entities/address'
require 'entities/address_template'
+require 'entities/forwarding_group'
+require 'entities/forwarding_group_template'
require 'entities/machine_configuration'
require 'entities/machine_admin'
require 'entities/machine_image'
@@ -36,8 +38,6 @@ require 'entities/network_port'
require 'entities/network_port_configuration'
require 'entities/network_port_template'
require 'entities/network_template'
-require 'entities/routing_group'
-require 'entities/routing_group_template'
require 'entities/vsp'
require 'entities/vsp_configuration'
require 'entities/vsp_template'
diff --git a/clients/cimi/lib/entities/forwarding_group.rb b/clients/cimi/lib/entities/forwarding_group.rb
new file mode 100644
index 0000000..6ba5d60
--- /dev/null
+++ b/clients/cimi/lib/entities/forwarding_group.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::ForwardingGroup < CIMI::Frontend::Entity
+
+ get '/cimi/forwarding_groups/:id' do
+ forwarding_group_xml = get_entity('forwarding_groups', params[:id], credentials)
+ @forwarding_group = CIMI::Model::ForwardingGroup.from_xml(forwarding_group_xml)
+ haml :'forwarding_groups/show'
+ end
+
+ get '/cimi/forwarding_groups' do
+ forwarding_groups_xml = get_entity_collection('forwarding_groups', credentials)
+ @forwarding_groups = CIMI::Model::ForwardingGroupCollection.from_xml(forwarding_groups_xml)
+ haml :'forwarding_groups/index'
+ end
+
+end
diff --git a/clients/cimi/lib/entities/forwarding_group_template.rb b/clients/cimi/lib/entities/forwarding_group_template.rb
new file mode 100644
index 0000000..1636ad8
--- /dev/null
+++ b/clients/cimi/lib/entities/forwarding_group_template.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::ForwardingGroupTemplate < CIMI::Frontend::Entity
+
+ get '/cimi/forwarding_group_templates/:id' do
+ fg_template_xml = get_entity('forwarding_group_templates', params[:id], credentials)
+ @fg_template = CIMI::Model::ForwardingGroupTemplate.from_xml(fg_template_xml)
+ haml :'forwarding_group_templates/show'
+ end
+
+ get '/cimi/forwarding_group_templates' do
+ fg_templates_xml = get_entity_collection('forwarding_group_templates', credentials)
+ @fg_templates = CIMI::Model::ForwardingGroupTemplateCollection.from_xml(fg_templates_xml)
+ haml :'forwarding_group_templates/index'
+ end
+
+end
diff --git a/clients/cimi/views/forwarding_group_templates/index.haml b/clients/cimi/views/forwarding_group_templates/index.haml
new file mode 100644
index 0000000..2c86e5c
--- /dev/null
+++ b/clients/cimi/views/forwarding_group_templates/index.haml
@@ -0,0 +1,29 @@
+- @title=collection_name @fg_templates
+
+- content_for :breadcrumb do
+ %ul.breadcrumb
+ %li
+ %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
+ %span.divider="/"
+ %li.active
+ ForwardingGroupTemplateCollection
+- content_for :actions do
+ %p
+ %a{ :href => "#{@fg_templates.id}?format=xml", :class => 'label warning' } XML
+ %a{ :href => "#{@fg_templates.id}?format=json", :class => 'label warning' } JSON
+
+%blockquote
+ %p
+ A Forwarding Group Template Collection entity represents the collection of Forwarding
+ Group Template entities within a Provider. This entity can be used to locate and
+ create Forwarding Group Templates.
+
+%h3 ForwardingGroupTemplateCollection
+%ul
+ - @fg_templates.forwarding_group_templates.each do |fg_template|
+ %li
+ %a{ :href => "/cimi/forwarding_group_templates/#{href_to_id fg_template.id}"}=href_to_id(fg_template.id)
+
+-details 'ForwardingGroupTemplateCollection details' do
+ -row 'ID', @fg_templates.id
+ -row 'Count', @fg_templates.count
diff --git a/clients/cimi/views/forwarding_group_templates/show.haml b/clients/cimi/views/forwarding_group_templates/show.haml
new file mode 100644
index 0000000..d5b78a0
--- /dev/null
+++ b/clients/cimi/views/forwarding_group_templates/show.haml
@@ -0,0 +1,31 @@
+- @title="#{@fg_template.name}"
+
+- content_for :breadcrumb do
+ %ul.breadcrumb
+ %li
+ %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
+ %span.divider="/"
+ %li
+ %a{ :href => "/cimi/forwarding_group_templates"} ForwardingGroupTemplateCollection
+ %span.divider="/"
+ %li.active
+ =@fg_template.name
+
+- content_for :actions do
+ %p
+ %a{ :href => "#{@fg_template.id}?format=xml", :class => 'label warning' } XML
+ %a{ :href => "#{@fg_template.id}?format=json", :class => 'label warning' } JSON
+
+%blockquote
+ %p
+ A ForwardingGroupTemplate entity captures the configuration values for realizing a ForwardingGroup.
+ A Forwarding Group Template may be used to create multiple ForwardingGroup
+
+-details 'ForwardingGroupTemplate details' do
+ -row 'ID', @fg_template.id
+ -row 'Description', @fg_template.description
+ -row 'Created', @fg_template.created
+
+-details 'ForwardingGroupTemplate networks' do
+ -@fg_template.networks.each do |net|
+ -row 'ID', net.href
diff --git a/clients/cimi/views/forwarding_groups/index.haml b/clients/cimi/views/forwarding_groups/index.haml
new file mode 100644
index 0000000..cb5a737
--- /dev/null
+++ b/clients/cimi/views/forwarding_groups/index.haml
@@ -0,0 +1,28 @@
+- @title=collection_name @forwarding_groups
+
+- content_for :breadcrumb do
+ %ul.breadcrumb
+ %li
+ %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
+ %span.divider="/"
+ %li.active
+ ForwardingGroupCollection
+- content_for :actions do
+ %p
+ %a{ :href => "#{@forwarding_groups.id}?format=xml", :class => 'label warning' } XML
+ %a{ :href => "#{@forwarding_groups.id}?format=json", :class => 'label warning' } JSON
+
+%blockquote
+ %p
+ A Forwarding Group Collection entity represents the collection of Forwarding Groups
+ within a Provider. This entity can be used to locate and create Forwarding Groups.
+
+%h3 ForwardingGroupCollection
+%ul
+ - @forwarding_groups.forwarding_groups.each do |group|
+ %li
+ %a{ :href => "/cimi/forwarding_groups/#{href_to_id group.id}"}=href_to_id(group.id)
+
+-details 'ForwardingGroupCollection details' do
+ -row 'ID', @forwarding_groups.id
+ -row 'Count', @forwarding_groups.count
diff --git a/clients/cimi/views/forwarding_groups/show.haml b/clients/cimi/views/forwarding_groups/show.haml
new file mode 100644
index 0000000..4ff032c
--- /dev/null
+++ b/clients/cimi/views/forwarding_groups/show.haml
@@ -0,0 +1,29 @@
+- @title="#{@forwarding_group.name}"
+
+- content_for :breadcrumb do
+ %ul.breadcrumb
+ %li
+ %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
+ %span.divider="/"
+ %li
+ %a{ :href => "/cimi/forwarding_groups"} ForwardingGroupCollection
+ %span.divider="/"
+ %li.active
+ = @forwarding_group.name
+
+- content_for :actions do
+ %p
+ %a{ :href => "#{@forwarding_group.id}?format=xml", :class => 'label warning' } XML
+ %a{ :href => "#{@forwarding_group.id}?format=json", :class => 'label warning' } JSON
+%blockquote
+ %p
+ A Forwarding Group represents a collection of Networks that route to each other.
+
+-details 'ForwardingGroup details' do
+ -row 'ID', @forwarding_group.id
+ -row 'Description',@forwarding_group.description
+ -row 'Created',@forwarding_group.created
+
+-details 'ForwardingGroup Networks' do
+ -@forwarding_group.networks.each do |net|
+ -row 'ID', net.href
--
1.7.9.5
Re: [PATCH] CIMI Webapp - Creating volume_images
Posted by Martha Chumo <ma...@gmail.com>.
Noticed the stacktrace - when creating VolumeImage ( all the other
entities); working on that.
The name makes it to the backend because it is displayed on the show page
of the created VolumeImage. It's the description not making it, so I
suspect a bug in the backend.
As for the VolumeImage image_location, I will send out another patch,
removing the select dropdown and having text input for the user to input
the URL (That is what I have undestood.)
On Wed, Feb 20, 2013 at 3:21 AM, David Lutterkort <lu...@redhat.com> wrote:
> On Wed, 2013-02-13 at 13:08 +0300, martha.c.chumo@gmail.com wrote:
> > From: NjeriChelimo <ma...@gmail.com>
> >
> > ---
> > clients/cimi/lib/entities/volume_image.rb | 21 +++++++++++++++++++++
> > clients/cimi/views/volume_images/index.haml | 26
> ++++++++++++++++++++++++++
> > 2 files changed, 47 insertions(+)
>
> When I try to create a new volume image with this, I get a stacktrace
> from the webapp after the POST to the CIMI server happens. It also seems
> that the name and description I enter for the new VolumeImage don't make
> it to the backend (or there is a bug in the backend)
>
> Also, the location of the VolumeImage should be a URL (href); users will
> set that to somewhere where they have the actual bits for the image (see
> section 5.15.7 in the CIMI spec)
>
> David
>
>
>
--
{ email : "martha.c.chumo@gmail.com" ,
social : [ { twitter : "@NjeriChelimo" } , {facebook : "Njeri Chelimo" }
],
code : [ { github : "Njeri Chelimo"}, { bitbucket : "nchelimo" } ],
skype : "martha.chumo"
}
Re: [PATCH] CIMI Webapp - Creating volume_images
Posted by David Lutterkort <lu...@redhat.com>.
On Wed, 2013-02-13 at 13:08 +0300, martha.c.chumo@gmail.com wrote:
> From: NjeriChelimo <ma...@gmail.com>
>
> ---
> clients/cimi/lib/entities/volume_image.rb | 21 +++++++++++++++++++++
> clients/cimi/views/volume_images/index.haml | 26 ++++++++++++++++++++++++++
> 2 files changed, 47 insertions(+)
When I try to create a new volume image with this, I get a stacktrace
from the webapp after the POST to the CIMI server happens. It also seems
that the name and description I enter for the new VolumeImage don't make
it to the backend (or there is a bug in the backend)
Also, the location of the VolumeImage should be a URL (href); users will
set that to somewhere where they have the actual bits for the image (see
section 5.15.7 in the CIMI spec)
David
[PATCH] CIMI Webapp - Creating volume_images
Posted by ma...@gmail.com.
From: NjeriChelimo <ma...@gmail.com>
---
clients/cimi/lib/entities/volume_image.rb | 21 +++++++++++++++++++++
clients/cimi/views/volume_images/index.haml | 26 ++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
diff --git a/clients/cimi/lib/entities/volume_image.rb b/clients/cimi/lib/entities/volume_image.rb
index f3cc56b..df96ddc 100644
--- a/clients/cimi/lib/entities/volume_image.rb
+++ b/clients/cimi/lib/entities/volume_image.rb
@@ -22,9 +22,30 @@ class CIMI::Frontend::VolumeImage < CIMI::Frontend::Entity
end
get '/cimi/volume_images' do
+ volumes_xml = get_entity_collection('volumes', credentials)
+ @volumes = CIMI::Model::VolumeCollection.from_xml(volumes_xml)
volume_images_xml = get_entity_collection('volume_images', credentials)
@volume_images = CIMI::Model::VolumeImageCollection.from_xml(volume_images_xml)
haml :'volume_images/index'
end
+ post '/cimi/volume_images' do
+ volume_image_xml = Nokogiri::XML::Builder.new do |xml|
+ xml.VolumeImage(:xmlns => CIMI::Frontend::CMWG_NAMESPACE) {
+ xml.name params[:volume_image][:name]
+ xml.description params[:volume_image][:description]
+ xml.imageLocation( :href => params[:volume_image][:image_location] )
+ }
+ end.to_xml
+ begin
+ result = create_entity('volume_images', volume_image_xml, credentials)
+ volume_image = CIMI::Model::VolumeImageCollection.from_xml(result)
+ flash[:success] = "Volume Image was successfully created."
+ redirect "/cimi/volume_images/#{volume_image.name}", 302
+ rescue => e
+ flash[:error] = "Volume Image cannot be created: #{e.message}"
+ redirect :back
+ end
+ end
+
end
diff --git a/clients/cimi/views/volume_images/index.haml b/clients/cimi/views/volume_images/index.haml
index ea32a1e..fa71008 100644
--- a/clients/cimi/views/volume_images/index.haml
+++ b/clients/cimi/views/volume_images/index.haml
@@ -9,6 +9,32 @@
VolumeImageCollection
- content_for :actions do
+
+ %p
+ %a{ :href => '#volumeImageModal', :class => 'btn btn-primary', :'data-toggle' => :modal} New Volume Image
+
+ %div{ :id => :volumeImageModal, :class => 'modal hide fade' }
+ .modal-header
+ %h3 Create new Volume Image
+ %form{ :action => "/cimi/volume_images", :method => :post }
+ %fieldset
+ .control-group
+ %label.control-label{ :for => 'volume_image[name]' } Volume Image Name
+ .controls
+ %input{ :type => :text, :name => 'volume_image[name]' }
+ %label.control-label{ :for => 'volume_image[description]' } Volume Image Description
+ .controls
+ %input{ :type => :text, :name => 'volume_image[description]' }
+ %label.control-label{ :for => 'volume_image[image_location]' } Image Location
+ .controls
+ %select{ :name => 'volume_image[image_location]' }
+ - @volumes.volumes.each do |volume|
+ %option{ :value => volume.id }=href_to_id(volume.id)
+ .modal-footer
+ %a{ :href => '#', :class => 'btn btn-primary', :'data-loading-text' => 'Creating VolumeImage...', :onclick => "postModalForm(this, 'volumeImageModal')"} Continue
+ %a{ :href => '#', :class => 'btn', :'data-dismiss' => 'modal'} Cancel
+ %p{:style => 'text-align:right;'}
+
%p
%a{ :href => "#{@volume_images.id}?format=xml", :class => 'label warning' } XML
%a{ :href => "#{@volume_images.id}?format=json", :class => 'label warning' } JSON
--
1.7.9.5
Re: [PATCH] CIMI webapp: creating new volume configs
Posted by David Lutterkort <lu...@redhat.com>.
On Wed, 2013-02-13 at 13:08 +0300, martha.c.chumo@gmail.com wrote:
> From: NjeriChelimo <ma...@gmail.com>
>
> ---
> clients/cimi/lib/entities/volume_configuration.rb | 20 ++++++++++++++
> clients/cimi/views/machine_templates/index.haml | 12 --------
> .../cimi/views/volume_configurations/index.haml | 29 ++++++++++++++++++++
> 3 files changed, 49 insertions(+), 12 deletions(-)
I can't apply this patch; can you rebase it to the latest master and
send again ?
David