1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-19 06:50:07 +03:00

Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Hector Sanjuan 2011-12-12 12:58:46 +01:00
commit bb3aa069c8
58 changed files with 845 additions and 631 deletions

View File

@ -228,12 +228,12 @@ public:
static string version()
{
return "OpenNebula 3.1.0";
return "OpenNebula 3.1.80";
};
static string db_version()
{
return "3.1.0";
return "3.1.80";
}
void start();

View File

@ -746,6 +746,7 @@ ONEDB_MIGRATOR_FILES="src/onedb/2.0_to_2.9.80.rb \
src/onedb/2.9.85_to_2.9.90.rb \
src/onedb/2.9.90_to_3.0.0.rb \
src/onedb/3.0.0_to_3.1.0.rb \
src/onedb/3.1.0_to_3.1.80.rb \
src/onedb/onedb.rb \
src/onedb/onedb_backend.rb"
@ -958,6 +959,7 @@ OCCI_ETC_TEMPLATE_FILES="src/cloud/occi/etc/templates/common.erb \
src/cloud/occi/etc/templates/custom.erb \
src/cloud/occi/etc/templates/small.erb \
src/cloud/occi/etc/templates/medium.erb \
src/cloud/occi/etc/templates/network.erb \
src/cloud/occi/etc/templates/large.erb"
#-----------------------------------------------------------------------------
@ -1111,6 +1113,9 @@ SUNSTONE_PUBLIC_IMAGES_FILES="src/sunstone/public/images/ajax-loader.gif \
src/sunstone/public/images/panel_short.png \
src/sunstone/public/images/pbar.gif \
src/sunstone/public/images/Refresh-icon.png \
src/sunstone/public/images/red_bullet.png \
src/sunstone/public/images/yellow_bullet.png \
src/sunstone/public/images/green_bullet.png \
src/sunstone/public/images/vnc_off.png \
src/sunstone/public/images/vnc_on.png"

View File

