You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by dk...@apache.org on 2013/07/15 09:00:15 UTC
[5/8] git commit: CIMI: add system and templates to client UI
CIMI: add system and templates to client UI
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/a8ed21e5
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/a8ed21e5
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/a8ed21e5
Branch: refs/heads/master
Commit: a8ed21e575548ff558108b9e85a3efe5c71d1a4f
Parents: 1d8b391
Author: Dies Koper <di...@fast.au.fujitsu.com>
Authored: Tue Jul 9 16:33:13 2013 +1000
Committer: Dies Koper <di...@fast.au.fujitsu.com>
Committed: Mon Jul 15 11:07:21 2013 +1000
----------------------------------------------------------------------
clients/cimi/app.rb | 2 +
clients/cimi/lib/client.rb | 10 +-
clients/cimi/lib/entities.rb | 2 +
clients/cimi/lib/entities/system.rb | 208 +++++++++++++++++++
clients/cimi/lib/entities/system_template.rb | 55 +++++
clients/cimi/views/system_templates/index.haml | 49 +++++
clients/cimi/views/system_templates/show.haml | 74 +++++++
clients/cimi/views/systems/index.haml | 70 +++++++
clients/cimi/views/systems/resources/index.haml | 34 +++
clients/cimi/views/systems/resources/show.haml | 31 +++
clients/cimi/views/systems/show.haml | 81 ++++++++
server/lib/cimi/models/system.rb | 10 +-
.../drivers/mock/mock_driver_cimi_methods.rb | 2 +
13 files changed, 619 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8ed21e5/clients/cimi/app.rb
----------------------------------------------------------------------
diff --git a/clients/cimi/app.rb b/clients/cimi/app.rb
index 104afde..350ed2d 100644
--- a/clients/cimi/app.rb
+++ b/clients/cimi/app.rb
@@ -39,6 +39,8 @@ module CIMI::Frontend
use CIMI::Frontend::NetworkTemplate
use CIMI::Frontend::NetworkPort
use CIMI::Frontend::ResourceMetadata
+ use CIMI::Frontend::System
+ use CIMI::Frontend::SystemTemplate
use Rack::Session::Cookie
helpers CIMI::Frontend::Helper
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8ed21e5/clients/cimi/lib/client.rb
----------------------------------------------------------------------
diff --git a/clients/cimi/lib/client.rb b/clients/cimi/lib/client.rb
index 0418682..e0ba51b 100644
--- a/clients/cimi/lib/client.rb
+++ b/clients/cimi/lib/client.rb
@@ -23,7 +23,9 @@ module CIMI
end
def get_entity(entity_type, id, credentials)
- client['%s/%s' % [entity_type, id]].get(auth_header(credentials))
+ entity_href = get_entity_collection_href(entity_type, credentials)
+ raise RestClient::ResourceNotFound if not entity_href
+ RestClient::Resource.new('%s/%s' % [entity_href, id]).get(auth_header(credentials))
end
def get_entity_collection(entity_type, credentials)
@@ -33,6 +35,10 @@ module CIMI
RestClient::Resource.new(entity_href).get(auth_header(credentials))
end
+ def get_sub_entity_collection(parent_href, credentials)
+ RestClient::Resource.new(parent_href).get(auth_header(credentials))
+ end
+
# look up entity collection url from cloud entry point
# returns nil if entity not in cloud entry point (i.e. not supported)
def get_entity_collection_href(entity_type, credentials)
@@ -52,7 +58,7 @@ module CIMI
end
def entity_action(entity_type, action, id, body, credentials)
- client["%s/%s/%s" % [entity_type, id, action.to_s]].post(body, auth_header(credentials))
+ client["%s/%s/%s" % [entity_type, id, action.to_s]].post(body, auth_header(credentials).merge(:content_type => 'application/xml'))
end
def provider_header(credentials)
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8ed21e5/clients/cimi/lib/entities.rb
----------------------------------------------------------------------
diff --git a/clients/cimi/lib/entities.rb b/clients/cimi/lib/entities.rb
index 680d52d..1d01db7 100644
--- a/clients/cimi/lib/entities.rb
+++ b/clients/cimi/lib/entities.rb
@@ -39,3 +39,5 @@ require 'entities/network_port_configuration'
require 'entities/network_port_template'
require 'entities/network_template'
require 'entities/resource_metadata'
+require 'entities/system'
+require 'entities/system_template'
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8ed21e5/clients/cimi/lib/entities/system.rb
----------------------------------------------------------------------
diff --git a/clients/cimi/lib/entities/system.rb b/clients/cimi/lib/entities/system.rb
new file mode 100644
index 0000000..996cb57
--- /dev/null
+++ b/clients/cimi/lib/entities/system.rb
@@ -0,0 +1,208 @@
+# 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::System < CIMI::Frontend::Entity
+
+ get '/cimi/systems' do
+ system_xml = get_entity_collection('systems', credentials)
+ @systems = collection_class_for(:system).from_xml(system_xml)
+ # We need to include this stuff for new System form
+ begin
+ system_templates_xml = get_entity_collection('system_templates', credentials)
+ @system_templates = collection_class_for(:system_template).from_xml(system_templates_xml)
+ rescue RestClient::ResourceNotFound # In case backend does not support System Template collection
+ @system_templates = nil
+ end
+ haml :'systems/index'
+ end
+
+ get '/cimi/systems/:id' do
+ system_xml = get_entity('systems', params[:id], credentials)
+ @system = CIMI::Model::System.from_xml(system_xml)
+ haml :'systems/show'
+ end
+
+ get '/cimi/systems/:id/systems' do
+ systems_resources_index('systems')
+ end
+
+ get '/cimi/systems/:id/machines' do
+ systems_resources_index('machines')
+ end
+
+ get '/cimi/systems/:id/credentials' do
+ systems_resources_index('credentials')
+ end
+
+ get '/cimi/systems/:id/volumes' do
+ systems_resources_index('volumes')
+ end
+
+ get '/cimi/systems/:id/networks' do
+ systems_resources_index('networks')
+ end
+
+ get '/cimi/systems/:id/network_ports' do
+ systems_resources_index('network_ports')
+ end
+
+ get '/cimi/systems/:id/addresses' do
+ systems_resources_index('addresses')
+ end
+
+ get '/cimi/systems/:id/forwarding_groups' do
+ systems_resources_index('forwarding_groups')
+ end
+
+ get '/cimi/systems/:id/systems/:res_id' do
+ systems_resources_show('systems')
+ end
+
+ get '/cimi/systems/:id/machines/:res_id' do
+ systems_resources_show('machines')
+ end
+
+ get '/cimi/systems/:id/credentials/:res_id' do
+ systems_resources_show('credentials')
+ end
+
+ get '/cimi/systems/:id/volumes/:res_id' do
+ systems_resources_show('volumes')
+ end
+
+ get '/cimi/systems/:id/networks/:res_id' do
+ systems_resources_show('networks')
+ end
+
+ get '/cimi/systems/:id/network_ports/:res_id' do
+ systems_resources_show('network_ports')
+ end
+
+ get '/cimi/systems/:id/addresses/:res_id' do
+ systems_resources_show('addresses')
+ end
+
+ get '/cimi/systems/:id/forwarding_groups/:res_id' do
+ systems_resources_show('forwarding_groups')
+ end
+
+ def systems_resources_show(res)
+ system_xml = get_entity('systems', params[:id], credentials)
+ @system = CIMI::Model::System.from_xml(system_xml)
+ @resource_collection = @system.send(res)
+ system_resources_xml = get_sub_entity_collection(@resource_collection.href, credentials)
+ @resource = XmlSimple.xml_in(system_resources_xml)[collection_name(@resource_collection).sub(/(.+)Collection/,'\1')].find do |r|
+ href_to_id r['id'][0] == params[:res_id]
+ end
+ raise RestClient::ResourceNotFound if not @resource
+ @resource_type = id_to_href(collection_name(@resource_collection).sub(/System(.+)Collection/,'\1'))[1..-1]
+ haml :'systems/resources/show'
+ end
+
+ def systems_resources_index(res)
+ system_xml = get_entity('systems', params[:id], credentials)
+ @system = CIMI::Model::System.from_xml(system_xml)
+ @resource_collection = @system.send(res)
+ system_resources_xml = get_sub_entity_collection(@resource_collection.href, credentials)
+ @resources = XmlSimple.xml_in(system_resources_xml)
+ haml :'systems/resources/index'
+ end
+
+ delete '/cimi/systems/:id/delete' do
+ result = destroy_entity('systems', params[:id], credentials)
+ if result.code == 200
+ flash[:success] = "System '#{params[:id]}' was successfully destroyed."
+ redirect '/cimi/systems'
+ else
+ flash[:error] = "Unable to destroy system #{params[:id]}"
+ end
+ end
+
+ post '/cimi/systems/:id/stop' do
+ action_xml = Nokogiri::XML::Builder.new do |xml|
+ xml.Action(:xmlns => CIMI::Frontend::CMWG_NAMESPACE) {
+ xml.action "http://schemas.dmtf.org/cimi/1/action/stop"
+ }
+ end.to_xml
+ entity_action 'systems', 'stop', action_xml, credentials, params[:id]
+ flash[:success] = "System stop successfully initiated."
+ redirect '/cimi/systems/%s' % params[:id]
+ end
+
+ post '/cimi/systems/:id/start' do
+ action_xml = Nokogiri::XML::Builder.new do |xml|
+ xml.Action(:xmlns => CIMI::Frontend::CMWG_NAMESPACE) {
+ xml.action "http://schemas.dmtf.org/cimi/1/action/start"
+ }
+ end.to_xml
+ entity_action 'systems', 'start', action_xml, credentials, params[:id]
+ flash[:success] = "System start successfully initiated."
+ redirect '/cimi/systems/%s' % params[:id]
+ end
+
+ post '/cimi/systems/:id/restart' do
+ action_xml = Nokogiri::XML::Builder.new do |xml|
+ xml.Action(:xmlns => CIMI::Frontend::CMWG_NAMESPACE) {
+ xml.action "http://schemas.dmtf.org/cimi/1/action/restart"
+ }
+ end.to_xml
+ entity_action 'systems', 'restart', action_xml, credentials, params[:id]
+ flash[:success] = "System restart successfully initiated."
+ redirect '/cimi/systems/%s' % params[:id]
+ end
+
+ post '/cimi/systems' do
+ system_xml = Nokogiri::XML::Builder.new do |xml|
+ xml.System(:xmlns => CIMI::Frontend::CMWG_NAMESPACE) {
+ xml.name params[:system][:name]
+ xml.systemTemplate( :href => params[:system][:system_template])
+ }
+ end.to_xml
+ begin
+ result = create_entity('systems', system_xml, credentials)
+ system = collection_class_for(:system).from_xml(result)
+ flash[:success] = "System create was successfully initiated."
+ redirect "/cimi/systems/#{href_to_id(system.id)}"
+ rescue => e
+ flash[:error] = "System cannot be created: #{e.message}"
+ end
+ end
+
+ post '/cimi/systems/import' do
+ action_xml = Nokogiri::XML::Builder.new do |xml|
+ xml.Action(:xmlns => CIMI::Frontend::CMWG_NAMESPACE) {
+ xml.action "http://schemas.dmtf.org/cimi/1/action/import"
+ xml.source params[:system][:source]
+ }
+ end.to_xml
+ entity_action 'systems', 'import', action_xml, credentials
+ flash[:success] = "System import successfully initiated."
+ redirect '/cimi/systems'
+ end
+
+ post '/cimi/systems/:id/export' do
+ action_xml = Nokogiri::XML::Builder.new do |xml|
+ xml.Action(:xmlns => CIMI::Frontend::CMWG_NAMESPACE) {
+ xml.action "http://schemas.dmtf.org/cimi/1/action/export"
+ xml.format params[:system][:format]
+ xml.destination params[:system][:destination]
+ }
+ end.to_xml
+ result = entity_action 'systems', 'export', action_xml, credentials, params[:id]
+ flash[:success] = "System export successfully initiated."
+ redirect '/cimi/systems/%s' % params[:id]
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8ed21e5/clients/cimi/lib/entities/system_template.rb
----------------------------------------------------------------------
diff --git a/clients/cimi/lib/entities/system_template.rb b/clients/cimi/lib/entities/system_template.rb
new file mode 100644
index 0000000..fdb30ec
--- /dev/null
+++ b/clients/cimi/lib/entities/system_template.rb
@@ -0,0 +1,55 @@
+# 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::SystemTemplate < CIMI::Frontend::Entity
+
+ get '/cimi/system_templates/:id' do
+ system_templates_xml = get_entity('system_templates', params[:id], credentials)
+ @system_template = CIMI::Model::SystemTemplate.from_xml(system_templates_xml)
+ haml :'system_templates/show'
+ end
+
+ get '/cimi/system_templates' do
+ system_template_xml = get_entity_collection('system_templates', credentials)
+ @system_templates = collection_class_for(:system_template).from_xml(system_template_xml)
+ haml :'system_templates/index'
+ end
+
+ post '/cimi/system_templates/import' do
+ action_xml = Nokogiri::XML::Builder.new do |xml|
+ xml.Action(:xmlns => CIMI::Frontend::CMWG_NAMESPACE) {
+ xml.action "http://schemas.dmtf.org/cimi/1/action/import"
+ xml.source params[:system_template][:source]
+ }
+ end.to_xml
+ entity_action 'system_templates', 'import', action_xml, credentials
+ flash[:success] = "System Template import successfully initiated."
+ redirect '/cimi/system_templates'
+ end
+
+ post '/cimi/system_templates/:id/export' do
+ action_xml = Nokogiri::XML::Builder.new do |xml|
+ xml.Action(:xmlns => CIMI::Frontend::CMWG_NAMESPACE) {
+ xml.action "http://schemas.dmtf.org/cimi/1/action/export"
+ xml.format params[:system_template][:format]
+ xml.destination params[:system_template][:destination]
+ }
+ end.to_xml
+ result = entity_action 'system_templates', 'export', action_xml, credentials, params[:id]
+ flash[:success] = "System Template export successfully initiated."
+ redirect '/cimi/system_templates/%s' % params[:id]
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8ed21e5/clients/cimi/views/system_templates/index.haml
----------------------------------------------------------------------
diff --git a/clients/cimi/views/system_templates/index.haml b/clients/cimi/views/system_templates/index.haml
new file mode 100644
index 0000000..17dc36c
--- /dev/null
+++ b/clients/cimi/views/system_templates/index.haml
@@ -0,0 +1,49 @@
+- @title=collection_name @system_templates
+
+- content_for :breadcrumb do
+ %ul.breadcrumb
+ %li
+ %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
+ %span.divider="/"
+ %li.active
+ SystemTemplateCollection
+
+- content_for :actions do
+
+ - if @system_templates.operations.find {|o| o.rel == 'http://schemas.dmtf.org/cimi/1/action/import'}
+ %p
+ %a{ :href => '#systemTemplateModal', :class => 'btn btn-primary', :'data-toggle' => :modal} Import System Template
+
+ %div{ :id => :systemTemplateModal, :class => 'modal hide fade' }
+ .modal-header
+ %h3 Import a System Template
+ .modal-body
+ %form{ :action => "/cimi/system_templates/import", :method => :post }
+ %fieldset
+ .control-group
+ %label.control-label{ :for => 'system_template[source]' } Source URI
+ .controls
+ %input{ :type => :text, :name => 'system_template[source]' }
+ .modal-footer
+ %a{ :href => '#', :class => 'btn btn-primary', :'data-loading-text' => 'Creating System Template...', :onclick => "postModalForm(this, 'systemTemplateModal')"} Continue
+ %a{ :href => '#', :class => 'btn', :'data-dismiss' => 'modal'} Cancel
+
+ %p{:style => 'text-align:right;'}
+ %a{ :href => "#{@system_templates.id}?format=xml", :class => 'label warning' } XML
+ %a{ :href => "#{@system_templates.id}?format=json", :class => 'label warning' } JSON
+
+%blockquote
+ %p
+ A System Template Collection entity represents the collection of
+ System Template entities within a Provider. This entity can be used to
+ create systems.
+
+%h3 SystemTemplateCollection
+%ul
+ - @system_templates.system_templates.each do |temp|
+ %li
+ %a{ :href => "/cimi/system_templates/#{href_to_id(temp.id)}"}=href_to_id(temp.id)
+
+- details do
+ -row 'id',@system_templates.id
+ -row 'Count',@system_templates.count
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8ed21e5/clients/cimi/views/system_templates/show.haml
----------------------------------------------------------------------
diff --git a/clients/cimi/views/system_templates/show.haml b/clients/cimi/views/system_templates/show.haml
new file mode 100644
index 0000000..c12ecbb
--- /dev/null
+++ b/clients/cimi/views/system_templates/show.haml
@@ -0,0 +1,74 @@
+- @title="#{@system_template.name}"
+
+- content_for :breadcrumb do
+ %ul.breadcrumb
+ %li
+ %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
+ %span.divider="/"
+ %li
+ %a{ :href => "/cimi/system_templates"} SystemTemplateCollection
+ %span.divider="/"
+ %li.active
+ = @system_template.name
+
+- content_for :actions do
+
+ %div{:class => 'btn-group btn-group-vertical'}
+ %form{ :action => "/cimi/system_templates/#{href_to_id @system_template.id}/delete", :method => :post, :style => 'display:inline', :id => 'frm_delete'}
+ %input{ :type => :hidden, :name => '_method', :value => 'delete'}
+ - if @system_template.operations.find {|o| o.rel == 'http://schemas.dmtf.org/cimi/1/action/export'}
+ %a{ :class => 'btn btn-primary', :href => '#systemModal', :'data-toggle' => :modal} Export
+ - if @system_template.operations.find {|o| o.rel == 'delete'}
+ %button{ :class => 'btn btn-danger', :type => :button, :onclick => '$("#frm_delete").submit()'} Destroy
+
+ %div{ :id => :systemModal, :class => 'modal hide fade' }
+ .modal-header
+ %h3 Export System Template entity
+ .modal-body
+ %form{ :action => "/cimi/system_templates/#{href_to_id @system_template.id}/export", :method => :post }
+ %fieldset
+ .control-group
+ %label.control-label{ :for => 'system_template[format]' } Media Type
+ .controls
+ %input{ :type => :text, :name => 'system_template[format]' }
+ %label.control-label{ :for => 'system_template[destination]' } Location to Put Exported Data
+ .controls
+ %input{ :type => :text, :name => 'system_template[destination]' }
+ .modal-footer
+ %a{ :href => '#', :class => 'btn btn-primary', :'data-loading-text' => 'System Template Export Initiated...', :onclick => "postModalForm(this, 'systemModal')"} Continue
+ %a{ :href => '#', :class => 'btn', :'data-dismiss' => 'modal'} Cancel
+
+ %p{:style => 'margin-top:1em;'}
+ %a{ :href => "#{@system_template.id}?format=xml", :class => 'label warning' } XML
+ %a{ :href => "#{@system_template.id}?format=json", :class => 'label warning' } JSON
+
+-details 'SystemTemplate details' do
+ -row 'ID',@system_template.id
+ -row 'Name',@system_template.name
+ -row 'Description',@system_template.description
+ -row 'Created',@system_template.created
+
+%h5 Component Descriptors
+%table{ :class => 'table table-bordered table-striped' }
+ %thead
+ %tr
+ %th Name
+ %th Description
+ %th Type
+ %th Component Template
+ %th Quantity
+ %tbody
+ - @system_template.component_descriptors.each do |compo|
+ %tr
+ %td=compo.name
+ %td=compo.description
+ %td=compo.type
+ -descriptors = [:machine_template,:system_template,:credential_template,:volume_template,:network_template,:network_port_template,:forwarding_group_template,:address_template]
+ -value = nil
+ -unless descriptors.find {|d| value = compo.send(d)[:href]}
+ -descriptors.find do |d|
+ - values = compo.send(d).attribute_values.collect do |k, v|
+ - "#{k} => #{v.attribute_values[:href]}" if v and v.respond_to? 'attribute_values' and v.attribute_values[:href]
+ - value = values.compact.join(' <br> ')
+ %td=value ? convert_urls(value) : 'N/A'
+ %td=compo.quantity ? compo.quantity : 1
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8ed21e5/clients/cimi/views/systems/index.haml
----------------------------------------------------------------------
diff --git a/clients/cimi/views/systems/index.haml b/clients/cimi/views/systems/index.haml
new file mode 100644
index 0000000..243e7d9
--- /dev/null
+++ b/clients/cimi/views/systems/index.haml
@@ -0,0 +1,70 @@
+- @title=collection_name @systems
+
+- content_for :breadcrumb do
+ %ul.breadcrumb
+ %li
+ %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
+ %span.divider="/"
+ %li.active
+ SystemCollection
+
+- content_for :actions do
+
+ - if @systems.operations.find {|o| o.rel == 'add'} and @system_templates
+ %p
+ %a{ :href => '#systemModal', :class => 'btn btn-primary', :'data-toggle' => :modal} New System
+
+ %div{ :id => :systemModal, :class => 'modal hide fade' }
+ .modal-header
+ %h3 Create new System entity
+ .modal-body
+ %form{ :action => "/cimi/systems", :method => :post }
+ %fieldset
+ .control-group
+ %label.control-label{ :for => 'system[name]' } System Name
+ .controls
+ %input{ :type => :text, :name => 'system[name]' }
+ %label.control-label{ :for => 'system[system_template]' } System Template
+ .controls
+ %select{ :name => 'system[system_template]' }
+ - @system_templates.system_templates.each do |template|
+ %option{ :value => template.id }=href_to_id(template.id)
+ .modal-footer
+ %a{ :href => '#', :class => 'btn btn-primary', :'data-loading-text' => 'Creating System...', :onclick => "postModalForm(this, 'systemModal')"} Continue
+ %a{ :href => '#', :class => 'btn', :'data-dismiss' => 'modal'} Cancel
+
+ - if @systems.operations.find {|o| o.rel == 'http://schemas.dmtf.org/cimi/1/action/import'}
+ %p
+ %a{ :href => '#systemImportModal', :class => 'btn btn-primary', :'data-toggle' => :modal} Import System
+
+ %div{ :id => :systemImportModal, :class => 'modal hide fade' }
+ .modal-header
+ %h3 Import system
+ .modal-body
+ %form{ :action => "/cimi/systems/import", :method => :post }
+ %fieldset
+ .control-group
+ %label.control-label{ :for => 'system[source]' } Source URI
+ .controls
+ %input{ :type => :text, :name => 'system[source]' }
+ .modal-footer
+ %a{ :href => '#', :class => 'btn btn-primary', :'data-loading-text' => 'Import...', :onclick => "postModalForm(this, 'systemImportModal')"} Continue
+ %a{ :href => '#', :class => 'btn', :'data-dismiss' => 'modal'} Cancel
+
+ %p{:style => 'text-align:right;'}
+ %a{ :href => "#{@systems.id}?format=xml", :class => 'label warning' } XML
+ %a{ :href => "#{@systems.id}?format=json", :class => 'label warning' } JSON
+
+%ul
+ - if @systems.systems and not @systems.systems.empty?
+ - @systems.systems.each do |system|
+ %li
+ %a{ :href => "/cimi/systems/#{href_to_id(system.id)}"}=href_to_id(system.id)
+ - else
+ .alert-message.block-message.warning
+ %p
+ There are no System entities defined for this collection.
+
+- details do
+ - row 'ID', @systems.id
+ - row 'Count', @systems.count
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8ed21e5/clients/cimi/views/systems/resources/index.haml
----------------------------------------------------------------------
diff --git a/clients/cimi/views/systems/resources/index.haml b/clients/cimi/views/systems/resources/index.haml
new file mode 100644
index 0000000..940c992
--- /dev/null
+++ b/clients/cimi/views/systems/resources/index.haml
@@ -0,0 +1,34 @@
+- @title=collection_name @resource_collection
+
+- content_for :breadcrumb do
+ %ul.breadcrumb
+ %li
+ %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
+ %span.divider="/"
+ %li
+ %a{ :href => "/cimi/systems"} SystemCollection
+ %span.divider="/"
+ %li
+ %a{ :href => "/cimi/systems/#{href_to_id(@system.id)}"}= href_to_id(@system.id)
+ %span.divider="/"
+ %li.active=collection_name @resource_collection
+
+- content_for :actions do
+ %p
+ %a{ :href => "#{@resource_collection.id}?format=xml", :class => 'label warning' } XML
+ %a{ :href => "#{@resource_collection.id}?format=json", :class => 'label warning' } JSON
+
+%ul
+ - resources = @resources[collection_name(@resource_collection).sub(/Collection/,'')]
+ - if resources and not resources.empty?
+ - @resources[collection_name(@resource_collection).sub(/Collection/,'')].each do |c|
+ %li
+ %a{ :href => "#{id_to_href(collection_name(@resource_collection).sub(/System(.+)Collection/,'\1'))[1..-1].pluralize}/#{href_to_id(c['id'][0])}"}=href_to_id(c['id'][0])
+ - else
+ .alert-message.block-message.warning
+ %p
+ There are no #{collection_name(@resource_collection).sub(/Collection/,'').pluralize} defined for this system.
+
+-details do
+ -row 'ID', @resources['id'][0]
+ -row 'Count', @resources['count'][0]
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8ed21e5/clients/cimi/views/systems/resources/show.haml
----------------------------------------------------------------------
diff --git a/clients/cimi/views/systems/resources/show.haml b/clients/cimi/views/systems/resources/show.haml
new file mode 100644
index 0000000..2e5851f
--- /dev/null
+++ b/clients/cimi/views/systems/resources/show.haml
@@ -0,0 +1,31 @@
+- @title="#{@resource['name'][0]}"
+
+- content_for :breadcrumb do
+ %ul.breadcrumb
+ %li
+ %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
+ %span.divider="/"
+ %li
+ %a{ :href => "/cimi/systems"} SystemCollection
+ %span.divider="/"
+ %li
+ %a{ :href => "/cimi/systems/#{href_to_id(@system.id)}"}= href_to_id(@system.id)
+ %span.divider="/"
+ %li
+ %a{ :href => "/cimi/systems/#{href_to_id(@system.id)}/#{@resource_type.pluralize}"}= collection_name @resource_collection
+ %span.divider="/"
+ %li.active
+ = @resource['name'][0]
+
+- content_for :actions do
+
+ %p{:style => 'margin-top:1em;'}
+ %a{ :href => "#{@resource['id'][0]}?format=xml", :class => 'label warning' } XML
+ %a{ :href => "#{@resource['id'][0]}?format=json", :class => 'label warning' } JSON
+
+- details do
+ -row 'ID', @resource['id'][0]
+ -row 'Name', @resource['name'][0]
+ -row 'Description', @resource['description'] ? @resource['description'][0] : 'N/A'
+ -row 'Created', @resource['created'] ? @resource['created'][0] : 'N/A'
+ -row collection_name(@resource_collection).sub(/System(.+)Collection/,'\1'), url("/cimi/#{@resource_type.pluralize}/#{href_to_id @resource[@resource_type][0]['href']}")
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8ed21e5/clients/cimi/views/systems/show.haml
----------------------------------------------------------------------
diff --git a/clients/cimi/views/systems/show.haml b/clients/cimi/views/systems/show.haml
new file mode 100644
index 0000000..6aab865
--- /dev/null
+++ b/clients/cimi/views/systems/show.haml
@@ -0,0 +1,81 @@
+- @title="#{@system.name}"
+
+- content_for :breadcrumb do
+ %ul.breadcrumb
+ %li
+ %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint
+ %span.divider="/"
+ %li
+ %a{ :href => "/cimi/systems"} SystemCollection
+ %span.divider="/"
+ %li.active
+ = @system.name
+
+- content_for :actions do
+
+ %div{:class => 'btn-group btn-group-vertical'}
+ %form{ :action => "/cimi/systems/#{href_to_id @system.id}/stop", :method => :post, :style => 'display:inline', :id => 'frm_stop'}
+ %form{ :action => "/cimi/systems/#{href_to_id @system.id}/start", :method => :post, :style => 'display:inline', :id => 'frm_start'}
+ %form{ :action => "/cimi/systems/#{href_to_id @system.id}/restart", :method => :post, :style => 'display:inline', :id => 'frm_restart'}
+ %form{ :action => "/cimi/systems/#{href_to_id @system.id}/delete", :method => :post, :style => 'display:inline', :id => 'frm_delete'}
+ %input{ :type => :hidden, :name => '_method', :value => 'delete'}
+ - if @system.operations.find {|o| o.rel == 'http://schemas.dmtf.org/cimi/1/action/stop'}
+ %button{ :class => 'btn btn-warning', :type => :button, :onclick => '$("#frm_stop").submit()'} Stop
+ - if @system.operations.find {|o| o.rel == 'http://schemas.dmtf.org/cimi/1/action/start'}
+ %button{ :class => 'btn btn-success', :type => :button, :onclick => '$("#frm_start").submit()'} Start
+ - if @system.operations.find {|o| o.rel == 'http://schemas.dmtf.org/cimi/1/action/restart'}
+ %button{ :class => 'btn btn-info', :type => :button, :onclick => '$("#frm_restart").submit()'} Reboot
+ - if @system.operations.find {|o| o.rel == 'http://schemas.dmtf.org/cimi/1/action/export'}
+ %a{ :class => 'btn btn-primary', :href => '#systemModal', :'data-toggle' => :modal} Export
+ - if @system.operations.find {|o| o.rel == 'delete'}
+ %button{ :class => 'btn btn-danger', :type => :button, :onclick => '$("#frm_delete").submit()'} Destroy
+
+ %div{ :id => :systemModal, :class => 'modal hide fade' }
+ .modal-header
+ %h3 Export System entity
+ .modal-body
+ %form{ :action => "/cimi/systems/#{href_to_id @system.id}/export", :method => :post }
+ %fieldset
+ .control-group
+ %label.control-label{ :for => 'system[format]' } Media Type
+ .controls
+ %input{ :type => :text, :name => 'system[format]' }
+ %label.control-label{ :for => 'system[destination]' } Location to Put Exported Data
+ .controls
+ %input{ :type => :text, :name => 'system[destination]' }
+ .modal-footer
+ %a{ :href => '#', :class => 'btn btn-primary', :'data-loading-text' => 'System Export Initiated...', :onclick => "postModalForm(this, 'systemModal')"} Continue
+ %a{ :href => '#', :class => 'btn', :'data-dismiss' => 'modal'} Cancel
+
+ %p{:style => 'margin-top:1em;'}
+ %a{ :href => "#{@system.id}?format=xml", :class => 'label warning' } XML
+ %a{ :href => "#{@system.id}?format=json", :class => 'label warning' } JSON
+
+- details do
+ -row 'ID', @system.id
+ -row 'Name',@system.name
+ -row 'Description',@system.description
+ -row 'Created', @system.created
+ -row 'State',state_span_for(@system.state)
+ -row 'Systems', @system.systems.href
+ -row 'Machines', @system.machines.href
+ -row 'Credentials', @system.credentials.href
+ -row 'Volumes', @system.volumes.href
+ -row 'Networks', @system.networks.href
+ -row 'NetworkPorts', @system.network_ports.href
+ -row 'Addresses', @system.addresses.href
+ -row 'ForwardingGroups', @system.forwarding_groups.href
+ -row 'Meters', (@system.meters.empty? ? "No meters" : ( @system.meters.each{|meter| meters.id}))
+
+%h5 Properties
+%table{ :class => 'table table-bordered table-striped' }
+ %thead
+ %tr
+ %th Name
+ %th Value
+ %tbody
+ - @system.property.each do |name, value|
+ %tr
+ %td
+ %code=name
+ %td=convert_urls value
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8ed21e5/server/lib/cimi/models/system.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/system.rb b/server/lib/cimi/models/system.rb
index 4a176ae..c9caa7e 100644
--- a/server/lib/cimi/models/system.rb
+++ b/server/lib/cimi/models/system.rb
@@ -26,13 +26,9 @@ class CIMI::Model::System < CIMI::Model::Base
collection :addresses, :class => CIMI::Model::SystemAddress
collection :forwarding_groups, :class => CIMI::Model::SystemForwardingGroup
- #TODO: implement the attributes commented out
-
- # array :meters do
- # scalar :href
- # end
-
- # href :event_log
+ array :meters do
+ scalar :href
+ end
array :operations do
scalar :rel, :href
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8ed21e5/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb b/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
index 10c6133..717582c 100644
--- a/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
@@ -142,6 +142,7 @@ module Deltacloud::Drivers::Mock
def export_system(credentials, opts={})
puts "export_system(#{opts})"
+ "http://cimi.example.org/ovf-packages/#{opts[:id]}" unless opts[:destination]
end
def system_machines(credentials, opts={})
@@ -237,6 +238,7 @@ module Deltacloud::Drivers::Mock
def export_system_template(credentials, opts={})
puts "export_system(#{opts})"
+ "http://cimi.example.org/ovf-packages/#{opts[:id]}" unless opts[:destination]
end
def networks(credentials, opts={})