diff --git a/src/cloud/ec2/bin/econe-describe-images b/src/cloud/ec2/bin/econe-describe-images index e1506e1ad9..ffe5fdf0ee 100755 --- a/src/cloud/ec2/bin/econe-describe-images +++ b/src/cloud/ec2/bin/econe-describe-images @@ -1,30 +1,4 @@ #!/usr/bin/env ruby - -# == Synopsis -# econe-describe-images -# -# List and describe previously uploaded images of a user for use -# with an OpenNebula Cloud. -# -# == Usage -# -# econe-describe-images [OPTIONS] -# -# -h, --help: -# show help -# -# --access-key , -K : -# The username of the user -# -# --secret-key , -S : -# The password of the user -# -# --url , -U : -# Set url as the web service url to use -# -# --headers, -H: -# Display column headers - # -------------------------------------------------------------------------- # # Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # # # @@ -53,14 +27,42 @@ end $: << RUBY_LIB_LOCATION $: << RUBY_LIB_LOCATION+"/cloud" +COMMANDS_HELP=<<-EOT + ** Synopsis + ----------- + econe-describe-images + + List and describe previously uploaded images of a user to be + used with an OpenNebula Cloud. + + ** Usage + -------- + econe-describe-images [OPTIONS] + + --help, -h: + Show help + + --access-key , -K : + The username of the user + + --secret-key , -S : + The password of the user + + --url , -U : + Set url as the web service url to use + + --headers, -H: + Display column headers + +EOT + require 'econe/EC2QueryClient' require 'CloudClient' require 'getoptlong' -require 'rdoc/usage' -require 'pp' include CloudCLI + opts = GetoptLong.new( ['--help', '-h',GetoptLong::NO_ARGUMENT], ['--access-key', '-K',GetoptLong::REQUIRED_ARGUMENT], @@ -79,7 +81,8 @@ begin opts.each do |opt, arg| case opt when '--help' - RDoc::usage + puts COMMANDS_HELP + return when '--access-key' access = arg when '--secret-key' diff --git a/src/cloud/ec2/bin/econe-describe-instances b/src/cloud/ec2/bin/econe-describe-instances index a171c12e5e..05f5605c13 100755 --- a/src/cloud/ec2/bin/econe-describe-instances +++ b/src/cloud/ec2/bin/econe-describe-instances @@ -1,29 +1,4 @@ #!/usr/bin/env ruby - -# == Synopsis -# econe-describe-instances -# -# List and describe running instances -# -# == Usage -# -# econe-describe-instances [OPTIONS] -# -# -h, --help: -# show help -# -# --access-key , -K : -# The username of the user -# -# --secret-key , -S : -# The password of the user -# -# --url , -U : -# Set url as the web service url to use -# -# --headers, -H: -# Display column headers - # -------------------------------------------------------------------------- # # Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # # # @@ -51,11 +26,37 @@ end $: << RUBY_LIB_LOCATION $: << RUBY_LIB_LOCATION+"/cloud" +COMMANDS_HELP=<<-EOT + ** Synopsis + ----------- + econe-describe-instances + + List and describe running instances + + ** Usage + -------- + econe-describe-instances [OPTIONS] + + --help, -h: + Show help + + --access-key , -K : + The username of the user + + --secret-key , -S : + The password of the user + + --url , -U : + Set url as the web service url to use + + --headers, -H: + Display column headers + +EOT + require 'econe/EC2QueryClient' require 'CloudClient' require 'getoptlong' -require 'rdoc/usage' -require 'pp' include CloudCLI @@ -77,7 +78,8 @@ begin opts.each do |opt, arg| case opt when '--help' - RDoc::usage + puts COMMANDS_HELP + return when '--access-key' access = arg when '--secret-key' diff --git a/src/cloud/ec2/bin/econe-register b/src/cloud/ec2/bin/econe-register index ce30d39fb4..917bc49abf 100755 --- a/src/cloud/ec2/bin/econe-register +++ b/src/cloud/ec2/bin/econe-register @@ -1,35 +1,4 @@ #!/usr/bin/env ruby - -# == Synopsis -# econe-register -# -# Register a previously uploaded image for use with an -# OpenNebula Cloud. -# -# == Usage -# -# econe-register [OPTIONS] ImageId -# -# -h, --help: -# show help -# -# --access-key , -K : -# The username of the user -# -# --secret-key , -S : -# The password of the user -# -# --url , -U : -# Set url as the web service url to use -# -# --headers, -H: -# Display column headers -# -# IMAGE-ID: The image identification as returned by -# the econe-upload command - - - # -------------------------------------------------------------------------- # # Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # # # @@ -57,11 +26,41 @@ end $: << RUBY_LIB_LOCATION $: << RUBY_LIB_LOCATION+"/cloud" +COMMANDS_HELP=<<-EOT + ** Synopsis + ----------- + econe-register + + Register a previously uploaded image for use with an + OpenNebula Cloud. + + ** Usage + -------- + econe-register [OPTIONS] IMAGE-ID + + --help, -h: + Show help + + --access-key , -K : + The username of the user + + --secret-key , -S : + The password of the user + + --url , -U : + Set url as the web service url to use + + --headers, -H: + Display column headers + + IMAGE-ID: The image identification as returned by + the econe-upload command + +EOT + require 'econe/EC2QueryClient' require 'CloudClient' require 'getoptlong' -require 'rdoc/usage' -require 'pp' include CloudCLI @@ -83,7 +82,8 @@ begin opts.each do |opt, arg| case opt when '--help' - RDoc::usage + puts COMMANDS_HELP + return when '--access-key' access = arg when '--secret-key' diff --git a/src/cloud/ec2/bin/econe-run-instances b/src/cloud/ec2/bin/econe-run-instances index 5976650a6f..cfa51b3e7d 100755 --- a/src/cloud/ec2/bin/econe-run-instances +++ b/src/cloud/ec2/bin/econe-run-instances @@ -1,31 +1,4 @@ #!/usr/bin/env ruby - -# == Synopsis -# econe-run-instances -# -# Runs an instance of a particular image -# -# == Usage -# -# econe-run-instances [OPTIONS] -# -# -h, --help: -# show help -# -# --access-key , -K : -# The username of the user -# -# --secret-key , -S : -# The password of the user -# -# --url , -U : -# Set url as the web service url to use -# -# --type , -t -# -# --headers, -H: -# Display column headers - # -------------------------------------------------------------------------- # # Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # # # @@ -54,11 +27,47 @@ end $: << RUBY_LIB_LOCATION $: << RUBY_LIB_LOCATION+"/cloud" +COMMANDS_HELP=<<-EOT + ** Synopsis + ----------- + econe-run-instances + + Runs an instance of a particular image + + ** Usage + -------- + econe-run-instances [OPTIONS] IMAGE-ID + + --help, -h: + Show help + + --access-key , -K : + The username of the user + + --secret-key , -S : + The password of the user + + --url , -U : + Set url as the web service url to use + + --type , -t : + OpenNebula template in which is based this instance + + -–user-data, -d: + Specifies Base64-encoded MIME user data to be made + available to the instance + + --headers, -H: + Display column headers + + IMAGE-ID: The image identification as returned by + the econe-upload command + +EOT + require 'econe/EC2QueryClient' require 'CloudClient' require 'getoptlong' -require 'rdoc/usage' -require 'pp' include CloudCLI @@ -84,7 +93,8 @@ begin opts.each do |opt, arg| case opt when '--help' - RDoc::usage + puts COMMANDS_HELP + return when '--access-key' access = arg when '--secret-key' diff --git a/src/cloud/ec2/bin/econe-terminate-instances b/src/cloud/ec2/bin/econe-terminate-instances index 8fee23000b..cc613980fe 100755 --- a/src/cloud/ec2/bin/econe-terminate-instances +++ b/src/cloud/ec2/bin/econe-terminate-instances @@ -1,31 +1,4 @@ #!/usr/bin/env ruby - -# == Synopsis -# econe-terminate-instances -# -# Terminate the selected running instance -# -# == Usage -# -# econe-register [OPTIONS] INSTANCE-ID -# -# -h, --help: -# show help -# -# --access-key , -K : -# The username of the user -# -# --secret-key , -S : -# The password of the user -# -# --url , -U : -# Set url as the web service url to use -# -# INSTANCE-ID: The instance identification as returned by -# the econe-run-instances command - - - # -------------------------------------------------------------------------- # # Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # # # @@ -54,11 +27,37 @@ end $: << RUBY_LIB_LOCATION $: << RUBY_LIB_LOCATION+"/cloud" +COMMANDS_HELP=<<-EOT + ** Synopsis + ----------- + econe-terminate-instances + + Terminate the selected running instance + + ** Usage + -------- + econe-register [OPTIONS] INSTANCE-ID + + --help, -h: + Show help + + --access-key , -K : + The username of the user + + --secret-key , -S : + The password of the user + + --url , -U : + Set url as the web service url to use + + INSTANCE-ID: The instance identification as returned by + the econe-run-instances command + +EOT + require 'econe/EC2QueryClient' require 'CloudClient' require 'getoptlong' -require 'rdoc/usage' -require 'pp' include CloudCLI @@ -78,7 +77,8 @@ begin opts.each do |opt, arg| case opt when '--help' - RDoc::usage + puts COMMANDS_HELP + return when '--access-key' access = arg when '--secret-key' diff --git a/src/cloud/ec2/bin/econe-upload b/src/cloud/ec2/bin/econe-upload index e88b0bce7d..2455b91fa6 100755 --- a/src/cloud/ec2/bin/econe-upload +++ b/src/cloud/ec2/bin/econe-upload @@ -1,32 +1,4 @@ #!/usr/bin/env ruby - -# == Synopsis -# econe-upload -# -# Uploads an image for use with an OpenNebula Cloud. This image should -# be later register with econe-register using the returned ImageId -# -# == Usage -# -# econe-upload [OPTIONS] IMAGE-PATH -# -# -h, --help: -# show help -# -# --access-key , -K : -# The username of the user -# -# --secret-key , -S : -# The password of the user -# -# --url , -U : -# Set url as the web service url to use -# -# --multipart, -M: -# Use 'multipart-post' library instead of Curb/Curl -# -# IMAGE-PATH: Path to the image to upload - # -------------------------------------------------------------------------- # # Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # # # @@ -54,11 +26,40 @@ end $: << RUBY_LIB_LOCATION $: << RUBY_LIB_LOCATION+"/cloud" +COMMANDS_HELP=<<-EOT + ** Synopsis + ----------- + econe-upload + + Uploads an image for use with an OpenNebula Cloud. This image should + be later register with econe-register using the returned ImageId + + ** Usage + -------- + econe-upload [OPTIONS] IMAGE-PATH + + --help, -h: + Show help + + --access-key , -K : + The username of the user + + --secret-key , -S : + The password of the user + + --url , -U : + Set url as the web service url to use + + --multipart, -M: + Use 'multipart-post' library instead of Curb/Curl + + IMAGE-PATH: Path to the image to upload + +EOT + require 'econe/EC2QueryClient' require 'CloudClient' require 'getoptlong' -require 'rdoc/usage' -require 'pp' include CloudCLI @@ -80,7 +81,8 @@ begin opts.each do |opt, arg| case opt when '--help' - RDoc::usage + puts COMMANDS_HELP + return when '--access-key' access = arg when '--secret-key' diff --git a/src/cloud/occi/bin/occi-compute b/src/cloud/occi/bin/occi-compute index 6b2de39b35..e67f8fa36a 100755 --- a/src/cloud/occi/bin/occi-compute +++ b/src/cloud/occi/bin/occi-compute @@ -1,54 +1,4 @@ #!/usr/bin/env ruby - -# == Synopsis -# occi-compute -# -# Manages compute resources -# -# == Usage -# -# occi-compute [OPTIONS] [ARGUMENTS] -# -# COMMANDS -# -# create -# creates a new compute resource described by the provided -# -# -# list -# lists available compute resources -# -# show -# retrieves the OCCI XML representation of the compute resource -# identified by -# -# update -# updates the representation of the compute resource represented by the -# provided -# -# delete -# deletes the compute resource idenfitied by -# -# -# OPTIONS -# -# -h, --help: -# show help -# -# --username , -U : -# The username of the user -# -# --password , -P : -# The password of the user -# -# --url , -R : -# Set url as the web service url to use -# -# --debug, -D -# Enables verbosity -# -# - # -------------------------------------------------------------------------- # # Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # # # @@ -78,10 +28,58 @@ end $: << RUBY_LIB_LOCATION $: << RUBY_LIB_LOCATION+"/cloud" +COMMANDS_HELP=<<-EOT + ** Synopsis + occi-compute + + Manages compute resources + + ** Usage + occi-compute [OPTIONS] [ARGUMENTS] + + COMMANDS + + create + creates a new compute resource described by the provided + + + list + lists available compute resources + + show + retrieves the OCCI XML representation of the compute resource + identified by + + update + updates the representation of the compute resource represented by the + provided + + delete + deletes the compute resource idenfitied by + + + OPTIONS + + --help, -h: + Show help + + --username , -U : + The username of the user + + --password , -P : + The password of the user + + --url , -R : + Set url as the web service url to use + + --debug, -D + Enables verbosity + +EOT + require 'occi/OCCIClient' require 'getoptlong' -require 'rdoc/usage' -require 'pp' +require "rexml/document" include CloudCLI @@ -103,7 +101,8 @@ begin opts.each do |opt, arg| case opt when '--help' - RDoc::usage + puts COMMANDS_HELP + return when '--username' username = arg when '--password' @@ -182,7 +181,23 @@ end if CloudClient::is_error?(rc) puts rc.to_s() -else - puts rc +else + begin + doc = REXML::Document.new(rc) + rescue REXML::ParseException => e + puts e.message + exit(-1) + end + + xml = doc.root + + if xml.nil? + puts "XML syntax error" + exit(-1) + end + + str = "" + REXML::Formatters::Pretty.new(4).write(xml,str) + puts "\n" + str + "\n " end diff --git a/src/cloud/occi/bin/occi-network b/src/cloud/occi/bin/occi-network index a85fc4baa3..e8c1686c26 100755 --- a/src/cloud/occi/bin/occi-network +++ b/src/cloud/occi/bin/occi-network @@ -1,53 +1,4 @@ #!/usr/bin/env ruby - -# == Synopsis -# occi-network -# -# Manages virtual networks -# -# == Usage -# -# occi-network [OPTIONS] [ARGUMENTS] -# -# COMMANDS -# -# create -# creates a new virtual network described by the provided -# -# -# list -# lists available virtual networks -# -# show -# retrieves the OCCI XML representation of the virtual network -# identified by -# -# delete -# deletes the virtual network idenfitied by -# -# -# -# OPTIONS -# -# -h, --help: -# show help -# -# --username , -U : -# The username of the user -# -# --password , -P : -# The password of the user -# -# --url , -R : -# Set url as the web service url to use -# -# --debug, -D -# Enables verbosity -# -# --multipart, -M: -# Use 'multipart-post' library instead of Curb/Curl -# - # -------------------------------------------------------------------------- # # Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # # # @@ -77,11 +28,59 @@ end $: << RUBY_LIB_LOCATION $: << RUBY_LIB_LOCATION+"/cloud" +COMMANDS_HELP=<<-EOT + ** Synopsis + occi-network + + Manages virtual networks + + ** Usage + occi-network [OPTIONS] [ARGUMENTS] + + COMMANDS + + create + creates a new virtual network described by the provided + + + list + lists available virtual networks + + show + retrieves the OCCI XML representation of the virtual network + identified by + + delete + deletes the virtual network idenfitied by + + + + OPTIONS + + --help, -h: + Show help + + --username , -U : + The username of the user + + --password , -P : + The password of the user + + --url , -R : + Set url as the web service url to use + + --debug, -D + Enables verbosity + + --multipart, -M: + Use 'multipart-post' library instead of Curb/Curl + +EOT + require 'occi/OCCIClient' require 'CloudClient' require 'getoptlong' -require 'rdoc/usage' -require 'pp' +require "rexml/document" include CloudCLI @@ -103,7 +102,8 @@ begin opts.each do |opt, arg| case opt when '--help' - RDoc::usage + puts COMMANDS_HELP + return when '--username' username = arg when '--password' @@ -174,6 +174,22 @@ end if CloudClient::is_error?(rc) puts rc.to_s() -else - puts rc +else + begin + doc = REXML::Document.new(rc) + rescue REXML::ParseException => e + puts e.message + exit(-1) + end + + xml = doc.root + + if xml.nil? + puts "XML syntax error" + exit(-1) + end + + str = "" + REXML::Formatters::Pretty.new(4).write(xml,str) + puts "\n" + str + "\n " end diff --git a/src/cloud/occi/bin/occi-storage b/src/cloud/occi/bin/occi-storage index 22c8e2b92b..3cb296a713 100755 --- a/src/cloud/occi/bin/occi-storage +++ b/src/cloud/occi/bin/occi-storage @@ -1,51 +1,4 @@ #!/usr/bin/env ruby - -# == Synopsis -# occi-storage -# -# Manages OCCI storage resource -# -# == Usage -# -# occi-storage [OPTIONS] [PARAMETERS] -# -# COMMANDS -# -# create -# creates a new storage resource described by the provided -# -# -# list -# lists available storage resources -# -# show -# retrieves the OCCI XML representation of the storage resource -# identified by -# -# delete -# deletes the storage resource idenfitied by -# -# -# OPTIONS -# -h, --help: -# show help -# -# --username , -U : -# The username of the user -# -# --password , -P : -# The password of the user -# -# --url , -R : -# Set url as the web service url to use -# -# --debug, -D -# Enables verbosity -# -# --multipart, -M: -# Use 'multipart-post' library instead of Curb/Curl -# - # -------------------------------------------------------------------------- # # Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # # # @@ -75,11 +28,57 @@ end $: << RUBY_LIB_LOCATION $: << RUBY_LIB_LOCATION+"/cloud" +COMMANDS_HELP=<<-EOT +** Synopsis +occi-storage + +Manages OCCI storage resource + +** Usage +occi-storage [OPTIONS] [PARAMETERS] + +COMMANDS + +create + creates a new storage resource described by the provided + + +list + lists available storage resources + +show + retrieves the OCCI XML representation of the storage resource + identified by + +delete + deletes the storage resource idenfitied by + + +OPTIONS +--help, -h: + Show help + +--username , -U : + The username of the user + +--password , -P : + The password of the user + +--url , -R : + Set url as the web service url to use + +--debug, -D + Enables verbosity + +--multipart, -M: + Use 'multipart-post' library instead of Curb/Curl + +EOT + require 'occi/OCCIClient' require 'CloudClient' require 'getoptlong' -require 'rdoc/usage' -require 'pp' +require "rexml/document" include CloudCLI @@ -103,7 +102,8 @@ begin opts.each do |opt, arg| case opt when '--help' - RDoc::usage + puts COMMANDS_HELP + return when '--username' username = arg when '--password' @@ -169,6 +169,22 @@ end if CloudClient::is_error?(rc) puts rc.to_s() -else - puts rc +else + begin + doc = REXML::Document.new(rc) + rescue REXML::ParseException => e + puts e.message + exit(-1) + end + + xml = doc.root + + if xml.nil? + puts "XML syntax error" + exit(-1) + end + + str = "" + REXML::Formatters::Pretty.new(4).write(xml,str) + puts "\n" + str + "\n " end diff --git a/src/cloud/occi/lib/ImageOCCI.rb b/src/cloud/occi/lib/ImageOCCI.rb index 4565189754..781423a5c9 100755 --- a/src/cloud/occi/lib/ImageOCCI.rb +++ b/src/cloud/occi/lib/ImageOCCI.rb @@ -27,12 +27,12 @@ module ImageOCCI <%= ((size/1024)/1024).to_s %> <%= description %> - }.gsub(/^ /, '') + } # Creates the OCCI representation of an Image def to_occi() occi = ERB.new(OCCI_IMAGE) - return occi.result(binding) + return occi.result(binding).gsub(/\n\s*/,'') end end diff --git a/src/cloud/occi/lib/ImagePoolOCCI.rb b/src/cloud/occi/lib/ImagePoolOCCI.rb index d082e8efcb..596c139575 100755 --- a/src/cloud/occi/lib/ImagePoolOCCI.rb +++ b/src/cloud/occi/lib/ImagePoolOCCI.rb @@ -26,7 +26,7 @@ class ImagePoolOCCI <% end %> - }.gsub(/^ /, '') + } def initialize(user_id) @images=Image.filter(:owner => user_id) @@ -34,7 +34,7 @@ class ImagePoolOCCI def to_occi(base_url) occi = ERB.new(OCCI_IMAGE_POOL) - return occi.result(binding) + return occi.result(binding).gsub(/\n\s*/,'') end end diff --git a/src/cloud/occi/lib/VirtualMachineOCCI.rb b/src/cloud/occi/lib/VirtualMachineOCCI.rb index 41aec5250b..3b0923de50 100755 --- a/src/cloud/occi/lib/VirtualMachineOCCI.rb +++ b/src/cloud/occi/lib/VirtualMachineOCCI.rb @@ -35,7 +35,7 @@ class VirtualMachineOCCI < VirtualMachine <%=template['INSTANCE_TYPE']%><% end %> - }.gsub(/^ /, '') + } # Creates the VMI representation of a Virtual Machine @@ -47,7 +47,7 @@ class VirtualMachineOCCI < VirtualMachine template['NIC']=[template['NIC']].flatten if template['NIC'] occi = ERB.new(OCCI_VM) - return occi.result(binding) + return occi.result(binding).gsub(/\n\s*/,'') end end diff --git a/src/cloud/occi/lib/VirtualMachinePoolOCCI.rb b/src/cloud/occi/lib/VirtualMachinePoolOCCI.rb index 3319da8ea7..2488f491b1 100755 --- a/src/cloud/occi/lib/VirtualMachinePoolOCCI.rb +++ b/src/cloud/occi/lib/VirtualMachinePoolOCCI.rb @@ -12,7 +12,7 @@ class VirtualMachinePoolOCCI < VirtualMachinePool } end %> - }.gsub(/^ /, '') + } # Creates the OCCI representation of a Virtual Machine Pool @@ -20,7 +20,7 @@ class VirtualMachinePoolOCCI < VirtualMachinePool pool_hash=to_hash occi = ERB.new(OCCI_VM_POOL) - return occi.result(binding) + return occi.result(binding).gsub(/\n\s*/,'') end end diff --git a/src/cloud/occi/lib/VirtualNetworkOCCI.rb b/src/cloud/occi/lib/VirtualNetworkOCCI.rb index 36ef471c3c..7da7094b14 100755 --- a/src/cloud/occi/lib/VirtualNetworkOCCI.rb +++ b/src/cloud/occi/lib/VirtualNetworkOCCI.rb @@ -27,7 +27,7 @@ class VirtualNetworkOCCI < VirtualNetwork
<%= vn_hash['VNET']['TEMPLATE']['NETWORK_ADDRESS'].strip %>
<%= vn_hash['VNET']['TEMPLATE']['NETWORK_SIZE'].strip %> - }.gsub(/^ /, '') + } ONE_NETWORK = %q{ NAME = <%= network_hash['NAME'] %> @@ -42,7 +42,7 @@ class VirtualNetworkOCCI < VirtualNetwork vn_hash = to_hash occi = ERB.new(OCCI_NETWORK) - return occi.result(binding) + return occi.result(binding).gsub(/\n\s*/,'') end def to_one_template(network_hash, bridge) diff --git a/src/cloud/occi/lib/VirtualNetworkPoolOCCI.rb b/src/cloud/occi/lib/VirtualNetworkPoolOCCI.rb index b46e4ead7a..3f640e100a 100755 --- a/src/cloud/occi/lib/VirtualNetworkPoolOCCI.rb +++ b/src/cloud/occi/lib/VirtualNetworkPoolOCCI.rb @@ -13,13 +13,13 @@ class VirtualNetworkPoolOCCI < VirtualNetworkPool } end %> - }.gsub(/^ /, '') + } # Creates the OCCI representation of a Virtual Network def to_occi(base_url) network_pool_hash=to_hash occi = ERB.new(OCCI_NETWORK_POOL) - return occi.result(binding) + return occi.result(binding).gsub(/\n\s*/,'') end end