@ -2,16 +2,17 @@
require 'pp'
PACKAGES=%w{optional sunstone quota cloud ozones_client ozones_server
ozones_server_mysql ozones_server_sqlite}
DEFAULT=%w{optional sunstone quota cloud ozones_server acct}
DEFAULT=%w{optional sunstone quota cloud ozones_server acct auth_ldap}
if defined?(RUBY_VERSION) && RUBY_VERSION>="1.8.7"
SQLITE='sqlite3'
# xmlparser gem is not compatible with ruby 1.9
OPTIONAL=%w{nokogiri}
if RUBY_VERSION=='1.8.7'
OPTIONAL << 'xmlparser'
end
else
SQLITE='sqlite3-ruby --version 1.2.0'
OPTIONAL=%w{nokogiri xmlparser}
@ -21,7 +22,7 @@ GROUPS={
:optional => OPTIONAL,
:quota => [SQLITE, 'sequel'],
:sunstone => ['json', 'rack', 'sinatra', 'thin', 'sequel', SQLITE],
:cloud => %w{amazon-ec2 rack sinatra thin uuid curb},
:cloud => %w{amazon-ec2 rack sinatra thin uuidtools curb},
:ozones_client => %w{json},
:ozones_server => %w{json data_mapper dm-sqlite-adapter dm-mysql-adapter}+[
SQLITE, 'mysql'
@ -30,9 +31,12 @@ GROUPS={
:ozones_server_mysql => %w{json data_mapper dm-mysql-adapter mysql},
:acct => ['sequel', SQLITE, 'mysql'],
:acct_sqlite => ['sequel', SQLITE],
:acct_mysql => ['sequel', 'mysql']
:acct_mysql => ['sequel', 'mysql'],
:auth_ldap => 'net-ldap'
}
PACKAGES=GROUPS.keys
DISTRIBUTIONS={
:debian => {
:id => ['Ubuntu', 'Debian'],
@ -82,6 +86,15 @@ class String
end
end
def installed_gems
text=`gem list --no-versions --no-details`
if $?.exitstatus!=0
nil
else
text.split(/\s+/)
end
end
def try_library(name, error_message)
begin
require name.to_s
@ -107,12 +120,14 @@ def help
puts
puts "If no parameters are specified then this list will be used:"
puts DEFAULT.join(' ')
puts
puts "Use --check parameter to search for non installed libraries."
end
def get_gems(packages)
packages.map do |package|
GROUPS[package.to_sym]
end.flatten.uniq
end.flatten.uniq-installed_gems
end
def detect_distro
@ -191,6 +206,88 @@ def install_dependencies(gems, distro)
end
end
def run_command(cmd)
puts cmd
system cmd
#system "true"
if $?!=0
puts "Error executing #{cmd}"
exit(-1)
end
end
def install_gems(packages)
gems_list=get_gems(packages)
if gems_list.empty?
puts "Gems already installed"
exit(0)
end
dist=detect_distro
install_dependencies(gems_list, dist)
packages_string=gems_list.join(' ')
prefix=""
if dist && dist.last[:gem_env]
prefix=dist.last[:gem_env].collect do |name, value|
"#{name}=\"#{value}\""
end.join(' ')+' '
end
command_string = "#{prefix}gem install --no-ri --no-rdoc"
install_warning(packages)
simple_gems=gems_list.select {|g| !(g.match(/\s/)) }
if simple_gems and !simple_gems.empty?
cmd=command_string+" " << simple_gems.join(' ')
run_command(cmd)
end
special_gems=gems_list.select {|g| g.match(/\s/) }
special_gems.each do |gem|
cmd=command_string+" "<<gem
run_command(cmd)
end
end
def check_lib(lib)
begin
require lib
true
rescue LoadError, Exception
false
end
end
def check_gems(packages)
list=get_gems(packages).compact
gems=list.map {|g| g.strip.split(/\s+/).first }
not_installed=Array.new
gems.each do |lib_name|
if !check_lib(lib_name)
not_installed << lib_name
end
end
if not_installed.empty?
puts "All ruby libraries installed"
exit(0)
else
puts "These ruby libraries are not installed:"
puts ""
puts "* "+not_installed.join("\n* ")
exit(-1)
end
end
try_library :rubygems, <<-EOT.unindent
rubygems required to use this tool
@ -224,45 +321,37 @@ try_library :mkmf, <<-EOT.unindent
* Install the ruby development package for your distro
EOT
if ARGV.include?('-h')
help
exit(0)
command=''
params=ARGV
if params.include?('-h')
params-=['-h']
command='help'
elsif params.include?('--check')
params-=['--check']
command='check'
else
command='install'
end
if ARGV.length>0
packages=ARGV
if params.length>0
packages=params
else
packages=DEFAULT
end
gems_list=get_gems(packages)
dist=detect_distro
install_dependencies(gems_list, dist)
packages_string=gems_list.join(' ')
prefix=""
if dist && dist.last[:gem_env]
prefix=dist.last[:gem_env].collect do |name, value|
"#{name}=\"#{value}\""
end.join(' ')+' '
case command
when 'help'
help
exit(0)
when 'check'
check_gems(packages)
when 'install'
install_gems(packages)
end
command_string = "#{prefix}gem install --no-ri --no-rdoc"
install_warning(packages)
gems_list.each do |gem|
cmd=command_string+" "<<gem
puts cmd
system cmd
if $?!=0
puts "Error installing #{gem}"
exit(-1)
end
end

View File

@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands"
.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands"
.SH NAME
OpenNebula \- OpenNebula econe-describe-images
.SH SYNOPSIS

View File

@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands"
.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands"
.SH NAME
OpenNebula \- OpenNebula econe-describe-instances
.SH SYNOPSIS

View File

@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands"
.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands"
.SH NAME
OpenNebula \- OpenNebula econe-register
.SH SYNOPSIS

View File

@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands"
.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands"
.SH NAME
OpenNebula \- OpenNebula econe-run-instances
.SH SYNOPSIS

View File

@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands"
.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands"
.SH NAME
OpenNebula \- OpenNebula econe-terminate-instances
.SH SYNOPSIS

View File

@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands"
.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.1.80" "User Commands"
.SH NAME
OpenNebula \- OpenNebula econe-upload
.SH SYNOPSIS

View File

@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands"
.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands"
.SH NAME
OpenNebula \- OpenNebula occi-compute
.SH SYNOPSIS

View File

@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands"
.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands"
.SH NAME
OpenNebula \- OpenNebula occi-network
.SH SYNOPSIS

View File

@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands"
.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands"
.SH NAME
OpenNebula \- OpenNebula occi-storage
.SH SYNOPSIS

View File

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "ONEACL" "1" "September 2011" "" "oneacl(1) -- manages OpenNebula ACLs"
.TH "ONEACL" "1" "December 2011" "" "oneacl(1) -- manages OpenNebula ACLs"
.
.SH "NAME"
\fBoneacl\fR
@ -128,7 +128,7 @@ Comma\-separated list of OpenNebula ACL names or ids
.IP "" 0
.
.SH "LICENSE"
OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
.
.P
Licensed 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

View File

@ -1,21 +1,12 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "ONEDB" "1" "September 2011" "" "onedb(1) -- OpenNebula database migration tool"
.TH "ONEDB" "1" "December 2011" "" "onedb(1) -- OpenNebula database migration tool"
.
.SH "NAME"
\fBonedb\fR
.
.P
DB Connection options:
.
.P
By default, onedb reads the connection data from oned\.conf If any of these options is set, oned\.conf is ignored (i\.e\. if you set MySQL\'s port onedb won\'t look for the rest of the options in oned\.conf)
.
.P
Description:
.
.P
This command enables the user to manage the OpenNebula database\. It provides information about the DB version, means to upgrade it to the latest version, and backup tools\.
.
.SH "OPTIONS"

View File

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "ONEGROUP" "1" "September 2011" "" "onegroup(1) -- manages OpenNebula groups"
.TH "ONEGROUP" "1" "December 2011" "" "onegroup(1) -- manages OpenNebula groups"
.
.SH "NAME"
\fBonegroup\fR
@ -160,7 +160,7 @@ Comma\-separated list of OpenNebula GROUP names or ids
.IP "" 0
.
.SH "LICENSE"
OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
.
.P
Licensed 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

View File

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "ONEHOST" "1" "September 2011" "" "onehost(1) -- manages OpenNebula hosts"
.TH "ONEHOST" "1" "December 2011" "" "onehost(1) -- manages OpenNebula hosts"
.
.SH "NAME"
\fBonehost\fR
@ -27,7 +27,7 @@
.SH "COMMANDS"
.
.IP "\(bu" 4
create \fIhostname\fR \fIim_mad\fR \fIvmm_mad\fR \fItm_mad\fR
create \fIhostname\fR \fIim_mad\fR \fIvmm_mad\fR \fItm_mad\fR \fIvnm_mad\fR
.
.IP "" 4
.
@ -234,7 +234,7 @@ Comma\-separated list of OpenNebula HOST names or ids
.IP "" 0
.
.SH "LICENSE"
OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
.
.P
Licensed 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

View File

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "ONEIMAGE" "1" "September 2011" "" "oneimage(1) -- manages OpenNebula images"
.TH "ONEIMAGE" "1" "December 2011" "" "oneimage(1) -- manages OpenNebula images"
.
.SH "NAME"
\fBoneimage\fR
@ -141,6 +141,20 @@ Enables the given Image
.
.IP "" 0
.
.IP "\(bu" 4
chtype \fIrange|imageid_list\fR \fItype\fR
.
.IP "" 4
.
.nf
Changes the Image\'s type
.
.fi
.
.IP "" 0
.
.IP "\(bu" 4
disable \fIrange|imageid_list\fR
@ -353,7 +367,7 @@ user IMAGE of the user identified by the username
.IP "" 0
.
.SH "LICENSE"
OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
.
.P
Licensed 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

View File

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "ONETEMPLATE" "1" "September 2011" "" "onetemplate(1) -- manages OpenNebula templates"
.TH "ONETEMPLATE" "1" "December 2011" "" "onetemplate(1) -- manages OpenNebula templates"
.
.SH "NAME"
\fBonetemplate\fR
@ -312,7 +312,7 @@ user VMTEMPLATE of the user identified by the username
.IP "" 0
.
.SH "LICENSE"
OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
.
.P
Licensed 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

View File

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "ONEUSER" "1" "September 2011" "" "oneuser(1) -- manages OpenNebula users"
.TH "ONEUSER" "1" "December 2011" "" "oneuser(1) -- manages OpenNebula users"
.
.SH "NAME"
\fBoneuser\fR
@ -14,11 +14,12 @@
.nf
\-r, \-\-read\-file Read password from file
\-p, \-\-plain Store plain password
\-\-sha1 The password will be hashed using the sha1 algorithm
\-\-ssh SSH Auth system
\-\-x509 x509 Auth system for x509 certificates
\-k, \-\-key path_to_private_key_pem Path to the Private Key of the User
\-c, \-\-cert path_to_user_cert_pem Path to the Certificate of the User
\-\-driver driver Driver to autehnticate this user
\-\-x509_proxy x509 Auth system based on x509 proxy certificates
\-\-proxy path_to_user_proxy_pem Path to the user proxy certificate
\-\-time x Token duration in seconds, defaults to 3600 (1 h)
@ -44,11 +45,25 @@ create \fIusername\fR [\fIpassword\fR]
Creates a new User
Examples:
oneuser create my_user my_password
oneuser create my_user /tmp/mypass \-r
oneuser create my_user \-r /tmp/mypass
oneuser create my_user \-\-ssh \-\-key /tmp/id_rsa
oneuser create my_user \-\-ssh \-r /tmp/public_key
oneuser create my_user \-\-x509 \-\-cert /tmp/my_cert\.pem
valid options: read_file, plain, ssh, x509, key, cert
valid options: read_file, sha1, ssh, x509, key, cert, driver
.
.fi
.
.IP "" 0
.
.IP "\(bu" 4
update \fIuserid\fR
.
.IP "" 4
.
.nf
Launches the system editor to modify and update the template contents
.
.fi
.
@ -112,7 +127,7 @@ passwd \fIuserid\fR [\fIpassword\fR]
.nf
Changes the given User\'s password
valid options: read_file, plain, ssh, x509, key, cert
valid options: read_file, sha1, ssh, x509, key, cert, driver
.
.fi
.
@ -132,6 +147,28 @@ Changes the User\'s main group
.
.IP "" 0
.
.IP "\(bu" 4
chauth \fIuserid\fR [\fIauth\fR] [\fIpassword\fR]
.
.IP "" 4
.
.nf
Changes the User\'s auth driver and its password (optional)
Examples:
oneuser chauth my_user core
oneuser chauth my_user core new_password
oneuser chauth my_user core \-r /tmp/mypass
oneuser chauth my_user \-\-ssh \-\-key /home/oneadmin/\.ssh/id_rsa
oneuser chauth my_user \-\-ssh \-r /tmp/public_key
oneuser chauth my_user \-\-x509 \-\-cert /tmp/my_cert\.pem
valid options: read_file, sha1, ssh, x509, key, cert, driver
.
.fi
.
.IP "" 0
.
.IP "\(bu" 4
list
@ -268,7 +305,7 @@ User password
.IP "" 0
.
.SH "LICENSE"
OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
.
.P
Licensed 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

View File

@ -1,184 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "ONEVDC" "1" "September 2011" "" "onevdc(1) -- manages OpenNebula Virtual DataCenters"
.TH "ONEVDC" "1" "December 2011" "" "onevdc(1) -- manages OpenNebula Virtual DataCenters"
.
.SH "NAME"
\fBonevdc\fR
.
.SH "SYNOPSIS"
\fBonevdc\fR command [\fIargs\fR] [\fIoptions\fR]
.
.SH "OPTIONS"
.
.nf
\-f, \-\-force Force the usage of Hosts in more than one VDC
\-l, \-\-list x,y,z Selects columns to display with list command
\-d, \-\-delay x Sets the delay in seconds for top command
\-x, \-\-xml Show the resource in xml format
\-n, \-\-numeric Do not translate user and group IDs
\-k, \-\-kilobytes Show units in kilobytes
\-v, \-\-verbose Verbose mode
\-h, \-\-help Show this message
\-V, \-\-version Show version and copyright information
.
.fi
.
.SH "COMMANDS"
.
.IP "\(bu" 4
create \fIfile\fR
.
.IP "" 4
.
.nf
Create a new VDC
valid options: force
.
.fi
.
.IP "" 0
.
.IP "\(bu" 4
show \fIvdcid\fR
.
.IP "" 4
.
.nf
Show information of a particular VDC
.
.fi
.
.IP "" 0
.
.IP "\(bu" 4
list
.
.IP "" 4
.
.nf
Lists VDCs in the pool
valid options: list, delay, xml, numeric, kilobytes
.
.fi
.
.IP "" 0
.
.IP "\(bu" 4
delete \fIvdcid\fR
.
.IP "" 4
.
.nf
Deletes a VDC
.
.fi
.
.IP "" 0
.
.IP "\(bu" 4
addhost \fIvdcid\fR \fIrange\fR
.
.IP "" 4
.
.nf
Adds the set of hosts to the VDC
valid options: force
.
.fi
.
.IP "" 0
.
.IP "\(bu" 4
delhost \fIvdcid\fR \fIrange\fR
.
.IP "" 4
.
.nf
Deletes the set of hosts from the VDC
valid options: force
.
.fi
.
.IP "" 0
.
.IP "" 0
.
.SH "ARGUMENT FORMATS"
.
.IP "\(bu" 4
file
.
.IP "" 4
.
.nf
Path to a file
.
.fi
.
.IP "" 0
.
.IP "\(bu" 4
range
.
.IP "" 4
.
.nf
List of id\'s in the form 1,8\.\.15
.
.fi
.
.IP "" 0
.
.IP "\(bu" 4
text
.
.IP "" 4
.
.nf
String
.
.fi
.
.IP "" 0
.
.IP "\(bu" 4
vdcid
.
.IP "" 4
.
.nf
VDC ID
.
.fi
.
.IP "" 0
.
.IP "" 0
.
.SH "LICENSE"
OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
.
.P
Licensed 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

View File

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "ONEVM" "1" "September 2011" "" "onevm(1) -- manages OpenNebula virtual machines"
.TH "ONEVM" "1" "December 2011" "" "onevm(1) -- manages OpenNebula virtual machines"
.
.SH "NAME"
\fBonevm\fR
@ -17,6 +17,7 @@
\-x, \-\-xml Show the resource in xml format
\-n, \-\-numeric Do not translate user and group IDs
\-k, \-\-kilobytes Show units in kilobytes
\-t, \-\-type type Type of the new Image
\-l, \-\-list x,y,z Selects columns to display with list command
\-d, \-\-delay x Sets the delay in seconds for top command
\-v, \-\-verbose Verbose mode
@ -106,6 +107,7 @@ shut down gracefuly (i\.e\., using \'onevm shutdown\' and not
\'onevm delete\')
States: ANY
valid options: type
.
.fi
.
@ -493,7 +495,7 @@ user VM of the user identified by the username
.IP "" 0
.
.SH "LICENSE"
OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
.
.P
Licensed 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

View File

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "ONEVNET" "1" "September 2011" "" "onevnet(1) -- manages OpenNebula networks"
.TH "ONEVNET" "1" "December 2011" "" "onevnet(1) -- manages OpenNebula networks"
.
.SH "NAME"
\fBonevnet\fR
@ -81,6 +81,34 @@ Removes a lease from the Virtual Network
.
.IP "" 0
.
.IP "\(bu" 4
hold \fIvnetid\fR \fIip\fR
.
.IP "" 4
.
.nf
Holds a Virtual Network lease, marking it as used
.
.fi
.
.IP "" 0
.
.IP "\(bu" 4
release \fIvnetid\fR \fIip\fR
.
.IP "" 4
.
.nf
Releases a Virtual Network lease on hold
.
.fi
.
.IP "" 0
.
.IP "\(bu" 4
publish \fIrange|vnetid_list\fR
@ -113,7 +141,7 @@ can\'t be used by any other User
.
.IP "\(bu" 4
chgrp \fIrange|vnid_list\fR \fIgroupid\fR
chgrp \fIrange|vnetid_list\fR \fIgroupid\fR
.
.IP "" 4
.
@ -127,7 +155,7 @@ Changes the Virtual Network group
.
.IP "\(bu" 4
chown \fIrange|vnid_list\fR \fIuserid\fR [\fIgroupid\fR]
chown \fIrange|vnetid_list\fR \fIuserid\fR [\fIgroupid\fR]
.
.IP "" 4
.
@ -169,6 +197,20 @@ valid options: xml
.
.IP "" 0
.
.IP "\(bu" 4
update \fIvnetid\fR
.
.IP "" 4
.
.nf
Launches the system editor to modify and update the template contents
.
.fi
.
.IP "" 0
.
.IP "" 0
.
@ -294,7 +336,7 @@ user VNET of the user identified by the username
.IP "" 0
.
.SH "LICENSE"
OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
.
.P
Licensed 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

View File

@ -1,156 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "ONEZONE" "1" "September 2011" "" "onezone(1) -- manages OpenNebula zones"
.TH "ONEZONE" "1" "December 2011" "" "onezone(1) -- manages OpenNebula zones"
.
.SH "NAME"
\fBonezone\fR
.
.SH "SYNOPSIS"
\fBonezone\fR \fIcommand\fR [\fIargs\fR] [\fIoptions\fR]
.
.SH "OPTIONS"
.
.nf
\-l, \-\-list x,y,z Selects columns to display with list command
\-d, \-\-delay x Sets the delay in seconds for top command
\-x, \-\-xml Show the resource in xml format
\-n, \-\-numeric Do not translate user and group IDs
\-k, \-\-kilobytes Show units in kilobytes
\-v, \-\-verbose Verbose mode
\-h, \-\-help Show this message
\-V, \-\-version Show version and copyright information
.
.fi
.
.SH "COMMANDS"
.
.IP "\(bu" 4
create \fIfile\fR
.
.IP "" 4
.
.nf
Create a new Zone
.
.fi
.
.IP "" 0
.
.IP "\(bu" 4
show \fIzoneid\fR [\fIresource\fR]
.
.IP "" 4
.
.nf
Show information of a particular Zone
Available resources: host, vm, image, vn, template, user
Examples:
onezone show 4
onezone show 4 host
.
.fi
.
.IP "" 0
.
.IP "\(bu" 4
list
.
.IP "" 4
.
.nf
Lists Zones in the pool
valid options: list, delay, xml, numeric, kilobytes
.
.fi
.
.IP "" 0
.
.IP "\(bu" 4
delete \fIzoneid\fR
.
.IP "" 4
.
.nf
Deletes a Zone
.
.fi
.
.IP "" 0
.
.IP "" 0
.
.SH "ARGUMENT FORMATS"
.
.IP "\(bu" 4
file
.
.IP "" 4
.
.nf
Path to a file
.
.fi
.
.IP "" 0
.
.IP "\(bu" 4
range
.
.IP "" 4
.
.nf
List of id\'s in the form 1,8\.\.15
.
.fi
.
.IP "" 0
.
.IP "\(bu" 4
text
.
.IP "" 4
.
.nf
String
.
.fi
.
.IP "" 0
.
.IP "\(bu" 4
zoneid
.
.IP "" 4
.
.nf
Zone ID
.
.fi
.
.IP "" 0
.
.IP "" 0
.
.SH "LICENSE"
OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
.
.P
Licensed 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

View File

@ -54,7 +54,7 @@ if options[:group]
end
if ldap.authenticate(user_name, secret)
puts "#{user} #{user_name}"
puts "ldap #{user} #{user_name}"
exit(0)
else
STDERR.puts "Bad user/password"

View File

@ -113,7 +113,15 @@ class Quota
def initialize
conf = YAML.load_file(CONF_FILE)
@conf=CONF.merge(conf) {|key,h1,h2|
h1.merge(h2) if h1.instance_of?(Hash) && h2.instance_of?(Hash)
if h1.instance_of?(Hash) && h2.instance_of?(Hash)
h1.merge(h2)
else
if h2
h2
else
h1
end
end
}
@client = OpenNebula::Client.new

View File

@ -21,7 +21,7 @@ include OpenNebula
module OpenNebulaHelper
ONE_VERSION=<<-EOT
OpenNebula 3.1.0
OpenNebula 3.1.80
Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org)
Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -99,10 +99,10 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
CLIHelper.print_header(str_h1 % "VIRTUAL MACHINE TEMPLATE",false)
puts vm.template_str
if vm.has_elements?("/VM/HISTORY_RECORDS/")
if vm.has_elements?("/VM/HISTORY_RECORDS")
puts
CLIHelper.print_header(str_h1 % "VIRTUAL MACHINE HISTORY",false)
format_history(vm)
end

View File

@ -105,7 +105,6 @@ class CloudAuth
if time_now > @token_expiration_time - EXPIRE_MARGIN
@token_expiration_time = time_now + EXPIRE_DELTA
update_userpool_cache
end
@token_expiration_time

View File

@ -173,7 +173,7 @@ module CloudCLI
def version_text
version=<<EOT
OpenNebula 3.1.0
OpenNebula 3.1.80
Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org)
Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -24,9 +24,6 @@
# SSL proxy that serves the API (set if is being used)
#:ssl_server: fqdm.of.the.server
# Configuration for OpenNebula's Virtual Networks
#:bridge: NAME_OF_DEFAULT_BRIDGE
# Authentication driver for incomming requests
# occi, for OpenNebula's user-password scheme
# x509, for x509 certificates based authentication

View File

@ -0,0 +1,25 @@
#
# This template is processed by the OCCI Server to include specific data for
# the VNET, you should not need to modify the ruby code.
# You can add common attributes for your VNET templates (e.g. VLAN, PHYDEV)
#
NAME = "<%= @vnet_info['NAME'] %>"
TYPE = RANGED
NETWORK_ADDRESS = <%= @vnet_info['ADDRESS'] %>
<% if @vnet_info['SIZE'] != nil %>
NETWORK_SIZE = <%= @vnet_info['SIZE']%>
<% end %>
<% if @vnet_info['DESCRIPTION'] != nil %>
DESCRIPTION = "<%= @vnet_info['DESCRIPTION'] %>"
<% end %>
<% if @vnet_info['PUBLIC'] != nil %>
PUBLIC = "<%= @vnet_info['PUBLIC'] %>"
<% end %>
#BRIDGE = NAME_OF_DEFAULT_BRIDGE
#PHYDEV = NAME_OF_PHYSICAL_DEVICE
#VLAN = YES|NO

View File

@ -30,7 +30,7 @@ class ImageOCCI < Image
<DESCRIPTION><%= self['TEMPLATE/DESCRIPTION'] %></DESCRIPTION>
<% end %>
<SIZE><%= self['SIZE'] %></SIZE>
<% if self['FSTYPE'] != nil %>
<% if self['FSTYPE'] != nil and !self['FSTYPE'].empty? %>
<FSTYPE><%= self['FSTYPE'] %></FSTYPE>
<% end %>
<PUBLIC><%= self['PUBLIC'] == "0" ? "NO" : "YES"%></PUBLIC>

View File

@ -40,6 +40,9 @@ require 'pp'
COLLECTIONS = ["compute", "instance_type", "network", "storage"]
# FLAG that will filter the elements retrieved from the Pools
POOL_FILTER = Pool::INFO_GROUP
class OCCIServer < CloudServer
# Server initializer
# config_file:: _String_ path of the config file
@ -109,21 +112,14 @@ class OCCIServer < CloudServer
# [return] _String_,_Integer_ Pool Representation or error, status code
def get_computes(request)
# --- Get User's VMs ---
user_flag = -1
vmpool = VirtualMachinePoolOCCI.new(
@client,
user_flag)
POOL_FILTER)
# --- Prepare XML Response ---
rc = vmpool.info
if OpenNebula.is_error?(rc)
if rc.message.match("Error getting")
return rc, 404
else
return rc, 500
end
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
return to_occi_xml(vmpool, 200)
@ -136,21 +132,14 @@ class OCCIServer < CloudServer
# => status code
def get_networks(request)
# --- Get User's VNETs ---
user_flag = -1
network_pool = VirtualNetworkPoolOCCI.new(
@client,
user_flag)
POOL_FILTER)
# --- Prepare XML Response ---
rc = network_pool.info
if OpenNebula.is_error?(rc)
if rc.message.match("Error getting")
return rc, 404
else
return rc, 500
end
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
return to_occi_xml(network_pool, 200)
@ -162,21 +151,14 @@ class OCCIServer < CloudServer
# status code
def get_storages(request)
# --- Get User's Images ---
user_flag = -1
image_pool = ImagePoolOCCI.new(
@client,
user_flag)
POOL_FILTER)
# --- Prepare XML Response ---
rc = image_pool.info
if OpenNebula.is_error?(rc)
if rc.message.match("Error getting")
return rc, 404
else
return rc, 500
end
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
return to_occi_xml(image_pool, 200)
@ -192,7 +174,6 @@ class OCCIServer < CloudServer
# --- Prepare XML Response ---
rc = user_pool.info
if OpenNebula.is_error?(rc)
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
@ -227,7 +208,9 @@ class OCCIServer < CloudServer
return template, 500 if OpenNebula.is_error?(template)
rc = vm.allocate(template)
return rc, 500 if OpenNebula.is_error?(rc)
if OpenNebula.is_error?(rc)
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
# --- Prepare XML Response ---
vm.info
@ -246,13 +229,8 @@ class OCCIServer < CloudServer
# --- Prepare XML Response ---
rc = vm.info
if OpenNebula.is_error?(rc)
if rc.message.match("Error getting")
return rc, 404
else
return rc, 500
end
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
return to_occi_xml(vm, 200)
@ -269,12 +247,11 @@ class OCCIServer < CloudServer
VirtualMachine.build_xml(params[:id]),
@client)
rc = vm.info
return rc, 404 if OpenNebula::is_error?(rc)
# --- Finalize the VM ---
result = vm.finalize
return result, 500 if OpenNebula::is_error?(result)
if OpenNebula.is_error?(result)
return result, CloudServer::HTTP_ERROR_CODE[result.errno]
end
return "", 204
end
@ -317,14 +294,16 @@ class OCCIServer < CloudServer
VirtualNetwork.build_xml,
@client,
request.body,
@config[:bridge])
@config[:template_location])
# --- Generate the template and Allocate the new Instance ---
template = network.to_one_template
return template, 500 if OpenNebula.is_error?(template)
rc = network.allocate(template)
return rc, 500 if OpenNebula.is_error?(rc)
if OpenNebula.is_error?(rc)
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
# --- Prepare XML Response ---
network.info
@ -342,13 +321,8 @@ class OCCIServer < CloudServer
# --- Prepare XML Response ---
rc = network.info
if OpenNebula.is_error?(rc)
if rc.message.match("Error getting")
return rc, 404
else
return rc, 500
end
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
return to_occi_xml(network, 200)
@ -363,12 +337,11 @@ class OCCIServer < CloudServer
VirtualNetwork.build_xml(params[:id]),
@client)
rc = network.info
return rc, 404 if OpenNebula::is_error?(rc)
# --- Delete the VNET ---
rc = network.delete
return rc, 500 if OpenNebula::is_error?(rc)
if OpenNebula.is_error?(rc)
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
return "", 204
end
@ -385,15 +358,15 @@ class OCCIServer < CloudServer
VirtualNetwork.build_xml(params[:id]),
@client)
rc = vnet.info
return rc, 400 if OpenNebula.is_error?(rc)
rc = nil
if vnet_info['PUBLIC'] == 'YES'
rc = vnet.publish
return rc, 400 if OpenNebula.is_error?(rc)
elsif vnet_info['PUBLIC'] == 'NO'
rc = vnet.unpublish
return rc, 400 if OpenNebula.is_error?(rc)
end
if OpenNebula.is_error?(rc)
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
# --- Prepare XML Response ---
@ -432,7 +405,9 @@ class OCCIServer < CloudServer
return template, 500 if OpenNebula.is_error?(template)
rc = image.allocate(template)
return rc, 500 if OpenNebula.is_error?(rc)
if OpenNebula.is_error?(rc)
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
# --- Prepare XML Response ---
image.info
@ -450,13 +425,8 @@ class OCCIServer < CloudServer
@client)
rc = image.info
if OpenNebula.is_error?(rc)
if rc.message.match("Error getting")
return rc, 404
else
return rc, 500
end
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
# --- Prepare XML Response ---
@ -473,12 +443,11 @@ class OCCIServer < CloudServer
Image.build_xml(params[:id]),
@client)
rc = image.info
return rc, 404 if OpenNebula::is_error?(rc)
# --- Delete the Image ---
rc = image.delete
return rc, 500 if OpenNebula::is_error?(rc)
if OpenNebula.is_error?(rc)
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
return "", 204
end
@ -495,24 +464,22 @@ class OCCIServer < CloudServer
Image.build_xml(params[:id]),
@client)
rc = image.info
return rc, 400 if OpenNebula.is_error?(rc)
rc = nil
if image_info['PERSISTENT'] && image_info['PUBLIC']
error_msg = "It is not allowed more than one change per request"
return OpenNebula::Error.new(error_msg), 400
elsif image_info['PERSISTENT'] == 'YES'
rc = image.persistent
return rc, 400 if OpenNebula.is_error?(rc)
elsif image_info['PERSISTENT'] == 'NO'
rc = image.nonpersistent
return rc, 400 if OpenNebula.is_error?(rc)
elsif image_info['PUBLIC'] == 'YES'
rc = image.publish
return rc, 400 if OpenNebula.is_error?(rc)
elsif image_info['PUBLIC'] == 'NO'
rc = image.unpublish
return rc, 400 if OpenNebula.is_error?(rc)
end
if OpenNebula.is_error?(rc)
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
# --- Prepare XML Response ---
@ -532,7 +499,6 @@ class OCCIServer < CloudServer
# --- Prepare XML Response ---
rc = user.info
if OpenNebula.is_error?(rc)
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end

