1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

Merge branch 'feature-239'

This commit is contained in:
Ruben S. Montero 2010-06-28 13:06:42 +02:00
commit 0bebbaaa35
15 changed files with 419 additions and 355 deletions

View File

@ -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 <id>, -K <id>:
# The username of the user
#
# --secret-key <key>, -S <key>:
# The password of the user
#
# --url <url>, -U <url>:
# 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 <id>, -K <id>:
The username of the user
--secret-key <key>, -S <key>:
The password of the user
--url <url>, -U <url>:
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'

View File

@ -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 <id>, -K <id>:
# The username of the user
#
# --secret-key <key>, -S <key>:
# The password of the user
#
# --url <url>, -U <url>:
# 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 <id>, -K <id>:
The username of the user
--secret-key <key>, -S <key>:
The password of the user
--url <url>, -U <url>:
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'

View File

@ -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 <id>, -K <id>:
# The username of the user
#
# --secret-key <key>, -S <key>:
# The password of the user
#
# --url <url>, -U <url>:
# 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 <id>, -K <id>:
The username of the user
--secret-key <key>, -S <key>:
The password of the user
--url <url>, -U <url>:
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'

View File

@ -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 <id>, -K <id>:
# The username of the user
#
# --secret-key <key>, -S <key>:
# The password of the user
#
# --url <url>, -U <url>:
# Set url as the web service url to use
#
# --type <type>, -t <type>
#
# --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 <id>, -K <id>:
The username of the user
--secret-key <key>, -S <key>:
The password of the user
--url <url>, -U <url>:
Set url as the web service url to use
--type <type>, -t <type>:
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'

View File

@ -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 <id>, -K <id>:
# The username of the user
#
# --secret-key <key>, -S <key>:
# The password of the user
#
# --url <url>, -U <url>:
# 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 <id>, -K <id>:
The username of the user
--secret-key <key>, -S <key>:
The password of the user
--url <url>, -U <url>:
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'

View File

@ -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 <id>, -K <id>:
# The username of the user
#
# --secret-key <key>, -S <key>:
# The password of the user
#
# --url <url>, -U <url>:
# 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 <id>, -K <id>:
The username of the user
--secret-key <key>, -S <key>:
The password of the user
--url <url>, -U <url>:
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'

View File

@ -1,54 +1,4 @@
#!/usr/bin/env ruby
# == Synopsis
# occi-compute
#
# Manages compute resources
#
# == Usage
#
# occi-compute <COMMAND> [OPTIONS] [ARGUMENTS]
#
# COMMANDS
#
# create <occi xml file>
# creates a new compute resource described by the provided
# <occi xml file>
#
# list
# lists available compute resources
#
# show <compute id>
# retrieves the OCCI XML representation of the compute resource
# identified by <compute id>
#
# update <occi xml file>
# updates the representation of the compute resource represented by the
# provided <occi xml file>
#
# delete <compute id>
# deletes the compute resource idenfitied by <compute id>
#
#
# OPTIONS
#
# -h, --help:
# show help
#
# --username <id>, -U <id>:
# The username of the user
#
# --password <key>, -P <key>:
# The password of the user
#
# --url <url>, -R <url>:
# 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 <COMMAND> [OPTIONS] [ARGUMENTS]
COMMANDS
create <occi xml file>
creates a new compute resource described by the provided
<occi xml file>
list
lists available compute resources
show <compute id>
retrieves the OCCI XML representation of the compute resource
identified by <compute id>
update <occi xml file>
updates the representation of the compute resource represented by the
provided <occi xml file>
delete <compute id>
deletes the compute resource idenfitied by <compute id>
OPTIONS
--help, -h:
Show help
--username <id>, -U <id>:
The username of the user
--password <key>, -P <key>:
The password of the user
--url <url>, -R <url>:
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

View File

