You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2011/10/17 19:04:48 UTC
svn commit: r1185284 [1/3] - in /incubator/deltacloud/trunk: ./ server/
server/bin/ server/lib/cimi/ server/lib/cimi/data/
server/lib/cimi/data/collections/ server/lib/cimi/data/default_res/
server/lib/cimi/helpers/ server/lib/deltacloud/ server/lib/de...
Author: lutter
Date: Mon Oct 17 17:04:45 2011
New Revision: 1185284
URL: http://svn.apache.org/viewvc?rev=1185284&view=rev
Log:
Alternative server frontend, exposing the DMTF CIMI API
The API is currently still under development. The implementation is based
on the work-in-progress report at http://dmtf.org/standards/cloud
The implementation is far from complete; thisis a starting point.
Signed-off-by: Tong Li <li...@us.ibm.com>
Added:
incubator/deltacloud/trunk/server/lib/cimi/
incubator/deltacloud/trunk/server/lib/cimi/data/
incubator/deltacloud/trunk/server/lib/cimi/data/collections/
incubator/deltacloud/trunk/server/lib/cimi/data/collections/machine.col.xml (with props)
incubator/deltacloud/trunk/server/lib/cimi/data/collections/machine_configuration.col.xml (with props)
incubator/deltacloud/trunk/server/lib/cimi/data/collections/machine_image.col.xml (with props)
incubator/deltacloud/trunk/server/lib/cimi/data/collections/volume.col.xml (with props)
incubator/deltacloud/trunk/server/lib/cimi/data/default_res/
incubator/deltacloud/trunk/server/lib/cimi/data/default_res/machine.col.xml (with props)
incubator/deltacloud/trunk/server/lib/cimi/data/default_res/machine_configuration.col.xml (with props)
incubator/deltacloud/trunk/server/lib/cimi/data/default_res/machine_image.col.xml (with props)
incubator/deltacloud/trunk/server/lib/cimi/data/default_res/volume.col.xml (with props)
incubator/deltacloud/trunk/server/lib/cimi/helpers/
incubator/deltacloud/trunk/server/lib/cimi/helpers/cmwgapp_helper.rb (with props)
incubator/deltacloud/trunk/server/lib/cimi/helpers/dmtfdep.rb (with props)
incubator/deltacloud/trunk/server/lib/cimi/server.rb (with props)
incubator/deltacloud/trunk/server/lib/deltacloud/server.rb (contents, props changed)
- copied, changed from r1185283, incubator/deltacloud/trunk/server/server.rb
incubator/deltacloud/trunk/server/public/images/bread-bg.png (with props)
incubator/deltacloud/trunk/server/public/images/logo-wide.png (with props)
incubator/deltacloud/trunk/server/public/images/topbar-bg.png (with props)
incubator/deltacloud/trunk/server/public/javascripts/cmwgapp.js (with props)
incubator/deltacloud/trunk/server/public/javascripts/jquery-1.4.2.min.js (with props)
incubator/deltacloud/trunk/server/tests/core_ext/
incubator/deltacloud/trunk/server/tests/core_ext/string.rb
- copied, changed from r1185283, incubator/deltacloud/trunk/server/config.ru
incubator/deltacloud/trunk/server/views/cimi/
incubator/deltacloud/trunk/server/views/cimi/cloudEntryPoint/
incubator/deltacloud/trunk/server/views/cimi/cloudEntryPoint/index.html.haml
incubator/deltacloud/trunk/server/views/cimi/cloudEntryPoint/index.xml.haml
incubator/deltacloud/trunk/server/views/cimi/collection/
incubator/deltacloud/trunk/server/views/cimi/collection/index.html.haml
incubator/deltacloud/trunk/server/views/cimi/collection/response.xml.haml
incubator/deltacloud/trunk/server/views/cimi/error.html.haml
incubator/deltacloud/trunk/server/views/cimi/errors/
incubator/deltacloud/trunk/server/views/cimi/errors/400.html.haml
incubator/deltacloud/trunk/server/views/cimi/errors/400.xml.haml
incubator/deltacloud/trunk/server/views/cimi/errors/401.html.haml
incubator/deltacloud/trunk/server/views/cimi/errors/401.xml.haml
incubator/deltacloud/trunk/server/views/cimi/errors/403.html.haml
incubator/deltacloud/trunk/server/views/cimi/errors/403.xml.haml
incubator/deltacloud/trunk/server/views/cimi/errors/404.html.haml
incubator/deltacloud/trunk/server/views/cimi/errors/404.xml.haml
incubator/deltacloud/trunk/server/views/cimi/errors/405.html.haml
incubator/deltacloud/trunk/server/views/cimi/errors/405.xml.haml
incubator/deltacloud/trunk/server/views/cimi/errors/500.html.haml
incubator/deltacloud/trunk/server/views/cimi/errors/500.xml.haml
incubator/deltacloud/trunk/server/views/cimi/errors/502.html.haml
incubator/deltacloud/trunk/server/views/cimi/errors/502.xml.haml
incubator/deltacloud/trunk/server/views/cimi/errors/backend_capability_failure.html.haml
incubator/deltacloud/trunk/server/views/cimi/layout.html.haml
incubator/deltacloud/trunk/server/views/cimi/machine_configurations/
incubator/deltacloud/trunk/server/views/cimi/machine_configurations/show.html.haml
incubator/deltacloud/trunk/server/views/cimi/machine_images/
incubator/deltacloud/trunk/server/views/cimi/machine_images/show.html.haml
incubator/deltacloud/trunk/server/views/cimi/machines/
incubator/deltacloud/trunk/server/views/cimi/machines/show.html.haml
incubator/deltacloud/trunk/server/views/cimi/volume/
incubator/deltacloud/trunk/server/views/cimi/volume/show.html.haml
Removed:
incubator/deltacloud/trunk/server/server.rb
Modified:
incubator/deltacloud/trunk/.gitignore
incubator/deltacloud/trunk/server/Rakefile
incubator/deltacloud/trunk/server/bin/deltacloudd
incubator/deltacloud/trunk/server/config.ru
incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb
incubator/deltacloud/trunk/server/lib/deltacloud/core_ext/string.rb
incubator/deltacloud/trunk/server/lib/sinatra/rack_syslog.rb
incubator/deltacloud/trunk/server/tests/common.rb
incubator/deltacloud/trunk/tests/ec2/support/env.rb
incubator/deltacloud/trunk/tests/mock/support/env.rb
incubator/deltacloud/trunk/tests/rhevm/support/env.rb
incubator/deltacloud/trunk/tests/sbc/support/env.rb
Modified: incubator/deltacloud/trunk/.gitignore
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/.gitignore?rev=1185284&r1=1185283&r2=1185284&view=diff
==============================================================================
--- incubator/deltacloud/trunk/.gitignore (original)
+++ incubator/deltacloud/trunk/.gitignore Mon Oct 17 17:04:45 2011
@@ -1 +1,2 @@
*.sw*
+*.project
Modified: incubator/deltacloud/trunk/server/Rakefile
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/Rakefile?rev=1185284&r1=1185283&r2=1185284&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/Rakefile (original)
+++ incubator/deltacloud/trunk/server/Rakefile Mon Oct 17 17:04:45 2011
@@ -26,6 +26,9 @@ begin
rescue LoadError
end
+$top_srcdir = File.dirname(__FILE__)
+$:.unshift File.join($top_srcdir, 'lib')
+
begin
require 'cucumber'
require 'cucumber/rake/task'
@@ -91,14 +94,25 @@ Gem::PackageTask.new(spec) do |pkg|
pkg.need_tar = true
end
-desc "List all REST routes defined through Rabbit"
-task :routes do
- require 'server.rb'
- Sinatra::Rabbit::routes.each do |m, path|
- puts sprintf("\033[1;30m%-8s\033[0m %s", m.to_s.upcase, path)
+namespace :routes do
+ desc "List all REST routes for the Deltacloud API"
+ task :api do
+ require 'deltacloud/server.rb'
+ Sinatra::Rabbit::routes.each do |m, path|
+ puts sprintf("\033[1;30m%-8s\033[0m %s", m.to_s.upcase, path)
+ end
+ end
+
+ desc "List all REST routes for the CIMI API"
+ task :cimi do
+ require 'cimi/server.rb'
+ Sinatra::Rabbit::routes.each do |m, path|
+ puts sprintf("\033[1;30m%-8s\033[0m %s", m.to_s.upcase, path)
+ end
end
end
+
namespace :mock do
namespace :fixtures do
desc "Setup Mock driver fixtures"
Modified: incubator/deltacloud/trunk/server/bin/deltacloudd
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/bin/deltacloudd?rev=1185284&r1=1185283&r2=1185284&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/bin/deltacloudd (original)
+++ incubator/deltacloud/trunk/server/bin/deltacloudd Mon Oct 17 17:04:45 2011
@@ -57,6 +57,9 @@ BANNER
opts.on( '-P', '--provider PROVIDER', 'Use PROVIDER (default is set in the driver)') do |provider|
ENV['API_PROVIDER'] = provider
end
+ opts.on('--cimi', 'USe the DMTF CIMI frontend, not the Deltacloud frontend') do
+ ENV['API_FRONTEND'] = 'cimi'
+ end
opts.on( '-c', '--config [FILE]', 'Read provider and other config from FILE (default: ~/.deltacloud/config)') do |config|
options[:config] = File::expand_path(config || DEFAULT_CONFIG)
end
Modified: incubator/deltacloud/trunk/server/config.ru
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/config.ru?rev=1185284&r1=1185283&r2=1185284&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/config.ru (original)
+++ incubator/deltacloud/trunk/server/config.ru Mon Oct 17 17:04:45 2011
@@ -16,10 +16,12 @@
require 'rubygems'
-top_srcdir = File.dirname(__FILE__)
+$top_srcdir = File.dirname(__FILE__)
-$:.unshift File.join(top_srcdir, 'lib')
+$:.unshift File.join($top_srcdir, 'lib')
-load File.join(top_srcdir, 'server.rb')
+server_dir = ENV['API_FRONTEND'] == 'cimi' ? 'cimi' : 'deltacloud'
+
+load File.join($top_srcdir, 'lib', server_dir, 'server.rb')
run Sinatra::Application
Added: incubator/deltacloud/trunk/server/lib/cimi/data/collections/machine.col.xml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/cimi/data/collections/machine.col.xml?rev=1185284&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/lib/cimi/data/collections/machine.col.xml (added)
+++ incubator/deltacloud/trunk/server/lib/cimi/data/collections/machine.col.xml Mon Oct 17 17:04:45 2011
@@ -0,0 +1,8 @@
+<?xml version='1.0' encoding='utf-8' ?>
+<MachineCollection xmlns="http://www.dmtf.org/cimi">
+ <uri>machine</uri>
+ <name>Machine collection </name>
+ <description>The machine collection</description>
+ <created>2011-09-12 11:37:28 UTC</created>
+ <operation rel="add" href="/machines" />
+</MachineCollection>
Propchange: incubator/deltacloud/trunk/server/lib/cimi/data/collections/machine.col.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/deltacloud/trunk/server/lib/cimi/data/collections/machine_configuration.col.xml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/cimi/data/collections/machine_configuration.col.xml?rev=1185284&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/lib/cimi/data/collections/machine_configuration.col.xml (added)
+++ incubator/deltacloud/trunk/server/lib/cimi/data/collections/machine_configuration.col.xml Mon Oct 17 17:04:45 2011
@@ -0,0 +1,8 @@
+<?xml version='1.0' encoding='utf-8' ?>
+<MachineConfigurationCollection xmlns="http://www.dmtf.org/cimi">
+ <uri>machineConfiguration</uri>
+ <name>Machine Configuration collection </name>
+ <description>That is jsut a test</description>
+ <created>2011-09-12 11:37:28 UTC</created>
+ <operation rel="add" href="/machine_configurations" />
+</MachineConfigurationCollection>
Propchange: incubator/deltacloud/trunk/server/lib/cimi/data/collections/machine_configuration.col.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/deltacloud/trunk/server/lib/cimi/data/collections/machine_image.col.xml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/cimi/data/collections/machine_image.col.xml?rev=1185284&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/lib/cimi/data/collections/machine_image.col.xml (added)
+++ incubator/deltacloud/trunk/server/lib/cimi/data/collections/machine_image.col.xml Mon Oct 17 17:04:45 2011
@@ -0,0 +1,8 @@
+<?xml version='1.0' encoding='utf-8' ?>
+<MachineImageCollection xmlns="http://www.dmtf.org/cimi">
+ <uri>machineImage</uri>
+ <name>Machine Config collection </name>
+ <description>The machine config collection</description>
+ <created>2011-09-12 11:37:28 UTC</created>
+ <operation rel="add" href="/machine_images" />
+</MachineImageCollection>
Propchange: incubator/deltacloud/trunk/server/lib/cimi/data/collections/machine_image.col.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/deltacloud/trunk/server/lib/cimi/data/collections/volume.col.xml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/cimi/data/collections/volume.col.xml?rev=1185284&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/lib/cimi/data/collections/volume.col.xml (added)
+++ incubator/deltacloud/trunk/server/lib/cimi/data/collections/volume.col.xml Mon Oct 17 17:04:45 2011
@@ -0,0 +1,8 @@
+<?xml version='1.0' encoding='utf-8' ?>
+<VolumeCollection xmlns="http://www.dmtf.org/cimi">
+ <uri>volume</uri>
+ <name>Volume collection </name>
+ <description>The volume collection</description>
+ <created>2011-09-12 11:37:28 UTC</created>
+ <operation rel="add" href="/volumes" />
+</VolumeCollection>
Propchange: incubator/deltacloud/trunk/server/lib/cimi/data/collections/volume.col.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/deltacloud/trunk/server/lib/cimi/data/default_res/machine.col.xml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/cimi/data/default_res/machine.col.xml?rev=1185284&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/lib/cimi/data/default_res/machine.col.xml (added)
+++ incubator/deltacloud/trunk/server/lib/cimi/data/default_res/machine.col.xml Mon Oct 17 17:04:45 2011
@@ -0,0 +1,35 @@
+<?xml version='1.0' encoding='utf-8' ?>
+<Machine xmlns="http://www.dmtf.org/cimi">
+ <uri>machine</uri>
+ <name>Default machine name </name>
+ <description>Default machine description</description>
+ <created>2011-01-01 00:00:01 UTC</created>
+ <property name="prop1" content="prop1 value" />
+ <status>Started</status>
+ <cpu>Intel</cpu>
+ <memory quantity="4" units="gigabyte" />
+ <disk>
+ <capacity quantity="200" units="gigabyte" />
+ <format>ntgs</format>
+ <attachmentPoint>/dev/sdb0</attachmentPoint>
+ <guestInterface>SATA</guestInterface>
+ </disk>
+ <volume href="http://host:port/volume/vol01" attachmentPoint="/dev/sdc01" protocol="NFS" />
+ <networkInterface>
+ <vsp href="http://host:port/vsp/vsp01" />
+ <hostname>example host name</hostname>
+ <macAddress>00:00:00:00:00:00</macAddress>
+ <state>Active</state>
+ <protocol>IPv6</protocol>
+ <allocation>Dynamic</allocation>
+ <address>10.10.10.1</address>
+ <defaultGateway>10.10.0.1</defaultGateway>
+ <dns>10.10.0.1</dns>
+ <maxTransmissionUnit>512</maxTransmissionUnit>
+ </networkInterface>
+ <meter href="/meter" />
+ <eventLog href="eventLog" />
+ <operation rel="edit" href="/machine"/>
+ <operation rel="delete" href="/machine"/>
+ <operation rel="http://www.dmtf.org/cimi/stop" href="/machine/stop"/>
+</Machine>
\ No newline at end of file
Propchange: incubator/deltacloud/trunk/server/lib/cimi/data/default_res/machine.col.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/deltacloud/trunk/server/lib/cimi/data/default_res/machine_configuration.col.xml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/cimi/data/default_res/machine_configuration.col.xml?rev=1185284&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/lib/cimi/data/default_res/machine_configuration.col.xml (added)
+++ incubator/deltacloud/trunk/server/lib/cimi/data/default_res/machine_configuration.col.xml Mon Oct 17 17:04:45 2011
@@ -0,0 +1,17 @@
+<?xml version='1.0' encoding='utf-8' ?>
+<MachineConfiguration xmlns="http://www.dmtf.org/cimi">
+ <uri>machineConfiguration</uri>
+ <name>Default machine configuration name </name>
+ <description>Default description</description>
+ <created>2011-01-01 00:00:01 UTC</created>
+ <cpu>i386</cpu>
+ <memory quantity="4" units="gigabyte" />
+ <disk>
+ <capacity quantity="200" units="gigabyte"/>
+ <guestInterface>SATA</guestInterface>
+ </disk>
+ <supportsSnapshots>false</supportsSnapshots>
+ <guestInterface>http://www.ibm.com</guestInterface>
+ <operation rel="edit" href="/machine_configuration"/>
+ <operation rel="delete" href="/machinie_configuration"/>
+</MachineConfiguration>
\ No newline at end of file
Propchange: incubator/deltacloud/trunk/server/lib/cimi/data/default_res/machine_configuration.col.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/deltacloud/trunk/server/lib/cimi/data/default_res/machine_image.col.xml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/cimi/data/default_res/machine_image.col.xml?rev=1185284&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/lib/cimi/data/default_res/machine_image.col.xml (added)
+++ incubator/deltacloud/trunk/server/lib/cimi/data/default_res/machine_image.col.xml Mon Oct 17 17:04:45 2011
@@ -0,0 +1,11 @@
+<?xml version='1.0' encoding='utf-8' ?>
+<MachineImage xmlns="http://www.dmtf.org/cimi">
+ <uri>machineImage</uri>
+ <name>Default machine image name </name>
+ <description>Default machine image description</description>
+ <created>2011-01-01 00:00:01 UTC</created>
+ <imageLocation>http://</imageLocation>
+ <imageData></imageData>
+ <operation rel="edit" href="/machine_image"/>
+ <operation rel="delete" href="/machinie_image"/>
+</MachineImage>
\ No newline at end of file
Propchange: incubator/deltacloud/trunk/server/lib/cimi/data/default_res/machine_image.col.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/deltacloud/trunk/server/lib/cimi/data/default_res/volume.col.xml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/cimi/data/default_res/volume.col.xml?rev=1185284&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/lib/cimi/data/default_res/volume.col.xml (added)
+++ incubator/deltacloud/trunk/server/lib/cimi/data/default_res/volume.col.xml Mon Oct 17 17:04:45 2011
@@ -0,0 +1,14 @@
+<?xml version='1.0' encoding='utf-8' ?>
+<Volume xmlns="http://www.dmtf.org/cimi">
+ <uri>volume</uri>
+ <name>Default volume name </name>
+ <description>Default volume description</description>
+ <created>2011-01-01 00:00:01 UTC</created>
+ <capacity quantity="200" units="gigabyte"/>
+ <bootable>true</bootable>
+ <format>ext4</format>
+ <supportsSnapshots>true</supportsSnapshots>
+ <guestInterface>SATA</guestInterface>
+ <operation rel="edit" href="/volume"/>
+ <operation rel="delete" href="/volume"/>
+</Volume>
\ No newline at end of file
Propchange: incubator/deltacloud/trunk/server/lib/cimi/data/default_res/volume.col.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/deltacloud/trunk/server/lib/cimi/helpers/cmwgapp_helper.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/cimi/helpers/cmwgapp_helper.rb?rev=1185284&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/lib/cimi/helpers/cmwgapp_helper.rb (added)
+++ incubator/deltacloud/trunk/server/lib/cimi/helpers/cmwgapp_helper.rb Mon Oct 17 17:04:45 2011
@@ -0,0 +1,146 @@
+# 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.
+
+# Methods added to this helper will be available to all templates in the application.
+
+# this section defines constants used in the implementation.
+
+#this method is to fixup the hash object to make sure it can be serialized into json
+#as DMTF spec requires. as the spec keeps changing, this method may need to be revisited
+#and modified again.
+def fixup_content(hash_obj, key_name="content", attr_name="name")
+ #this check is to make sure we are not handling nil values.
+ if hash_obj
+ hash_obj.each_pair do |key, value|
+ if value.kind_of? Hash
+ #We can only handle the element without any other attribute,
+ #if the element also has other attribute, then we can not do fixups since it will lose information.
+ if value[key_name] && value.size == 1
+ hash_obj[key] = value[key_name]
+ elsif value[key_name] && value[attr_name] && value.size == 2
+ hash_obj[key] = { "#{value[attr_name]}" => value[key_name] }
+ else
+ fixup_content value, key_name, attr_name
+ end
+ end
+ end
+ end
+end
+
+module ApplicationHelper
+
+ include Deltacloud
+
+ def bread_crumb_ext
+ s = "<ul class='breadcrumb'><li class='first'><a href='#{settings.root_url}'>δ home</a></li>"
+ s+="<li class='docs'>#{link_to_documentation}</li>"
+ s+="</ul>"
+ end
+
+ def respond_to_collection(collType)
+ respond_to do |format|
+ format.html do
+ root_hash = XmlSimple.xml_in(File.join(STOREROOT, 'collections/' + collType),
+ { 'ForceArray' => false, 'KeepRoot'=>true, 'KeyAttr' => ['name']})
+
+ @xml_root_node = root_hash.first[0]
+ @dmtfitem = root_hash.first[1]
+ haml :"collection/index"
+ end
+ format.xml do
+ root_hash = XmlSimple.xml_in(File.join(STOREROOT, 'collections/' + collType),
+ { 'ForceArray' => true, 'KeepRoot'=>true, 'KeyAttr' => ['name']})
+ col_item_name = root_hash.first[0]
+ content_type get_response_content_type(col_item_name, 'xml'), :charset => 'utf-8'
+ col_item_name = col_item_name.sub(/Collection/,'') #Remove the Collection at the end.
+ col_item_name = col_item_name[0].downcase + col_item_name[1, col_item_name.length]
+
+ urls = []
+ @dmtf_col_items.map do |item|
+ urls << {"href" => item["href"]}
+ end
+
+ root_hash.first[1][0]["#{col_item_name}"] = urls
+
+ XmlSimple.xml_out(root_hash, { 'KeyAttr' => 'name', 'KeepRoot' => true, 'ContentKey' => 'content'})
+ end
+ format.json do
+ root_hash = XmlSimple.xml_in(File.join(STOREROOT, 'collections/' + collType),
+ { 'ForceArray' => false, 'KeepRoot'=>true, 'KeyAttr' => ['name']})
+ col_item_name = root_hash.first[0]
+ content_type get_response_content_type(col_item_name, 'json'), :charset => 'utf-8'
+ #Remove the Collection at the end.
+ col_item_name = col_item_name.sub(/Collection/,'')
+ col_item_name = col_item_name[0].downcase + col_item_name[1, col_item_name.length]
+
+ urls = []
+ @dmtf_col_items.map do |item|
+ urls << {"href" => item["href"]}
+ end
+
+ root_hash.first[1]["#{col_item_name}"] = urls
+
+ json_hash = root_hash.first[1]
+ if json_hash.has_key?("xmlns")
+ json_hash.delete "xmlns"
+ end
+ fixup_content json_hash
+ res = json_hash.to_json
+ end
+ end
+ end
+
+ def get_response_content_type(coll_type, format="html")
+ case format
+ when "text/html"
+ ""
+ when "xml"
+ "application/CIMI-" + coll_type + "+xml"
+ when "json"
+ "application/CIMI-" + coll_type + "+json"
+ end
+ end
+
+ def get_resource_default(coll_type)
+ file_path = File.join STOREROOT, "default_res/" + coll_type + ".col.xml"
+ if File.exist?(file_path)
+ root_hash = XmlSimple.xml_in(file_path, {'ForceArray'=>false, 'KeepRoot'=>true, 'KeyAttr'=>['name']})
+ { "xml_root_node" => root_hash.first[0], "dmtfitem" => root_hash.first[1]}
+ end
+ end
+
+ def show_resource(resource_path, content_type)
+ respond_to do |format|
+ format.xml do
+ content_type "application/CIMI-#{content_type}+xml", :charset => 'utf-8'
+ haml :"#{resource_path}", :layout => false
+ end
+ format.html do
+ haml :"#{resource_path}"
+ end
+ format.json do
+ content_type "application/CIMI-#{content_type}+json", :charset => 'utf-8'
+ engine = Haml::Engine.new(File.read(settings.views + "/#{resource_path}.xml.haml"))
+ responseXML = engine.render self
+ hash_response = XmlSimple.xml_in responseXML, {'ForceArray' => false, 'KeepRoot'=>true, 'KeyAttr' => ['name']}
+ hash_response = hash_response.first[1]
+ if hash_response.has_key?("xmlns")
+ hash_response.delete "xmlns"
+ end
+ hash_response.to_json
+ end
+ end
+ end
+end
Propchange: incubator/deltacloud/trunk/server/lib/cimi/helpers/cmwgapp_helper.rb
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/deltacloud/trunk/server/lib/cimi/helpers/dmtfdep.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/cimi/helpers/dmtfdep.rb?rev=1185284&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/lib/cimi/helpers/dmtfdep.rb (added)
+++ incubator/deltacloud/trunk/server/lib/cimi/helpers/dmtfdep.rb Mon Oct 17 17:04:45 2011
@@ -0,0 +1,64 @@
+#
+# 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.
+
+#this file defines all the required components for dmtf implementation.
+#if new dependencies are needed, please make changes to this file.
+
+require 'sinatra'
+require 'deltacloud/drivers'
+require 'deltacloud/core_ext/integer'
+require 'deltacloud/core_ext/hash'
+require 'deltacloud/core_ext/string'
+require 'deltacloud/base_driver'
+require 'deltacloud/hardware_profile'
+require 'deltacloud/state_machine'
+require 'deltacloud/helpers'
+require 'deltacloud/models/base_model'
+require 'deltacloud/models/realm'
+require 'deltacloud/models/image'
+require 'deltacloud/models/instance'
+require 'deltacloud/models/key'
+require 'deltacloud/models/address'
+require 'deltacloud/models/instance_profile'
+require 'deltacloud/models/storage_snapshot'
+require 'deltacloud/models/storage_volume'
+require 'deltacloud/models/bucket'
+require 'deltacloud/models/blob'
+require 'deltacloud/models/load_balancer'
+require 'deltacloud/models/firewall'
+require 'deltacloud/models/firewall_rule'
+
+require 'json'
+require 'sinatra/rack_accept'
+require 'sinatra/static_assets'
+require 'sinatra/rabbit'
+require 'sinatra/lazy_auth'
+require 'erb'
+require 'haml'
+require 'open3'
+require 'uuidtools'
+require 'xmlsimple'
+require 'benchmark'
+require 'deltacloud/helpers/blob_stream'
+require 'sinatra/rack_driver_select'
+require 'sinatra/rack_runtime'
+require 'sinatra/rack_etag'
+require 'sinatra/rack_date'
+require 'sinatra/rack_matrix_params'
+require 'sinatra/rack_syslog'
+require 'sinatra/sinatra_verbose'
+
+CMWG_NAMESPACE = "http://www.dmtf.org/cimi"
Propchange: incubator/deltacloud/trunk/server/lib/cimi/helpers/dmtfdep.rb
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/deltacloud/trunk/server/lib/cimi/server.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/cimi/server.rb?rev=1185284&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/lib/cimi/server.rb (added)
+++ incubator/deltacloud/trunk/server/lib/cimi/server.rb Mon Oct 17 17:04:45 2011
@@ -0,0 +1,282 @@
+# 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.
+
+
+require 'cimi/helpers/dmtfdep'
+require 'cimi/helpers/cmwgapp_helper'
+
+set :version, '0.1.0'
+
+include Deltacloud::Drivers
+set :drivers, Proc.new { driver_config }
+
+STOREROOT = File.join($top_srcdir, 'lib', 'cimi', 'data')
+#We would like to know the storage root.
+puts "store root is " + STOREROOT
+
+Sinatra::Application.register Rack::RespondTo
+
+use Rack::ETag
+use Rack::Runtime
+use Rack::MatrixParams
+use Rack::DriverSelect
+use Rack::MediaType
+use Rack::Date
+
+configure do
+ set :root_url, "/cimi"
+ set :views, File::join($top_srcdir, 'views', 'cimi')
+ set :public, File::join($top_srcdir, 'public')
+ # Try to load the driver on startup to fail early if there are issues
+ driver
+ set :store, STOREROOT
+end
+
+configure :production do
+ use Rack::SyslogLogger
+ disable :logging
+ enable :show_errors
+ set :dump_errors, false
+ $stdout = SyslogFile.new
+ $stderr = $stdout
+end
+
+configure :development do
+ set :raise_errors => false
+ set :show_exceptions, false
+ $stdout.sync = true
+ $stderr.sync = true
+end
+
+# You could use $API_HOST environment variable to change your hostname to
+# whatever you want (eg. if you running API behind NAT)
+HOSTNAME=ENV['API_HOST'] ? ENV['API_HOST'] : nil
+
+error do
+ report_error
+end
+
+get "#{settings.root_url}\/?" do
+ if params[:force_auth]
+ return [401, 'Authentication failed'] unless driver.valid_credentials?(credentials)
+ end
+
+ redirect "#{settings.root_url}/cloudEntryPoint", 301
+end
+
+collection :cloudEntryPoint do
+ # Make sure this collection can be accessed, regardless of whether the
+ # driver supports it or not
+ global!
+
+ description <<EOS
+ cloud entry point
+EOS
+
+ operation :index do
+ description "list all resources of the cloud"
+ control do
+ @collections = entry_points.reject { |p| p[0] == :cloudEntryPoint }
+ show_resource "cloudEntryPoint/index", "CloudEntryPoint"
+ end
+ end
+end
+
+collection :machine_configurations do
+ global!
+
+ description <<EOS
+List all machine configurations
+EOS
+
+ operation :index do
+ description "List all machine configurations"
+ control do
+ profiles = driver.hardware_profiles(credentials, nil)
+ @dmtf_col_items = []
+ if profiles
+ profiles.map do |profile|
+ new_item = { "name" => profile.name,
+ "href" => machine_configuration_url(profile.name) }
+ @dmtf_col_items.insert 0, new_item
+ end
+ end
+ respond_to_collection "machine_configuration.col.xml"
+ end
+ end
+
+ operation :show do
+ description "Show specific machine configuration."
+ with_capability :hardware_profile
+ param :id, :string, :required
+ control do
+ @profile = driver.hardware_profile(credentials, params[:id])
+ if @profile
+ #setup the default values for a machine configuration
+ resource_default = get_resource_default "machine_configuration"
+ #get the actual values from profile
+ resource_value = { "name" => @profile.name,"uri" => @profile.name,
+ "href" => machine_configuration_url(@profile.name) }
+ #mixin actual values get from profile
+ @dmtfitem = resource_default["dmtfitem"].merge resource_value
+ show_resource "machine_configurations/show", "MachineConfiguration"
+ else
+ report_error(404)
+ end
+ end
+ end
+end
+
+collection :machine_images do
+ global!
+
+ description <<EOS
+List all machine images
+EOS
+
+ operation :index do
+ description "List all machine configurations"
+ control do
+ images = driver.send(:images, credentials, {})
+ @dmtf_col_items = []
+ if images
+ images.map do |image|
+ new_item = { "name" => image.name,
+ "href" => machine_image_url(image.id) }
+ @dmtf_col_items.insert 0, new_item
+ end
+ end
+ respond_to_collection "machine_image.col.xml"
+ end
+ end
+
+ operation :show do
+ description "Show specific machine image."
+ with_capability :image
+ param :id, :string, :required
+ control do
+ @image = driver.send(:image, credentials, { :id => params[:id]} )
+ if @image
+ #setup the default values for a machine imageion
+ resource_default = get_resource_default "machine_image"
+ #get the actual values from image
+ resource_value = { "name" => @image.name,
+ "description" => @image.description,
+ "uri" => @image.id,"href" => machine_image_url(@image.id) }
+ #mixin actual values get from the specific image
+ @dmtfitem = resource_default["dmtfitem"].merge resource_value
+ show_resource "machine_images/show", "MachineImage"
+ else
+ report_error(404)
+ end
+ end
+ end
+
+end
+
+collection :machines do
+ global!
+
+ description <<EOS
+List all machine
+EOS
+
+ operation :index do
+ description "List all machines"
+ control do
+ instances = driver.send(:instances, credentials, {})
+ @dmtf_col_items = []
+ if instances
+ instances.map do |instance|
+ new_item = { "name" => instance.name,
+ "href" => machine_url(instance.id) }
+ @dmtf_col_items.insert 0, new_item
+ end
+ end
+ respond_to_collection "machine.col.xml"
+ end
+ end
+
+ operation :show do
+ description "Show specific machine."
+ with_capability :instance
+ param :id, :string, :required
+ control do
+ @machine = driver.send(:instance, credentials, { :id => params[:id]} )
+ if @machine
+ #setup the default values for a machine imageion
+ resource_default = get_resource_default "machine"
+ #get the actual values from image
+ resource_value = { "name" => @machine.name,
+ "status" => @machine.state, "uri" => @machine.id,
+ "href" => machine_url(@machine.id) }
+ #mixin actual values get from the specific image
+ @dmtfitem = resource_default["dmtfitem"].merge resource_value
+ show_resource "machines/show", "Machine"
+ else
+ report_error(404)
+ end
+ end
+ end
+
+end
+
+collection :volumes do
+ global!
+
+ description <<EOS
+List all volumes
+EOS
+
+ operation :index do
+ description "List all volumes"
+ control do
+ instances = driver.send(:storage_volumes, credentials, {})
+ @dmtf_col_items = []
+ if instances
+ instances.map do |instance|
+ new_item = { "name" => instance.id,
+ "href" => volume_url(instance.id) }
+ @dmtf_col_items.insert 0, new_item
+ end
+ end
+ respond_to_collection "volume.col.xml"
+ end
+ end
+
+ operation :show do
+ description "Show specific machine."
+ with_capability :storage_volume
+ param :id, :string, :required
+ control do
+ @volume = driver.send(:storage_volume, credentials, { :id => params[:id]} )
+ if @volume
+ #setup the default values for a machine imageion
+ resource_default = get_resource_default "volume"
+ #get the actual values from image
+ resource_value = { "name" => @volume.id,
+ "status" => @volume.state, "uri" => @volume.id,
+ "href" => volume_url(@volume.id),
+ "capacity" => { "quantity" => @volume.capacity, "units" => "gigabyte"} }
+ #mixin actual values get from the specific image
+ @dmtfitem = resource_default["dmtfitem"].merge resource_value
+ show_resource "volumes/show", "Volume"
+ else
+ report_error(404)
+ end
+ end
+ end
+
+end
Propchange: incubator/deltacloud/trunk/server/lib/cimi/server.rb
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb?rev=1185284&r1=1185283&r2=1185284&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb Mon Oct 17 17:04:45 2011
@@ -14,7 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-require 'lib/deltacloud/base_driver/exceptions'
+require 'deltacloud/base_driver/exceptions'
module Deltacloud
Modified: incubator/deltacloud/trunk/server/lib/deltacloud/core_ext/string.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/core_ext/string.rb?rev=1185284&r1=1185283&r2=1185284&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/core_ext/string.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/core_ext/string.rb Mon Oct 17 17:04:45 2011
@@ -49,4 +49,9 @@ class String
tr("-", "_").
downcase
end
+
+
+ def camelize
+ gsub(/_[a-z]/) { |match| match[1].chr.upcase }
+ end
end
Copied: incubator/deltacloud/trunk/server/lib/deltacloud/server.rb (from r1185283, incubator/deltacloud/trunk/server/server.rb)
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/server.rb?p2=incubator/deltacloud/trunk/server/lib/deltacloud/server.rb&p1=incubator/deltacloud/trunk/server/server.rb&r1=1185283&r2=1185284&rev=1185284&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/server.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/server.rb Mon Oct 17 17:04:45 2011
@@ -47,8 +47,8 @@ use Rack::Date
configure do
set :root_url, "/api"
- set :views, File.dirname(__FILE__) + '/views'
- set :public_folder, File.dirname(__FILE__) + '/public'
+ set :views, File::join($top_srcdir, 'views')
+ set :public_folder, File::join($top_srcdir, 'public')
# Try to load the driver on startup to fail early if there are issues
driver
end
Propchange: incubator/deltacloud/trunk/server/lib/deltacloud/server.rb
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/deltacloud/trunk/server/lib/sinatra/rack_syslog.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/sinatra/rack_syslog.rb?rev=1185284&r1=1185283&r2=1185284&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/sinatra/rack_syslog.rb (original)
+++ incubator/deltacloud/trunk/server/lib/sinatra/rack_syslog.rb Mon Oct 17 17:04:45 2011
@@ -1,5 +1,5 @@
require 'syslog'
-require 'lib/sinatra/body_proxy'
+require 'sinatra/body_proxy'
class SyslogFile < File
Added: incubator/deltacloud/trunk/server/public/images/bread-bg.png
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/public/images/bread-bg.png?rev=1185284&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/deltacloud/trunk/server/public/images/bread-bg.png
------------------------------------------------------------------------------
svn:mime-type = image/png
Added: incubator/deltacloud/trunk/server/public/images/logo-wide.png
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/public/images/logo-wide.png?rev=1185284&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/deltacloud/trunk/server/public/images/logo-wide.png
------------------------------------------------------------------------------
svn:mime-type = image/png
Added: incubator/deltacloud/trunk/server/public/images/topbar-bg.png
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/public/images/topbar-bg.png?rev=1185284&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/deltacloud/trunk/server/public/images/topbar-bg.png
------------------------------------------------------------------------------
svn:mime-type = image/png
Added: incubator/deltacloud/trunk/server/public/javascripts/cmwgapp.js
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/public/javascripts/cmwgapp.js?rev=1185284&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/public/javascripts/cmwgapp.js (added)
+++ incubator/deltacloud/trunk/server/public/javascripts/cmwgapp.js Mon Oct 17 17:04:45 2011
@@ -0,0 +1,249 @@
+// Place your application-specific JavaScript functions and classes here
+// This file is automatically included by javascript_include_tag :defaults
+
+function doPut(theNode)
+{
+ $.ajax({
+ type: "PUT",
+ url: $(theNode.form).attr("action"),
+ data: $(theNode.form).serializeArray(),
+ success: function(returnData) {
+ alert("Command executed successfully!");
+ var flag = theNode.form.elements["refresh"];
+ if (flag != null && flag.value == "true") {
+ location.reload(true);
+ }
+ },
+ error: function(errorData) {
+ alert("Command executed unsuccessfully!")
+ },
+ dataType: "xml"
+ });
+}
+
+function doXmlPut(theNode, addId, func)
+{
+ var xmlData = "";
+ if (func) {
+ xmlData = fixupXml(theNode);
+ }
+ else {
+ xmlData = "<?xml version='1.0' encoding='utf-8' ?>";
+ xmlData += "<" + $(theNode.form).attr("xmlRootNode").value + " xmlns='http://www.dmtf.org/cimi'>";
+ xmlData += getStandardData(theNode);
+ xmlData += "</" + $(theNode.form).attr("xmlRootNode").value + ">";
+ }
+
+ var padding = "";
+ if (addId) {
+ padding = "/" + $(theNode.form).attr("id").value;
+ }
+
+ $.ajax({
+ type: "PUT",
+ url: $(theNode.form).attr("action") + padding,
+ data: xmlData,
+ contentType: 'application/xml',
+ accepts: 'application/xml',
+ success: function(data, textStatus, jqXHR) {
+ alert("Command executed successfully!");
+ var flag = theNode.form.elements["refresh"];
+ if (flag != null && flag.value == "true") {
+ location.reload(true);
+ }
+ },
+ error: function(a, b, c) {
+ alert("Command executed unsuccessfully!")
+ },
+ statusCode: {
+ 204: function() {
+ alert("Command executed successfully!")
+ }
+ },
+ dataType: "xml"
+ });
+}
+
+function doXmlPost(theNode, func)
+{
+ var xmlData = "";
+ if (func) {
+ xmlData = fixupXml(theNode);
+ }
+ else {
+ xmlData = "<?xml version='1.0' encoding='utf-8' ?>";
+ xmlData += "<" + $(theNode.form).attr("xmlRootNode").value + " xmlns='http://www.dmtf.org/cimi'>";
+ xmlData += getStandardData(theNode)
+ xmlData += "</" + $(theNode.form).attr("xmlRootNode").value + ">";
+ }
+
+ $.ajax({
+ type: "POST",
+ url: $(theNode.form).attr("action"),
+ data: xmlData,
+ contentType: 'application/xml',
+ accepts: 'application/xml',
+ success: function(data, textStatus, jqXHR) {
+ alert("Command executed successfully!");
+ window.location.href = $(theNode.form).attr("refreshURI").value
+ },
+ error: function(jqXHR, data1, data2) {
+ alert("Command executed unsuccessfully!")
+ },
+ statusCode: {
+ 201: function() {
+ alert("Command executed successfully!")
+ }
+ },
+ dataType: "xml"
+ });
+}
+
+function doXmlDelete(theNode, addId)
+{
+ var xmlData = "<?xml version='1.0' encoding='utf-8' ?>";
+ var padding = "";
+ if (addId) {
+ padding = "/" + $(theNode.form).attr("id").value;
+ }
+
+ $.ajax({
+ type: "DELETE",
+ url: $(theNode.form).attr("action") + padding,
+ data: xmlData,
+ contentType: 'application/xml',
+ accepts: 'application/xml',
+ success: function(returnData) {
+ alert("Command executed successfully!")
+ //window.location.href = $(theNode.form).attr("action")
+ window.location.href = $(theNode.form).attr("refreshURI").value
+ },
+ error: function(errorData) {
+ alert("Command executed unsuccessfully!")
+ },
+ dataType: "xml"
+ });
+}
+
+function getStandardData(theNode) {
+ var xmlData = "";
+ xmlData += "<uri>" + $(theNode.form).attr("id").value + "</uri>";
+ xmlData += "<name>" + $(theNode.form).attr("name").value + "</name>";
+ xmlData += "<description>" + $(theNode.form).attr("description").value + "</description>";
+ xmlData += "<created>" + $(theNode.form).attr("created").value + "</created>";
+
+ //handling properties
+ var index=0;
+ while ($(theNode.form).attr("param_name_" + index)) {
+ if ($(theNode.form).attr("param_name_" + index).value != null &&
+ $(theNode.form).attr("param_name_" + index).value.length > 0) {
+ xmlData += "<property name='" + $(theNode.form).attr("param_name_" + index).value + "'>" +
+ $(theNode.form).attr("param_value_" + index).value + "</property>";
+ }
+ index++;
+ }
+
+ //handling operations
+ index = 0
+ while ($(theNode.form).attr("operation_" + index)) {
+ var aOpNode = ttt0 = $(theNode.form).attr("operation_" + index);
+ xmlData += "<operation rel='" + $(aOpNode).attr("oper_type") + "' href='" +
+ aOpNode.value + "' />";
+ index++;
+ }
+
+ return xmlData;
+}
+
+function doDelete(theNode)
+{
+ var theURL = $(theNode.form).attr("action");
+ var theData = $(theNode.form).serializeArray();
+
+ $.ajax({
+ type: "DELETE",
+ url: $(theNode.form).attr("action"),
+ data: $(theNode.form).serializeArray(),
+ success: function(returnData) {
+ alert("Command executed successfully!")
+ var flag = theNode.form.elements["refresh"];
+ if (flag != null && flag.value == "true") {
+ location.reload(true);
+ }
+ },
+ error: function(errorData) {
+ alert("Command executed unsuccessfully!")
+ },
+ dataType: "xml"
+ });
+}
+
+function doPost(theNode)
+{
+ var theURL = $(theNode.form).attr("action");
+ var theData = $(theNode.form).serializeArray();
+
+ $.ajax({
+ type: "POST",
+ url: $(theNode.form).attr("action"),
+ data: $(theNode.form).serializeArray(),
+ success: function(returnData) {
+ alert("Command executed successfully!")
+ var flag = theNode.form.elements["refresh"];
+ if (flag != null && flag.value == "true") {
+ location.reload(true);
+ }
+ },
+ error: function(errorData) {
+ alert("Command executed unsuccessfully!")
+ },
+ dataType: "xml"
+ });
+}
+
+function AddNewPproperty(tableId)
+{
+ var tbl = document.getElementById(tableId);
+ var lastRow = tbl.rows.length;
+ // if there's no header row in the table, then iteration = lastRow + 1
+ var iteration = lastRow;
+ var row = tbl.insertRow(lastRow);
+
+ // left cell
+ var cellLeft = row.insertCell(0);
+ var el = document.createElement('input');
+ el.type = 'text';
+ el.name = 'param_name_' + iteration;
+ el.id = 'param_name_' + iteration;
+ el.size = 25;
+ cellLeft.appendChild(el);
+
+
+ // right cell
+ var cellRight = row.insertCell(1);
+ var em = document.createElement('input');
+ em.type = 'text';
+ em.name = 'param_value_' + iteration;
+ em.id = 'param_value_' + iteration;
+ em.size = 25;
+ cellRight.appendChild(em);
+
+ // select cell
+ var cellRightBut = row.insertCell(2);
+ var er = document.createElement('input');
+ er.type = 'button';
+ er.name = 'param_remove' + iteration;
+ er.id = 'param_remove' + iteration;
+ er.value = "Remove";
+ er.tableRow = row
+ $(er).click(function() {
+ removeProperty(this);
+ })
+
+ cellRightBut.appendChild(er);
+}
+
+function removeProperty(theNode)
+{
+ $(theNode.parentNode.parentNode).remove();
+}
Propchange: incubator/deltacloud/trunk/server/public/javascripts/cmwgapp.js
------------------------------------------------------------------------------
svn:eol-style = native