View File

@ -100,11 +100,11 @@ class VirtualMachineOCCI < VirtualMachine
def to_one_template()
if @vm_info == nil
error_msg = "Missing COMPUTE section in the XML body"
return OpenNebula::Error.new(error_msg), 400
return OpenNebula::Error.new(error_msg)
end
if @template == nil
return OpenNebula::Error.new("Bad instance type"), 500
return OpenNebula::Error.new("Bad instance type")
end
begin

View File

@ -15,6 +15,7 @@
#--------------------------------------------------------------------------- #
require 'OpenNebula'
require 'ipaddr'
include OpenNebula
@ -26,35 +27,23 @@ class VirtualNetworkOCCI < VirtualNetwork
<% if self['TEMPLATE/DESCRIPTION'] != nil %>
<DESCRIPTION><%= self['TEMPLATE/DESCRIPTION'] %></DESCRIPTION>
<% end %>
<ADDRESS><%= self['TEMPLATE/NETWORK_ADDRESS'] %></ADDRESS>
<% if self['TEMPLATE/NETWORK_SIZE'] %>
<SIZE><%= self['TEMPLATE/NETWORK_SIZE'] %></SIZE>
<% if network_address != nil %>
<ADDRESS><%= network_address %></ADDRESS>
<% end %>
<% if network_size != nil %>
<SIZE><%= network_size %></SIZE>
<% end %>
<USED_LEASES><%= self['TOTAL_LEASES'] %></USED_LEASES>
<PUBLIC><%= self['PUBLIC'] == "0" ? "NO" : "YES"%></PUBLIC>
</NETWORK>
}
ONE_NETWORK = %q{
NAME = "<%= @vnet_info['NAME'] %>"
TYPE = RANGED
<% if @vnet_info['DESCRIPTION'] != nil %>
DESCRIPTION = "<%= @vnet_info['DESCRIPTION'] %>"
<% end %>
<% if @vnet_info['PUBLIC'] != nil %>
PUBLIC = "<%= @vnet_info['PUBLIC'] %>"
<% end %>
<% if @bridge %>
BRIDGE = <%= @bridge %>
<% end %>
NETWORK_ADDRESS = <%= @vnet_info['ADDRESS'] %>
NETWORK_SIZE = <%= @vnet_info['SIZE']%>
}.gsub(/^ /, '')
# Class constructor
def initialize(xml, client, xml_info=nil, bridge=nil)
#
def initialize(xml, client, xml_info=nil, base=nil)
super(xml, client)
@bridge = bridge
@vnet_info = nil
@common_template = base + '/network.erb' if base
if xml_info != nil
xmldoc = XMLElement.build_xml(xml_info, 'NETWORK')
@ -64,6 +53,18 @@ class VirtualNetworkOCCI < VirtualNetwork
# Creates the OCCI representation of a Virtual Network
def to_occi(base_url)
network_address = nil
network_size = nil
if self['RANGE/IP_START']
network_address = self['RANGE/IP_START']
ip_start = IPAddr.new(network_address, Socket::AF_INET)
ip_end = IPAddr.new(self['RANGE/IP_END'], Socket::AF_INET)
network_size = ip_end.to_i - ip_start.to_i
end
begin
occi = ERB.new(OCCI_NETWORK)
occi_text = occi.result(binding)
@ -78,11 +79,16 @@ class VirtualNetworkOCCI < VirtualNetwork
def to_one_template()
if @vnet_info == nil
error_msg = "Missing NETWORK section in the XML body"
error = OpenNebula::Error.new(error_msg)
return OpenNebula::Error.new(error_msg), 400
end
begin
template = ERB.new(File.read(@common_template)).result(binding)
rescue Exception => e
error = OpenNebula::Error.new(e.message)
return error
end
one = ERB.new(ONE_NETWORK)
return one.result(binding)
return template
end
end