@ -1,53 +1,4 @@
#!/usr/bin/env ruby
# == Synopsis
# occi-network
#
# Manages virtual networks
#
# == Usage
#
# occi-network <COMMAND> [OPTIONS] [ARGUMENTS]
#
# COMMANDS
#
# create <occi xml file>
# creates a new virtual network described by the provided
# <occi xml file>
#
# list
# lists available virtual networks
#
# show <network id>
# retrieves the OCCI XML representation of the virtual network
# identified by <network id>
#
# delete <network id>
# deletes the virtual network idenfitied by <network id>
#
#
#
# OPTIONS
#
# -h, --help:
# show help
#
# --username <id>, -U <id>:
# The username of the user
#
# --password <key>, -P <key>:
# The password of the user
#
# --url <url>, -R <url>:
# 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 <COMMAND> [OPTIONS] [ARGUMENTS]
COMMANDS
create <occi xml file>
creates a new virtual network described by the provided
<occi xml file>
list
lists available virtual networks
show <network id>
retrieves the OCCI XML representation of the virtual network
identified by <network id>
delete <network id>
deletes the virtual network idenfitied by <network id>
OPTIONS
--help, -h:
Show help
--username <id>, -U <id>:
The username of the user
--password <key>, -P <key>:
The password of the user
--url <url>, -R <url>:
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

View File

@ -1,51 +1,4 @@
#!/usr/bin/env ruby
# == Synopsis
# occi-storage
#
# Manages OCCI storage resource
#
# == Usage
#
# occi-storage <COMMAND> [OPTIONS] [PARAMETERS]
#
# COMMANDS
#
# create <occi xml file>
# creates a new storage resource described by the provided
# <occi xml file>
#
# list
# lists available storage resources
#
# show <storage id>
# retrieves the OCCI XML representation of the storage resource
# identified by <storage id>
#
# delete <storage id>
# deletes the storage resource idenfitied by <storage id>
#
#
# OPTIONS
# -h, --help:
# show help
#
# --username <id>, -U <id>:
# The username of the user
#
# --password <key>, -P <key>:
# The password of the user
#
# --url <url>, -R <url>:
# 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 <COMMAND> [OPTIONS] [PARAMETERS]
COMMANDS
create <occi xml file>
creates a new storage resource described by the provided
<occi xml file>
list
lists available storage resources
show <storage id>
retrieves the OCCI XML representation of the storage resource
identified by <storage id>
delete <storage id>
deletes the storage resource idenfitied by <storage id>
OPTIONS
--help, -h:
Show help
--username <id>, -U <id>:
The username of the user
--password <key>, -P <key>:
The password of the user
--url <url>, -R <url>:
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

View File

@ -27,12 +27,12 @@ module ImageOCCI
<SIZE><%= ((size/1024)/1024).to_s %></SIZE>
<URL><%= description %></URL>
</DISK>
}.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

View File

@ -26,7 +26,7 @@ class ImagePoolOCCI
<DISK href="<%= base_url%>/storage/<%= image[:id] %>"/><%
end %>
</STORAGE>
}.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

View File

@ -35,7 +35,7 @@ class VirtualMachineOCCI < VirtualMachine
<INSTANCE_TYPE><%=template['INSTANCE_TYPE']%></INSTANCE_TYPE><%
end %>
</COMPUTE>
}.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

View File

@ -12,7 +12,7 @@ class VirtualMachinePoolOCCI < VirtualMachinePool
}
end %>
</COMPUTES>
}.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

View File

@ -27,7 +27,7 @@ class VirtualNetworkOCCI < VirtualNetwork
<ADDRESS><%= vn_hash['VNET']['TEMPLATE']['NETWORK_ADDRESS'].strip %></ADDRESS>
<SIZE><%= vn_hash['VNET']['TEMPLATE']['NETWORK_SIZE'].strip %></SIZE>
</NETWORK>
}.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)

View File

@ -13,13 +13,13 @@ class VirtualNetworkPoolOCCI < VirtualNetworkPool
}
end %>
</NETWORKS>
}.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