View File

@ -0,0 +1,215 @@
# -------------------------------------------------------------------------- *
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
# Licensed 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 'digest/sha1'
require "rexml/document"
include REXML
require 'ipaddr'
module Migrator
def db_version
"3.1.80"
end
def one_version
"OpenNebula 3.1.80"
end
def up
puts " > Networking isolation hooks have been moved to Host drivers.\n"<<
" If you were using a networking hook, enter its name, or press enter\n"<<
" to use the default dummy vn_mad driver.\n\n"
vn_mad = ""
while !( ["802.1Q", "dummy", "ebtables", "ovswitch"].include?(vn_mad) ) do
print " Driver name (802.1Q, dummy, ebtables, ovswitch): "
vn_mad = gets.chomp
vn_mad = "dummy" if vn_mad.empty?
end
# 0 = all, 1 = none, 2 = interactive
vlan_option = 1
if ( vn_mad == "ebtables" || vn_mad == "ovswitch" )
puts
puts " > A new attribute, VLAN = YES/NO will be added to each VNET.\n"<<
" For driver '#{vn_mad}', please choose if you want to isolate all networks (all),\n"<<
" none (none), or be asked individually for each VNET (interactive)\n"
vlan = ""
while !( ["all", "none", "interactive"].include?(vlan) ) do
print " Isolate VNETs (all, none, interactive): "
vlan = gets.chomp
end
case vlan
when "all"
vlan_option = 0
when "none"
vlan_option = 1
when "interactive"
vlan_option = 2
end
end
# New VN_MAD element for hosts
@db.run "ALTER TABLE host_pool RENAME TO old_host_pool;"
@db.run "CREATE TABLE host_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, state INTEGER, last_mon_time INTEGER, UNIQUE(name));"
@db.fetch("SELECT * FROM old_host_pool") do |row|
doc = Document.new(row[:body])
vn_mad_elem = doc.root.add_element("VN_MAD")
vn_mad_elem.text = vn_mad
@db[:host_pool].insert(
:oid => row[:oid],
:name => row[:name],
:body => doc.root.to_s,
:state => row[:state],
:last_mon_time => row[:last_mon_time])
end
@db.run "DROP TABLE old_host_pool;"
# New VLAN and RANGE for vnets
@db.run "ALTER TABLE network_pool RENAME TO old_network_pool;"
@db.run "CREATE TABLE network_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, public INTEGER, UNIQUE(name,uid));"
@db.fetch("SELECT * FROM old_network_pool") do |row|
doc = Document.new(row[:body])
type = ""
doc.root.each_element("TYPE") { |e|
type = e.text
}
if type == "0" # RANGED
range_elem = doc.root.add_element("RANGE")
ip_start_elem = range_elem.add_element("IP_START")
ip_end_elem = range_elem.add_element("IP_END")
net_address = ""
doc.root.each_element("TEMPLATE/NETWORK_ADDRESS") { |e|
net_address = e.text
}
net_valid = false
while !net_valid do
begin
net_address = IPAddr.new(net_address, Socket::AF_INET)
net_valid = true
rescue ArgumentError
puts
puts " > Error processing VNET ##{row[:oid]} '#{row[:name]}'\n"<<
" This network address is invalid: '#{net_address}'\n"
print " Please enter a valid network address: "
net_address = gets.chomp
end
end
st_size = ""
doc.root.each_element("TEMPLATE/NETWORK_SIZE") { |e|
st_size = e.text
}
if ( st_size == "C" || st_size == "c" )
host_bits = 8
elsif ( st_size == "B" || st_size == "b" )
host_bits = 16
elsif ( st_size == "A" || st_size == "a" )
host_bits = 24
else
size = st_size.to_i
host_bits = (Math.log(size+2)/Math.log(2)).ceil
end
net_mask = 0xFFFFFFFF << host_bits
net_address = net_address.to_i & net_mask
ip_start_elem.text = IPAddr.new((net_address + 1), Socket::AF_INET).to_s
ip_end_elem.text = IPAddr.new((net_address + (1 << host_bits) - 2), Socket::AF_INET).to_s
end
phydev_present = false
doc.root.each_element("PHYDEV") { |e|
phydev_present = true
}
vlan_elem = doc.root.add_element("VLAN")
if phydev_present
vlan_elem.text = "1"
else
case vlan_option
when 0
vlan_elem.text = "1"
when 1
vlan_elem.text = "0"
when 2
vlan = ""
while !( ["y", "n"].include?(vlan) ) do
print " > Isolate VNET ##{row[:oid]} '#{row[:name]}'? (y/n) : "
vlan = gets.chomp
end
if ( vlan == "y" )
vlan_elem.text = "1"
else
vlan_elem.text = "0"
end
end
end
@db[:network_pool].insert(
:oid => row[:oid],
:name => row[:name],
:body => doc.root.to_s,
:uid => row[:uid],
:gid => row[:gid],
:public => row[:public])
end
@db.run "DROP TABLE old_network_pool;"
# Add empty HISTORY_RECORDS element to VMs without any records
@db.run "ALTER TABLE vm_pool RENAME TO old_vm_pool;"
@db.run "CREATE TABLE vm_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, last_poll INTEGER, state INTEGER, lcm_state INTEGER);"
@db.run "INSERT INTO vm_pool SELECT * FROM old_vm_pool;"
@db.fetch("SELECT * FROM old_vm_pool") do |row|
doc = Document.new(row[:body])
found = false
doc.root.each_element("HISTORY_RECORDS") { |e|
found = true
}
if !found
doc.root.add_element("HISTORY_RECORDS")
end
end
@db.run "DROP TABLE old_vm_pool;"
return true
end
end

View File

@ -59,7 +59,7 @@
</div>
</div>
<div id="footer" class="ui-layout-south">
Copyright 2002-2011 &copy; OpenNebula Project Leads (<a href="http://opennebula.org" target="_blank">OpenNebula.org</a>). All Rights Reserved. OpenNebula 3.1.0
Copyright 2002-2011 &copy; OpenNebula Project Leads (<a href="http://opennebula.org" target="_blank">OpenNebula.org</a>). All Rights Reserved. OpenNebula 3.1.80
</div>

View File

@ -67,7 +67,7 @@
</div>
</div>
<div id="footer" class="ui-layout-south">
Copyright 2002-2011 &copy; OpenNebula Project Leads (<a href="http://opennebula.org" target="_blank">OpenNebula.org</a>). All Rights Reserved. OpenNebula 3.1.0
Copyright 2002-2011 &copy; OpenNebula Project Leads (<a href="http://opennebula.org" target="_blank">OpenNebula.org</a>). All Rights Reserved. OpenNebula 3.1.80
</div>

View File

@ -301,7 +301,7 @@ int History::rebuild_attributes()
rc += xpath(stime , "/HISTORY/STIME", 0);
rc += xpath(etime , "/HISTORY/ETIME", 0);
rc += xpath(vmm_mad_name , "/HISTORY/VMMMAD", "not_found");
rc += xpath(vnm_mad_name , "/HISTORY/VNMMAD", "not_found");
xpath(vnm_mad_name , "/HISTORY/VNMMAD", "dummy");
rc += xpath(tm_mad_name , "/HISTORY/TMMAD", "not_found");
rc += xpath(prolog_stime , "/HISTORY/PSTIME", 0);
rc += xpath(prolog_etime , "/HISTORY/PETIME", 0);

View File

@ -146,7 +146,6 @@ void get_image_attribute(VirtualMachine * vm,
ImagePool * ipool = nd.get_ipool();
Image * img;
int iid = -1;
string iid_str;
int num;
vector<const Attribute *> attrs;
@ -154,7 +153,7 @@ void get_image_attribute(VirtualMachine * vm,
attr_value.clear();
if (img_name.empty() || img_name != "IMAGE_ID")
if ( img_name.empty() || (img_name!="IMAGE" && img_name!="IMAGE_ID") )
{
return;
}
@ -174,11 +173,10 @@ void get_image_attribute(VirtualMachine * vm,
continue;
}
iid_str = disk->vector_value("IMAGE_ID");
if ( iid_str == img_value )
if ( disk->vector_value(img_name.c_str()) == img_value )
{
istringstream iss(img_value);
string iid_str = disk->vector_value("IMAGE_ID");
istringstream iss(iid_str);
iss >> iid;
@ -232,7 +230,6 @@ void get_network_attribute(VirtualMachine * vm,
VirtualNetworkPool * vnpool = nd.get_vnpool();
VirtualNetwork * vn;
int vnet_id = -1;
string vnet_id_str;
int num;
vector<const Attribute *> attrs;
@ -240,7 +237,7 @@ void get_network_attribute(VirtualMachine * vm,
attr_value.clear();
if (net_name.empty() || net_name != "NETWORK_ID")
if ( net_name.empty() || (net_name!="NETWORK" && net_name!="NETWORK_ID") )
{
return;
}
@ -260,11 +257,10 @@ void get_network_attribute(VirtualMachine * vm,
continue;
}
vnet_id_str = net->vector_value("NETWORK_ID");
if ( vnet_id_str == net_value )
if ( net->vector_value(net_name.c_str()) == net_value )
{
istringstream iss(net_value);
string vnet_id_str = net->vector_value("NETWORK_ID");
istringstream iss(vnet_id_str);
iss >> vnet_id;
@ -460,7 +456,7 @@ void insert_vector(VirtualMachine * vm,
/* Line 268 of yacc.c */
#line 464 "vm_var_syntax.cc"
#line 460 "vm_var_syntax.cc"
/* Enabling traces. */
#ifndef YYDEBUG
@ -506,7 +502,7 @@ typedef union YYSTYPE
{
/* Line 293 of yacc.c */
#line 408 "vm_var_syntax.y"
#line 404 "vm_var_syntax.y"
char * val_str;
int val_int;
@ -515,7 +511,7 @@ typedef union YYSTYPE
/* Line 293 of yacc.c */
#line 519 "vm_var_syntax.cc"
#line 515 "vm_var_syntax.cc"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
@ -540,7 +536,7 @@ typedef struct YYLTYPE
/* Line 343 of yacc.c */
#line 544 "vm_var_syntax.cc"
#line 540 "vm_var_syntax.cc"
#ifdef short
# undef short
@ -830,7 +826,7 @@ static const yytype_int8 yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
0, 432, 432, 433, 436, 440, 453, 468
0, 428, 428, 429, 432, 436, 449, 464
};
#endif
@ -1831,7 +1827,7 @@ yyreduce:
case 4:
/* Line 1806 of yacc.c */
#line 437 "vm_var_syntax.y"
#line 433 "vm_var_syntax.y"
{
(*parsed) << (yyvsp[(1) - (1)].val_str);
}
@ -1840,7 +1836,7 @@ yyreduce:
case 5:
/* Line 1806 of yacc.c */
#line 441 "vm_var_syntax.y"
#line 437 "vm_var_syntax.y"
{
string name((yyvsp[(1) - (2)].val_str));
@ -1858,7 +1854,7 @@ yyreduce:
case 6:
/* Line 1806 of yacc.c */
#line 454 "vm_var_syntax.y"
#line 450 "vm_var_syntax.y"
{
string name((yyvsp[(1) - (5)].val_str));
string vname((yyvsp[(3) - (5)].val_str));
@ -1878,7 +1874,7 @@ yyreduce:
case 7:
/* Line 1806 of yacc.c */
#line 469 "vm_var_syntax.y"
#line 465 "vm_var_syntax.y"
{
string name((yyvsp[(1) - (9)].val_str));
string vname((yyvsp[(3) - (9)].val_str));
@ -1901,7 +1897,7 @@ yyreduce:
/* Line 1806 of yacc.c */
#line 1905 "vm_var_syntax.cc"
#line 1901 "vm_var_syntax.cc"
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
@ -2139,7 +2135,7 @@ yyreturn:
/* Line 2067 of yacc.c */
#line 487 "vm_var_syntax.y"
#line 483 "vm_var_syntax.y"
extern "C" void vm_var__error(

View File

@ -56,7 +56,7 @@ typedef union YYSTYPE
{
/* Line 2068 of yacc.c */
#line 408 "vm_var_syntax.y"
#line 404 "vm_var_syntax.y"
char * val_str;
int val_int;

View File

@ -85,7 +85,6 @@ void get_image_attribute(VirtualMachine * vm,
ImagePool * ipool = nd.get_ipool();
Image * img;
int iid = -1;
string iid_str;
int num;
vector<const Attribute *> attrs;
@ -93,7 +92,7 @@ void get_image_attribute(VirtualMachine * vm,
attr_value.clear();
if (img_name.empty() || img_name != "IMAGE_ID")
if ( img_name.empty() || (img_name!="IMAGE" && img_name!="IMAGE_ID") )
{
return;
}
@ -113,11 +112,10 @@ void get_image_attribute(VirtualMachine * vm,
continue;
}
iid_str = disk->vector_value("IMAGE_ID");
if ( iid_str == img_value )
if ( disk->vector_value(img_name.c_str()) == img_value )
{
istringstream iss(img_value);
string iid_str = disk->vector_value("IMAGE_ID");
istringstream iss(iid_str);
iss >> iid;
@ -171,7 +169,6 @@ void get_network_attribute(VirtualMachine * vm,
VirtualNetworkPool * vnpool = nd.get_vnpool();
VirtualNetwork * vn;
int vnet_id = -1;
string vnet_id_str;
int num;
vector<const Attribute *> attrs;
@ -179,7 +176,7 @@ void get_network_attribute(VirtualMachine * vm,
attr_value.clear();
if (net_name.empty() || net_name != "NETWORK_ID")
if ( net_name.empty() || (net_name!="NETWORK" && net_name!="NETWORK_ID") )
{
return;
}
@ -199,11 +196,10 @@ void get_network_attribute(VirtualMachine * vm,
continue;
}
vnet_id_str = net->vector_value("NETWORK_ID");
if ( vnet_id_str == net_value )
if ( net->vector_value(net_name.c_str()) == net_value )
{
istringstream iss(net_value);
string vnet_id_str = net->vector_value("NETWORK_ID");
istringstream iss(vnet_id_str);
iss >> vnet_id;

View File

@ -115,7 +115,7 @@ class VmmAction
# Executes a set of steps. If one step fails any recover action is performed
# and the step execution breaks.
# @param [Array] array of steps to be executed
# @return [String, Hash] "SUCCESS/FAILURE" for the step set, and
# @return [String, Hash] "SUCCESS/FAILURE" for the step set, and
# information associated to each step (by :<action>_info). In case of
# failure information is also in [:failed_info]
def execute_steps(steps)
@ -124,7 +124,7 @@ class VmmAction
steps.each do |step|
# Execute Step
case step[:driver]
when :vmm
when :vmm
if step[:destination]
host = @data[:dest_host]
ssh = @ssh_dst
@ -134,7 +134,7 @@ class VmmAction
end
result, info = @vmm.do_action(get_parameters(step[:parameters]),
@id,
@id,
host,
step[:action],
:ssh_stream => ssh,
@ -147,26 +147,27 @@ class VmmAction
vnm = @vnm_src
end
result, info = vnm.do_action(@id, step[:action])
result, info = vnm.do_action(@id, step[:action],
:parameters => get_parameters(step[:parameters]))
else
result = DriverExecHelper.const_get(:RESULT)[:failure]
info = "No driver in #{step[:action]}"
end
# Save the step info
# Save the step info
@data["#{step[:action]}_info".to_sym] = info
# Roll back steps, store failed info and break steps
if DriverExecHelper.failed?(result)
if DriverExecHelper.failed?(result)
execute_steps(@data[:fail_actions]) if @data[:fail_actions]
@data[:failed_info] = info
@vmm.log(@id,
@vmm.log(@id,
"Failed to execute #{DRIVER_NAMES[step[:driver]]} " \
"operation: #{step[:action]}.")
break
else
@vmm.log(@id,
@vmm.log(@id,
"Sussecfully execute #{DRIVER_NAMES[step[:driver]]} " \
"operation: #{step[:action]}.")
end
@ -217,7 +218,7 @@ class ExecDriver < VirtualMachineDriver
@options={
:threaded => true
}.merge!(options)
super("vmm/#{hypervisor}", @options)
@hypervisor = hypervisor
@ -273,15 +274,16 @@ class ExecDriver < VirtualMachineDriver
},
# Boot the Virtual Machine
{
:driver => :vmm,
:action => :deploy,
:parameters => [dfile, :host],
:stdin => domain
},
:driver => :vmm,
:action => :deploy,
:parameters => [dfile, :host],
:stdin => domain,
},
# Execute post-boot networking setup
{
:driver => :vnm,
:action => :post,
:parameters => [:deploy_info],
:fail_actions => [
{
:driver => :vmm,
@ -492,5 +494,3 @@ exec_driver = ExecDriver.new(hypervisor,
:local_actions => local_actions)
exec_driver.start_driver

View File

@ -44,12 +44,17 @@ class VirtualNetworkDriver
# @param [String, Symbol] aname name of the action
# @param [Hash] ops extra options for the command
# @option ops [String] :stdin text to be writen to stdin
# @option ops [String] :parameters additional parameters for vnm action
def do_action(id, aname, ops = {})
options={
:stdin => nil,
:stdin => nil,
:parameters => nil
}.merge(ops)
cmd = action_command_line(aname, @vm_encoded)
cmd_params = "#{@vm_encoded}"
cmd_params << " #{options[:parameters]}" if options[:parameters]
cmd = action_command_line(aname, cmd_params)
if action_is_local?(aname)
execution = LocalCommand.run(cmd, log_method(id))
@ -67,4 +72,4 @@ class VirtualNetworkDriver
result, info = get_info_from_execution(execution)
end
end
end

View File

@ -17,8 +17,10 @@
require 'OpenNebulaNetwork'
class OpenNebulaHM < OpenNebulaNetwork
def initialize(vm, hypervisor = nil)
super(vm,hypervisor)
XPATH_FILTER = "TEMPLATE/NIC[VLAN='YES']"
def initialize(vm, deploy_id = nil, hypervisor = nil)
super(vm,XPATH_FILTER,deploy_id,hypervisor)
@bridges = get_interfaces
end
@ -64,7 +66,8 @@ class OpenNebulaHM < OpenNebulaNetwork
def device_exists?(dev, vlan=nil)
dev = "#{dev}.#{vlan}" if vlan
OpenNebula.exec_and_log("#{COMMANDS[:ip]} link show #{dev}")
`#{COMMANDS[:ip]} link show #{dev}`
$?.exitstatus == 0
end
def create_dev_vlan(dev, vlan)

View File

@ -22,6 +22,9 @@ $: << File.join(File.dirname(__FILE__), "..")
require 'OpenNebulaNetwork'
require 'Firewall'
fw = OpenNebulaFirewall.from_base64(ARGV[0])
template64 = ARGV[0]
deploy_id = ARGV[1]
fw = OpenNebulaFirewall.from_base64(template64, deploy_id)
fw.activate

View File

@ -15,9 +15,13 @@
#--------------------------------------------------------------------------- #
class OpenNebulaFirewall < OpenNebulaNetwork
def initialize(vm, hypervisor = nil)
super(vm,hypervisor)
XPATH_FILTER = "TEMPLATE/NIC[ICMP|WHITE_PORTS_TCP|WHITE_PORTS_UDP|" <<
"BLACK_PORTS_TCP|BLACK_PORTS_UDP]"
def initialize(vm, deploy_id = nil, hypervisor = nil)
super(vm,XPATH_FILTER,deploy_id,hypervisor)
end
def activate
vm_id = @vm['ID']
process do |nic|

View File

@ -43,16 +43,20 @@ COMMANDS = {
}
class VM
attr_accessor :nics, :vm_info
attr_accessor :nics, :vm_info, :deploy_id
def initialize(vm_root, hypervisor)
@vm_root = vm_root
@hypervisor = hypervisor
@vm_info = Hash.new
def initialize(vm_root, xpath_filter, deploy_id, hypervisor)
@vm_root = vm_root
@xpath_filter = xpath_filter
@deploy_id = deploy_id
@hypervisor = hypervisor
@vm_info = Hash.new
@deploy_id = nil if deploy_id == "-"
nics = Nics.new(@hypervisor)
@vm_root.elements.each("TEMPLATE/NIC[VLAN='YES']") do |nic_element|
@vm_root.elements.each(@xpath_filter) do |nic_element|
nic = nics.new_nic
nic_element.elements.each('*') do |nic_attribute|
@ -91,19 +95,19 @@ end
class OpenNebulaNetwork
attr_reader :hypervisor, :vm
def self.from_base64(vm_64, hypervisor=nil)
def self.from_base64(vm_64, deploy_id = nil, hypervisor = nil)
vm_xml = Base64::decode64(vm_64)
self.new(vm_xml, hypervisor)
self.new(vm_xml, deploy_id, hypervisor)
end
def initialize(vm_tpl, hypervisor=nil)
def initialize(vm_tpl, xpath_filter, deploy_id = nil, hypervisor = nil)
if !hypervisor
@hypervisor = detect_hypervisor
else
@hypervisor = hypervisor
end
@vm = VM.new(REXML::Document.new(vm_tpl).root, @hypervisor)
@vm = VM.new(REXML::Document.new(vm_tpl).root, xpath_filter, deploy_id, @hypervisor)
end
def process(&block)

View File

@ -39,7 +39,11 @@ class NicKVM < Hash
end
def get_info(vm)
deploy_id = vm['DEPLOY_ID']
if vm.deploy_id
deploy_id = vm.deploy_id
else
deploy_id = vm['DEPLOY_ID']
end
if deploy_id and vm.vm_info[:dumpxml].nil?
vm.vm_info[:dumpxml] = `#{COMMANDS[:virsh]} dumpxml #{deploy_id} \

View File

@ -17,8 +17,10 @@
require 'OpenNebulaNetwork'
class EbtablesVLAN < OpenNebulaNetwork
def initialize(vm, hypervisor = nil)
super(vm,hypervisor)
XPATH_FILTER = "TEMPLATE/NIC[VLAN='YES']"
def initialize(vm, deploy_id = nil, hypervisor = nil)
super(vm,XPATH_FILTER,deploy_id,hypervisor)
end
def ebtables(rule)

View File

@ -22,10 +22,13 @@ $: << File.join(File.dirname(__FILE__), "..")
require 'Ebtables'
require 'Firewall'
onevlan = EbtablesVLAN.from_base64(ARGV[0])
template64 = ARGV[0]
deploy_id = ARGV[1]
onevlan = EbtablesVLAN.from_base64(template64, deploy_id)
onevlan.activate
fw = OpenNebulaFirewall.from_base64(ARGV[0])
fw = OpenNebulaFirewall.from_base64(template64, deploy_id)
fw.activate

View File

@ -22,6 +22,9 @@ $: << File.join(File.dirname(__FILE__), "..")
require 'OpenNebulaNetwork'
require 'Firewall'
fw = OpenNebulaFirewall.from_base64(ARGV[0])
template64 = ARGV[0]
deploy_id = ARGV[1]
fw = OpenNebulaFirewall.from_base64(template64, deploy_id)
fw.activate

View File

@ -17,8 +17,10 @@
require 'OpenNebulaNetwork'
class OpenvSwitchVLAN < OpenNebulaNetwork
def initialize(vm, hypervisor = nil)
super(vm,hypervisor)
XPATH_FILTER = "TEMPLATE/NIC[VLAN='YES']"
def initialize(vm, deploy_id = nil, hypervisor = nil)
super(vm,XPATH_FILTER,deploy_id,hypervisor)
end
def activate

View File

@ -22,11 +22,13 @@ $: << File.join(File.dirname(__FILE__), "..")
require 'OpenvSwitch'
require 'Firewall'
template64 = ARGV[0]
deploy_id = ARGV[1]
onevlan = OpenvSwitchVLAN.from_base64(ARGV[0])
onevlan = OpenvSwitchVLAN.from_base64(template64, deploy_id)
onevlan.activate
fw = OpenNebulaFirewall.from_base64(ARGV[0])
fw = OpenNebulaFirewall.from_base64(template64, deploy_id)
fw.activate

View File

@ -1,10 +1,10 @@
#!/usr/bin/env ruby
$: << File.dirname(__FILE__) + '/..'
$: << File.dirname(__FILE__) + '/../ebtables'
$: << File.dirname(__FILE__) + '/../802.1Q'
$: << File.dirname(__FILE__) + '/../ovswitch'
$: << File.dirname(__FILE__) + '/../../../mad/ruby'
$: << File.dirname(__FILE__) + '/..'
$: << File.dirname(__FILE__) + '/../ebtables'
$: << File.dirname(__FILE__) + '/../802.1Q'
$: << File.dirname(__FILE__) + '/../ovswitch'
$: << File.dirname(__FILE__) + '/../../../mad/ruby'
$: << './'
$: << File.dirname(__FILE__)
$: << File.join(File.dirname(__FILE__), '..')
@ -43,7 +43,7 @@ describe 'networking' do
$capture_commands = {
/virsh.*dumpxml/ => OUTPUT[:virsh_dumpxml]
}
onevlan = OpenNebulaNetwork.new(OUTPUT[:onevm_show],"kvm")
onevlan = OpenNebulaNetwork.new(OUTPUT[:onevm_show],"TEMPLATE/NIC",nil,"kvm")
nics_expected = [{:bridge=>"br0",
:ip=>"172.16.0.100",
:mac=>"02:00:ac:10:00:64",
@ -76,7 +76,7 @@ describe 'ebtables' do
/virsh.*dumpxml/ => OUTPUT[:virsh_dumpxml],
/ebtables/ => nil
}
onevlan = EbtablesVLAN.new(OUTPUT[:onevm_show],"kvm")
onevlan = EbtablesVLAN.new(OUTPUT[:onevm_show],nil,"kvm")
onevlan.activate
ebtables_cmds = [
"sudo /sbin/ebtables -A FORWARD -s ! 02:00:ac:10:00:00/ff:ff:ff:ff:ff:00 -o vnet0 -j DROP",
@ -98,7 +98,7 @@ describe 'openvswitch' do
/virsh.*dumpxml/ => OUTPUT[:virsh_dumpxml],
/ovs-vsctl/ => nil
}
onevlan = OpenvSwitchVLAN.new(OUTPUT[:onevm_show],"kvm")
onevlan = OpenvSwitchVLAN.new(OUTPUT[:onevm_show],nil,"kvm")
onevlan.activate
openvswitch_tags = [
"sudo /usr/local/bin/ovs-vsctl set Port vnet0 tag=2",
@ -117,7 +117,7 @@ describe 'openvswitch' do
/brctl show/ => OUTPUT[:brctl_show],
/ovs-vsctl/ => nil
}
onevlan = OpenvSwitchVLAN.new(OUTPUT[:onevm_show_vlan_id_kvm],"kvm")
onevlan = OpenvSwitchVLAN.new(OUTPUT[:onevm_show_vlan_id_kvm],nil,"kvm")
onevlan.activate
onevlan_rules = ["sudo /usr/local/bin/ovs-vsctl set Port vnet0 tag=6",
@ -159,36 +159,37 @@ end
describe 'host-managed' do
it "tag tun/tap devices with vlans in kvm" do
$capture_commands = {
/virsh.*dumpxml/ => OUTPUT[:virsh_dumpxml_phydev],
/virsh.*dumpxml/ => nil,
/brctl show/ => OUTPUT[:brctl_show],
/brctl add/ => nil,
/brctl add/ => nil,
/vconfig/ => nil,
/ip link/ => nil
/ip link set/ => nil,
/ip link show/ => [nil,255]
}
hm = OpenNebulaHM.new(OUTPUT[:onevm_show_phydev_kvm],"kvm")
hm = OpenNebulaHM.new(OUTPUT[:onevm_show_phydev_kvm],nil,"kvm")
hm.activate
hm_activate_rules = ["sudo /sbin/brctl addbr onebr6",
"sudo /sbin/ip link set onebr6 up",
"sudo /sbin/ip link show eth0.8",
"sudo /sbin/vconfig add eth0 8",
"sudo /sbin/ip link set eth0.8 up",
"sudo /sbin/brctl addif onebr6 eth0.8"]
hm_activate_rules.map{|c| c + " 2>&1 1>/dev/null"}.each do |cmd|
$collector[:backtick].include?(cmd).should == true
hm_activate_rules.each do |cmd|
$collector[:backtick].grep(Regexp.new("^"+cmd)).length.should >= 1
end
end
it "force VLAN_ID for vlans in kvm" do
$capture_commands = {
/virsh.*dumpxml/ => OUTPUT[:virsh_dumpxml_vlan_id],
/virsh.*dumpxml/ => nil,
/brctl show/ => OUTPUT[:brctl_show],
/brctl add/ => nil,
/vconfig/ => nil,
/ip link/ => nil
/ip link set/ => nil,
/ip link show/ => [nil,255]
}
hm = OpenNebulaHM.new(OUTPUT[:onevm_show_vlan_id_kvm],"kvm")
hm = OpenNebulaHM.new(OUTPUT[:onevm_show_vlan_id_kvm],nil,"kvm")
hm.activate
hm_vlan_id = ["sudo /sbin/brctl addbr onebr10",
@ -204,8 +205,36 @@ describe 'host-managed' do
"sudo /sbin/ip link set eth0.51 up",
"sudo /sbin/brctl addif specialbr eth0.51"]
hm_vlan_id.map{|c| c + " 2>&1 1>/dev/null"}.each do |cmd|
$collector[:backtick].include?(cmd).should == true
hm_vlan_id.each do |cmd|
$collector[:backtick].grep(Regexp.new("^"+cmd)).length.should >= 1
end
end
it "ignore interfaces that don't have vlan=yes" do
$capture_commands = {
/virsh.*dumpxml/ => nil,
/brctl show/ => OUTPUT[:brctl_show],
/brctl add/ => nil,
/vconfig/ => nil,
/ip link set/ => nil,
/ip link show/ => [nil,255]
}
hm = OpenNebulaHM.new(OUTPUT[:onevm_show_mixed],nil,"kvm")
hm.activate
hm_vlan_tag = [ "sudo /sbin/brctl show",
"sudo /sbin/brctl addbr onebr1",
"sudo /sbin/ip link set onebr1 up",
"sudo /sbin/ip link show eth0.50",
"sudo /sbin/vconfig add eth0 50",
"sudo /sbin/ip link set eth0.50 up",
"sudo /sbin/brctl addif onebr1 eth0.50" ]
hm_vlan_tag.each do |cmd|
$collector[:backtick].grep(Regexp.new("^"+cmd)).length.should >= 1
end
end
end

View File

@ -2,9 +2,16 @@ module SystemMock
def execute_cmd(cmd)
if $capture_commands
$capture_commands.each do |regex, output|
$capture_commands.each do |regex, params|
code = nil
if params.instance_of? Array
output, code = params
else
output = params
end
code ||= 0
if cmd.match(regex)
Kernel.send(:`,":;exit 0")
Kernel.send(:`,":;exit #{code}")
return output
end
end

View File

@ -0,0 +1,81 @@
<VM>
<ID>12</ID>
<UID>0</UID>
<GID>0</GID>
<UNAME>oneadmin</UNAME>
<GNAME>oneadmin</GNAME>
<NAME>ttylinux</NAME>
<LAST_POLL>1323096916</LAST_POLL>
<STATE>3</STATE>
<LCM_STATE>3</LCM_STATE>
<STIME>1323096908</STIME>
<ETIME>0</ETIME>
<DEPLOY_ID>one-12</DEPLOY_ID>
<MEMORY>0</MEMORY>
<CPU>0</CPU>
<NET_TX>0</NET_TX>
<NET_RX>0</NET_RX>
<TEMPLATE>
<CPU><![CDATA[0.1]]></CPU>
<DISK>
<CLONE><![CDATA[YES]]></CLONE>
<DISK_ID><![CDATA[0]]></DISK_ID>
<IMAGE><![CDATA[ttylinux]]></IMAGE>
<IMAGE_ID><![CDATA[0]]></IMAGE_ID>
<READONLY><![CDATA[NO]]></READONLY>
<SAVE><![CDATA[NO]]></SAVE>
<SOURCE><![CDATA[/var/lib/one/images/d7d95d4043b690b58f36f88a34910e44]]></SOURCE>
<TARGET><![CDATA[hda]]></TARGET>
<TYPE><![CDATA[DISK]]></TYPE>
</DISK>
<FEATURES>
<ACPI><![CDATA[no]]></ACPI>
</FEATURES>
<GRAPHICS>
<LISTEN><![CDATA[0.0.0.0]]></LISTEN>
<PORT><![CDATA[5900]]></PORT>
<TYPE><![CDATA[vnc]]></TYPE>
</GRAPHICS>
<MEMORY><![CDATA[64]]></MEMORY>
<NAME><![CDATA[ttylinux]]></NAME>
<NIC>
<BRIDGE><![CDATA[br0]]></BRIDGE>
<IP><![CDATA[172.16.0.201]]></IP>
<MAC><![CDATA[02:00:ac:10:00:c9]]></MAC>
<NETWORK><![CDATA[net_172]]></NETWORK>
<NETWORK_ID><![CDATA[0]]></NETWORK_ID>
<VLAN><![CDATA[NO]]></VLAN>
</NIC>
<NIC>
<BRIDGE><![CDATA[onebr1]]></BRIDGE>
<IP><![CDATA[10.0.0.250]]></IP>
<MAC><![CDATA[02:00:0a:00:00:fa]]></MAC>
<NETWORK><![CDATA[vlan50]]></NETWORK>
<NETWORK_ID><![CDATA[1]]></NETWORK_ID>
<PHYDEV><![CDATA[eth0]]></PHYDEV>
<VLAN><![CDATA[YES]]></VLAN>
<VLAN_ID><![CDATA[50]]></VLAN_ID>
</NIC>
<VMID><![CDATA[12]]></VMID>
</TEMPLATE>
<HISTORY_RECORDS>
<HISTORY>
<SEQ>0</SEQ>
<HOSTNAME>localhost</HOSTNAME>
<VM_DIR>/var/lib/one/</VM_DIR>
<HID>1</HID>
<STIME>1323096914</STIME>
<ETIME>0</ETIME>
<VMMMAD>vmm_kvm</VMMMAD>
<VNMMAD>802.1Q</VNMMAD>
<TMMAD>tm_shared</TMMAD>
<PSTIME>1323096914</PSTIME>
<PETIME>1323096914</PETIME>
<RSTIME>1323096914</RSTIME>
<RETIME>0</RETIME>
<ESTIME>0</ESTIME>
<EETIME>0</EETIME>
<REASON>0</REASON>
</HISTORY>
</HISTORY_RECORDS>
</VM>

View File

@ -34,7 +34,7 @@
<NETWORK><![CDATA[virt-net]]></NETWORK>
<NETWORK_ID><![CDATA[3]]></NETWORK_ID>
<VLAN><![CDATA[YES]]></VLAN>
<WHITE_PORTS_TCP><![CDATA[22,80]]></WHITE_PORTS_TCP>
<WHITE_PORTS_TCP><![CDATA[22, 80]]></WHITE_PORTS_TCP>
</NIC>
<NIC>
<BRIDGE><![CDATA[onebr2]]></BRIDGE>