From 0f3574463230aa91199106e604000c31f99e63fb Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 9 Sep 2011 13:56:42 +0200 Subject: [PATCH 01/90] bug #802: This commit includes - Comment options in configuration files so default values can use $ONE_LOCATION if defined - Better check of YAML syntax errors - Changed some tabs for spaces - By default the installer creates auth/certificates (cherry picked from commit 3527bbd1f721d344afca282dab03d84332a72a24) --- install.sh | 1 + src/authm_mad/remotes/server/server_auth.conf | 5 ++- src/authm_mad/remotes/server/server_auth.rb | 6 +-- src/authm_mad/remotes/x509/x509_auth.conf | 3 +- src/authm_mad/remotes/x509/x509_auth.rb | 45 ++++++++++--------- 5 files changed, 33 insertions(+), 27 deletions(-) diff --git a/install.sh b/install.sh index e33d064816..a2aada53ec 100755 --- a/install.sh +++ b/install.sh @@ -191,6 +191,7 @@ ETC_DIRS="$ETC_LOCATION/im_kvm \ $ETC_LOCATION/tm_lvm \ $ETC_LOCATION/hm \ $ETC_LOCATION/auth \ + $ETC_LOCATION/auth/certificates \ $ETC_LOCATION/ec2query_templates \ $ETC_LOCATION/occi_templates \ $ETC_LOCATION/cli" diff --git a/src/authm_mad/remotes/server/server_auth.conf b/src/authm_mad/remotes/server/server_auth.conf index 2d48125dcd..57b669e4eb 100644 --- a/src/authm_mad/remotes/server/server_auth.conf +++ b/src/authm_mad/remotes/server/server_auth.conf @@ -1,4 +1,5 @@ # Path to the certificate used by the OpenNebula Services # Certificates must be in PEM format -:one_cert: "/etc/one/auth/cert.pem" -:one_key: "/etc/one/auth/pk.pem" + +#:one_cert: "/etc/one/auth/cert.pem" +#:one_key: "/etc/one/auth/pk.pem" diff --git a/src/authm_mad/remotes/server/server_auth.rb b/src/authm_mad/remotes/server/server_auth.rb index e4003f3289..1c3e427bea 100644 --- a/src/authm_mad/remotes/server/server_auth.rb +++ b/src/authm_mad/remotes/server/server_auth.rb @@ -63,7 +63,7 @@ class ServerAuth < X509Auth token_txt = "#{user}:#{user_pass}:#{expires}" token = encrypt(token_txt) - token64 = Base64::encode64(token).strip.delete("\n") + token64 = Base64::encode64(token).strip.delete("\n") login_out = "#{user}:server:#{token64}" @@ -76,7 +76,7 @@ class ServerAuth < X509Auth # auth method for auth_mad def authenticate(user, pass, signed_text) begin - # Decryption demonstrates that the user posessed the private key. + # Decryption demonstrates that the user posessed the private key. _user, user_pass, expires = decrypt(signed_text).split(':') return "User name missmatch" if user != _user @@ -85,7 +85,7 @@ class ServerAuth < X509Auth # Check that the signed password matches one for the user. if !pass.split('|').include?(user_pass) - return "User password missmatch" + return "User password missmatch" end return true diff --git a/src/authm_mad/remotes/x509/x509_auth.conf b/src/authm_mad/remotes/x509/x509_auth.conf index 679610ba0c..b841529176 100644 --- a/src/authm_mad/remotes/x509/x509_auth.conf +++ b/src/authm_mad/remotes/x509/x509_auth.conf @@ -1,3 +1,4 @@ # Path to the trusted CA directory. It should contain the trusted CA's for # the server, each CA certificate shoud be name CA_hash.0 -:ca_dir: "/etc/one/auth/certificates" + +#:ca_dir: "/etc/one/auth/certificates" diff --git a/src/authm_mad/remotes/x509/x509_auth.rb b/src/authm_mad/remotes/x509/x509_auth.rb index dbb69746d7..d9c15c8374 100644 --- a/src/authm_mad/remotes/x509/x509_auth.rb +++ b/src/authm_mad/remotes/x509/x509_auth.rb @@ -91,17 +91,17 @@ class X509Auth def login_token(user, expire) if expire != 0 expires = Time.now.to_i + expire.to_i - else - expires = @cert_chain[0].not_after.to_i - end + else + expires = @cert_chain[0].not_after.to_i + end text_to_sign = "#{user}:#{expires}" signed_text = encrypt(text_to_sign) certs_pem = @cert_chain.collect{|cert| cert.to_pem}.join(":") - token = "#{signed_text}:#{certs_pem}" - token64 = Base64::encode64(token).strip.delete("\n") + token = "#{signed_text}:#{certs_pem}" + token64 = Base64::encode64(token).strip.delete("\n") login_out = "#{user}:x509:#{token64}" @@ -114,23 +114,25 @@ class X509Auth # auth method for auth_mad def authenticate(user, pass, signed_text) begin - # Decryption demonstrates that the user posessed the private key. + # Decryption demonstrates that the user posessed the private key. _user, expires = decrypt(signed_text).split(':') return "User name missmatch" if user != _user return "x509 proxy expired" if Time.now.to_i >= expires.to_i - # Some DN in the chain must match a DN in the password - dn_ok = @cert_chain.each do |cert| - break true if pass.split('|').include?(cert.subject.to_s.delete("\s")) + # Some DN in the chain must match a DN in the password + dn_ok = @cert_chain.each do |cert| + if pass.split('|').include?(cert.subject.to_s.delete("\s")) + break true + end end - - unless dn_ok == true - return "Certificate subject missmatch" + + unless dn_ok == true + return "Certificate subject missmatch" end - - validate + + validate return true rescue => e @@ -159,9 +161,10 @@ private # Load class options form a configuration file (yaml syntax) def load_options(conf_file) if File.readable?(conf_file) - config = File.read(conf_file) - - @options.merge!(YAML::load(config)) + conf_txt = File.read(conf_file) + conf_opt = YAML::load(conf_txt) + + @options.merge!(conf_opt) if conf_opt != false end end @@ -184,7 +187,7 @@ private # Validate the user certificate ########################################################################### def validate - now = Time.now + now = Time.now failed = "Could not validate user credentials: " # Check start time and end time of certificates @@ -196,10 +199,10 @@ private end begin - # Validate the proxy certifcates + # Validate the proxy certifcates signee = @cert_chain[0] - @cert_chain[1..-1].each do |cert| + @cert_chain[1..-1].each do |cert| if !((signee.issuer.to_s == cert.subject.to_s) && (signee.verify(cert.public_key))) raise failed + signee.subject.to_s + " with issuer " + @@ -210,7 +213,7 @@ private end # Validate the End Entity certificate - if !@options[:ca_dir] + if !@options[:ca_dir] raise failed + "No certifcate authority directory was specified." end From 4eb0d69e5c70feab921b1de8711e0b8253c2c4de Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 9 Sep 2011 18:28:26 +0200 Subject: [PATCH 02/90] Bug: The x509 driver removes spaces in certificate DNs (DNs are used as passwd by this driver). Command line will not modify the passwd if plain or ssh method is used. (cherry picked from commit f8ee2d6c2defed34789400e2e574f51aebf9ed76) --- src/authm_mad/remotes/x509/x509_auth.rb | 2 +- src/cli/one_helper/oneuser_helper.rb | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/authm_mad/remotes/x509/x509_auth.rb b/src/authm_mad/remotes/x509/x509_auth.rb index d9c15c8374..a75a79a09a 100644 --- a/src/authm_mad/remotes/x509/x509_auth.rb +++ b/src/authm_mad/remotes/x509/x509_auth.rb @@ -81,7 +81,7 @@ class X509Auth # Returns the dn of the user certificate def dn - @cert_chain[0].subject.to_s + @cert_chain[0].subject.to_s.delete("\s") end # Generates a login token in the form: diff --git a/src/cli/one_helper/oneuser_helper.rb b/src/cli/one_helper/oneuser_helper.rb index f76ace7cc8..70ec8804bf 100644 --- a/src/cli/one_helper/oneuser_helper.rb +++ b/src/cli/one_helper/oneuser_helper.rb @@ -37,8 +37,10 @@ class OneUserHelper < OpenNebulaHelper::OneHelper return -1, "Can not read file: #{arg}" end else - if options[:plain] || options[:ssh] || options[:x509] - password = arg.gsub(/\s/, '') + if options[:plain] || options[:ssh] + password = arg + elsif options[:x509] + password = arg.delete("\s") else password = Digest::SHA1.hexdigest(arg) end From 0faf6203fbeabb8dd7f79139a60a071449f79ff1 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 9 Sep 2011 18:31:46 +0200 Subject: [PATCH 03/90] bug #797: OpenNebula core prevents a password with spaces to be used (cherry picked from commit f0410c9e75a6314976d1c3bc45d5cff11b0feb16) --- include/User.h | 35 +++++++++++++++++++++++++++++--- src/rm/RequestManagerAllocate.cc | 7 +++++++ src/rm/RequestManagerUser.cc | 13 +++++++++--- src/um/User.cc | 2 ++ 4 files changed, 51 insertions(+), 6 deletions(-) diff --git a/include/User.h b/include/User.h index 5e3ab15a4a..35050850f3 100644 --- a/include/User.h +++ b/include/User.h @@ -31,6 +31,11 @@ class User : public PoolObjectSQL { public: + /** + * Characters that can not be in a password + */ + static const string NO_PASSWD_CHARS; + /** * Function to print the User object into a string in XML format * @param xml the resulting XML string @@ -73,11 +78,35 @@ public: }; /** - * Sets user password + * Checks if a password is valid. + * @param passwd to be checked + * @return true if the password is valid */ - void set_password(string _password) + static bool is_valid_password(const string& passwd) { - password = _password; + return passwd.find_first_of(NO_PASSWD_CHARS) == string::npos; + } + + /** + * Sets user password. It checks that the new password does not contain + * forbidden chars. + * @param _password the new pass + * @returns -1 if the password is not valid + */ + int set_password(const string& passwd) + { + int rc = 0; + + if (is_valid_password(passwd)) + { + password = passwd; + } + else + { + rc = -1; + } + + return rc; }; /** diff --git a/src/rm/RequestManagerAllocate.cc b/src/rm/RequestManagerAllocate.cc index abaa83ff36..7db6c60e3b 100644 --- a/src/rm/RequestManagerAllocate.cc +++ b/src/rm/RequestManagerAllocate.cc @@ -242,6 +242,13 @@ int UserAllocate::pool_allocate(xmlrpc_c::paramList const& paramList, ugname = GroupPool::USERS_NAME; } + if (!User::is_valid_password(passwd)) + { + error_str = "Invalid password, it can not contain spaces."; + + return -1; + } + return upool->allocate(&id,ugid,uname,ugname,passwd,true,error_str); } diff --git a/src/rm/RequestManagerUser.cc b/src/rm/RequestManagerUser.cc index 1536f42c92..663a091c41 100644 --- a/src/rm/RequestManagerUser.cc +++ b/src/rm/RequestManagerUser.cc @@ -61,13 +61,20 @@ int UserChangePassword::user_action(User * user, string new_pass = xmlrpc_c::value_string(paramList.getString(2)); - user->set_password(new_pass); + int rc = user->set_password(new_pass); - pool->update(user); + if ( rc == 0 ) + { + pool->update(user); + } + else + { + error_str = "Invalid password, it can not contain spaces."; + } user->unlock(); - return 0; + return rc; } /* ------------------------------------------------------------------------- */ diff --git a/src/um/User.cc b/src/um/User.cc index 6a509b60b5..71837e68de 100644 --- a/src/um/User.cc +++ b/src/um/User.cc @@ -27,6 +27,8 @@ #include "Group.h" +const string User::NO_PASSWD_CHARS = " \t\n\v\f\r"; + /* ************************************************************************** */ /* User :: Database Access Functions */ /* ************************************************************************** */ From d8a5325495aff82d765f41de4a6b5ead30e65f8a Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 9 Sep 2011 19:13:05 +0200 Subject: [PATCH 04/90] bug: dummy auth driver returns the passwd specify by the user if it does not exists (cherry picked from commit c2351158888141c71b32c024fbe4c264d121501a) --- src/authm_mad/remotes/dummy/authenticate | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/authm_mad/remotes/dummy/authenticate b/src/authm_mad/remotes/dummy/authenticate index 5ef03d7900..2e28d18be9 100755 --- a/src/authm_mad/remotes/dummy/authenticate +++ b/src/authm_mad/remotes/dummy/authenticate @@ -17,8 +17,9 @@ #--------------------------------------------------------------------------- # # $1 = username -# $2 = password -echo $* +# $2 = "-" if user is not registered in opennebula +# $3 = password +echo $1 $3 From cb4dc7123a63ddf722f1df39e257d86592f066eb Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 9 Sep 2011 19:14:45 +0200 Subject: [PATCH 05/90] Bug #485: Moves passwd checks to user allocate. Driver responses are now better parsed, user creation fails if it contains spaces in passwd. (cherry picked from commit 59e72d93a4979ad81dac8202ecf516e414213569) --- src/rm/RequestManagerAllocate.cc | 7 ------- src/um/UserPool.cc | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/rm/RequestManagerAllocate.cc b/src/rm/RequestManagerAllocate.cc index 7db6c60e3b..abaa83ff36 100644 --- a/src/rm/RequestManagerAllocate.cc +++ b/src/rm/RequestManagerAllocate.cc @@ -242,13 +242,6 @@ int UserAllocate::pool_allocate(xmlrpc_c::paramList const& paramList, ugname = GroupPool::USERS_NAME; } - if (!User::is_valid_password(passwd)) - { - error_str = "Invalid password, it can not contain spaces."; - - return -1; - } - return upool->allocate(&id,ugid,uname,ugname,passwd,true,error_str); } diff --git a/src/um/UserPool.cc b/src/um/UserPool.cc index 60933f7a45..73bf9ddb98 100644 --- a/src/um/UserPool.cc +++ b/src/um/UserPool.cc @@ -136,6 +136,11 @@ int UserPool::allocate ( ostringstream oss; + if (password.empty() || !User::is_valid_password(password)) + { + goto error_pass; + } + if ( uname.empty() ) { goto error_name; @@ -176,6 +181,10 @@ int UserPool::allocate ( return *oid; +error_pass: + oss << "Invalid password, it can not contain spaces."; + goto error_common; + error_name: oss << "NAME cannot be empty."; goto error_common; @@ -293,7 +302,12 @@ bool UserPool::authenticate(const string& session, if ( is.good() ) { - is >> mad_name >> ws >> mad_pass; + is >> mad_name >> ws; + } + + if ( !is.fail() ) + { + getline(is, mad_pass); } if ( !is.fail() ) @@ -314,7 +328,7 @@ bool UserPool::authenticate(const string& session, oss << "Can't create user: " << error_str << ". Driver response: " << ar.message; - ar.message = oss.str(); + NebulaLog::log("AuM",Log::ERROR,oss); } else { From f500cc93ecaf25b4825ed796cdc9d3a8c7f4af8c Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Mon, 12 Sep 2011 13:00:05 +0200 Subject: [PATCH 06/90] bug #745: little format error on cli help --- src/cli/command_parser.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cli/command_parser.rb b/src/cli/command_parser.rb index 3fb18ae7bd..0d523680ad 100755 --- a/src/cli/command_parser.rb +++ b/src/cli/command_parser.rb @@ -278,6 +278,8 @@ EOT printf cmd_format10, l puts } + + puts } end From 26996edcb33c81191629187cb38b0d436f887a85 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Mon, 12 Sep 2011 13:00:47 +0200 Subject: [PATCH 07/90] bug #754: new man pages with the format error fixed --- share/man/oneacl.1 | 62 +++++- share/man/onedb.1 | 117 +++++++---- share/man/onegroup.1 | 107 +++++++--- share/man/onehost.1 | 149 ++++++++----- share/man/oneimage.1 | 319 ++++++++++++++++++---------- share/man/onetemplate.1 | 306 +++++++++++++++++---------- share/man/oneuser.1 | 210 +++++++++++++++---- share/man/onevdc.1 | 83 ++++++-- share/man/onevm.1 | 454 ++++++++++++++++++++++++---------------- share/man/onevnet.1 | 223 ++++++++++++++------ share/man/onezone.1 | 87 ++++++-- 11 files changed, 1457 insertions(+), 660 deletions(-) diff --git a/share/man/oneacl.1 b/share/man/oneacl.1 index 5b5ecb7fe1..83ca8a8ec3 100644 --- a/share/man/oneacl.1 +++ b/share/man/oneacl.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEACL" "1" "July 2011" "" "oneacl(1) -- manages OpenNebula ACLs" +.TH "ONEACL" "1" "September 2011" "" "oneacl(1) -- manages OpenNebula ACLs" . .SH "NAME" \fBoneacl\fR @@ -23,14 +23,13 @@ .SH "COMMANDS" . .IP "\(bu" 4 -list +create \fIuser|rulestr\fR [\fIresource\fR] [\fIrights\fR] . .IP "" 4 . .nf -Lists the ACL rule set -valid options: xml +Adds a new ACL rule . .fi . @@ -52,13 +51,14 @@ Deletes an existing ACL rule . .IP "\(bu" 4 -create \fIuser|rulestr\fR [\fIresource\fR] [\fIrights\fR] +list . .IP "" 4 . .nf -Adds a new ACL rule +Lists the ACL rule set +valid options: xml . .fi . @@ -70,21 +70,65 @@ Adds a new ACL rule .SH "ARGUMENT FORMATS" . .IP "\(bu" 4 -text +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 -file +text +. +.IP "" 4 +. +.nf + +String +. +.fi +. +.IP "" 0 + . .IP "\(bu" 4 aclid_list +. +.IP "" 4 +. +.nf + +Comma\-separated list of OpenNebula ACL names or ids +. +.fi +. +.IP "" 0 + . .IP "" 0 . .SH "LICENSE" -OpenNebula 2\.9\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 2\.9\.85 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 diff --git a/share/man/onedb.1 b/share/man/onedb.1 index 8b6a6232bf..91683af3ab 100644 --- a/share/man/onedb.1 +++ b/share/man/onedb.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEDB" "1" "July 2011" "" "onedb(1) -- OpenNebula database migration tool" +.TH "ONEDB" "1" "September 2011" "" "onedb(1) -- OpenNebula database migration tool" . .SH "NAME" \fBonedb\fR @@ -27,26 +27,25 @@ This command enables the user to manage the OpenNebula database\. It provides in \-v, \-\-verbose Verbose mode \-h, \-\-help Show this message \-V, \-\-version Show version and copyright information - \-s file, \-\-sqlite file SQLite DB file - \-S host, \-\-server host MySQL server hostname or IP\. Defaults to localhost - \-P port, \-\-port port MySQL server port\. Defaults to 3306 - \-u user, \-\-username user MySQL username - \-p pass, \-\-password pass MySQL password\. Leave unset to be prompted for it - \-d dbname, \-\-dbname dbname MySQL DB name for OpenNebula + \-s, \-\-sqlite file SQLite DB file + \-S, \-\-server host MySQL server hostname or IP\. Defaults to localhost + \-P, \-\-port port MySQL server port\. Defaults to 3306 + \-u, \-\-username user MySQL username + \-p, \-\-password pass MySQL password\. Leave unset to be prompted for it + \-d, \-\-dbname dbname MySQL DB name for OpenNebula . .fi . .SH "COMMANDS" . .IP "\(bu" 4 -restore [\fIbackup_file\fR] +backup [\fIoutput_file\fR] . .IP "" 4 . .nf -Restores the DB from a backup file\. Only restores backups generated -from the same backend (SQLite or MySQL) +Dumps the DB to a file specified in the argument valid options: force . .fi @@ -68,6 +67,36 @@ Use \-v flag to see also OpenNebula version . .IP "" 0 +. +.IP "\(bu" 4 +history +. +.IP "" 4 +. +.nf + +Prints the upgrades history +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +restore [\fIbackup_file\fR] +. +.IP "" 4 +. +.nf + +Restores the DB from a backup file\. Only restores backups generated +from the same backend (SQLite or MySQL) +valid options: force +. +.fi +. +.IP "" 0 + . .IP "\(bu" 4 upgrade [\fIversion\fR] @@ -85,48 +114,52 @@ valid options: force, backup . .IP "" 0 -. -.IP "\(bu" 4 -backup [\fIoutput_file\fR] -. -.IP "" 4 -. -.nf - -Dumps the DB to a file specified in the argument -valid options: force -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -history -. -.IP "" 4 -. -.nf - -Prints the upgrades history -. -.fi -. -.IP "" 0 - . .IP "" 0 . .SH "ARGUMENT FORMATS" . .IP "\(bu" 4 -text -. -.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 "" 0 diff --git a/share/man/onegroup.1 b/share/man/onegroup.1 index 444c0eac6a..c7491abcfc 100644 --- a/share/man/onegroup.1 +++ b/share/man/onegroup.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEGROUP" "1" "July 2011" "" "onegroup(1) -- manages OpenNebula groups" +.TH "ONEGROUP" "1" "September 2011" "" "onegroup(1) -- manages OpenNebula groups" . .SH "NAME" \fBonegroup\fR @@ -38,6 +38,20 @@ Creates a new Group . .IP "" 0 +. +.IP "\(bu" 4 +delete \fIrange|groupid_list\fR +. +.IP "" 4 +. +.nf + +Deletes the given Group +. +.fi +. +.IP "" 0 + . .IP "\(bu" 4 list @@ -55,21 +69,7 @@ valid options: list, delay, xml, numeric . .IP "\(bu" 4 -delete \fIrange|groupid_list\fR -. -.IP "" 4 -. -.nf - -Deletes the given Group -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -show \fIgroupid\fR +show [\fIgroupid\fR] . .IP "" 4 . @@ -88,24 +88,79 @@ valid options: xml .SH "ARGUMENT FORMATS" . .IP "\(bu" 4 -groupid_list -. -.IP "\(bu" 4 -text -. -.IP "\(bu" 4 -groupid -. -.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 +groupid +. +.IP "" 4 +. +.nf + +OpenNebula GROUP name or id +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +groupid_list +. +.IP "" 4 +. +.nf + +Comma\-separated list of OpenNebula GROUP names or ids +. +.fi +. +.IP "" 0 + . .IP "" 0 . .SH "LICENSE" -OpenNebula 2\.9\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 2\.9\.85 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 diff --git a/share/man/onehost.1 b/share/man/onehost.1 index 1f0060b697..c5598b5d12 100644 --- a/share/man/onehost.1 +++ b/share/man/onehost.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEHOST" "1" "July 2011" "" "onehost(1) -- manages OpenNebula hosts" +.TH "ONEHOST" "1" "September 2011" "" "onehost(1) -- manages OpenNebula hosts" . .SH "NAME" \fBonehost\fR @@ -27,13 +27,13 @@ .SH "COMMANDS" . .IP "\(bu" 4 -enable \fIrange|hostid_list\fR +create \fIhostname\fR \fIim_mad\fR \fIvmm_mad\fR \fItm_mad\fR . .IP "" 4 . .nf -Enables the given Host +Creates a new Host . .fi . @@ -41,13 +41,27 @@ Enables the given Host . .IP "\(bu" 4 -update \fIhostid\fR +delete \fIrange|hostid_list\fR . .IP "" 4 . .nf -Launches the system editor to modify and update the template contents +Deletes the given Host +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +enable \fIrange|hostid_list\fR +. +.IP "" 4 +. +.nf + +Enables the given Host . .fi . @@ -69,28 +83,13 @@ Disables the given Host . .IP "\(bu" 4 -top +update \fIhostid\fR . .IP "" 4 . .nf -Lists Hosts continuously -valid options: list, delay, xml, numeric, kilobytes -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -create \fIhostname\fR \fIim_mad\fR \fIvmm_mad\fR \fItm_mad\fR -. -.IP "" 4 -. -.nf - -Creates a new Host +Launches the system editor to modify and update the template contents . .fi . @@ -112,21 +111,6 @@ The copy is performed the next time the Host is monitored . .IP "" 0 -. -.IP "\(bu" 4 -show \fIhostid\fR -. -.IP "" 4 -. -.nf - -Shows information for the given Host -valid options: xml -. -.fi -. -.IP "" 0 - . .IP "\(bu" 4 list @@ -144,13 +128,29 @@ valid options: list, delay, xml, numeric, kilobytes . .IP "\(bu" 4 -delete \fIrange|hostid_list\fR +show \fIhostid\fR . .IP "" 4 . .nf -Deletes the given Host +Shows information for the given Host +valid options: xml +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +top +. +.IP "" 4 +. +.nf + +Lists Hosts continuously +valid options: list, delay, xml, numeric, kilobytes . .fi . @@ -162,24 +162,79 @@ Deletes the given Host .SH "ARGUMENT FORMATS" . .IP "\(bu" 4 -hostid_list -. -.IP "\(bu" 4 file . -.IP "\(bu" 4 -text +.IP "" 4 . -.IP "\(bu" 4 -hostid +.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 +hostid +. +.IP "" 4 +. +.nf + +OpenNebula HOST name or id +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +hostid_list +. +.IP "" 4 +. +.nf + +Comma\-separated list of OpenNebula HOST names or ids +. +.fi +. +.IP "" 0 + . .IP "" 0 . .SH "LICENSE" -OpenNebula 2\.9\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 2\.9\.85 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 diff --git a/share/man/oneimage.1 b/share/man/oneimage.1 index 3fc1241a4d..d47d831509 100644 --- a/share/man/oneimage.1 +++ b/share/man/oneimage.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEIMAGE" "1" "July 2011" "" "oneimage(1) -- manages OpenNebula images" +.TH "ONEIMAGE" "1" "September 2011" "" "oneimage(1) -- manages OpenNebula images" . .SH "NAME" \fBoneimage\fR @@ -13,9 +13,9 @@ . .nf - \-x, \-\-xml Show the resource in xml format \-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 \-v, \-\-verbose Verbose mode \-h, \-\-help Show this message @@ -24,92 +24,6 @@ .fi . .SH "COMMANDS" -. -.IP "\(bu" 4 -enable \fIrange|imageid_list\fR -. -.IP "" 4 -. -.nf - -Enables the given Image -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -update \fIimageid\fR -. -.IP "" 4 -. -.nf - -Launches the system editor to modify and update the template contents -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -disable \fIrange|imageid_list\fR -. -.IP "" 4 -. -.nf - -Disables the given Image -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -unpublish \fIrange|imageid_list\fR -. -.IP "" 4 -. -.nf - -Unpublishes the given Image\. A private Image can\'t be used by any other -User -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -show \fIimageid\fR -. -.IP "" 4 -. -.nf - -Shows information for the given Image -valid options: xml -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -chgrp \fIrange|imageid_list\fR \fIgroupid\fR -. -.IP "" 4 -. -.nf - -Changes the Image group -. -.fi -. -.IP "" 0 - . .IP "\(bu" 4 create \fIfile\fR @@ -126,14 +40,43 @@ Creates a new Image from the given template file . .IP "\(bu" 4 -list [\fIfilterflag\fR] +delete \fIrange|imageid_list\fR . .IP "" 4 . .nf -Lists Images in the pool -valid options: list, delay, xml, numeric +Deletes the given Image +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +publish \fIrange|imageid_list\fR +. +.IP "" 4 +. +.nf + +Publishes the given Image\. A public Image can be seen and used by other +Users in the Image\'s group +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +unpublish \fIrange|imageid_list\fR +. +.IP "" 4 +. +.nf + +Unpublishes the given Image\. A private Image can\'t be used by any other +User . .fi . @@ -158,13 +101,13 @@ one VM instance at a time\. . .IP "\(bu" 4 -delete \fIrange|imageid_list\fR +nonpersistent \fIrange|imageid_list\fR . .IP "" 4 . .nf -Deletes the given Image +Makes the given Image non persistent\. See \'oneimage persistent\' . .fi . @@ -172,14 +115,55 @@ Deletes the given Image . .IP "\(bu" 4 -top [\fIfilterflag\fR] +update \fIimageid\fR . .IP "" 4 . .nf -Lists Images continuously -valid options: list, delay, xml, numeric +Launches the system editor to modify and update the template contents +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +enable \fIrange|imageid_list\fR +. +.IP "" 4 +. +.nf + +Enables the given Image +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +disable \fIrange|imageid_list\fR +. +.IP "" 4 +. +.nf + +Disables the given Image +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +chgrp \fIrange|imageid_list\fR \fIgroupid\fR +. +.IP "" 4 +. +.nf + +Changes the Image group . .fi . @@ -201,14 +185,14 @@ Changes the Image owner and group . .IP "\(bu" 4 -publish \fIrange|imageid_list\fR +list [\fIfilterflag\fR] . .IP "" 4 . .nf -Publishes the given Image\. A public Image can be seen and used by other -Users in the Image\'s group +Lists Images in the pool +valid options: list, delay, xml, numeric . .fi . @@ -216,13 +200,29 @@ Users in the Image\'s group . .IP "\(bu" 4 -nonpersistent \fIrange|imageid_list\fR +show \fIimageid\fR . .IP "" 4 . .nf -Makes the given Image non persistent\. See \'oneimage persistent\' +Shows information for the given Image +valid options: xml +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +top [\fIfilterflag\fR] +. +.IP "" 4 +. +.nf + +Lists Images continuously +valid options: list, delay, xml, numeric . .fi . @@ -234,33 +234,126 @@ Makes the given Image non persistent\. See \'oneimage persistent\' .SH "ARGUMENT FORMATS" . .IP "\(bu" 4 -userid +file . -.IP "\(bu" 4 -imageid +.IP "" 4 . -.IP "\(bu" 4 -filterflag +.nf + +Path to a file . -.IP "\(bu" 4 -groupid +.fi +. +.IP "" 0 + . .IP "\(bu" 4 range . -.IP "\(bu" 4 -file +.IP "" 4 . -.IP "\(bu" 4 -imageid_list +.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 +groupid +. +.IP "" 4 +. +.nf + +OpenNebula GROUP name or id +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +userid +. +.IP "" 4 +. +.nf + +OpenNebula USER name or id +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +imageid +. +.IP "" 4 +. +.nf + +OpenNebula IMAGE name or id +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +imageid_list +. +.IP "" 4 +. +.nf + +Comma\-separated list of OpenNebula IMAGE names or ids +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +filterflag +. +.IP "" 4 +. +.nf + +a, all all the known IMAGEs +m, mine the IMAGE belonging to the user in ONE_AUTH +g, group \'mine\' plus the IMAGE belonging to the groups + the user is member of +uid IMAGE of the user identified by this uid +user IMAGE of the user identified by the username +. +.fi +. +.IP "" 0 + . .IP "" 0 . .SH "LICENSE" -OpenNebula 2\.9\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 2\.9\.85 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 diff --git a/share/man/onetemplate.1 b/share/man/onetemplate.1 index 41dc9b833f..a8f9cb2066 100644 --- a/share/man/onetemplate.1 +++ b/share/man/onetemplate.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONETEMPLATE" "1" "July 2011" "" "onetemplate(1) -- manages OpenNebula templates" +.TH "ONETEMPLATE" "1" "September 2011" "" "onetemplate(1) -- manages OpenNebula templates" . .SH "NAME" \fBonetemplate\fR @@ -13,9 +13,11 @@ . .nf - \-x, \-\-xml Show the resource in xml format + \-n, \-\-name vm_name Name of the new Virtual Machine + \-m, \-\-multiple x Instance multiple VMs \-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 \-v, \-\-verbose Verbose mode \-h, \-\-help Show this message @@ -24,50 +26,6 @@ .fi . .SH "COMMANDS" -. -.IP "\(bu" 4 -show \fItemplateid\fR -. -.IP "" 4 -. -.nf - -Shows information for the given Template -valid options: xml -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -update \fItemplateid\fR -. -.IP "" 4 -. -.nf - -Launches the system editor to modify and update the template contents -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -unpublish \fIrange|templateid_list\fR -. -.IP "" 4 -. -.nf - -Unpublishes the given Template\. A private Template can\'t be -instantiated by any other User -. -.fi -. -.IP "" 0 - . .IP "\(bu" 4 create \fIfile\fR @@ -82,50 +40,6 @@ Creates a new Template from the given template file . .IP "" 0 -. -.IP "\(bu" 4 -chgrp \fIrange|templateid_list\fR \fIgroupid\fR -. -.IP "" 4 -. -.nf - -Changes the Template group -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -list [\fIfilterflag\fR] -. -.IP "" 4 -. -.nf - -Lists Templates in the pool -valid options: list, delay, xml, numeric -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -top [\fIfilterflag\fR] -. -.IP "" 4 -. -.nf - -Lists Templates continuously -valid options: list, delay, xml, numeric -. -.fi -. -.IP "" 0 - . .IP "\(bu" 4 delete \fIrange|templateid_list\fR @@ -140,6 +54,22 @@ Deletes the given Image . .IP "" 0 +. +.IP "\(bu" 4 +instantiate \fItemplateid\fR +. +.IP "" 4 +. +.nf + +Creates a new VM instance from the given Template\. This VM can be +managed with the \'onevm\' command +valid options: vm_name, multiple +. +.fi +. +.IP "" 0 + . .IP "\(bu" 4 publish \fIrange|templateid_list\fR @@ -155,6 +85,35 @@ instantiated by other Users in the Template\'s group . .IP "" 0 +. +.IP "\(bu" 4 +unpublish \fIrange|templateid_list\fR +. +.IP "" 4 +. +.nf + +Unpublishes the given Template\. A private Template can\'t be +instantiated by any other User +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +chgrp \fIrange|templateid_list\fR \fIgroupid\fR +. +.IP "" 4 +. +.nf + +Changes the Template group +. +.fi +. +.IP "" 0 + . .IP "\(bu" 4 chown \fIrange|templateid_list\fR \fIuserid\fR [\fIgroupid\fR] @@ -171,14 +130,58 @@ Changes the Template owner and group . .IP "\(bu" 4 -instantiate \fIrange|templateid_list\fR +update \fItemplateid\fR . .IP "" 4 . .nf -Creates a new VM instance from the given Template\. This VM can be -managed with the \'onevm\' command +Launches the system editor to modify and update the template contents +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +list [\fIfilterflag\fR] +. +.IP "" 4 +. +.nf + +Lists Templates in the pool +valid options: list, delay, xml, numeric +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +show \fItemplateid\fR +. +.IP "" 4 +. +.nf + +Shows information for the given Template +valid options: xml +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +top [\fIfilterflag\fR] +. +.IP "" 4 +. +.nf + +Lists Templates continuously +valid options: list, delay, xml, numeric . .fi . @@ -190,33 +193,126 @@ managed with the \'onevm\' command .SH "ARGUMENT FORMATS" . .IP "\(bu" 4 -userid +file . -.IP "\(bu" 4 -templateid +.IP "" 4 . -.IP "\(bu" 4 -filterflag +.nf + +Path to a file . -.IP "\(bu" 4 -groupid +.fi +. +.IP "" 0 + . .IP "\(bu" 4 range . -.IP "\(bu" 4 -file +.IP "" 4 . -.IP "\(bu" 4 -templateid_list +.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 +groupid +. +.IP "" 4 +. +.nf + +OpenNebula GROUP name or id +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +userid +. +.IP "" 4 +. +.nf + +OpenNebula USER name or id +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +templateid +. +.IP "" 4 +. +.nf + +OpenNebula VMTEMPLATE name or id +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +templateid_list +. +.IP "" 4 +. +.nf + +Comma\-separated list of OpenNebula VMTEMPLATE names or ids +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +filterflag +. +.IP "" 4 +. +.nf + +a, all all the known VMTEMPLATEs +m, mine the VMTEMPLATE belonging to the user in ONE_AUTH +g, group \'mine\' plus the VMTEMPLATE belonging to the groups + the user is member of +uid VMTEMPLATE of the user identified by this uid +user VMTEMPLATE of the user identified by the username +. +.fi +. +.IP "" 0 + . .IP "" 0 . .SH "LICENSE" -OpenNebula 2\.9\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 2\.9\.85 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 diff --git a/share/man/oneuser.1 b/share/man/oneuser.1 index 9004b6e12f..8a327e1d63 100644 --- a/share/man/oneuser.1 +++ b/share/man/oneuser.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEUSER" "1" "July 2011" "" "oneuser(1) -- manages OpenNebula users" +.TH "ONEUSER" "1" "September 2011" "" "oneuser(1) -- manages OpenNebula users" . .SH "NAME" \fBoneuser\fR @@ -13,11 +13,18 @@ . .nf - \-x, \-\-xml Show the resource in xml format \-r, \-\-read\-file Read password from file \-p, \-\-plain Store plain password + \-\-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 + \-\-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) \-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 \-v, \-\-verbose Verbose mode \-h, \-\-help Show this message @@ -28,14 +35,84 @@ .SH "COMMANDS" . .IP "\(bu" 4 -show [\fIuserid\fR] +create \fIusername\fR [\fIpassword\fR] . .IP "" 4 . .nf -Shows information for the given User -valid options: xml +Creates a new User +Examples: + oneuser create my_user my_password + oneuser create my_user /tmp/mypass \-r + 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 +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +login \fIusername\fR +. +.IP "" 4 +. +.nf + +Creates the Login token for authentication +Examples: + oneuser login my_user \-\-ssh \-\-key /tmp/id_rsa \-\-time 72000 + oneuser login my_user \-\-x509 \-\-cert /tmp/my_cert\.pem \-\-key /tmp/my_key\.pk \-\-time 72000 + oneuser login my_user \-\-x509_proxy \-\-proxy /tmp/my_cert\.pem \-\-time 72000 +valid options: ssh, x509, x509_proxy, key, cert, proxy, time +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +key +. +.IP "" 4 +. +.nf + +Shows a public key from a private SSH key\. Use it as password +for the SSH authentication mechanism\. +valid options: key +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +delete \fIrange|userid_list\fR +. +.IP "" 4 +. +.nf + +Deletes the given User +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +passwd \fIuserid\fR [\fIpassword\fR] +. +.IP "" 4 +. +.nf + +Changes the given User\'s password +valid options: read_file, plain, ssh, x509, key, cert . .fi . @@ -55,21 +132,6 @@ Changes the User\'s main group . .IP "" 0 -. -.IP "\(bu" 4 -create \fIusername\fR \fIpassword\fR -. -.IP "" 4 -. -.nf - -Creates a new User -valid options: read_file, plain -. -.fi -. -.IP "" 0 - . .IP "\(bu" 4 list @@ -87,27 +149,14 @@ valid options: list, delay, xml, numeric . .IP "\(bu" 4 -delete \fIrange|userid_list\fR +show [\fIuserid\fR] . .IP "" 4 . .nf -Deletes the given User -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -passwd \fIuserid\fR \fIpassword\fR -. -.IP "" 4 -. -.nf - -Changes the given User\'s password +Shows information for the given User +valid options: xml . .fi . @@ -119,30 +168,107 @@ Changes the given User\'s password .SH "ARGUMENT FORMATS" . .IP "\(bu" 4 -userid +file . -.IP "\(bu" 4 -password +.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 "\(bu" 4 -file +.IP "" 4 +. +.nf + +String +. +.fi +. +.IP "" 0 + . .IP "\(bu" 4 groupid +. +.IP "" 4 +. +.nf + +OpenNebula GROUP name or id +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +userid +. +.IP "" 4 +. +.nf + +OpenNebula USER name or id +. +.fi +. +.IP "" 0 + . .IP "\(bu" 4 userid_list +. +.IP "" 4 +. +.nf + +Comma\-separated list of OpenNebula USER names or ids +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +password +. +.IP "" 4 +. +.nf + +User password +. +.fi +. +.IP "" 0 + . .IP "" 0 . .SH "LICENSE" -OpenNebula 2\.9\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 2\.9\.85 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 diff --git a/share/man/onevdc.1 b/share/man/onevdc.1 index 9d958560da..5ca56052f5 100644 --- a/share/man/onevdc.1 +++ b/share/man/onevdc.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEVDC" "1" "July 2011" "" "onevdc(1) -- manages OpenNebula Virtual DataCenters" +.TH "ONEVDC" "1" "September 2011" "" "onevdc(1) -- manages OpenNebula Virtual DataCenters" . .SH "NAME" \fBonevdc\fR @@ -27,7 +27,21 @@ .SH "COMMANDS" . .IP "\(bu" 4 -show \fItext\fR +create \fIfile\fR +. +.IP "" 4 +. +.nf + +Create a new VDC +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +show \fIvdcid\fR . .IP "" 4 . @@ -68,38 +82,71 @@ Deletes a VDC . .IP "" 0 +. +.IP "" 0 +. +.SH "ARGUMENT FORMATS" . .IP "\(bu" 4 -create \fIfile\fR +file . .IP "" 4 . .nf -Create a new VDC +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 "ARGUMENT FORMATS" -. -.IP "\(bu" 4 -file -. -.IP "\(bu" 4 -text -. -.IP "\(bu" 4 -range . .IP "" 0 . .SH "LICENSE" -OpenNebula 2\.9\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 2\.9\.85 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 diff --git a/share/man/onevm.1 b/share/man/onevm.1 index d69ea82637..5b24c0f7ca 100644 --- a/share/man/onevm.1 +++ b/share/man/onevm.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEVM" "1" "July 2011" "" "onevm(1) -- manages OpenNebula virtual machines" +.TH "ONEVM" "1" "September 2011" "" "onevm(1) -- manages OpenNebula virtual machines" . .SH "NAME" \fBonevm\fR @@ -13,12 +13,12 @@ . .nf + \-m, \-\-multiple x Instance multiple VMs \-x, \-\-xml Show the resource in xml format - \-l, \-\-list x,y,z Selects columns to display with list command - \-d, \-\-delay x Sets the delay in seconds for top command \-n, \-\-numeric Do not translate user and group IDs \-k, \-\-kilobytes Show units in kilobytes - \-m, \-\-multiple x Instance multiple VMs + \-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 \-h, \-\-help Show this message \-V, \-\-version Show version and copyright information @@ -28,13 +28,16 @@ .SH "COMMANDS" . .IP "\(bu" 4 -chgrp \fIrange|vmid_list\fR \fIgroupid\fR +create \fIfile\fR . .IP "" 4 . .nf -Changes the VM group +Creates a new VM from the given template file\. This command bypasses +the Template pool, which is the preferred way to instantiate new VMs\. +See \'onetemplate create\' and \'onetemplate instantiate\' +valid options: multiple, xml, numeric, kilobytes . .fi . @@ -42,15 +45,48 @@ Changes the VM group . .IP "\(bu" 4 -restart \fIrange|vmid_list\fR +delete \fIrange|vmid_list\fR . .IP "" 4 . .nf -Forces a re\-deployment of the given VM, issuing a boot action\. +Deletes the given VM -States: UNKNOWN, BOOT +States: ANY +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +hold \fIrange|vmid_list\fR +. +.IP "" 4 +. +.nf + +Sets the given VM on hold\. A VM on hold is not scheduled until it is +released\. It can be, however, deployed manually; see \'onevm deploy\' + +States: PENDING +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +release \fIrange|vmid_list\fR +. +.IP "" 4 +. +.nf + +Releases a VM on hold\. See \'onevm hold\' + +States: HOLD . .fi . @@ -77,14 +113,33 @@ States: ANY . .IP "\(bu" 4 -show \fIvmid\fR +shutdown \fIrange|vmid_list\fR . .IP "" 4 . .nf -Shows information for the given VM -valid options: xml +Shuts down the given VM\. + +States: RUNNING +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +deploy \fIrange|vmid_list\fR \fIhostid\fR +. +.IP "" 4 +. +.nf + +Deploys the given VM in the specified Host\. This command forces the +deployment, in a standard installation the Scheduler is in charge +of this decision + +States: PENDING . .fi . @@ -108,13 +163,82 @@ States: RUNNING . .IP "\(bu" 4 -shutdown \fIrange|vmid_list\fR +migrate \fIrange|vmid_list\fR \fIhostid\fR . .IP "" 4 . .nf -Shuts down the given VM\. +Saves the given running VM and starts it again in the specified Host + +States: RUNNING +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +restart \fIrange|vmid_list\fR +. +.IP "" 4 +. +.nf + +Forces a re\-deployment of the given VM, issuing a boot action\. + +States: UNKNOWN, BOOT +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +resubmit \fIrange|vmid_list\fR +. +.IP "" 4 +. +.nf + +Resubmits the VM to PENDING state\. This is intented for VMs stuck in a +transient state\. To re\-deploy a fresh copy of the same VM, create a +Template and instantiante it, see \'onetemplate instantiate\' + +States: ANY, except SUSPENDED or DONE +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +cancel \fIrange|vmid_list\fR +. +.IP "" 4 +. +.nf + +Cancels the given VM\. The process is checked by OpenNebula, so +if the process fails the VM remains in running state\. If the action +succeeds the VMDIR in the remote machine is not deleted + +States: RUNNING +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +stop \fIrange|vmid_list\fR +. +.IP "" 4 +. +.nf + +Stops a running VM\. The VM state is saved and transferred back to the +front\-end along with the disk files States: RUNNING . @@ -143,16 +267,15 @@ States: RUNNING . .IP "\(bu" 4 -hold \fIrange|vmid_list\fR +resume \fIrange|vmid_list\fR . .IP "" 4 . .nf -Sets the given VM on hold\. A VM on hold is not scheduled until it is -released\. It can be, however, deployed manually; see \'onevm deploy\' +Resumes the execution of the a saved VM -States: PENDING +States: STOPPED, SUSPENDED . .fi . @@ -160,17 +283,27 @@ States: PENDING . .IP "\(bu" 4 -resubmit \fIrange|vmid_list\fR +chgrp \fIrange|vmid_list\fR \fIgroupid\fR . .IP "" 4 . .nf -Resubmits the VM to PENDING state\. This is intented for VMs stuck in a -transient state\. To re\-deploy a fresh copy of the same VM, create a -Template and instantiante it, see \'onetemplate instantiate\' +Changes the VM group +. +.fi +. +.IP "" 0 -States: ANY, except SUSPENDED or DONE +. +.IP "\(bu" 4 +chown \fIrange|vmid_list\fR \fIuserid\fR [\fIgroupid\fR] +. +.IP "" 4 +. +.nf + +Changes the Image owner and group . .fi . @@ -193,147 +326,14 @@ valid options: list, delay, xml, numeric, kilobytes . .IP "\(bu" 4 -stop \fIrange|vmid_list\fR +show \fIvmid\fR . .IP "" 4 . .nf -Stops a running VM\. The VM state is saved and transferred back to the -front\-end along with the disk files - -States: RUNNING -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -deploy \fIrange|vmid_list\fR \fIhostid\fR -. -.IP "" 4 -. -.nf - -Deploys the given VM in the specified Host\. This command forces the -deployment, in a standard installation the Scheduler is in charge -of this decision - -States: PENDING -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -delete \fIrange|vmid_list\fR -. -.IP "" 4 -. -.nf - -Deletes the given VM - -States: ANY -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -resume \fIrange|vmid_list\fR -. -.IP "" 4 -. -.nf - -Resumes the execution of the a saved VM - -States: STOPPED, SUSPENDED -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -migrate \fIrange|vmid_list\fR \fIhostid\fR -. -.IP "" 4 -. -.nf - -Saves the given running VM and starts it again in the specified Host - -States: RUNNING -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -release \fIrange|vmid_list\fR -. -.IP "" 4 -. -.nf - -Releases a VM on hold\. See \'onevm hold\' - -States: HOLD -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -chown \fIrange|vmid_list\fR \fIuserid\fR [\fIgroupid\fR] -. -.IP "" 4 -. -.nf - -Changes the Image owner and group -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -cancel \fIrange|vmid_list\fR -. -.IP "" 4 -. -.nf - -Cancels the given VM\. The process is checked by OpenNebula, so -if the process fails the VM remains in running state\. If the action -succeeds the VMDIR in the remote machine is not deleted - -States: RUNNING -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -create \fIfile\fR -. -.IP "" 4 -. -.nf - -Creates a new VM from the given template file\. This command bypasses -the Template pool, which is the preferred way to instantiate new VMs\. -See \'onetemplate create\' and \'onetemplate instantiate\' -valid options: multiple, xml, numeric, kilobytes +Shows information for the given VM +valid options: xml . .fi . @@ -360,36 +360,140 @@ valid options: list, delay, xml, numeric, kilobytes .SH "ARGUMENT FORMATS" . .IP "\(bu" 4 -text -. -.IP "\(bu" 4 -vmid_list -. -.IP "\(bu" 4 -groupid -. -.IP "\(bu" 4 file . -.IP "\(bu" 4 -userid +.IP "" 4 . -.IP "\(bu" 4 -hostid +.nf + +Path to a file . -.IP "\(bu" 4 -vmid +.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 +hostid +. +.IP "" 4 +. +.nf + +OpenNebula HOST name or id +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +groupid +. +.IP "" 4 +. +.nf + +OpenNebula GROUP name or id +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +userid +. +.IP "" 4 +. +.nf + +OpenNebula USER name or id +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +vmid +. +.IP "" 4 +. +.nf + +OpenNebula VM name or id +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +vmid_list +. +.IP "" 4 +. +.nf + +Comma\-separated list of OpenNebula VM names or ids +. +.fi +. +.IP "" 0 + . .IP "\(bu" 4 filterflag +. +.IP "" 4 +. +.nf + +a, all all the known VMs +m, mine the VM belonging to the user in ONE_AUTH +g, group \'mine\' plus the VM belonging to the groups + the user is member of +uid VM of the user identified by this uid +user VM of the user identified by the username +. +.fi +. +.IP "" 0 + . .IP "" 0 . .SH "LICENSE" -OpenNebula 2\.9\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 2\.9\.85 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 diff --git a/share/man/onevnet.1 b/share/man/onevnet.1 index f1a4cb5912..db089aae93 100644 --- a/share/man/onevnet.1 +++ b/share/man/onevnet.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEVNET" "1" "July 2011" "" "onevnet(1) -- manages OpenNebula networks" +.TH "ONEVNET" "1" "September 2011" "" "onevnet(1) -- manages OpenNebula networks" . .SH "NAME" \fBonevnet\fR @@ -13,9 +13,9 @@ . .nf - \-x, \-\-xml Show the resource in xml format \-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 @@ -27,13 +27,13 @@ .SH "COMMANDS" . .IP "\(bu" 4 -rmleases \fIvnetid\fR \fIip\fR +create \fIfile\fR . .IP "" 4 . .nf -Removes a lease from the Virtual Network +Creates a new Virtual Network from the given template file . .fi . @@ -41,13 +41,13 @@ Removes a lease from the Virtual Network . .IP "\(bu" 4 -chgrp \fIrange|vnid_list\fR \fIgroupid\fR +delete \fIrange|vnetid_list\fR . .IP "" 4 . .nf -Changes the Virtual Network group +Deletes the given Virtual Network . .fi . @@ -69,14 +69,13 @@ Adds a lease to the Virtual Network . .IP "\(bu" 4 -show \fIvnetid\fR +rmleases \fIvnetid\fR \fIip\fR . .IP "" 4 . .nf -Shows information for the given Virtual Network -valid options: xml +Removes a lease from the Virtual Network . .fi . @@ -97,49 +96,6 @@ seen and used by other Users in the Virtual Network\'s group . .IP "" 0 -. -.IP "\(bu" 4 -list [\fIfilterflag\fR] -. -.IP "" 4 -. -.nf - -Lists Virtual Networks in the pool -valid options: list, delay, xml, numeric, kilobytes -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -delete \fIrange|vnetid_list\fR -. -.IP "" 4 -. -.nf - -Deletes the given Virtual Network -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -create \fIfile\fR -. -.IP "" 4 -. -.nf - -Creates a new Virtual Network from the given template file -. -.fi -. -.IP "" 0 - . .IP "\(bu" 4 unpublish \fIrange|vnetid_list\fR @@ -155,6 +111,20 @@ can\'t be used by any other User . .IP "" 0 +. +.IP "\(bu" 4 +chgrp \fIrange|vnid_list\fR \fIgroupid\fR +. +.IP "" 4 +. +.nf + +Changes the Virtual Network group +. +.fi +. +.IP "" 0 + . .IP "\(bu" 4 chown \fIrange|vnid_list\fR \fIuserid\fR [\fIgroupid\fR] @@ -169,39 +139,162 @@ Changes the Virtual Network owner and group . .IP "" 0 +. +.IP "\(bu" 4 +list [\fIfilterflag\fR] +. +.IP "" 4 +. +.nf + +Lists Virtual Networks in the pool +valid options: list, delay, xml, numeric, kilobytes +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +show \fIvnetid\fR +. +.IP "" 4 +. +.nf + +Shows information for the given Virtual Network +valid options: xml +. +.fi +. +.IP "" 0 + . .IP "" 0 . .SH "ARGUMENT FORMATS" . .IP "\(bu" 4 -vnetid_list -. -.IP "\(bu" 4 -userid -. -.IP "\(bu" 4 file . -.IP "\(bu" 4 -vnetid +.IP "" 4 . -.IP "\(bu" 4 -filterflag +.nf + +Path to a file . -.IP "\(bu" 4 -groupid +.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 +groupid +. +.IP "" 4 +. +.nf + +OpenNebula GROUP name or id +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +userid +. +.IP "" 4 +. +.nf + +OpenNebula USER name or id +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +vnetid +. +.IP "" 4 +. +.nf + +OpenNebula VNET name or id +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +vnetid_list +. +.IP "" 4 +. +.nf + +Comma\-separated list of OpenNebula VNET names or ids +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +filterflag +. +.IP "" 4 +. +.nf + +a, all all the known VNETs +m, mine the VNET belonging to the user in ONE_AUTH +g, group \'mine\' plus the VNET belonging to the groups + the user is member of +uid VNET of the user identified by this uid +user VNET of the user identified by the username +. +.fi +. +.IP "" 0 + . .IP "" 0 . .SH "LICENSE" -OpenNebula 2\.9\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 2\.9\.85 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 diff --git a/share/man/onezone.1 b/share/man/onezone.1 index df1d049446..a25d516379 100644 --- a/share/man/onezone.1 +++ b/share/man/onezone.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEZONE" "1" "July 2011" "" "onezone(1) -- manages OpenNebula zones" +.TH "ONEZONE" "1" "September 2011" "" "onezone(1) -- manages OpenNebula zones" . .SH "NAME" \fBonezone\fR @@ -27,13 +27,31 @@ .SH "COMMANDS" . .IP "\(bu" 4 -show \fItext\fR [\fItext\fR] +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 . @@ -68,38 +86,71 @@ Deletes a Zone . .IP "" 0 +. +.IP "" 0 +. +.SH "ARGUMENT FORMATS" . .IP "\(bu" 4 -create \fIfile\fR +file . .IP "" 4 . .nf -Create a new Zone +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 "ARGUMENT FORMATS" -. -.IP "\(bu" 4 -file -. -.IP "\(bu" 4 -text -. -.IP "\(bu" 4 -range . .IP "" 0 . .SH "LICENSE" -OpenNebula 2\.9\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 2\.9\.85 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 From 79f6fad41d2b09f97c931ad97baed764de10894c Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Mon, 12 Sep 2011 16:15:59 +0200 Subject: [PATCH 08/90] bug #568: get network consumption from all interfaces (kvm) --- src/vmm_mad/remotes/poll_xen_kvm.rb | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/vmm_mad/remotes/poll_xen_kvm.rb b/src/vmm_mad/remotes/poll_xen_kvm.rb index 2be25119f3..2e39a24c88 100755 --- a/src/vmm_mad/remotes/poll_xen_kvm.rb +++ b/src/vmm_mad/remotes/poll_xen_kvm.rb @@ -138,17 +138,21 @@ private interfaces=get_interface_names(vmid) if interfaces && !interfaces.empty? - text=`#{virsh(:domifstat)} #{vmid} #{interfaces.join(' ')}` - values={} + values[:netrx]=0 + values[:nettx]=0 - text.each_line do |line| - columns=line.split(/\s+/) - case columns[1] - when 'rx_bytes' - values[:netrx]=columns[2] - when 'tx_bytes' - values[:nettx]=columns[2] + interfaces.each do |interface| + text=`#{virsh(:domifstat)} #{vmid} #{interface}` + + text.each_line do |line| + columns=line.split(/\s+/) + case columns[1] + when 'rx_bytes' + values[:netrx]+=columns[2].to_i + when 'tx_bytes' + values[:nettx]+=columns[2].to_i + end end end From ac71f33c15c2210a8be18cf3a958a00882f5ad10 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Thu, 8 Sep 2011 19:23:43 +0200 Subject: [PATCH 09/90] Sunstone: Fix some widths in create ACL dialog Affects the proper alignment of the deploy checkbox and the acl string preview field position. (cherry picked from commit e540743a3b26161092ceed215ef63e6bfeb90967) --- src/sunstone/public/js/plugins/acls-tab.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sunstone/public/js/plugins/acls-tab.js b/src/sunstone/public/js/plugins/acls-tab.js index d25e45dc49..d78f542fd4 100644 --- a/src/sunstone/public/js/plugins/acls-tab.js +++ b/src/sunstone/public/js/plugins/acls-tab.js @@ -65,7 +65,7 @@ var create_acl_tmpl = \ \
\ - \ + \ Create
\ Delete
\ Use
\ @@ -312,7 +312,7 @@ function setupCreateAclDialog(){ dialog.dialog({ autoOpen: false, modal:true, - width: 600, + width: 650, height: height }); From aee86437c3445c878ba6091e68cd9d657379f125 Mon Sep 17 00:00:00 2001 From: Ted Date: Mon, 12 Sep 2011 11:06:51 -0500 Subject: [PATCH 10/90] Added support for X509 authorization in econe server. --- src/cloud/common/CloudServer.rb | 39 +++++++++++- src/cloud/ec2/lib/EC2QueryServer.rb | 96 ++++++++++++++++++++++------- src/cloud/ec2/lib/econe-server.rb | 8 ++- 3 files changed, 119 insertions(+), 24 deletions(-) diff --git a/src/cloud/common/CloudServer.rb b/src/cloud/common/CloudServer.rb index e05757ee07..070ae9d59d 100755 --- a/src/cloud/common/CloudServer.rb +++ b/src/cloud/common/CloudServer.rb @@ -88,7 +88,12 @@ class CloudServer # [return] an OpenNebula client session def one_client_user(name, password) client = Client.new("dummy:dummy") - client.one_auth = "#{name}:#{password}" + if name=="dummy" + #STDERR.puts "#{password}" + client.one_auth = "#{password}" + else + client.one_auth = "#{name}:#{password}" + end return client end @@ -101,7 +106,37 @@ class CloudServer return @user_pool["USER[NAME=\"#{name}\"]/PASSWORD"] end - + # Gets the username associated with a password + # password:: _String_ the password + # [return] _Hash_ with the username + def get_username(password) + @user_pool.info + #STDERR.puts 'the password is ' + password + #STDERR.puts @user_pool["User[PASSWORD=\"#{password}\"]"] + username = @user_pool["User[PASSWORD=\"#{password}\"]/NAME"] + return username if (username != nil) + + # Check if the DN is part of a |-separted multi-DN password + user_elts = Array.new + @user_pool.each {|e| user_elts << e['PASSWORD']} + multiple_users = user_elts.select {|e| e=~ /\|/ } + matched = nil + multiple_users.each do |e| + e.to_s.split('|').each do |w| + if (w == password) + matched=e + break + end + end + break if matched + end + if matched + password = matched.to_s + end + puts("The password is " + password) + return @user_pool["USER[PASSWORD=\"#{password}\"]/NAME"] + end + # Finds out if a port is available on ip # ip:: _String_ IP address where the port to check is # port:: _String_ port to find out whether is open diff --git a/src/cloud/ec2/lib/EC2QueryServer.rb b/src/cloud/ec2/lib/EC2QueryServer.rb index 1d8c786729..1329f8b8eb 100644 --- a/src/cloud/ec2/lib/EC2QueryServer.rb +++ b/src/cloud/ec2/lib/EC2QueryServer.rb @@ -86,34 +86,88 @@ class EC2QueryServer < CloudServer # params:: of the request # [return] true if authenticated def authenticate(params,env) - password = get_user_password(params['AWSAccessKeyId']) - return nil if !password + + failed = 'Authentication failed. ' + + # For https, the web service should be set to include the user cert in the environment. + cert_line = env['HTTP_SSL_CLIENT_CERT'] + cert_line = nil if cert_line == '(null)' # For Apache mod_ssl + + if cert_line == nil + # Use the secret key for authentication. + + password = get_user_password(params['AWSAccessKeyId']) + return nil if !password - signature = case params['SignatureVersion'] - when "1" then signature_version_1(params.clone, password) - when "2" then signature_version_2(params, - password, - env, - true, - false) - end - - if params['Signature']==signature - return one_client_user(params['AWSAccessKeyId'], password) - else - if params['SignatureVersion']=="2" - signature = signature_version_2(params, + signature = case params['SignatureVersion'] + when "1" then signature_version_1(params.clone, password) + when "2" then signature_version_2(params, password, env, - false, + true, false) - if params['Signature']==signature - return one_client_user(params['AWSAccessKeyId'], password) + end + + if params['Signature']==signature + return one_client_user(params['AWSAccessKeyId'], password) + else + if params['SignatureVersion']=="2" + signature = signature_version_2(params, + password, + env, + false, + false) + if params['Signature']==signature + return one_client_user(params['AWSAccessKeyId'], password) + end end end - end - return nil + return nil + else + # Use the https credentials for authentication + require 'server_auth' + while cert_line + begin + cert_array=cert_line.scan(/([^\s]*)\s/) + cert_array = cert_array[2..-3] + cert_array.unshift('-----BEGIN CERTIFICATE-----') + cert_array.push('-----END CERTIFICATE-----') + cert_pem = cert_array.join("\n") + #cert_pem = cert_line.scan(/(-+BEGIN CERTIFICATE-+\n[^-]*\n-+END CERTIFICATE-+)/) + cert = OpenSSL::X509::Certificate.new(cert_pem) + rescue + raise failed + "Could not create X509 certificate from " + cert_line + end + # Password should be DN with whitespace removed. + subjectname = cert.subject.to_s.delete("\s") + #STDERR.puts 'the cert is' + cert.subject.to_s + begin + username = get_username(subjectname) + rescue + username = nil + end + #STDERR.puts "the username is " + username + break if username + chain_dn = (!chain_dn ? "" : chain_dn) + "\n" + subjectname + chain_index = !chain_index ? 0 : chain_index + 1 + cert_line = env["HTTP_SSL_CLIENT_CERT_CHAIN_#{chain_index}"] + cert_line = nil if cert_line == '(null)' # For Apache mod_ssl + end + + if !cert_line + raise failed + "Username not found in certificate chain " + chain_dn + end + + auth = ServerAuth.new + + login = auth.login_token(username, subjectname, 300) + + STDERR.puts login + + return one_client_user("dummy", login) + + end end diff --git a/src/cloud/ec2/lib/econe-server.rb b/src/cloud/ec2/lib/econe-server.rb index 4255af408d..c9ac018571 100644 --- a/src/cloud/ec2/lib/econe-server.rb +++ b/src/cloud/ec2/lib/econe-server.rb @@ -70,7 +70,13 @@ set :port, $econe_server.config[:port] ############################################################################## before do - @client = $econe_server.authenticate(params,env) + #STDERR.puts Time.now.strftime("%d/%b/%Y %H:%M:%S") + begin + @client = $econe_server.authenticate(params,env) + rescue => e + #STDERR.puts Time.now.strftime("%d/%b/%Y %H:%M:%S") + ' Exception in authentication. ' + e.to_s + @client = nil + end if @client.nil? error 400, error_xml("AuthFailure", 0) From 591f761c69de9a7bb5e4a18c10438d7549c81af0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Mon, 12 Sep 2011 18:12:36 +0200 Subject: [PATCH 11/90] Bug #668: Change the LCM, the cancel action executes the epilog on success (cherry picked from commit 5b67dd2ebbe65142954c9e260aa9a2386b92384d) --- share/doc/states/states-complete.dot | 4 ++-- share/doc/states/states-simple.dot | 5 ++--- src/lcm/LifeCycleStates.cc | 25 +++++++++++++++---------- src/lcm/test/LifeCycleManagerTest.cc | 2 +- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/share/doc/states/states-complete.dot b/share/doc/states/states-complete.dot index 2f80a2a1ff..9937c7a306 100644 --- a/share/doc/states/states-complete.dot +++ b/share/doc/states/states-complete.dot @@ -23,7 +23,7 @@ digraph OpenNebula { subgraph { rank = same; prolog; prolog_resume; prolog_migrate; color="white" } - subgraph { rank = max; suspended; done; cancel; failure; + subgraph { rank = max; suspended; done; failure; stopped;color="white" } # create @@ -64,7 +64,7 @@ digraph OpenNebula { # cancel running -> cancel [label="cancel"]; - cancel -> done [style="dashed"]; + cancel -> epilog [style="dashed"]; # suspend running -> save_suspend [label="suspend"]; diff --git a/share/doc/states/states-simple.dot b/share/doc/states/states-simple.dot index 12d4ddb8a6..21d37fb8b9 100644 --- a/share/doc/states/states-simple.dot +++ b/share/doc/states/states-simple.dot @@ -34,8 +34,8 @@ digraph OpenNebula { # shutdown running -> shutdown [label="shutdown"]; - shutdown -> epilog [label="shutdown", style="dashed"]; - epilog -> done [label="shutdown", style="dashed"]; + shutdown -> epilog [style="dashed"]; + epilog -> done [style="dashed"]; # livemigrate running -> migrate [label="livemigrate"]; @@ -59,7 +59,6 @@ digraph OpenNebula { # cancel running -> shutdown [label="cancel"]; - shutdown -> done [label="cancel", style="dashed"]; # suspend running -> save [label="suspend"]; diff --git a/src/lcm/LifeCycleStates.cc b/src/lcm/LifeCycleStates.cc index a57fe25c44..ac01274093 100644 --- a/src/lcm/LifeCycleStates.cc +++ b/src/lcm/LifeCycleStates.cc @@ -598,12 +598,10 @@ void LifeCycleManager::epilog_failure_action(int vid) void LifeCycleManager::cancel_success_action(int vid) { + Nebula& nd = Nebula::instance(); + TransferManager * tm = nd.get_tm(); VirtualMachine * vm; time_t the_time = time(0); - int cpu,mem,disk; - - Nebula& nd = Nebula::instance(); - DispatchManager * dm = nd.get_dm(); vm = vmpool->get(vid,true); @@ -612,20 +610,27 @@ void LifeCycleManager::cancel_success_action(int vid) return; } - vm->set_running_etime(the_time); - vm->set_etime(the_time); + //---------------------------------------------------- + // EPILOG STATE + //---------------------------------------------------- + + vm->set_state(VirtualMachine::EPILOG); + + vmpool->update(vm); vm->set_reason(History::CANCEL); + vm->set_epilog_stime(the_time); + + vm->set_running_etime(the_time); + vmpool->update_history(vm); - vm->get_requirements(cpu,mem,disk); - - hpool->del_capacity(vm->get_hid(),cpu,mem,disk); + vm->log("LCM", Log::INFO, "New VM state is EPILOG"); //---------------------------------------------------- - dm->trigger(DispatchManager::DONE,vid); + tm->trigger(TransferManager::EPILOG,vid); vm->unlock(); } diff --git a/src/lcm/test/LifeCycleManagerTest.cc b/src/lcm/test/LifeCycleManagerTest.cc index 414be71a67..c2d4386d2e 100644 --- a/src/lcm/test/LifeCycleManagerTest.cc +++ b/src/lcm/test/LifeCycleManagerTest.cc @@ -714,7 +714,7 @@ public: dm->cancel(vm->get_oid()); - wait_assert(vm, VirtualMachine::DONE); + wait_assert(vm, VirtualMachine::ACTIVE, VirtualMachine::EPILOG ); } /* -------------------------------------------------------------------------- */ From 2df1eabaa6d5b721dab4ade4e0f1074f0afeca34 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Mon, 12 Sep 2011 18:15:07 +0200 Subject: [PATCH 12/90] Remove duplicated JSONUtils file (cherry picked from commit c10b9630caca6fda9b991a29fcb76eb0e2a745bc) --- install.sh | 2 +- src/ozones/Server/models/JSONUtils.rb | 87 --------------------------- 2 files changed, 1 insertion(+), 88 deletions(-) delete mode 100644 src/ozones/Server/models/JSONUtils.rb diff --git a/install.sh b/install.sh index a2aada53ec..8a28e0d9cd 100755 --- a/install.sh +++ b/install.sh @@ -1033,7 +1033,7 @@ OZONES_ETC_FILES="src/ozones/Server/etc/ozones-server.conf" OZONES_MODELS_FILES="src/ozones/Server/models/OzonesServer.rb \ src/ozones/Server/models/Auth.rb \ src/ozones/Server/models/OCAInteraction.rb \ - src/ozones/Server/models/JSONUtils.rb" + src/sunstone/models/OpenNebulaJSON/JSONUtils.rb" OZONES_TEMPLATE_FILES="src/ozones/Server/templates/index.html \ src/ozones/Server/templates/login.html" diff --git a/src/ozones/Server/models/JSONUtils.rb b/src/ozones/Server/models/JSONUtils.rb deleted file mode 100644 index 85a23d9bb2..0000000000 --- a/src/ozones/Server/models/JSONUtils.rb +++ /dev/null @@ -1,87 +0,0 @@ -# -------------------------------------------------------------------------- # -# 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 'json' - -module JSONUtils - def to_json - begin - JSON.pretty_generate self.to_hash - rescue Exception => e - OpenNebula::Error.new(e.message) - end - end - - def parse_json(json_str, root_element) - begin - hash = JSON.parse(json_str) - rescue Exception => e - return OpenNebula::Error.new(e.message) - end - - if hash.has_key?(root_element) - return hash[root_element] - else - return OpenNebula::Error.new("Error parsing JSON: Wrong resource type") - end - end - - def template_to_str(attributes, indent=true) - if indent - ind_enter="\n" - ind_tab=' ' - else - ind_enter='' - ind_tab=' ' - end - - str=attributes.collect do |key, value| - if value - str_line="" - if value.class==Array && !value.empty? - value.each do |value2| - str_line << key.to_s.upcase << "=[" << ind_enter - if value2 && value2.class==Hash - str_line << value2.collect do |key3, value3| - str = ind_tab + key3.to_s.upcase + "=" - str += "\"#{value3.to_s}\"" if value3 - str - end.compact.join(",\n") - end - str_line << "\n]\n" - end - - elsif value.class==Hash && !value.empty? - str_line << key.to_s.upcase << "=[" << ind_enter - - str_line << value.collect do |key3, value3| - str = ind_tab + key3.to_s.upcase + "=" - str += "\"#{value3.to_s}\"" if value3 - str - end.compact.join(",\n") - - str_line << "\n]\n" - - else - str_line< Date: Mon, 12 Sep 2011 11:20:20 -0500 Subject: [PATCH 13/90] Removed comment line. --- src/cloud/ec2/lib/EC2QueryServer.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cloud/ec2/lib/EC2QueryServer.rb b/src/cloud/ec2/lib/EC2QueryServer.rb index 1329f8b8eb..3c573e32d2 100644 --- a/src/cloud/ec2/lib/EC2QueryServer.rb +++ b/src/cloud/ec2/lib/EC2QueryServer.rb @@ -134,7 +134,6 @@ class EC2QueryServer < CloudServer cert_array.unshift('-----BEGIN CERTIFICATE-----') cert_array.push('-----END CERTIFICATE-----') cert_pem = cert_array.join("\n") - #cert_pem = cert_line.scan(/(-+BEGIN CERTIFICATE-+\n[^-]*\n-+END CERTIFICATE-+)/) cert = OpenSSL::X509::Certificate.new(cert_pem) rescue raise failed + "Could not create X509 certificate from " + cert_line From a013c562c93c77e96883078f8e8981e592310055 Mon Sep 17 00:00:00 2001 From: Ted Date: Mon, 12 Sep 2011 11:21:32 -0500 Subject: [PATCH 14/90] Removed comment lines. --- src/cloud/ec2/lib/EC2QueryServer.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/cloud/ec2/lib/EC2QueryServer.rb b/src/cloud/ec2/lib/EC2QueryServer.rb index 3c573e32d2..b4845a5805 100644 --- a/src/cloud/ec2/lib/EC2QueryServer.rb +++ b/src/cloud/ec2/lib/EC2QueryServer.rb @@ -139,14 +139,12 @@ class EC2QueryServer < CloudServer raise failed + "Could not create X509 certificate from " + cert_line end # Password should be DN with whitespace removed. - subjectname = cert.subject.to_s.delete("\s") - #STDERR.puts 'the cert is' + cert.subject.to_s + subjectname = cert.subject.to_s.delete("\s") begin username = get_username(subjectname) rescue username = nil end - #STDERR.puts "the username is " + username break if username chain_dn = (!chain_dn ? "" : chain_dn) + "\n" + subjectname chain_index = !chain_index ? 0 : chain_index + 1 From 9515d78bc9dc3e0b54764780cd18ee2bdd357968 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Mon, 12 Sep 2011 18:25:36 +0200 Subject: [PATCH 15/90] bug #803: added auth documentation to oned.conf --- share/etc/oned.conf | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/share/etc/oned.conf b/share/etc/oned.conf index 80d4b8690f..1f110b3b6d 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -538,17 +538,22 @@ HM_MAD = [ #******************************************************************************* # Auth Manager Configuration #******************************************************************************* -# The Driver (AUTHM_MAD) that will be used to authenticate and authorize -# OpenNebula requests. If not defined OpenNebula will use the built-in auth -# policies +# The Driver (AUTH_MAD) that will be used to authenticate (authn) and +# authorize (authz) OpenNebula requests. If defined OpenNebula will use the +# built-in auth policies. +# # executable: path of the auth driver executable, can be an # absolute path or relative to $ONE_LOCATION/lib/mads (or # /usr/lib/one/mads/ if OpenNebula was installed in /) # -# arguments : for the driver executable, can be an absolute path or relative -# to $ONE_LOCATION/etc (or /etc/one/ if OpenNebula was installed -# in /) +# arguments : +# --authn: list of authentication modules separated by commas, if not +# defined all the modules available will be enabled +# --authz: authorization module #------------------------------------------------------------------------------- #AUTH_MAD = [ -# executable = "one_auth_mad" ] +# executable = "one_auth_mad", +# arguments = "--authz quota --authn plain,ssh,x509" +#] + From 497821e1b1945c2ba72635dcf4b1e760439dcb62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Tue, 13 Sep 2011 12:14:36 +0200 Subject: [PATCH 16/90] Fix tests for onedb: ignore the Image SIZE element --- src/onedb/test/test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/onedb/test/test.sh b/src/onedb/test/test.sh index 0a7cd2f9cf..5253b93cee 100755 --- a/src/onedb/test/test.sh +++ b/src/onedb/test/test.sh @@ -120,7 +120,7 @@ echo "XML output collected. A diff will be performed." mkdir results/diff_files diff <(grep -v -e "" -e "" -e "NAME>" results/xml_files/host-pool.xml) <(grep -v -e "" -e "" -e "NAME>" results/xml_files/host-pool-upgraded.xml) > results/diff_files/host-pool.diff -diff <(grep -v -e "" -e "" results/xml_files/image-pool.xml) <(grep -v -e "" -e "" results/xml_files/image-pool-upgraded.xml) > results/diff_files/image-pool.diff +diff <(grep -v -e "" -e "" -e "" results/xml_files/image-pool.xml) <(grep -v -e "" -e "" -e "" results/xml_files/image-pool-upgraded.xml) > results/diff_files/image-pool.diff diff <(grep -v -e "" -e "TIME>" -e "" -e "" -e "" results/xml_files/vm-pool.xml) <(grep -v -e "" -e "TIME>" -e "" -e "" -e "" results/xml_files/vm-pool-upgraded.xml) > results/diff_files/vm-pool.diff for obj in vnet acl group user; do @@ -132,7 +132,7 @@ for i in 0 1 2 3 4; do diff <(cat results/xml_files/vnet-$i.xml) <(cat results/xml_files/vnet-$i-upgraded.xml) > results/diff_files/vnet-$i.diff - diff <(grep -v -e "" -e "" results/xml_files/image-$i.xml) <(grep -v -e "" -e "" results/xml_files/image-$i-upgraded.xml) > results/diff_files/image-$i.diff + diff <(grep -v -e "" -e "" -e "" results/xml_files/image-$i.xml) <(grep -v -e "" -e "" -e "" results/xml_files/image-$i-upgraded.xml) > results/diff_files/image-$i.diff diff <(grep -v -e "" -e "TIME>" -e "" -e "" -e "" -e "" results/xml_files/vm-$i.xml) <(grep -v -e "" -e "TIME>" -e "" -e "" -e "" -e "" results/xml_files/vm-$i-upgraded.xml) > results/diff_files/vm-$i.diff From 06ab68f306bbe2fb8369ebc880331a1f14ed3287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Tue, 13 Sep 2011 13:02:10 +0200 Subject: [PATCH 17/90] Feature #788: Fix ImagePoolTest, adding SIZE element --- src/image/test/ImagePoolTest.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/image/test/ImagePoolTest.cc b/src/image/test/ImagePoolTest.cc index 78a353f766..002736709a 100644 --- a/src/image/test/ImagePoolTest.cc +++ b/src/image/test/ImagePoolTest.cc @@ -53,19 +53,19 @@ const string templates[] = const string xmls[] = { - "001oneoneadminImage one0010000000000-40", + "001oneoneadminImage one0010000000000-040", - "111twooneadminSecond Image0100000000000-40", + "111twooneadminSecond Image0100000000000-040", - "021threeusersThe third image0000000000000-40" + "021threeusersThe third image0000000000000-040" }; // This xml dump result has the STIMEs modified to 0000000000 const string xml_dump = -"001oneoneadminImage one0010000000000-40111twooneadminSecond Image0100000000000-40221threeusersThe third image0000000000000-40"; +"001oneoneadminImage one0010000000000-040111twooneadminSecond Image0100000000000-040221threeusersThe third image0000000000000-040"; const string xml_dump_where = -"001oneoneadminImage one0010000000000-40111twooneadminSecond Image0100000000000-40"; +"001oneoneadminImage one0010000000000-040111twooneadminSecond Image0100000000000-040"; /* ************************************************************************* */ /* ************************************************************************* */ From 6d42518b9011b81b6bc0b4d5b73adbb7d87f4773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Tue, 13 Sep 2011 13:10:48 +0200 Subject: [PATCH 18/90] Bug #797: Fix UserPoolTest, spaces in names or password are no longer allowed --- src/um/test/UserPoolTest.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/um/test/UserPoolTest.cc b/src/um/test/UserPoolTest.cc index 3e38e73ece..8012cbacdc 100644 --- a/src/um/test/UserPoolTest.cc +++ b/src/um/test/UserPoolTest.cc @@ -27,8 +27,8 @@ using namespace std; /* ************************************************************************* */ /* ************************************************************************* */ -const string usernames[] = { "A user", "B user", "C user", "D user", "E user" }; -const string passwords[] = { "A pass", "B pass", "C pass", "D pass", "E pass" }; +const string usernames[] = { "A_user", "B_user", "C_user", "D_user", "E_user" }; +const string passwords[] = { "A_pass", "B_pass", "C_pass", "D_pass", "E_pass" }; const string dump_result = "00oneadminone_user_test5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8110oneadminap120oneadmina namepass130oneadmina_namepassword140oneadminanother namesecret150oneadminuser12341"; From 7d0ac75b0f873e17088c5aa3fd23e8e3cb6e7c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Tue, 13 Sep 2011 14:58:38 +0200 Subject: [PATCH 19/90] Bug #477: Fix AuthManagerTest, now the authorization errors are more vebose --- src/authm/test/AuthManagerTest.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/authm/test/AuthManagerTest.cc b/src/authm/test/AuthManagerTest.cc index 3e0c871148..f23358069b 100644 --- a/src/authm/test/AuthManagerTest.cc +++ b/src/authm/test/AuthManagerTest.cc @@ -220,14 +220,14 @@ public: cout << endl << "ar.result: " << ar.result << endl; } - if ( ar.message != astr ) + if ( ar.message.find(astr) == ar.message.npos ) { cout << endl << "ar.message: " << ar.message; cout << endl << "expected: " << astr << endl; } //*/ CPPUNIT_ASSERT(ar.result==false); - CPPUNIT_ASSERT(ar.message==astr); + CPPUNIT_ASSERT(ar.message.find(astr) != ar.message.npos); AuthRequest ar1(2, 2); @@ -248,14 +248,14 @@ public: cout << endl << "ar.result: " << ar1.result << endl; } - if ( ar1.message != astr1 ) + if ( ar1.message.find(astr1) == ar1.message.npos ) { cout << endl << "ar.message: " << ar1.message; cout << endl << "expected: " << astr1 << endl; } //*/ CPPUNIT_ASSERT(ar1.result==false); - CPPUNIT_ASSERT(ar1.message==astr1); + CPPUNIT_ASSERT(ar1.message.find(astr1) != ar1.message.npos); AuthRequest ar2(2, 2); From dfac4dcba1d116d61693f638256319e9eb89bbe1 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Tue, 13 Sep 2011 16:31:43 +0200 Subject: [PATCH 20/90] nokogiri and xmlparser dependencies swapped in install_gems (cherry picked from commit 90cbbd621518d46160705c8b09d8ccc6da99ea51) --- share/install_gems/install_gems | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/share/install_gems/install_gems b/share/install_gems/install_gems index 3a9219d4be..0574ec5760 100755 --- a/share/install_gems/install_gems +++ b/share/install_gems/install_gems @@ -36,8 +36,8 @@ DISTRIBUTIONS={ SQLITE => ['gcc', 'libsqlite3-dev'], 'mysql' => ['gcc', 'libmysqlclient-dev'], 'curb' => ['gcc', 'libcurl4-openssl-dev'], - 'nokogiri' => ['gcc', 'libexpat1-dev'], - 'xmlparser' => %w{gcc rake libxml2-dev libxslt1-dev}, + 'nokogiri' => %w{gcc rake libxml2-dev libxslt1-dev}, + 'xmlparser' => ['gcc', 'libexpat1-dev'], 'thin' => ['g++'] }, :install_command => 'apt-get install' @@ -48,8 +48,8 @@ DISTRIBUTIONS={ SQLITE => ['gcc', 'sqlite-devel'], 'mysql' => ['gcc', 'mysql-devel'], 'curb' => ['gcc', 'curl-devel'], - 'nokogiri' => ['gcc', 'expat-devel'], - 'xmlparser' => %w{gcc rubygem-rake libxml2-devel libxslt-devel}, + 'nokogiri' => %w{gcc rubygem-rake libxml2-devel libxslt-devel}, + 'xmlparser' => ['gcc', 'expat-devel'], 'thin' => ['gcc-c++'] }, :install_command => 'yum install' @@ -60,8 +60,8 @@ DISTRIBUTIONS={ SQLITE => ['gcc', 'sqlite3-devel'], 'mysql' => ['gcc', 'libmysqlclient-devel'], 'curb' => ['gcc', 'libcurl-devel'], - 'nokogiri' => ['gcc', 'libexpat-devel'], - 'xmlparser' => %w{rubygem-rake gcc rubygem-rake libxml2-devel libxslt-devel}, + 'nokogiri' => %w{rubygem-rake gcc rubygem-rake libxml2-devel libxslt-devel}, + 'xmlparser' => ['gcc', 'libexpat-devel'], 'thin' => ['rubygem-rake', 'gcc-c++'] }, :install_command => 'zypper install' From 60584602847a53c87d3d81a5897ef7d4469b5a6a Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Tue, 13 Sep 2011 16:33:15 +0200 Subject: [PATCH 21/90] bug #800: added rake path in debian based distros (cherry picked from commit 404844786c3731d41cc98e4f56598402949aa1c7) --- share/install_gems/install_gems | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/share/install_gems/install_gems b/share/install_gems/install_gems index 0574ec5760..8b6758a803 100755 --- a/share/install_gems/install_gems +++ b/share/install_gems/install_gems @@ -40,7 +40,10 @@ DISTRIBUTIONS={ 'xmlparser' => ['gcc', 'libexpat1-dev'], 'thin' => ['g++'] }, - :install_command => 'apt-get install' + :install_command => 'apt-get install', + :gem_env => { + 'rake' => '/usr/bin/rake' + } }, :redhat => { :id => ['CentOS', /^RedHat/], @@ -235,8 +238,15 @@ install_dependencies(gems_list, dist) packages_string=gems_list.join(' ') +prefix="" -command_string = "gem install --no-ri --no-rdoc" +if 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) From f2a45ed13988a6f00fb42c878d5414610da978ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Tue, 13 Sep 2011 17:50:45 +0200 Subject: [PATCH 22/90] Bugs #797, #485: Add invalid character checks to user names, add invalid char ':' --- include/User.h | 37 ++++++++++++++++++++++++++++-------- src/rm/RequestManagerUser.cc | 6 +----- src/um/User.cc | 2 +- src/um/UserPool.cc | 8 ++++---- src/um/test/UserPoolTest.cc | 8 ++++---- 5 files changed, 39 insertions(+), 22 deletions(-) diff --git a/include/User.h b/include/User.h index 35050850f3..c78ed283f6 100644 --- a/include/User.h +++ b/include/User.h @@ -34,7 +34,7 @@ public: /** * Characters that can not be in a password */ - static const string NO_PASSWD_CHARS; + static const string INVALID_CHARS; /** * Function to print the User object into a string in XML format @@ -78,31 +78,52 @@ public: }; /** - * Checks if a password is valid. - * @param passwd to be checked - * @return true if the password is valid + * Checks if a name or password is valid, i.e. it is not empty and does not + * contain invalid characters. + * @param str Name or password to be checked + * @param error_str Returns the error reason, if any + * @return true if the string is valid */ - static bool is_valid_password(const string& passwd) + static bool is_valid(const string& str, string& error_str) { - return passwd.find_first_of(NO_PASSWD_CHARS) == string::npos; + if ( str.empty() ) + { + error_str = "cannot be empty"; + return false; + } + + size_t pos = str.find_first_of(INVALID_CHARS); + + if ( pos != string::npos ) + { + ostringstream oss; + oss << "character '" << str.at(pos) << "' is not allowed"; + + error_str = oss.str(); + return false; + } + + return true; } /** * Sets user password. It checks that the new password does not contain * forbidden chars. * @param _password the new pass + * @param error_str Returns the error reason, if any * @returns -1 if the password is not valid */ - int set_password(const string& passwd) + int set_password(const string& passwd, string& error_str) { int rc = 0; - if (is_valid_password(passwd)) + if (is_valid(passwd, error_str)) { password = passwd; } else { + error_str = string("Invalid password: ").append(error_str); rc = -1; } diff --git a/src/rm/RequestManagerUser.cc b/src/rm/RequestManagerUser.cc index 663a091c41..2dcb17401d 100644 --- a/src/rm/RequestManagerUser.cc +++ b/src/rm/RequestManagerUser.cc @@ -61,16 +61,12 @@ int UserChangePassword::user_action(User * user, string new_pass = xmlrpc_c::value_string(paramList.getString(2)); - int rc = user->set_password(new_pass); + int rc = user->set_password(new_pass, error_str); if ( rc == 0 ) { pool->update(user); } - else - { - error_str = "Invalid password, it can not contain spaces."; - } user->unlock(); diff --git a/src/um/User.cc b/src/um/User.cc index 71837e68de..71b2d4cd28 100644 --- a/src/um/User.cc +++ b/src/um/User.cc @@ -27,7 +27,7 @@ #include "Group.h" -const string User::NO_PASSWD_CHARS = " \t\n\v\f\r"; +const string User::INVALID_CHARS = " :\t\n\v\f\r"; /* ************************************************************************** */ /* User :: Database Access Functions */ diff --git a/src/um/UserPool.cc b/src/um/UserPool.cc index 73bf9ddb98..f2ba70a7a7 100644 --- a/src/um/UserPool.cc +++ b/src/um/UserPool.cc @@ -136,12 +136,12 @@ int UserPool::allocate ( ostringstream oss; - if (password.empty() || !User::is_valid_password(password)) + if ( !User::is_valid(password, error_str) ) { goto error_pass; } - if ( uname.empty() ) + if ( !User::is_valid(uname, error_str) ) { goto error_name; } @@ -182,11 +182,11 @@ int UserPool::allocate ( return *oid; error_pass: - oss << "Invalid password, it can not contain spaces."; + oss << "Invalid password, " << error_str << "."; goto error_common; error_name: - oss << "NAME cannot be empty."; + oss << "Invalid NAME, " << error_str << "."; goto error_common; error_duplicated: diff --git a/src/um/test/UserPoolTest.cc b/src/um/test/UserPoolTest.cc index 8012cbacdc..09be4b1588 100644 --- a/src/um/test/UserPoolTest.cc +++ b/src/um/test/UserPoolTest.cc @@ -31,10 +31,10 @@ const string usernames[] = { "A_user", "B_user", "C_user", "D_user", "E_user" }; const string passwords[] = { "A_pass", "B_pass", "C_pass", "D_pass", "E_pass" }; const string dump_result = - "00oneadminone_user_test5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8110oneadminap120oneadmina namepass130oneadmina_namepassword140oneadminanother namesecret150oneadminuser12341"; + "00oneadminone_user_test5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8110oneadminap120oneadmina_namepass130oneadmina_name_2password140oneadminanother_namesecret150oneadminuser12341"; const string dump_where_result = - "10oneadminap120oneadmina namepass130oneadmina_namepassword140oneadminanother namesecret1"; + "10oneadminap120oneadmina_namepass130oneadmina_name_2password140oneadminanother_namesecret1"; #include "NebulaTest.h" @@ -313,7 +313,7 @@ public: void dump() { - string d_names[] = {"a", "a name", "a_name", "another name", "user"}; + string d_names[] = {"a", "a_name", "a_name_2", "another_name", "user"}; string d_pass[] = {"p", "pass", "password", "secret", "1234"}; int oid; @@ -340,7 +340,7 @@ public: void dump_where() { - string d_names[] = {"a", "a name", "a_name", "another name", "user"}; + string d_names[] = {"a", "a_name", "a_name_2", "another_name", "user"}; string d_pass[] = {"p", "pass", "password", "secret", "1234"}; int oid; From 1ff5ae0f0ec836f0afb362da6717c62703b841f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Tue, 13 Sep 2011 19:17:12 +0200 Subject: [PATCH 23/90] Bug #806: Fix rc variable initialization in ImagePool::disk_attribute --- src/image/ImagePool.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/image/ImagePool.cc b/src/image/ImagePool.cc index bafdfd4abb..69931e6798 100644 --- a/src/image/ImagePool.cc +++ b/src/image/ImagePool.cc @@ -135,7 +135,7 @@ int ImagePool::disk_attribute(VectorAttribute * disk, { string source; Image * img = 0; - int rc; + int rc = 0; ostringstream oss; From 1a864ef3f13397e4a7938e34bc3c0ce520c1f5f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 14 Sep 2011 12:27:08 +0200 Subject: [PATCH 24/90] Fix oca incompatibility with ruby 1.8.5 --- src/oca/ruby/OpenNebula/Group.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/oca/ruby/OpenNebula/Group.rb b/src/oca/ruby/OpenNebula/Group.rb index 5ec9c2f1e7..98c359ed3a 100644 --- a/src/oca/ruby/OpenNebula/Group.rb +++ b/src/oca/ruby/OpenNebula/Group.rb @@ -127,7 +127,11 @@ module OpenNebula # Returns whether or not the user with id 'uid' is part of this group def contains(uid) - return self["USERS/ID[.=#{uid}]"] != nil + # This doesn't work in ruby 1.8.5 +# return self["USERS/ID[.=#{uid}]"] != nil + + id_array = retrieve_elements('USERS/ID') + return id_array != nil && id_array.include?(uid.to_s) end # Returns an array with the numeric user ids From d37f19638e6cc1dd3262868d8b30f4ffb7da8b6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 14 Sep 2011 17:05:27 +0200 Subject: [PATCH 25/90] Add new Image unit test, and fix segfault problems --- src/image/test/ImagePoolTest.cc | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/image/test/ImagePoolTest.cc b/src/image/test/ImagePoolTest.cc index 002736709a..6ec2480186 100644 --- a/src/image/test/ImagePoolTest.cc +++ b/src/image/test/ImagePoolTest.cc @@ -146,10 +146,7 @@ class ImagePoolTest : public PoolTest CPPUNIT_TEST ( bus_source_assignment ); CPPUNIT_TEST ( public_attribute ); CPPUNIT_TEST ( persistence ); - -// Requires ImageManger, and NebulaTest -// CPPUNIT_TEST ( imagepool_disk_attribute ); - + CPPUNIT_TEST ( imagepool_disk_attribute ); CPPUNIT_TEST ( dump ); CPPUNIT_TEST ( dump_where ); @@ -159,6 +156,7 @@ protected: NebulaTestImage * tester; ImagePool * ipool; + ImageManager * imagem; void bootstrap(SqlDB* db) { @@ -217,12 +215,23 @@ public: neb.start(); ipool = neb.get_ipool(); + imagem = neb.get_imagem(); pool = ipool; }; void tearDown() { + // ----------------------------------------------------------- + // Stop the managers & free resources + // ----------------------------------------------------------- + + imagem->finalize(); + pthread_join(imagem->get_thread_id(),0); + + //XML Library + xmlCleanupParser(); + delete_db(); delete tester; @@ -614,7 +623,7 @@ public: // Disk using image 0 disk = new VectorAttribute("DISK"); - disk->replace("IMAGE", "Image 0"); + disk->replace("IMAGE_ID", "0"); ((ImagePool*)imp)->disk_attribute(disk, 0, &index, &img_type,0); @@ -622,9 +631,6 @@ public: value = disk->vector_value("TARGET"); CPPUNIT_ASSERT( value == "hda" ); - value = ""; - value = disk->vector_value("IMAGE_ID"); - CPPUNIT_ASSERT( value == "0" ); delete disk; From de0d8cba732a9e024fd654271defa908dd219bc8 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 14 Sep 2011 17:10:49 +0200 Subject: [PATCH 26/90] bug #716: Fix monitoring information when no resources are present --- src/acct/accounting.rb | 2 +- src/acct/monitoring.rb | 12 ++++- src/acct/watch_client.rb | 46 ++++++++-------- src/acct/watch_helper.rb | 113 +++++++++++++++++++++++++-------------- 4 files changed, 110 insertions(+), 63 deletions(-) diff --git a/src/acct/accounting.rb b/src/acct/accounting.rb index de872c4d60..9f07eb1274 100644 --- a/src/acct/accounting.rb +++ b/src/acct/accounting.rb @@ -72,7 +72,7 @@ module OneWatch # Upate the active VMs @active_vms = new_active_vms.sort - WatchHelper::Vm.flush(@timestamp) + WatchHelper::Vm.flush end private diff --git a/src/acct/monitoring.rb b/src/acct/monitoring.rb index c01e66f83c..4ff76c7dcc 100644 --- a/src/acct/monitoring.rb +++ b/src/acct/monitoring.rb @@ -28,7 +28,7 @@ module OneWatch } end - sql_elem.flush(timestamp) + sql_elem.flush end private @@ -50,6 +50,11 @@ module OneWatch WatchHelper::Vm end end + + def generate_timestamp + ts = super + WatchHelper::VmTimestamp.find_or_create(:id=>ts) + end end class HostMonitoring < Monitoring @@ -64,5 +69,10 @@ module OneWatch WatchHelper::Host end end + + def generate_timestamp + ts = super + WatchHelper::HostTimestamp.find_or_create(:id=>ts) + end end end diff --git a/src/acct/watch_client.rb b/src/acct/watch_client.rb index 1b1feb6a5c..36efadb078 100644 --- a/src/acct/watch_client.rb +++ b/src/acct/watch_client.rb @@ -97,25 +97,21 @@ module OneWatchClient # Get the MAX for each VM and last_poll value max_per_vm = rsql. - group(:id, :last_poll). - select{[:last_poll, max(mr.to_sym).as(:max_mr)]} + group(:vm_id, :timestamp). + select{[:timestamp, max(mr.to_sym).as(:max_mr)]} # SUM the monitoring resource for each last_poll value last_poll_and_sum = max_per_vm. from_self. - group(:last_poll). - select{[:last_poll, sum(:max_mr).as(:sum_mr)]} + group(:timestamp). + select{[:timestamp, sum(:max_mr).as(:sum_mr)]} - # Retrieve the information in an Array - a = Array.new - last_poll_and_sum.each do |row| - if row[:last_poll] && row[:last_poll] != 0 - a << [row[:last_poll], row[:sum_mr].to_i] - end - end - - a + # Add all the existing timestamps + with_ts = timestamps.left_join(last_poll_and_sum, :timestamp=>:id) + with_ts.collect do |row| + [row[:id], row[:sum_mr].to_i] + end end def count_monitoring(rsql, opt) @@ -126,13 +122,13 @@ module OneWatchClient else return nil end - a = Array.new + count = resources.group_and_count(:timestamp) - resources.group_and_count(:timestamp).all.each { |row| - a << [row[:timestamp], row[:count].to_i] - } - - a + # Add all the existing timestamps + with_ts = timestamps.left_join(count, :timestamp=>:id) + with_ts.collect do |row| + [row[:id], row[:count].to_i] + end end end @@ -157,6 +153,10 @@ module OneWatchClient pool.filter(:state=>3) end + def timestamps + WatchHelper::HostTimestamp + end + def filter_pool(filter) if filter[:uid] filter[:uid]==0 ? (hosts = pool) : (return nil) @@ -166,7 +166,7 @@ module OneWatchClient hosts = pool end - hosts.join(WatchHelper::HostSample, :host_id=>:id) + WatchHelper::HostSample.join(vms.select(:id.as(:host_id)), [:host_id]) end def filter_resource(id, filter) @@ -204,6 +204,10 @@ module OneWatchClient pool.filter(:state=>7) end + def timestamps + WatchHelper::VmTimestamp + end + def filter_pool(filter) if filter[:uid] vms = pool.filter(:uid=>filter[:uid]) @@ -213,7 +217,7 @@ module OneWatchClient vms = pool end - vms.join(WatchHelper::VmSample, :vm_id=>:id) + WatchHelper::VmSample.join(vms.select(:id.as(:vm_id)), [:vm_id]) end def filter_resource(id, filter) diff --git a/src/acct/watch_helper.rb b/src/acct/watch_helper.rb index edb7456d90..439606dd6c 100644 --- a/src/acct/watch_helper.rb +++ b/src/acct/watch_helper.rb @@ -140,7 +140,7 @@ module WatchHelper Integer :uid Integer :gid Integer :mem - Integer :cpu + Float :cpu Integer :vcpu Integer :stime Integer :etime @@ -154,12 +154,16 @@ module WatchHelper String :tm_mad end + DB.create_table? :vm_timestamps do + Integer :id, :primary_key=>true + end + DB.create_table? :vm_samples do foreign_key :vm_id, :vms, :key=>:id + foreign_key :timestamp, :vm_timestamps, :key=>:id Integer :state Integer :lcm_state Integer :last_poll - Integer :timestamp VM_SAMPLE.each { |key,value| column key, value[:type] @@ -168,10 +172,14 @@ module WatchHelper primary_key [:vm_id, :timestamp] end + DB.create_table? :host_timestamps do + Integer :id, :primary_key=>true + end + DB.create_table? :host_samples do foreign_key :host_id, :hosts, :key=>:id + foreign_key :timestamp, :host_timestamps, :key=>:id Integer :last_poll - Integer :timestamp Integer :state HOST_SAMPLE.each { |key,value| @@ -216,12 +224,62 @@ module WatchHelper unrestrict_primary_key many_to_one :vm + many_to_one :timestamp, + :class=>"WatchHelper::VmTimestamp", + :key=>:id + end + + class VmTimestamp < Sequel::Model + unrestrict_primary_key + + one_to_many :samples, + :order=>:timestamp, + :class=>"WatchHelper::VmSample", + :key=>:timestamp + + @@window_size = WatchHelper::get_config( + :VM_MONITORING, + :WINDOW_SIZE + ) + + def self.fix_size + if self.count > @@window_size + last_timestamp = self.all.first + last_timestamp.samples_dataset.destroy + last_timestamp.destroy + end + end end class HostSample < Sequel::Model unrestrict_primary_key many_to_one :host + many_to_one :timestamp, + :class=>"WatchHelper::HostTimestamp", + :key=>:id + end + + class HostTimestamp < Sequel::Model + unrestrict_primary_key + + one_to_many :samples, + :order=>:timestamp, + :class=>"WatchHelper::HostSample", + :key=>:timestamp + + @@window_size = WatchHelper::get_config( + :HOST_MONITORING, + :WINDOW_SIZE + ) + + def self.fix_size + if self.count > @@window_size + last_timestamp = self.all.first + last_timestamp.remove_all_samples + last_timestamp.destroy + end + end end class Register < Sequel::Model @@ -256,26 +314,21 @@ module WatchHelper # Accounting one_to_many :registers, :order=>:seq - one_to_many :deltas, :order=>:timestamp, :class=>VmDelta + one_to_many :deltas, :order=>:timestamp, :class=>"WatchHelper::VmDelta" # Monitoring - one_to_many :samples, :order=>:timestamp, :class=>VmSample + one_to_many :samples, :order=>:timestamp, :class=>"WatchHelper::VmSample" @@samples_cache = [] @@deltas_cache = [] - @@vm_window_size = WatchHelper::get_config( - :VM_MONITORING, - :WINDOW_SIZE - ) - def self.info(vm) Vm.find_or_create(:id=>vm['ID']) { |v| v.name = vm['NAME'] v.uid = vm['UID'].to_i v.gid = vm['GID'].to_i v.mem = vm['TEMPLATE/MEMORY'].to_i - v.cpu = vm['TEMPLATE/CPU'].to_i + v.cpu = vm['TEMPLATE/CPU'].to_f v.vcpu = vm['TEMPLATE/VCPU'].to_i v.stime = vm['STIME'].to_i v.etime = vm['ETIME'].to_i @@ -300,7 +353,7 @@ module WatchHelper def add_sample_from_resource(vm, timestamp) hash = { :vm_id => vm['ID'], - :timestamp => timestamp, + :timestamp => timestamp.id, :last_poll => vm['LAST_POLL'], :state => vm['STATE'], :lcm_state => vm['LCM_STATE'] @@ -343,21 +396,14 @@ module WatchHelper @@deltas_cache << hash end - def self.flush(timestamp) + def self.flush DB.transaction do VmDelta.multi_insert(@@deltas_cache) VmSample.multi_insert(@@samples_cache) + + VmTimestamp.fix_size end - step = WatchHelper::get_config(:STEP) - ws = WatchHelper::get_config(:VM_MONITORING,:WINDOW_SIZE) - vm_s = WatchHelper::get_config(:VM_MONITORING,:STEPS) - - t = step*ws*vm_s - tl = timestamp - t - - VmSample.filter('timestamp < ?', tl).destroy - @@samples_cache = [] @@deltas_cache = [] end @@ -367,16 +413,10 @@ module WatchHelper unrestrict_primary_key # Monitoring - one_to_many :samples, :order=>:timestamp, :class=>HostSample + one_to_many :samples, :order=>:timestamp, :class=>:HostSample @@samples_cache = [] - @@host_window_size = WatchHelper::get_config( - :HOST_MONITORING, - :WINDOW_SIZE - ) - - def self.info(host) Host.find_or_create(:id=>host['ID']) { |h| h.name = host['NAME'] @@ -389,7 +429,7 @@ module WatchHelper def add_sample_from_resource(host, timestamp) hash = { :host_id => host['ID'], - :timestamp => timestamp, + :timestamp => timestamp.id, :last_poll => host['LAST_MON_TIME'], :state => host['STATE'], } @@ -402,20 +442,13 @@ module WatchHelper @@samples_cache << hash end - def self.flush(timestamp) + def self.flush DB.transaction do HostSample.multi_insert(@@samples_cache) + + HostTimestamp.fix_size end - step = WatchHelper::get_config(:STEP) - ws = WatchHelper::get_config(:HOST_MONITORING,:WINDOW_SIZE) - vm_s = WatchHelper::get_config(:HOST_MONITORING,:STEPS) - - t = step*ws*vm_s - tl = timestamp - t - - HostSample.filter('timestamp < ?', tl).destroy - @@samples_cache = [] end end From aab42cee603ad28899232346593987f173216a80 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 14 Sep 2011 17:12:08 +0200 Subject: [PATCH 27/90] bug #716: Add monitoring tests --- src/acct/test/1Vm1His.rb | 2 + src/acct/test/1VmXHis.rb | 2 + src/acct/test/XVm1His.rb | 2 + src/acct/test/cmonitoring_spec.rb | 273 ++++++++++++++++--------- src/acct/test/helper/test_helper.rb | 3 +- src/acct/test/monitoring_spec.rb | 102 ---------- src/acct/test/vm_monitoring_spec.rb | 299 ++++++++++++++++++++++++++++ 7 files changed, 485 insertions(+), 198 deletions(-) delete mode 100644 src/acct/test/monitoring_spec.rb create mode 100644 src/acct/test/vm_monitoring_spec.rb diff --git a/src/acct/test/1Vm1His.rb b/src/acct/test/1Vm1His.rb index 0dad640a1c..babf836dc9 100644 --- a/src/acct/test/1Vm1His.rb +++ b/src/acct/test/1Vm1His.rb @@ -1,3 +1,5 @@ +$: << '.' + require 'helper/test_helper.rb' describe "1 Vm 1 History" do diff --git a/src/acct/test/1VmXHis.rb b/src/acct/test/1VmXHis.rb index d0a94a0840..0d92ebb369 100644 --- a/src/acct/test/1VmXHis.rb +++ b/src/acct/test/1VmXHis.rb @@ -1,3 +1,5 @@ +$: << '.' + require 'helper/test_helper.rb' describe "1 Vm X History" do diff --git a/src/acct/test/XVm1His.rb b/src/acct/test/XVm1His.rb index 1aa11c2d7c..c0640feb48 100644 --- a/src/acct/test/XVm1His.rb +++ b/src/acct/test/XVm1His.rb @@ -1,3 +1,5 @@ +$: << '.' + require 'helper/test_helper.rb' describe "X Vm 1 History" do diff --git a/src/acct/test/cmonitoring_spec.rb b/src/acct/test/cmonitoring_spec.rb index 814ce9a7f4..dd79ed8719 100644 --- a/src/acct/test/cmonitoring_spec.rb +++ b/src/acct/test/cmonitoring_spec.rb @@ -1,4 +1,7 @@ +$: << '.' + require 'helper/test_helper.rb' +require 'watch_client' describe "VmWatchClient tests" do before(:all) do @@ -13,7 +16,7 @@ describe "VmWatchClient tests" do @db[:vms].count.should eql(0) end - it "1 VM, 1 timestamp. Check totals, sums and resource info" do + it "Create a VM: uid=2 gid=4, timestamp=100" do @monitoring.set_mock_timestamp(100) @monitoring.insert(create_vmpool_hash) @@ -24,7 +27,7 @@ describe "VmWatchClient tests" do :memory => 128, :net_tx => 200, :net_rx => 400, - :last_poll => 90, + :last_poll => 100, :uid => 2, :gid => 4, :history => [ @@ -55,16 +58,16 @@ describe "VmWatchClient tests" do monitoring.keys.size.should eql(4) monitoring[:cpu_usage].size.should eql(1) - monitoring[:cpu_usage].first.should eql([90,1]) + monitoring[:cpu_usage].first.should eql([100,1]) monitoring[:mem_usage].size.should eql(1) - monitoring[:mem_usage].first.should eql([90,128]) + monitoring[:mem_usage].first.should eql([100,128]) monitoring[:net_tx].size.should eql(1) - monitoring[:net_tx].first.should eql([90,200]) + monitoring[:net_tx].first.should eql([100,200]) monitoring[:net_rx].size.should eql(1) - monitoring[:net_rx].first.should eql([90,400]) + monitoring[:net_rx].first.should eql([100,400]) end it "should check all the monitoring resources are shown by default and filtered" do @@ -78,16 +81,16 @@ describe "VmWatchClient tests" do monitoring.keys.size.should eql(4) monitoring[:cpu_usage].size.should eql(1) - monitoring[:cpu_usage].first.should eql([90,1]) + monitoring[:cpu_usage].first.should eql([100,1]) monitoring[:mem_usage].size.should eql(1) - monitoring[:mem_usage].first.should eql([90,128]) + monitoring[:mem_usage].first.should eql([100,128]) monitoring[:net_tx].size.should eql(1) - monitoring[:net_tx].first.should eql([90,200]) + monitoring[:net_tx].first.should eql([100,200]) monitoring[:net_rx].size.should eql(1) - monitoring[:net_rx].first.should eql([90,400]) + monitoring[:net_rx].first.should eql([100,400]) end it "should check no info for non exisiting user" do @@ -104,7 +107,7 @@ describe "VmWatchClient tests" do monitoring.keys.size.should eql(1) monitoring[:net_tx].size.should eql(1) - monitoring[:net_tx].first.should eql([90,200]) + monitoring[:net_tx].first.should eql([100,200]) end it "should check only two monitoring resources are shown if specified" do @@ -115,10 +118,10 @@ describe "VmWatchClient tests" do monitoring.keys.size.should eql(2) monitoring[:net_tx].size.should eql(1) - monitoring[:net_tx].first.should eql([90,200]) + monitoring[:net_tx].first.should eql([100,200]) monitoring[:cpu_usage].size.should eql(1) - monitoring[:cpu_usage].first.should eql([90,1]) + monitoring[:cpu_usage].first.should eql([100,1]) end it "should check all the total monitoring resources are shown by default" do @@ -134,19 +137,20 @@ describe "VmWatchClient tests" do monitoring[:active].size.should eql(1) monitoring[:active].first.should eql([100,1]) - monitoring[:error].size.should eql(0) + monitoring[:error].size.should eql(1) + monitoring[:error].first.should eql([100,0]) monitoring[:cpu_usage].size.should eql(1) - monitoring[:cpu_usage].first.should eql([90,1]) + monitoring[:cpu_usage].first.should eql([100,1]) monitoring[:mem_usage].size.should eql(1) - monitoring[:mem_usage].first.should eql([90,128]) + monitoring[:mem_usage].first.should eql([100,128]) monitoring[:net_tx].size.should eql(1) - monitoring[:net_tx].first.should eql([90,200]) + monitoring[:net_tx].first.should eql([100,200]) monitoring[:net_rx].size.should eql(1) - monitoring[:net_rx].first.should eql([90,400]) + monitoring[:net_rx].first.should eql([100,400]) end it "should check only one total monitoring resources is shown if specified" do @@ -172,7 +176,7 @@ describe "VmWatchClient tests" do mon.should eql(nil) end - it "add a second VM" do + it "Create a second VM: uid=2 gid=4, timestamp=200" do @monitoring.set_mock_timestamp(200) values = { @@ -180,7 +184,7 @@ describe "VmWatchClient tests" do :memory => 128, :net_tx => 200, :net_rx => 400, - :last_poll => 90, + :last_poll => 100, :uid => 2, :gid => 4, :history => [ @@ -211,16 +215,16 @@ describe "VmWatchClient tests" do monitoring.keys.size.should eql(4) monitoring[:cpu_usage].size.should eql(2) - monitoring[:cpu_usage].first.should eql([90,1]) + monitoring[:cpu_usage].first.should eql([100,1]) monitoring[:mem_usage].size.should eql(2) - monitoring[:mem_usage].first.should eql([90,128]) + monitoring[:mem_usage].first.should eql([100,128]) monitoring[:net_tx].size.should eql(2) - monitoring[:net_tx].first.should eql([90,200]) + monitoring[:net_tx].first.should eql([100,200]) monitoring[:net_rx].size.should eql(2) - monitoring[:net_rx].first.should eql([90,400]) + monitoring[:net_rx].first.should eql([100,400]) mon = @watch_client.resource_monitoring(2) @@ -232,16 +236,16 @@ describe "VmWatchClient tests" do monitoring.keys.size.should eql(4) monitoring[:cpu_usage].size.should eql(1) - monitoring[:cpu_usage].first.should eql([90,1]) + monitoring[:cpu_usage].first.should eql([100,1]) monitoring[:mem_usage].size.should eql(1) - monitoring[:mem_usage].first.should eql([90,128]) + monitoring[:mem_usage].first.should eql([100,128]) monitoring[:net_tx].size.should eql(1) - monitoring[:net_tx].first.should eql([90,200]) + monitoring[:net_tx].first.should eql([100,200]) monitoring[:net_rx].size.should eql(1) - monitoring[:net_rx].first.should eql([90,400]) + monitoring[:net_rx].first.should eql([100,400]) end it "should check all the total monitoring resources are shown by default" do @@ -259,22 +263,28 @@ describe "VmWatchClient tests" do monitoring[:active].first.should eql([100,1]) monitoring[:active][1].should eql([200,2]) - monitoring[:error].size.should eql(0) + monitoring[:error].size.should eql(2) + monitoring[:error].first.should eql([100,0]) + monitoring[:error][1].should eql([200,0]) - monitoring[:cpu_usage].size.should eql(1) - monitoring[:cpu_usage].first.should eql([90,1*2]) + monitoring[:cpu_usage].size.should eql(2) + monitoring[:cpu_usage].first.should eql([100,1]) + monitoring[:cpu_usage][1].should eql([200,1*2]) - monitoring[:mem_usage].size.should eql(1) - monitoring[:mem_usage].first.should eql([90,128*2]) + monitoring[:mem_usage].size.should eql(2) + monitoring[:mem_usage].first.should eql([100,128]) + monitoring[:mem_usage][1].should eql([200,128*2]) - monitoring[:net_tx].size.should eql(1) - monitoring[:net_tx].first.should eql([90,200*2]) + monitoring[:net_tx].size.should eql(2) + monitoring[:net_tx].first.should eql([100,200]) + monitoring[:net_tx][1].should eql([200,200*2]) - monitoring[:net_rx].size.should eql(1) - monitoring[:net_rx].first.should eql([90,400*2]) + monitoring[:net_rx].size.should eql(2) + monitoring[:net_rx].first.should eql([100,400]) + monitoring[:net_rx][1].should eql([200,400*2]) end - it "add a third VM" do + it "Create a third VM: uid=3 gid=5, timestamp=300" do @monitoring.set_mock_timestamp(300) values = { @@ -282,7 +292,7 @@ describe "VmWatchClient tests" do :memory => 128, :net_tx => 200, :net_rx => 400, - :last_poll => 90, + :last_poll => 270, :uid => 3, :gid => 5, :history => [ @@ -302,63 +312,93 @@ describe "VmWatchClient tests" do @db[:vms].count.should eql(3) end - it "should check the total monitoring resources are filtered by user" do + it "should check the total monitoring resources are filtered by uid(3)" do mon = @watch_client.total_monitoring(nil, :uid=>3) mon[:resource].should eql("VM_POOL") monitoring = mon[:monitoring] - monitoring[:total].size.should eql(1) - monitoring[:total].first.should eql([300,1]) + monitoring[:total].size.should eql(3) + monitoring[:total].first.should eql([100,0]) + monitoring[:total][1].should eql([200,0]) + monitoring[:total][2].should eql([300,1]) - monitoring[:active].size.should eql(1) - monitoring[:active].first.should eql([300,1]) + monitoring[:active].size.should eql(3) + monitoring[:active].first.should eql([100,0]) + monitoring[:active][1].should eql([200,0]) + monitoring[:active][2].should eql([300,1]) - monitoring[:error].size.should eql(0) + monitoring[:error].size.should eql(3) + monitoring[:error].first.should eql([100,0]) + monitoring[:error][1].should eql([200,0]) + monitoring[:error][2].should eql([300,0]) - monitoring[:cpu_usage].size.should eql(1) - monitoring[:cpu_usage].first.should eql([90,1]) + monitoring[:cpu_usage].size.should eql(3) + monitoring[:cpu_usage].first.should eql([100,0]) + monitoring[:cpu_usage][1].should eql([200,0]) + monitoring[:cpu_usage][2].should eql([300,1]) - monitoring[:mem_usage].size.should eql(1) - monitoring[:mem_usage].first.should eql([90,128]) + monitoring[:mem_usage].size.should eql(3) + monitoring[:mem_usage].first.should eql([100,0]) + monitoring[:mem_usage][1].should eql([200,0]) + monitoring[:mem_usage][2].should eql([300,128]) - monitoring[:net_tx].size.should eql(1) - monitoring[:net_tx].first.should eql([90,200]) + monitoring[:net_tx].size.should eql(3) + monitoring[:net_tx].first.should eql([100,0]) + monitoring[:net_tx][1].should eql([200,0]) + monitoring[:net_tx][2].should eql([300,200]) - monitoring[:net_rx].size.should eql(1) - monitoring[:net_rx].first.should eql([90,400]) + monitoring[:net_rx].size.should eql(3) + monitoring[:net_rx].first.should eql([100,0]) + monitoring[:net_rx][1].should eql([200,0]) + monitoring[:net_rx][2].should eql([300,400]) end - it "should check the total monitoring resources are filtered by group" do + it "should check the total monitoring resources are filtered by gid(5)" do mon = @watch_client.total_monitoring(nil, :gid=>5) mon[:resource].should eql("VM_POOL") monitoring = mon[:monitoring] - monitoring[:total].size.should eql(1) - monitoring[:total].first.should eql([300,1]) + monitoring[:total].size.should eql(3) + monitoring[:total].first.should eql([100,0]) + monitoring[:total][1].should eql([200,0]) + monitoring[:total][2].should eql([300,1]) - monitoring[:active].size.should eql(1) - monitoring[:active].first.should eql([300,1]) + monitoring[:active].size.should eql(3) + monitoring[:active].first.should eql([100,0]) + monitoring[:active][1].should eql([200,0]) + monitoring[:active][2].should eql([300,1]) - monitoring[:error].size.should eql(0) + monitoring[:error].size.should eql(3) + monitoring[:error].first.should eql([100,0]) + monitoring[:error][1].should eql([200,0]) + monitoring[:error][2].should eql([300,0]) - monitoring[:cpu_usage].size.should eql(1) - monitoring[:cpu_usage].first.should eql([90,1]) + monitoring[:cpu_usage].size.should eql(3) + monitoring[:cpu_usage].first.should eql([100,0]) + monitoring[:cpu_usage][1].should eql([200,0]) + monitoring[:cpu_usage][2].should eql([300,1]) - monitoring[:mem_usage].size.should eql(1) - monitoring[:mem_usage].first.should eql([90,128]) + monitoring[:mem_usage].size.should eql(3) + monitoring[:mem_usage].first.should eql([100,0]) + monitoring[:mem_usage][1].should eql([200,0]) + monitoring[:mem_usage][2].should eql([300,128]) - monitoring[:net_tx].size.should eql(1) - monitoring[:net_tx].first.should eql([90,200]) + monitoring[:net_tx].size.should eql(3) + monitoring[:net_tx].first.should eql([100,0]) + monitoring[:net_tx][1].should eql([200,0]) + monitoring[:net_tx][2].should eql([300,200]) - monitoring[:net_rx].size.should eql(1) - monitoring[:net_rx].first.should eql([90,400]) + monitoring[:net_rx].size.should eql(3) + monitoring[:net_rx].first.should eql([100,0]) + monitoring[:net_rx][1].should eql([200,0]) + monitoring[:net_rx][2].should eql([300,400]) end - it "should check the total monitoring resources are filtered by user" do + it "should check the total monitoring resources are filtered by uid(2)" do mon = @watch_client.total_monitoring(nil, :uid=>2) mon[:resource].should eql("VM_POOL") @@ -375,22 +415,33 @@ describe "VmWatchClient tests" do monitoring[:active][1].should eql([200,2]) monitoring[:active].last.should eql([300,2]) - monitoring[:error].size.should eql(0) + monitoring[:error].size.should eql(3) + monitoring[:error].first.should eql([100,0]) + monitoring[:error][1].should eql([200,0]) + monitoring[:error][2].should eql([300,0]) - monitoring[:cpu_usage].size.should eql(1) - monitoring[:cpu_usage].first.should eql([90,1*2]) + monitoring[:cpu_usage].size.should eql(3) + monitoring[:cpu_usage].first.should eql([100,1]) + monitoring[:cpu_usage][1].should eql([200,2]) + monitoring[:cpu_usage][2].should eql([300,2]) - monitoring[:mem_usage].size.should eql(1) - monitoring[:mem_usage].first.should eql([90,128*2]) + monitoring[:mem_usage].size.should eql(3) + monitoring[:mem_usage].first.should eql([100,128]) + monitoring[:mem_usage][1].should eql([200,256]) + monitoring[:mem_usage][2].should eql([300,256]) - monitoring[:net_tx].size.should eql(1) - monitoring[:net_tx].first.should eql([90,200*2]) + monitoring[:net_tx].size.should eql(3) + monitoring[:net_tx].first.should eql([100,200]) + monitoring[:net_tx][1].should eql([200,400]) + monitoring[:net_tx][2].should eql([300,400]) - monitoring[:net_rx].size.should eql(1) - monitoring[:net_rx].first.should eql([90,400*2]) + monitoring[:net_rx].size.should eql(3) + monitoring[:net_rx].first.should eql([100,400]) + monitoring[:net_rx][1].should eql([200,800]) + monitoring[:net_rx][2].should eql([300,800]) end - it "should check the total monitoring resources are filtered by group" do + it "should check the total monitoring resources are filtered by gid(4)" do mon = @watch_client.total_monitoring(nil, :gid=>4) mon[:resource].should eql("VM_POOL") @@ -400,26 +451,37 @@ describe "VmWatchClient tests" do monitoring[:total].size.should eql(3) monitoring[:total].first.should eql([100,1]) monitoring[:total][1].should eql([200,2]) - monitoring[:active].last.should eql([300,2]) + monitoring[:total].last.should eql([300,2]) monitoring[:active].size.should eql(3) monitoring[:active].first.should eql([100,1]) monitoring[:active][1].should eql([200,2]) monitoring[:active].last.should eql([300,2]) - monitoring[:error].size.should eql(0) + monitoring[:error].size.should eql(3) + monitoring[:error].first.should eql([100,0]) + monitoring[:error][1].should eql([200,0]) + monitoring[:error][2].should eql([300,0]) - monitoring[:cpu_usage].size.should eql(1) - monitoring[:cpu_usage].first.should eql([90,1*2]) + monitoring[:cpu_usage].size.should eql(3) + monitoring[:cpu_usage].first.should eql([100,1]) + monitoring[:cpu_usage][1].should eql([200,2]) + monitoring[:cpu_usage][2].should eql([300,2]) - monitoring[:mem_usage].size.should eql(1) - monitoring[:mem_usage].first.should eql([90,128*2]) + monitoring[:mem_usage].size.should eql(3) + monitoring[:mem_usage].first.should eql([100,128]) + monitoring[:mem_usage][1].should eql([200,256]) + monitoring[:mem_usage][2].should eql([300,256]) - monitoring[:net_tx].size.should eql(1) - monitoring[:net_tx].first.should eql([90,200*2]) + monitoring[:net_tx].size.should eql(3) + monitoring[:net_tx].first.should eql([100,200]) + monitoring[:net_tx][1].should eql([200,400]) + monitoring[:net_tx][2].should eql([300,400]) - monitoring[:net_rx].size.should eql(1) - monitoring[:net_rx].first.should eql([90,400*2]) + monitoring[:net_rx].size.should eql(3) + monitoring[:net_rx].first.should eql([100,400]) + monitoring[:net_rx][1].should eql([200,800]) + monitoring[:net_rx][2].should eql([300,800]) end it "should check no total info for non existing user" do @@ -429,18 +491,39 @@ describe "VmWatchClient tests" do monitoring = mon[:monitoring] - monitoring[:total].size.should eql(0) + monitoring[:total].size.should eql(3) + monitoring[:total].first.should eql([100,0]) + monitoring[:total][1].should eql([200,0]) + monitoring[:total].last.should eql([300,0]) - monitoring[:active].size.should eql(0) + monitoring[:active].size.should eql(3) + monitoring[:active].first.should eql([100,0]) + monitoring[:active][1].should eql([200,0]) + monitoring[:active].last.should eql([300,0]) - monitoring[:error].size.should eql(0) + monitoring[:error].size.should eql(3) + monitoring[:error].first.should eql([100,0]) + monitoring[:error][1].should eql([200,0]) + monitoring[:error][2].should eql([300,0]) - monitoring[:cpu_usage].size.should eql(0) + monitoring[:cpu_usage].size.should eql(3) + monitoring[:cpu_usage].first.should eql([100,0]) + monitoring[:cpu_usage][1].should eql([200,0]) + monitoring[:cpu_usage][2].should eql([300,0]) - monitoring[:mem_usage].size.should eql(0) + monitoring[:mem_usage].size.should eql(3) + monitoring[:mem_usage].first.should eql([100,0]) + monitoring[:mem_usage][1].should eql([200,0]) + monitoring[:mem_usage][2].should eql([300,0]) - monitoring[:net_tx].size.should eql(0) + monitoring[:net_tx].size.should eql(3) + monitoring[:net_tx].first.should eql([100,0]) + monitoring[:net_tx][1].should eql([200,0]) + monitoring[:net_tx][2].should eql([300,0]) - monitoring[:net_rx].size.should eql(0) + monitoring[:net_rx].size.should eql(3) + monitoring[:net_rx].first.should eql([100,0]) + monitoring[:net_rx][1].should eql([200,0]) + monitoring[:net_rx][2].should eql([300,0]) end end \ No newline at end of file diff --git a/src/acct/test/helper/test_helper.rb b/src/acct/test/helper/test_helper.rb index eab69fbf94..ef4b0948dd 100644 --- a/src/acct/test/helper/test_helper.rb +++ b/src/acct/test/helper/test_helper.rb @@ -18,7 +18,6 @@ $: << '..' require 'examples/acct_client' -require 'watch_client' require 'mock_client' require 'accounting' @@ -58,6 +57,8 @@ def clean_db WatchHelper::VmDelta.destroy WatchHelper::VmSample.destroy WatchHelper::HostSample.destroy + WatchHelper::VmTimestamp.destroy + WatchHelper::HostTimestamp.destroy WatchHelper::Vm.destroy WatchHelper::Host.destroy rescue Exception => e diff --git a/src/acct/test/monitoring_spec.rb b/src/acct/test/monitoring_spec.rb deleted file mode 100644 index f3f7272a17..0000000000 --- a/src/acct/test/monitoring_spec.rb +++ /dev/null @@ -1,102 +0,0 @@ -require 'helper/test_helper.rb' - -describe "1 Vm 1 10 steps" do - before(:each) do - clean_db - - @mock_client = MockClient.new - @monitoring = OneWatch::VmMonitoring.new - - @watch_client = OneWatchClient::WatchClient.new - - @db = WatchHelper::DB - @db[:vms].count.should eql(0) - end - - it "CPU testing" do - ts1 = 100 - @monitoring.set_mock_timestamp(ts1) - - @monitoring.insert(create_vmpool_hash) - @db[:vms].count.should eql(0) - - 10.times { |i| - ts2 = 200+100*i - @monitoring.set_mock_timestamp(ts2) - - values = { - :cpu => 80+i, - :memory => 122+i, - :net_tx => 200+i, - :net_rx => 134+i, - :last_poll => 1309275256+i, - :uid => 2, - :gid => 4, - :history => [ - :hid => 7, - :pstime => 150, - :petime => 0, - :rstime => 0, - :retime => 0, - :estime => 0, - :eetime => 0, - :reason => 0 - ] - } - - @mock_client.add_vm(1, values) - - @monitoring.insert(create_vmpool_hash) - @db[:vms].count.should eql(1) - @db[:vm_samples].count.should eql(1+i > 5 ? 5 : 1+i) - - @watch_client.vm_monitoring(1, ['cpu', 'net_tx']) - - @watch_client.vm_total - } - end - - it "Total testing" do - ts1 = 100 - @monitoring.set_mock_timestamp(ts1) - - @monitoring.insert(create_vmpool_hash) - @db[:vms].count.should eql(0) - - 10.times { |i| - ts2 = 200+100*i - @monitoring.set_mock_timestamp(ts2) - - values = { - :cpu => 80+i, - :memory => 122+i, - :net_tx => 200+i, - :net_rx => 134+i, - :state => 7, - :last_poll => 1309275256+i, - :uid => 2, - :gid => 4, - :history => [ - :hid => 7, - :pstime => 150, - :petime => 0, - :rstime => 0, - :retime => 0, - :estime => 0, - :eetime => 0, - :reason => 0 - ] - } - - values[:state] = 7 - @mock_client.add_vm(i+100, values) - values[:state] = 3 - @mock_client.add_vm(i+10, values) - - @monitoring.insert(create_vmpool_hash) - - @db[:vm_samples].count - total = @watch_client.vm_total([:total, :error, :active]) - } - end -end \ No newline at end of file diff --git a/src/acct/test/vm_monitoring_spec.rb b/src/acct/test/vm_monitoring_spec.rb new file mode 100644 index 0000000000..5465a238a8 --- /dev/null +++ b/src/acct/test/vm_monitoring_spec.rb @@ -0,0 +1,299 @@ +$: << '.' + +require 'helper/test_helper.rb' + +describe "VM Monitoring tests" do + before(:all) do + clean_db + + @mock_client = MockClient.new + @monitoring = OneWatch::VmMonitoring.new + + #@watch_client = OneWatchClient::WatchClient.new + + @db = WatchHelper::DB + @db[:vms].count.should eql(0) + @db[:vm_samples].count.should eql(0) + @db[:vm_timestamps].count.should eql(0) + end + + it "after monitoring an empty pool: 0 VMs, 0 Samples, 1 Timestamp" do + ts1 = 100 + @monitoring.set_mock_timestamp(ts1) + + @monitoring.insert(create_vmpool_hash) + @db[:vms].count.should eql(0) + @db[:vm_samples].count.should eql(0) + @db[:vm_timestamps].count.should eql(1) + end + + it "after monitoring a pool of 1 VM: 1 VMs, 1 Samples, 2 Timestamp" do + values = { + :cpu => 80, + :memory => 122, + :net_tx => 200, + :net_rx => 134, + :last_poll => 1309275256, + :uid => 2, + :gid => 4, + :history => [ + :hid => 7, + :pstime => 150, + :petime => 0, + :rstime => 0, + :retime => 0, + :estime => 0, + :eetime => 0, + :reason => 0 + ] + } + + @mock_client.add_vm(0, values) + + ts2 = 200 + @monitoring.set_mock_timestamp(ts2) + + @monitoring.insert(create_vmpool_hash) + @db[:vms].count.should eql(1) + @db[:vm_samples].count.should eql(1) + @db[:vm_timestamps].count.should eql(2) + end + + it "after monitoring a pool of 1 VM: 1 VMs, 2 Samples, 3 Timestamp" do + values = { + :cpu => 80, + :memory => 122, + :net_tx => 200, + :net_rx => 134, + :last_poll => 1309275256, + :uid => 2, + :gid => 4, + :history => [ + :hid => 7, + :pstime => 150, + :petime => 0, + :rstime => 0, + :retime => 0, + :estime => 0, + :eetime => 0, + :reason => 0 + ] + } + + @mock_client.add_vm(0, values) + + ts = 300 + @monitoring.set_mock_timestamp(ts) + + @monitoring.insert(create_vmpool_hash) + @db[:vms].count.should eql(1) + @db[:vm_samples].count.should eql(2) + @db[:vm_timestamps].count.should eql(3) + end + + it "after monitoring a pool of 2 VM: 2 VMs, 4 Samples, 4 Timestamp" do + values = { + :cpu => 80, + :memory => 122, + :net_tx => 200, + :net_rx => 134, + :last_poll => 1309275256, + :uid => 2, + :gid => 4, + :history => [ + :hid => 7, + :pstime => 150, + :petime => 0, + :rstime => 0, + :retime => 0, + :estime => 0, + :eetime => 0, + :reason => 0 + ] + } + + @mock_client.add_vm(1, values) + + ts = 400 + @monitoring.set_mock_timestamp(ts) + + @monitoring.insert(create_vmpool_hash) + @db[:vms].count.should eql(2) + @db[:vm_samples].count.should eql(4) + @db[:vm_timestamps].count.should eql(4) + end + + it "after monitoring a pool of 2 VM: 2 VMs, 6 Samples, 5 Timestamp" do + values = { + :cpu => 80, + :memory => 122, + :net_tx => 200, + :net_rx => 134, + :last_poll => 1309275256, + :uid => 2, + :gid => 4, + :history => [ + :hid => 7, + :pstime => 150, + :petime => 0, + :rstime => 0, + :retime => 0, + :estime => 0, + :eetime => 0, + :reason => 0 + ] + } + + @mock_client.add_vm(1, values) + + ts = 500 + @monitoring.set_mock_timestamp(ts) + + @monitoring.insert(create_vmpool_hash) + @db[:vms].count.should eql(2) + @db[:vm_samples].count.should eql(6) + @db[:vm_timestamps].count.should eql(5) + end + + it "after monitoring a pool of 3 VM: 3 VMs, 9 Samples, 5 Timestamp" do + values = { + :cpu => 80, + :memory => 122, + :net_tx => 200, + :net_rx => 134, + :last_poll => 1309275256, + :uid => 2, + :gid => 4, + :history => [ + :hid => 7, + :pstime => 150, + :petime => 0, + :rstime => 0, + :retime => 0, + :estime => 0, + :eetime => 0, + :reason => 0 + ] + } + + @mock_client.add_vm(2, values) + + ts = 600 + @monitoring.set_mock_timestamp(ts) + + @monitoring.insert(create_vmpool_hash) + @db[:vms].count.should eql(3) + @db[:vm_samples].count.should eql(9) + @db[:vm_timestamps].count.should eql(5) + end + + it "after monitoring a pool of 3 VM: 3 VMs, 11 Samples, 5 Timestamp" do + values = { + :cpu => 80, + :memory => 122, + :net_tx => 200, + :net_rx => 134, + :last_poll => 1309275256, + :uid => 2, + :gid => 4, + :history => [ + :hid => 7, + :pstime => 150, + :petime => 0, + :rstime => 0, + :retime => 0, + :estime => 0, + :eetime => 0, + :reason => 0 + ] + } + + @mock_client.add_vm(2, values) + + ts = 700 + @monitoring.set_mock_timestamp(ts) + + @monitoring.insert(create_vmpool_hash) + @db[:vms].count.should eql(3) + @db[:vm_samples].count.should eql(11) + @db[:vm_timestamps].count.should eql(5) + end + + + it "after monitoring a pool of 3 VM: 3 VMs, 13 Samples, 5 Timestamp" do + values = { + :cpu => 80, + :memory => 122, + :net_tx => 200, + :net_rx => 134, + :last_poll => 1309275256, + :uid => 2, + :gid => 4, + :history => [ + :hid => 7, + :pstime => 150, + :petime => 0, + :rstime => 0, + :retime => 0, + :estime => 0, + :eetime => 0, + :reason => 0 + ] + } + + @mock_client.add_vm(2, values) + + ts = 800 + @monitoring.set_mock_timestamp(ts) + + @monitoring.insert(create_vmpool_hash) + @db[:vms].count.should eql(3) + @db[:vm_samples].count.should eql(13) + @db[:vm_timestamps].count.should eql(5) + end + + it "after monitoring a pool of 4 VM: 4 VMs, 16 Samples, 5 Timestamp" do + values = { + :cpu => 80, + :memory => 122, + :net_tx => 200, + :net_rx => 134, + :last_poll => 1309275256, + :uid => 2, + :gid => 4, + :history => [ + :hid => 7, + :pstime => 150, + :petime => 0, + :rstime => 0, + :retime => 0, + :estime => 0, + :eetime => 0, + :reason => 0 + ] + } + + @mock_client.add_vm(3, values) + + ts = 900 + @monitoring.set_mock_timestamp(ts) + + @monitoring.insert(create_vmpool_hash) + @db[:vms].count.should eql(4) + @db[:vm_samples].count.should eql(15) + @db[:vm_timestamps].count.should eql(5) + end + + it "after (10)monitoring a pool of 4 VM: 4 VMs, 20 Samples, 5 Timestamp" do + 10.times { |i| + ts = 1000+i*100 + @monitoring.set_mock_timestamp(ts) + + @monitoring.insert(create_vmpool_hash) + } + + @db[:vms].count.should eql(4) + @db[:vm_samples].count.should eql(20) + @db[:vm_timestamps].count.should eql(5) + end +end \ No newline at end of file From e1d6264ea88a0b64c8cb13704cb9a418bc1e0718 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 14 Sep 2011 18:06:03 +0200 Subject: [PATCH 28/90] bug #716: Fix bug in host monitoring client(cherry picked from commit 16424e9a52632b734af6de789c8b168caf78319c) --- src/acct/watch_client.rb | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/acct/watch_client.rb b/src/acct/watch_client.rb index 36efadb078..0ff9c4f7c0 100644 --- a/src/acct/watch_client.rb +++ b/src/acct/watch_client.rb @@ -97,18 +97,11 @@ module OneWatchClient # Get the MAX for each VM and last_poll value max_per_vm = rsql. - group(:vm_id, :timestamp). - select{[:timestamp, max(mr.to_sym).as(:max_mr)]} - - # SUM the monitoring resource for each last_poll value - last_poll_and_sum = - max_per_vm. - from_self. group(:timestamp). - select{[:timestamp, sum(:max_mr).as(:sum_mr)]} + select{[:timestamp, sum(mr.to_sym).as(:sum_mr)]} # Add all the existing timestamps - with_ts = timestamps.left_join(last_poll_and_sum, :timestamp=>:id) + with_ts = timestamps.left_join(max_per_vm, :timestamp=>:id) with_ts.collect do |row| [row[:id], row[:sum_mr].to_i] end @@ -166,7 +159,7 @@ module OneWatchClient hosts = pool end - WatchHelper::HostSample.join(vms.select(:id.as(:host_id)), [:host_id]) + WatchHelper::HostSample.join(hosts.select(:id.as(:host_id)), [:host_id]) end def filter_resource(id, filter) From 96a539d481767365d0e13beca2ee5d727e535196 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 14 Sep 2011 18:25:06 +0200 Subject: [PATCH 29/90] bug #716: Fix constant name(cherry picked from commit 6cc9a076a881b725ac1222d0a5ea9550e537005f) --- src/acct/watch_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/acct/watch_helper.rb b/src/acct/watch_helper.rb index 439606dd6c..8a87182d39 100644 --- a/src/acct/watch_helper.rb +++ b/src/acct/watch_helper.rb @@ -413,7 +413,7 @@ module WatchHelper unrestrict_primary_key # Monitoring - one_to_many :samples, :order=>:timestamp, :class=>:HostSample + one_to_many :samples, :order=>:timestamp, :class=>"WatchHelper::HostSample" @@samples_cache = [] From 459b41fb425c9f343b11e0b98b66d78c96e2e28f Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Thu, 15 Sep 2011 12:54:29 +0200 Subject: [PATCH 30/90] Bug #811: Image delete does not use the old image repo anymore (cherry picked from commit c8c82f03783c5f297fa8db4bc3fad54a335d6738) --- src/cloud/occi/lib/OCCIServer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cloud/occi/lib/OCCIServer.rb b/src/cloud/occi/lib/OCCIServer.rb index f86f90dda5..9ba674a869 100755 --- a/src/cloud/occi/lib/OCCIServer.rb +++ b/src/cloud/occi/lib/OCCIServer.rb @@ -563,7 +563,7 @@ class OCCIServer < CloudServer return rc, 404 if OpenNebula::is_error?(rc) # --- Delete the Image --- - rc = @img_repo.delete(image) + rc = image.delete return rc, 500 if OpenNebula::is_error?(rc) return "", 204 From 954715074aecf27e0ff0c0a196c0872d37dd5611 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 15 Sep 2011 14:07:22 +0200 Subject: [PATCH 31/90] Bug #805: Saveas images are now left in lock state (cherry picked from commit 4ff07776d812cc86cd900f6c38ddf5862ec7618a) --- src/image/ImageManagerActions.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/image/ImageManagerActions.cc b/src/image/ImageManagerActions.cc index 9d88e98ea1..1d3cdd8dec 100644 --- a/src/image/ImageManagerActions.cc +++ b/src/image/ImageManagerActions.cc @@ -382,11 +382,16 @@ int ImageManager::register_image(int iid) } else { - img->set_state(Image::READY); - ipool->update(img); + string source = img->get_source(); - oss << "Using source " << img->get_source() - << " from template for image " << img->get_name(); + if (source != "-") //SAVE_AS IMAGE DO NOT ENABLE THE IMAGE + { + img->set_state(Image::READY); + ipool->update(img); + + oss << "Using source " << img->get_source() + << " from template for image " << img->get_name(); + } } } else //PATH -> COPY TO REPOSITORY AS SOURCE From 1abd55d030c07daa498118b9d6f0b28a93919da3 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Tue, 12 Jul 2011 18:08:07 +0200 Subject: [PATCH 32/90] feature #715: changed tm_nfs name to tm_shared (cherry picked from commit 67d278990b282e98f2968b204cc44b2e3e324f8d) --- install.sh | 30 +++++++++---------- share/etc/oned.conf | 6 ++-- src/mad/ruby/test/fixtures/var/config | 2 +- src/oca/java/test/oned.conf | 6 ++-- src/onedb/test/oned.conf | 6 ++-- src/scheduler/src/pool/test/HostXMLTest.cc | 10 +++---- .../src/pool/test/VirtualMachineXMLTest.cc | 10 +++---- src/sunstone/public/js/plugins/hosts-tab.js | 2 +- src/tm_mad/{nfs => shared}/tm_clone.sh | 0 src/tm_mad/{nfs => shared}/tm_context.sh | 0 src/tm_mad/{nfs => shared}/tm_delete.sh | 0 src/tm_mad/{nfs => shared}/tm_ln.sh | 0 src/tm_mad/{nfs => shared}/tm_mkimage.sh | 0 src/tm_mad/{nfs => shared}/tm_mkswap.sh | 0 src/tm_mad/{nfs => shared}/tm_mv.sh | 0 .../tm_nfs.conf => shared/tm_shared.conf} | 14 ++++----- .../{nfs/tm_nfsrc => shared/tm_sharedrc} | 0 src/vnm_mad/test/output/onevm_show | 2 +- src/xml/test/ObjectXMLTest.cc | 2 +- 19 files changed, 45 insertions(+), 45 deletions(-) rename src/tm_mad/{nfs => shared}/tm_clone.sh (100%) rename src/tm_mad/{nfs => shared}/tm_context.sh (100%) rename src/tm_mad/{nfs => shared}/tm_delete.sh (100%) rename src/tm_mad/{nfs => shared}/tm_ln.sh (100%) rename src/tm_mad/{nfs => shared}/tm_mkimage.sh (100%) rename src/tm_mad/{nfs => shared}/tm_mkswap.sh (100%) rename src/tm_mad/{nfs => shared}/tm_mv.sh (100%) rename src/tm_mad/{nfs/tm_nfs.conf => shared/tm_shared.conf} (85%) rename src/tm_mad/{nfs/tm_nfsrc => shared/tm_sharedrc} (100%) diff --git a/install.sh b/install.sh index 8a28e0d9cd..4628a9a348 100755 --- a/install.sh +++ b/install.sh @@ -185,7 +185,7 @@ ETC_DIRS="$ETC_LOCATION/im_kvm \ $ETC_LOCATION/im_ec2 \ $ETC_LOCATION/vmm_ec2 \ $ETC_LOCATION/vmm_exec \ - $ETC_LOCATION/tm_nfs \ + $ETC_LOCATION/tm_shared \ $ETC_LOCATION/tm_ssh \ $ETC_LOCATION/tm_dummy \ $ETC_LOCATION/tm_lvm \ @@ -204,7 +204,7 @@ LIB_DIRS="$LIB_LOCATION/ruby \ $LIB_LOCATION/ruby/cloud/occi \ $LIB_LOCATION/ruby/onedb \ $LIB_LOCATION/tm_commands \ - $LIB_LOCATION/tm_commands/nfs \ + $LIB_LOCATION/tm_commands/shared \ $LIB_LOCATION/tm_commands/ssh \ $LIB_LOCATION/tm_commands/dummy \ $LIB_LOCATION/tm_commands/lvm \ @@ -336,7 +336,7 @@ INSTALL_FILES=( VMM_EXEC_XEN_KVM_POLL:$VAR_LOCATION/remotes/vmm/xen/poll VMM_EXEC_GANGLIA_POLL:$VAR_LOCATION/remotes/vmm/kvm/poll_local VMM_EXEC_GANGLIA_POLL:$VAR_LOCATION/remotes/vmm/xen/poll_local - NFS_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/nfs + SHARED_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/shared SSH_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/ssh DUMMY_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/dummy LVM_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/lvm @@ -445,7 +445,7 @@ INSTALL_ETC_FILES=( VMM_EC2_ETC_FILES:$ETC_LOCATION/vmm_ec2 VMM_EXEC_ETC_FILES:$ETC_LOCATION/vmm_exec IM_EC2_ETC_FILES:$ETC_LOCATION/im_ec2 - TM_NFS_ETC_FILES:$ETC_LOCATION/tm_nfs + TM_SHARED_ETC_FILES:$ETC_LOCATION/tm_shared TM_SSH_ETC_FILES:$ETC_LOCATION/tm_ssh TM_DUMMY_ETC_FILES:$ETC_LOCATION/tm_dummy TM_LVM_ETC_FILES:$ETC_LOCATION/tm_lvm @@ -609,19 +609,19 @@ AUTH_QUOTA_FILES="src/authm_mad/remotes/quota/authorize" #------------------------------------------------------------------------------- # Transfer Manager commands, to be installed under $LIB_LOCATION/tm_commands -# - NFS TM, $LIB_LOCATION/tm_commands/nfs +# - SHARED TM, $LIB_LOCATION/tm_commands/shared # - SSH TM, $LIB_LOCATION/tm_commands/ssh # - dummy TM, $LIB_LOCATION/tm_commands/dummy # - LVM TM, $LIB_LOCATION/tm_commands/lvm #------------------------------------------------------------------------------- -NFS_TM_COMMANDS_LIB_FILES="src/tm_mad/nfs/tm_clone.sh \ - src/tm_mad/nfs/tm_delete.sh \ - src/tm_mad/nfs/tm_ln.sh \ - src/tm_mad/nfs/tm_mkswap.sh \ - src/tm_mad/nfs/tm_mkimage.sh \ - src/tm_mad/nfs/tm_mv.sh \ - src/tm_mad/nfs/tm_context.sh" +SHARED_TM_COMMANDS_LIB_FILES="src/tm_mad/shared/tm_clone.sh \ + src/tm_mad/shared/tm_delete.sh \ + src/tm_mad/shared/tm_ln.sh \ + src/tm_mad/shared/tm_mkswap.sh \ + src/tm_mad/shared/tm_mkimage.sh \ + src/tm_mad/shared/tm_mv.sh \ + src/tm_mad/shared/tm_context.sh" SSH_TM_COMMANDS_LIB_FILES="src/tm_mad/ssh/tm_clone.sh \ src/tm_mad/ssh/tm_delete.sh \ @@ -691,14 +691,14 @@ IM_EC2_ETC_FILES="src/im_mad/ec2/im_ec2rc \ #------------------------------------------------------------------------------- # Storage drivers config. files, to be installed under $ETC_LOCATION -# - nfs, $ETC_LOCATION/tm_nfs +# - shared, $ETC_LOCATION/tm_shared # - ssh, $ETC_LOCATION/tm_ssh # - dummy, $ETC_LOCATION/tm_dummy # - lvm, $ETC_LOCATION/tm_lvm #------------------------------------------------------------------------------- -TM_NFS_ETC_FILES="src/tm_mad/nfs/tm_nfs.conf \ - src/tm_mad/nfs/tm_nfsrc" +TM_SHARED_ETC_FILES="src/tm_mad/shared/tm_shared.conf \ + src/tm_mad/shared/tm_sharedrc" TM_SSH_ETC_FILES="src/tm_mad/ssh/tm_ssh.conf \ src/tm_mad/ssh/tm_sshrc" diff --git a/share/etc/oned.conf b/share/etc/oned.conf index 1f110b3b6d..762465c9df 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -254,12 +254,12 @@ VM_MAD = [ #******************************************************************************* #------------------------------------------------------------------------------- -# NFS Transfer Manager Driver Configuration +# SHARED Transfer Manager Driver Configuration #------------------------------------------------------------------------------- TM_MAD = [ - name = "tm_nfs", + name = "tm_shared", executable = "one_tm", - arguments = "tm_nfs/tm_nfs.conf" ] + arguments = "tm_shared/tm_shared.conf" ] #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- diff --git a/src/mad/ruby/test/fixtures/var/config b/src/mad/ruby/test/fixtures/var/config index bc785fa891..58ddb96adf 100644 --- a/src/mad/ruby/test/fixtures/var/config +++ b/src/mad/ruby/test/fixtures/var/config @@ -12,7 +12,7 @@ MANAGER_TIMER=15 NETWORK_SIZE=254 PORT=2633 SCRIPTS_REMOTE_DIR=/var/tmp/one -TM_MAD=ARGUMENTS=tm_nfs/tm_nfs.conf,EXECUTABLE=one_tm,NAME=tm_nfs +TM_MAD=ARGUMENTS=tm_shared/tm_shared.conf,EXECUTABLE=one_tm,NAME=tm_shared VM_DIR=/Users/jfontan/tmp/borrar/git/one/install/var/ VM_MAD=ARGUMENTS=-t 15 -r 0 kvm,DEFAULT=vmm_ssh/vmm_ssh_kvm.conf,EXECUTABLE=one_vmm_ssh,NAME=vmm_kvm,TYPE=kvm VM_POLLING_INTERVAL=600 diff --git a/src/oca/java/test/oned.conf b/src/oca/java/test/oned.conf index cc7eb53924..4a82a75f18 100644 --- a/src/oca/java/test/oned.conf +++ b/src/oca/java/test/oned.conf @@ -250,12 +250,12 @@ VM_MAD = [ name="vmm_dummy", executable="one_vmm_dummy", type="xml" ] #******************************************************************************* #------------------------------------------------------------------------------- -# NFS Transfer Manager Driver Configuration +# SHARED Transfer Manager Driver Configuration #------------------------------------------------------------------------------- TM_MAD = [ - name = "tm_nfs", + name = "tm_shared", executable = "one_tm", - arguments = "tm_nfs/tm_nfs.conf" ] + arguments = "tm_shared/tm_shared.conf" ] #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- diff --git a/src/onedb/test/oned.conf b/src/onedb/test/oned.conf index 1394fcdd2a..e8a6aca4f9 100644 --- a/src/onedb/test/oned.conf +++ b/src/onedb/test/oned.conf @@ -245,12 +245,12 @@ VM_MAD = [ name="vmm_dummy", executable="one_vmm_dummy", type="xml" ] #******************************************************************************* #------------------------------------------------------------------------------- -# NFS Transfer Manager Driver Configuration +# SHARED Transfer Manager Driver Configuration #------------------------------------------------------------------------------- #TM_MAD = [ -# name = "tm_nfs", +# name = "tm_shared", # executable = "one_tm", -# arguments = "tm_nfs/tm_nfs.conf" ] +# arguments = "tm_shared/tm_shared.conf" ] #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- diff --git a/src/scheduler/src/pool/test/HostXMLTest.cc b/src/scheduler/src/pool/test/HostXMLTest.cc index 2d47c9e5e4..b928f52679 100644 --- a/src/scheduler/src/pool/test/HostXMLTest.cc +++ b/src/scheduler/src/pool/test/HostXMLTest.cc @@ -266,7 +266,7 @@ const string FriendHostPool::xmls[] = 2\ im_kvm\ vmm_kvm\ - tm_nfs\ + tm_shared\ 1274107238\ \ 1\ @@ -307,7 +307,7 @@ const string FriendHostPool::xmls[] = 2\ im_kvm\ vmm_kvm\ - tm_nfs\ + tm_shared\ 1274107299\ \ 2\ @@ -350,7 +350,7 @@ const string FriendHostPool::xmls[] = 2\ im_kvm\ vmm_kvm\ - tm_nfs\ + tm_shared\ 1274107328\ \ 4\ @@ -391,7 +391,7 @@ const string FriendHostPool::xmls[] = 2\ im_kvm\ vmm_kvm\ - tm_nfs\ + tm_shared\ 1274107300\ \ 5\ @@ -428,6 +428,6 @@ const string FriendHostPool::xmls[] = }; const string FriendHostPool::host_dump = -" 1 ursa12 2 im_kvm vmm_kvm tm_nfs 1274107145 1 0 0 0 0 8194368 800 0 7955180 800 0 535848 0 0 2 ursa 2 im_kvm vmm_kvm tm_nfs 1274107206 2 0 4280320 700 0 16468252 800 0 9109156 628 0 13891232 172 7 4 ursa11 2 im_kvm vmm_kvm tm_nfs 1274107145 4 0 0 0 0 8194368 800 0 7958684 800 0 621616 0 0 5 ursa10 2 im_kvm vmm_kvm tm_nfs 1274107207 5 0 0 0 0 8194368 800 0 7870776 796 0 2192424 4 0 6 ursa08 3 im_kvm vmm_kvm tm_nfs 1274107176 6 0 0 0 0 0 0 0 6585200 0 0 1132608 0 0 7 ursa09 3 im_kvm vmm_kvm tm_nfs 1274107146 7 0 524288 100 0 8194368 800 0 7286128 798 0 8011908 1 1 "; +" 1 ursa12 2 im_kvm vmm_kvm tm_shared 1274107145 1 0 0 0 0 8194368 800 0 7955180 800 0 535848 0 0 2 ursa 2 im_kvm vmm_kvm tm_shared 1274107206 2 0 4280320 700 0 16468252 800 0 9109156 628 0 13891232 172 7 4 ursa11 2 im_kvm vmm_kvm tm_shared 1274107145 4 0 0 0 0 8194368 800 0 7958684 800 0 621616 0 0 5 ursa10 2 im_kvm vmm_kvm tm_shared 1274107207 5 0 0 0 0 8194368 800 0 7870776 796 0 2192424 4 0 6 ursa08 3 im_kvm vmm_kvm tm_shared 1274107176 6 0 0 0 0 0 0 0 6585200 0 0 1132608 0 0 7 ursa09 3 im_kvm vmm_kvm tm_shared 1274107146 7 0 524288 100 0 8194368 800 0 7286128 798 0 8011908 1 1 "; diff --git a/src/scheduler/src/pool/test/VirtualMachineXMLTest.cc b/src/scheduler/src/pool/test/VirtualMachineXMLTest.cc index d28823a547..5780793a7c 100644 --- a/src/scheduler/src/pool/test/VirtualMachineXMLTest.cc +++ b/src/scheduler/src/pool/test/VirtualMachineXMLTest.cc @@ -333,7 +333,7 @@ const string FriendHostPool::xmls[] = 2\ im_kvm\ vmm_kvm\ - tm_nfs\ + tm_shared\ 1274107238\ \ 1\ @@ -374,7 +374,7 @@ const string FriendHostPool::xmls[] = 2\ im_kvm\ vmm_kvm\ - tm_nfs\ + tm_shared\ 1274107299\ \ 2\ @@ -417,7 +417,7 @@ const string FriendHostPool::xmls[] = 2\ im_kvm\ vmm_kvm\ - tm_nfs\ + tm_shared\ 1274107328\ \ 4\ @@ -458,7 +458,7 @@ const string FriendHostPool::xmls[] = 2\ im_kvm\ vmm_kvm\ - tm_nfs\ + tm_shared\ 1274107300\ \ 5\ @@ -495,6 +495,6 @@ const string FriendHostPool::xmls[] = }; const string FriendHostPool::host_dump = -" 1 ursa12 2 im_kvm vmm_kvm tm_nfs 1274107145 1 0 0 0 0 8194368 800 0 7955180 800 0 535848 0 0 2 ursa 2 im_kvm vmm_kvm tm_nfs 1274107206 2 0 4280320 700 0 16468252 800 0 9109156 628 0 13891232 172 7 4 ursa11 2 im_kvm vmm_kvm tm_nfs 1274107145 4 0 0 0 0 8194368 800 0 7958684 800 0 621616 0 0 5 ursa10 2 im_kvm vmm_kvm tm_nfs 1274107207 5 0 0 0 0 8194368 800 0 7870776 796 0 2192424 4 0 6 ursa08 3 im_kvm vmm_kvm tm_nfs 1274107176 6 0 0 0 0 0 0 0 6585200 0 0 1132608 0 0 7 ursa09 3 im_kvm vmm_kvm tm_nfs 1274107146 7 0 524288 100 0 8194368 800 0 7286128 798 0 8011908 1 1 "; +" 1 ursa12 2 im_kvm vmm_kvm tm_shared 1274107145 1 0 0 0 0 8194368 800 0 7955180 800 0 535848 0 0 2 ursa 2 im_kvm vmm_kvm tm_shared 1274107206 2 0 4280320 700 0 16468252 800 0 9109156 628 0 13891232 172 7 4 ursa11 2 im_kvm vmm_kvm tm_shared 1274107145 4 0 0 0 0 8194368 800 0 7958684 800 0 621616 0 0 5 ursa10 2 im_kvm vmm_kvm tm_shared 1274107207 5 0 0 0 0 8194368 800 0 7870776 796 0 2192424 4 0 6 ursa08 3 im_kvm vmm_kvm tm_shared 1274107176 6 0 0 0 0 0 0 0 6585200 0 0 1132608 0 0 7 ursa09 3 im_kvm vmm_kvm tm_shared 1274107146 7 0 524288 100 0 8194368 800 0 7286128 798 0 8011908 1 1 "; diff --git a/src/sunstone/public/js/plugins/hosts-tab.js b/src/sunstone/public/js/plugins/hosts-tab.js index 497e585f61..d3a09a0be7 100644 --- a/src/sunstone/public/js/plugins/hosts-tab.js +++ b/src/sunstone/public/js/plugins/hosts-tab.js @@ -83,7 +83,7 @@ var create_host_tmpl =
\ \ \ diff --git a/src/tm_mad/nfs/tm_clone.sh b/src/tm_mad/shared/tm_clone.sh similarity index 100% rename from src/tm_mad/nfs/tm_clone.sh rename to src/tm_mad/shared/tm_clone.sh diff --git a/src/tm_mad/nfs/tm_context.sh b/src/tm_mad/shared/tm_context.sh similarity index 100% rename from src/tm_mad/nfs/tm_context.sh rename to src/tm_mad/shared/tm_context.sh diff --git a/src/tm_mad/nfs/tm_delete.sh b/src/tm_mad/shared/tm_delete.sh similarity index 100% rename from src/tm_mad/nfs/tm_delete.sh rename to src/tm_mad/shared/tm_delete.sh diff --git a/src/tm_mad/nfs/tm_ln.sh b/src/tm_mad/shared/tm_ln.sh similarity index 100% rename from src/tm_mad/nfs/tm_ln.sh rename to src/tm_mad/shared/tm_ln.sh diff --git a/src/tm_mad/nfs/tm_mkimage.sh b/src/tm_mad/shared/tm_mkimage.sh similarity index 100% rename from src/tm_mad/nfs/tm_mkimage.sh rename to src/tm_mad/shared/tm_mkimage.sh diff --git a/src/tm_mad/nfs/tm_mkswap.sh b/src/tm_mad/shared/tm_mkswap.sh similarity index 100% rename from src/tm_mad/nfs/tm_mkswap.sh rename to src/tm_mad/shared/tm_mkswap.sh diff --git a/src/tm_mad/nfs/tm_mv.sh b/src/tm_mad/shared/tm_mv.sh similarity index 100% rename from src/tm_mad/nfs/tm_mv.sh rename to src/tm_mad/shared/tm_mv.sh diff --git a/src/tm_mad/nfs/tm_nfs.conf b/src/tm_mad/shared/tm_shared.conf similarity index 85% rename from src/tm_mad/nfs/tm_nfs.conf rename to src/tm_mad/shared/tm_shared.conf index bb980d7e48..1e09c41cff 100644 --- a/src/tm_mad/nfs/tm_nfs.conf +++ b/src/tm_mad/shared/tm_shared.conf @@ -14,10 +14,10 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -CLONE = nfs/tm_clone.sh -LN = nfs/tm_ln.sh -MKSWAP = nfs/tm_mkswap.sh -MKIMAGE = nfs/tm_mkimage.sh -DELETE = nfs/tm_delete.sh -MV = nfs/tm_mv.sh -CONTEXT = nfs/tm_context.sh +CLONE = shared/tm_clone.sh +LN = shared/tm_ln.sh +MKSWAP = shared/tm_mkswap.sh +MKIMAGE = shared/tm_mkimage.sh +DELETE = shared/tm_delete.sh +MV = shared/tm_mv.sh +CONTEXT = shared/tm_context.sh diff --git a/src/tm_mad/nfs/tm_nfsrc b/src/tm_mad/shared/tm_sharedrc similarity index 100% rename from src/tm_mad/nfs/tm_nfsrc rename to src/tm_mad/shared/tm_sharedrc diff --git a/src/vnm_mad/test/output/onevm_show b/src/vnm_mad/test/output/onevm_show index a64d22fa1b..ec56cbf225 100644 --- a/src/vnm_mad/test/output/onevm_show +++ b/src/vnm_mad/test/output/onevm_show @@ -62,7 +62,7 @@ 1304502543 0 vmm_kvm - tm_nfs + tm_shared 1304502543 1304502544 1304502544 diff --git a/src/xml/test/ObjectXMLTest.cc b/src/xml/test/ObjectXMLTest.cc index fd538203d3..977189c35b 100644 --- a/src/xml/test/ObjectXMLTest.cc +++ b/src/xml/test/ObjectXMLTest.cc @@ -434,7 +434,7 @@ const string ObjectXMLTest::host = "2" "im_kvm" "vmm_kvm" - "tm_nfs" + "tm_shared" "1273799044" "cluster A" "" From 7f88793fa9aadaf084043baa341024ce825c21bb Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 15 Sep 2011 17:43:13 +0200 Subject: [PATCH 33/90] bug #616: files copied in multiple dirs are now links --- install.sh | 15 ++++----------- src/vmm_mad/remotes/kvm/poll | 1 + src/vmm_mad/remotes/kvm/poll_local | 1 + src/vmm_mad/remotes/xen/poll | 1 + src/vmm_mad/remotes/xen/poll_local | 1 + 5 files changed, 8 insertions(+), 11 deletions(-) create mode 120000 src/vmm_mad/remotes/kvm/poll create mode 120000 src/vmm_mad/remotes/kvm/poll_local create mode 120000 src/vmm_mad/remotes/xen/poll create mode 120000 src/vmm_mad/remotes/xen/poll_local diff --git a/install.sh b/install.sh index 4628a9a348..d6bc746d5b 100755 --- a/install.sh +++ b/install.sh @@ -332,10 +332,6 @@ INSTALL_FILES=( AUTH_QUOTA_FILES:$VAR_LOCATION/remotes/auth/quota VMM_EXEC_KVM_SCRIPTS:$VAR_LOCATION/remotes/vmm/kvm VMM_EXEC_XEN_SCRIPTS:$VAR_LOCATION/remotes/vmm/xen - VMM_EXEC_XEN_KVM_POLL:$VAR_LOCATION/remotes/vmm/kvm/poll - VMM_EXEC_XEN_KVM_POLL:$VAR_LOCATION/remotes/vmm/xen/poll - VMM_EXEC_GANGLIA_POLL:$VAR_LOCATION/remotes/vmm/kvm/poll_local - VMM_EXEC_GANGLIA_POLL:$VAR_LOCATION/remotes/vmm/xen/poll_local SHARED_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/shared SSH_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/ssh DUMMY_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/dummy @@ -552,6 +548,8 @@ VMM_EXEC_KVM_SCRIPTS="src/vmm_mad/remotes/kvm/cancel \ src/vmm_mad/remotes/kvm/migrate_local \ src/vmm_mad/remotes/kvm/restore \ src/vmm_mad/remotes/kvm/save \ + src/vmm_mad/remotes/kvm/poll \ + src/vmm_mad/remotes/kvm/poll_local \ src/vmm_mad/remotes/kvm/shutdown" #------------------------------------------------------------------------------- @@ -564,15 +562,10 @@ VMM_EXEC_XEN_SCRIPTS="src/vmm_mad/remotes/xen/cancel \ src/vmm_mad/remotes/xen/migrate \ src/vmm_mad/remotes/xen/restore \ src/vmm_mad/remotes/xen/save \ + src/vmm_mad/remotes/xen/poll \ + src/vmm_mad/remotes/xen/poll_local \ src/vmm_mad/remotes/xen/shutdown" -#----------------------------------------------------------------------------- -# VMM SH Driver xen/kvm scripts, to be installed under $REMOTES_LOCATION/vmm/* -#----------------------------------------------------------------------------- - -VMM_EXEC_XEN_KVM_POLL="src/vmm_mad/remotes/poll_xen_kvm.rb" -VMM_EXEC_GANGLIA_POLL="src/vmm_mad/remotes/poll_ganglia.rb" - #------------------------------------------------------------------------------- # Information Manager Probes, to be installed under $REMOTES_LOCATION/im #------------------------------------------------------------------------------- diff --git a/src/vmm_mad/remotes/kvm/poll b/src/vmm_mad/remotes/kvm/poll new file mode 120000 index 0000000000..fb5e9b8f73 --- /dev/null +++ b/src/vmm_mad/remotes/kvm/poll @@ -0,0 +1 @@ +../poll_xen_kvm.rb \ No newline at end of file diff --git a/src/vmm_mad/remotes/kvm/poll_local b/src/vmm_mad/remotes/kvm/poll_local new file mode 120000 index 0000000000..ca1f0231c9 --- /dev/null +++ b/src/vmm_mad/remotes/kvm/poll_local @@ -0,0 +1 @@ +../poll_ganglia.rb \ No newline at end of file diff --git a/src/vmm_mad/remotes/xen/poll b/src/vmm_mad/remotes/xen/poll new file mode 120000 index 0000000000..fb5e9b8f73 --- /dev/null +++ b/src/vmm_mad/remotes/xen/poll @@ -0,0 +1 @@ +../poll_xen_kvm.rb \ No newline at end of file diff --git a/src/vmm_mad/remotes/xen/poll_local b/src/vmm_mad/remotes/xen/poll_local new file mode 120000 index 0000000000..ca1f0231c9 --- /dev/null +++ b/src/vmm_mad/remotes/xen/poll_local @@ -0,0 +1 @@ +../poll_ganglia.rb \ No newline at end of file From 5a39c6b5bd395758c68d6b6181110b9d39b52bcb Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 15 Sep 2011 17:50:49 +0200 Subject: [PATCH 34/90] poll_local is now called poll_ganglia --- src/vmm_mad/remotes/kvm/{poll_local => poll_ganglia} | 0 src/vmm_mad/remotes/xen/{poll_local => poll_ganglia} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/vmm_mad/remotes/kvm/{poll_local => poll_ganglia} (100%) rename src/vmm_mad/remotes/xen/{poll_local => poll_ganglia} (100%) diff --git a/src/vmm_mad/remotes/kvm/poll_local b/src/vmm_mad/remotes/kvm/poll_ganglia similarity index 100% rename from src/vmm_mad/remotes/kvm/poll_local rename to src/vmm_mad/remotes/kvm/poll_ganglia diff --git a/src/vmm_mad/remotes/xen/poll_local b/src/vmm_mad/remotes/xen/poll_ganglia similarity index 100% rename from src/vmm_mad/remotes/xen/poll_local rename to src/vmm_mad/remotes/xen/poll_ganglia From 91d554b3aa9d78008ecc4399c673325fa58a2309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 15 Sep 2011 19:06:16 +0200 Subject: [PATCH 35/90] Bug #804: Better image release rollback when a VM can't be created --- include/ImageManager.h | 21 ++++++++++++ include/ImagePool.h | 4 ++- src/image/ImageManagerActions.cc | 10 ++---- src/image/ImagePool.cc | 4 +-- src/vm/VirtualMachine.cc | 55 ++++++++++++++++++++++---------- 5 files changed, 67 insertions(+), 27 deletions(-) diff --git a/include/ImageManager.h b/include/ImageManager.h index 4e7daca0dd..de14c32455 100644 --- a/include/ImageManager.h +++ b/include/ImageManager.h @@ -96,6 +96,27 @@ public: void release_image(const string& iid, const string& disk_path, int disk_num, + const string& saveid) + { + int image_id; + istringstream iss; + + iss.str(iid); + iss >> image_id; + + return release_image(image_id, disk_path, disk_num, saveid); + }; + + /** + * Releases an image and triggers any needed operations in the repo + * @param iid image id of the image to be released + * @param disk_path base path for disk location + * @param disk number for this image in the VM + * @param saveid id of image to save the current image + */ + void release_image(int iid, + const string& disk_path, + int disk_num, const string& saveid); /** diff --git a/include/ImagePool.h b/include/ImagePool.h index d69a2f3a60..78052d7349 100644 --- a/include/ImagePool.h +++ b/include/ImagePool.h @@ -130,6 +130,7 @@ public: * automatically increased. * @param img_type will be set to the used image's type * @param uid of VM owner (to look for the image id within its images) + * @param image_id on success returns the acquired image id * @return 0 on success, * -1 error, * -2 not using the pool, @@ -139,7 +140,8 @@ public: int disk_id, int * index, Image::ImageType * img_type, - int uid); + int uid, + int& image_id); /** * Generates an Authorization token for the DISK attribute * @param disk the disk to be authorized diff --git a/src/image/ImageManagerActions.cc b/src/image/ImageManagerActions.cc index 1d3cdd8dec..769c8dffbf 100644 --- a/src/image/ImageManagerActions.cc +++ b/src/image/ImageManagerActions.cc @@ -141,14 +141,13 @@ void ImageManager::disk_to_image(const string& disk_path, /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -void ImageManager::release_image(const string& image_id, +void ImageManager::release_image(int iid, const string& disk_path, int disk_num, const string& save_id) { int rvms; - int iid; int sid = -1; istringstream iss; @@ -156,13 +155,8 @@ void ImageManager::release_image(const string& image_id, ostringstream disk_file; - iss.str(image_id); - - iss >> iid; - if ( save_id.empty() == false ) { - iss.clear(); iss.str(save_id); iss >> sid; @@ -180,7 +174,7 @@ void ImageManager::release_image(const string& image_id, case Image::USED: rvms = img->dec_running(); - if ( img->isPersistent() ) + if ( img->isPersistent() && !disk_path.empty() ) { disk_file << disk_path << "/disk." << disk_num; diff --git a/src/image/ImagePool.cc b/src/image/ImagePool.cc index 69931e6798..f64a0bb386 100644 --- a/src/image/ImagePool.cc +++ b/src/image/ImagePool.cc @@ -131,7 +131,8 @@ int ImagePool::disk_attribute(VectorAttribute * disk, int disk_id, int * index, Image::ImageType * img_type, - int uid) + int uid, + int& image_id) { string source; Image * img = 0; @@ -143,7 +144,6 @@ int ImagePool::disk_attribute(VectorAttribute * disk, ImageManager * imagem = nd.get_imagem(); istringstream is; - int image_id; source = disk->vector_value("IMAGE"); diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index 99a082ca9c..b7dbc1b66a 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -220,7 +220,7 @@ int VirtualMachine::insert(SqlDB * db, string& error_str) if ( rc != 0 ) { - goto error_leases; + goto error_leases_rollback; } // ------------------------------------------------------------------------ @@ -231,7 +231,9 @@ int VirtualMachine::insert(SqlDB * db, string& error_str) if ( rc != 0 ) { - goto error_images; + // The get_disk_images method has an internal rollback for + // the acquired images, release_disk_images() would release all disks + goto error_leases_rollback; } // ------------------------------------------------------------------------- @@ -269,26 +271,24 @@ int VirtualMachine::insert(SqlDB * db, string& error_str) error_update: error_str = "Can not insert VM in the database."; - goto error_common; - -error_leases: - NebulaLog::log("ONE",Log::ERROR, error_str); - release_network_leases(); - return -1; - -error_images: - goto error_common; + goto error_rollback; error_context: - goto error_common; + goto error_rollback; error_requirements: - goto error_common; + goto error_rollback; + +error_rollback: + release_disk_images(); + +error_leases_rollback: + release_network_leases(); + goto error_common; // just to avoid compilation warnings error_common: NebulaLog::log("ONE",Log::ERROR, error_str); - release_network_leases(); - release_disk_images(); + return -1; } @@ -663,11 +663,13 @@ int VirtualMachine::get_disk_images(string& error_str) vector disks; ImagePool * ipool; VectorAttribute * disk; + vector acquired_images; int n_os = 0; // Number of OS images int n_cd = 0; // Number of CDROMS int n_db = 0; // Number of DATABLOCKS string type; + int image_id; ostringstream oss; Image::ImageType img_type; @@ -686,10 +688,12 @@ int VirtualMachine::get_disk_images(string& error_str) continue; } - rc = ipool->disk_attribute(disk, i, &index, &img_type, uid); + rc = ipool->disk_attribute(disk, i, &index, &img_type, uid, image_id); if (rc == 0 ) { + acquired_images.push_back(image_id); + switch(img_type) { case Image::OS: @@ -728,6 +732,10 @@ int VirtualMachine::get_disk_images(string& error_str) { goto error_name; } + else if ( rc != -2 ) // The only known code left + { + goto error_unknown; + } } return 0; @@ -750,8 +758,23 @@ error_image: error_name: error_str = "IMAGE is not supported for DISK. Use IMAGE_ID instead."; + goto error_common; + +error_unknown: + error_str = "Unknown error code."; error_common: + ImageManager * imagem = nd.get_imagem(); + + vector::iterator it; + + for ( it=acquired_images.begin() ; it < acquired_images.end(); it++ ) + { + // Set disk_path and save_id to empty string, this way the image manager + // won't try to move any files + imagem->release_image(*it,"",-1,""); + } + return -1; } From 84a8d9e2821d45593b3a592be0aa2dc677f4c5a0 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 15 Sep 2011 23:15:13 +0200 Subject: [PATCH 36/90] Bug #804:removed unneeded return (cherry picked from commit 2fc3d7fbb4a49d89c088125435789d6cb962252f) --- include/ImageManager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ImageManager.h b/include/ImageManager.h index de14c32455..509a25f7d2 100644 --- a/include/ImageManager.h +++ b/include/ImageManager.h @@ -104,7 +104,7 @@ public: iss.str(iid); iss >> image_id; - return release_image(image_id, disk_path, disk_num, saveid); + release_image(image_id, disk_path, disk_num, saveid); }; /** From b4bb68be2e8442c65aaa6c1e125f34b83ccf1644 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 15 Sep 2011 23:15:54 +0200 Subject: [PATCH 37/90] Added execution permissions to driver file (cherry picked from commit 1ebae15af962f7dfe267724a6cd2d5b80f622fac) --- src/vmm_mad/remotes/kvm/migrate_local | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 src/vmm_mad/remotes/kvm/migrate_local diff --git a/src/vmm_mad/remotes/kvm/migrate_local b/src/vmm_mad/remotes/kvm/migrate_local old mode 100644 new mode 100755 From 6aa268d52fb6263db4d78864fbf4ccc365f59fcd Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 15 Sep 2011 23:16:13 +0200 Subject: [PATCH 38/90] Installs poll_ganglia instead of non-existent poll_local (cherry picked from commit 9a419d498cb7b6edd19995451dd110e478ac88d7) --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index d6bc746d5b..a0706fea87 100755 --- a/install.sh +++ b/install.sh @@ -549,7 +549,7 @@ VMM_EXEC_KVM_SCRIPTS="src/vmm_mad/remotes/kvm/cancel \ src/vmm_mad/remotes/kvm/restore \ src/vmm_mad/remotes/kvm/save \ src/vmm_mad/remotes/kvm/poll \ - src/vmm_mad/remotes/kvm/poll_local \ + src/vmm_mad/remotes/kvm/poll_ganglia \ src/vmm_mad/remotes/kvm/shutdown" #------------------------------------------------------------------------------- @@ -563,7 +563,7 @@ VMM_EXEC_XEN_SCRIPTS="src/vmm_mad/remotes/xen/cancel \ src/vmm_mad/remotes/xen/restore \ src/vmm_mad/remotes/xen/save \ src/vmm_mad/remotes/xen/poll \ - src/vmm_mad/remotes/xen/poll_local \ + src/vmm_mad/remotes/xen/poll_ganglia \ src/vmm_mad/remotes/xen/shutdown" #------------------------------------------------------------------------------- From c6a8c1fbdcc1d11df23f8ead30a1fd0df3d2630e Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 16 Sep 2011 11:52:55 +0200 Subject: [PATCH 39/90] bug #265: Failure actions will *NOT* remove VM files in the host. Host files will be removed from the remote host upon VM resubmition or deletion. This will let sysadmins to easily debug any failure or perform forensic analysis. --- src/dm/DispatchManagerActions.cc | 6 ++++-- src/lcm/LifeCycleActions.cc | 12 +++++++----- src/lcm/LifeCycleStates.cc | 5 +---- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/dm/DispatchManagerActions.cc b/src/dm/DispatchManagerActions.cc index 93d95a4ab1..37189b4a81 100644 --- a/src/dm/DispatchManagerActions.cc +++ b/src/dm/DispatchManagerActions.cc @@ -565,6 +565,7 @@ int DispatchManager::finalize( switch (state) { case VirtualMachine::SUSPENDED: + case VirtualMachine::FAILED: tm->trigger(TransferManager::EPILOG_DELETE,vid); case VirtualMachine::INIT: @@ -573,7 +574,6 @@ int DispatchManager::finalize( case VirtualMachine::STOPPED: vm->set_exit_time(time(0)); - case VirtualMachine::FAILED: vm->set_state(VirtualMachine::LCM_INIT); vm->set_state(VirtualMachine::DONE); vmpool->update(vm); @@ -608,6 +608,7 @@ int DispatchManager::resubmit(int vid) Nebula& nd = Nebula::instance(); LifeCycleManager * lcm = nd.get_lcm(); + TransferManager * tm = nd.get_tm(); vm = vmpool->get(vid,true); @@ -628,9 +629,10 @@ int DispatchManager::resubmit(int vid) case VirtualMachine::PENDING: break; + case VirtualMachine::FAILED: //Cleanup VM host files + tm->trigger(TransferManager::EPILOG_DELETE,vid); case VirtualMachine::HOLD: // Move the VM to PENDING in any of these case VirtualMachine::STOPPED: - case VirtualMachine::FAILED: vm->set_state(VirtualMachine::LCM_INIT); vm->set_state(VirtualMachine::PENDING); vmpool->update(vm); diff --git a/src/lcm/LifeCycleActions.cc b/src/lcm/LifeCycleActions.cc index 03683a2473..c415692bed 100644 --- a/src/lcm/LifeCycleActions.cc +++ b/src/lcm/LifeCycleActions.cc @@ -500,8 +500,7 @@ void LifeCycleManager::delete_action(int vid) VirtualMachine::LcmState state = vm->get_lcm_state(); if ((state == VirtualMachine::LCM_INIT) || - (state == VirtualMachine::CLEANUP) || - (state == VirtualMachine::FAILURE)) + (state == VirtualMachine::CLEANUP)) { vm->unlock(); return; @@ -535,8 +534,7 @@ void LifeCycleManager::clean_action(int vid) VirtualMachine::LcmState state = vm->get_lcm_state(); if ((state == VirtualMachine::LCM_INIT) || - (state == VirtualMachine::CLEANUP) || - (state == VirtualMachine::FAILURE)) + (state == VirtualMachine::CLEANUP)) { vm->unlock(); return; @@ -664,7 +662,11 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm) tm->trigger(TransferManager::EPILOG_DELETE,vid); break; - default: //FAILURE,LCM_INIT,CLEANUP + case VirtualMachine::FAILURE: + tm->trigger(TransferManager::EPILOG_DELETE,vid); + break; + + default: //LCM_INIT,CLEANUP break; } diff --git a/src/lcm/LifeCycleStates.cc b/src/lcm/LifeCycleStates.cc index ac01274093..5d9eb8dc61 100644 --- a/src/lcm/LifeCycleStates.cc +++ b/src/lcm/LifeCycleStates.cc @@ -778,7 +778,6 @@ void LifeCycleManager::monitor_done_action(int vid) void LifeCycleManager::failure_action(VirtualMachine * vm) { Nebula& nd = Nebula::instance(); - TransferManager * tm = nd.get_tm(); DispatchManager * dm = nd.get_dm(); time_t the_time = time(0); @@ -802,11 +801,9 @@ void LifeCycleManager::failure_action(VirtualMachine * vm) hpool->del_capacity(vm->get_hid(),cpu,mem,disk); - //------------- Clean up remote files ---------------- + //--- VM to FAILED. Remote host cleanup upon VM deletion --- dm->trigger(DispatchManager::FAILED,vm->get_oid()); - - tm->trigger(TransferManager::EPILOG_DELETE,vm->get_oid()); } /* -------------------------------------------------------------------------- */ From d582636e47688be98c78ff82243fd1338f59973a Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 16 Sep 2011 12:09:37 +0200 Subject: [PATCH 40/90] bug: wrong access to exitstatus (cherry picked from commit 1aad41ffe6990fad4f7a57d2291cb92d888216fb) --- src/mad/ruby/scripts_common.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mad/ruby/scripts_common.rb b/src/mad/ruby/scripts_common.rb index c5a7119b79..ba24205e20 100644 --- a/src/mad/ruby/scripts_common.rb +++ b/src/mad/ruby/scripts_common.rb @@ -53,7 +53,8 @@ module OpenNebula # the command fails def self.exec_and_log(command, message=nil) output=`#{command} 2>&1 1>/dev/null` - code=$? + code=$?.exitstatus + if code!=0 log_error "Command \"#{command}\" failed." log_error output From 770728fb2148b4dc9c26ca9a2a3a5e3c5dc4a30b Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 16 Sep 2011 12:23:22 +0200 Subject: [PATCH 41/90] bug #810: Gets device prefix from defaults if DEV_PREFIX attribute is removed from image template --- src/image/Image.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/image/Image.cc b/src/image/Image.cc index a66af4935c..ace9db96ba 100644 --- a/src/image/Image.cc +++ b/src/image/Image.cc @@ -433,6 +433,11 @@ int Image::disk_attribute( VectorAttribute * disk, get_template_attribute("DEV_PREFIX", prefix); + if (prefix.empty())//Removed from image template, get it again from defaults + { + prefix = ImagePool::default_dev_prefix(); + } + //--------------------------------------------------------------------------- // BASE DISK ATTRIBUTES //--------------------------------------------------------------------------- From da07254da7520c5ba386e3767001d217514c79af Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 16 Sep 2011 13:39:52 +0200 Subject: [PATCH 42/90] bug: fixes exitstatus access in Ruby scripts (cherry picked from commit db74e8532a219c2283019621062bbf812714b82c) --- src/cli/one_helper.rb | 3 ++- src/im_mad/remotes/kvm.d/kvm.rb | 6 +++--- src/im_mad/remotes/xen.d/xen.rb | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index f1ce493baa..8bd8d69115 100644 --- a/src/cli/one_helper.rb +++ b/src/cli/one_helper.rb @@ -398,7 +398,8 @@ EOT editor_path = ENV["EDITOR"] ? ENV["EDITOR"] : EDITOR_PATH system("#{editor_path} #{path}") - unless $?==0 + + unless $?.exitstatus == 0 puts "Editor not defined" exit -1 end diff --git a/src/im_mad/remotes/kvm.d/kvm.rb b/src/im_mad/remotes/kvm.d/kvm.rb index ec857ccfd2..9fd51c7eb6 100755 --- a/src/im_mad/remotes/kvm.d/kvm.rb +++ b/src/im_mad/remotes/kvm.d/kvm.rb @@ -27,7 +27,7 @@ end ###### nodeinfo_text = `virsh -c qemu:///system nodeinfo` -exit(-1) if $?!=0 +exit(-1) if $?.exitstatus != 0 nodeinfo_text.split(/\n/).each{|line| if line.match('^CPU\(s\)') @@ -46,7 +46,7 @@ nodeinfo_text.split(/\n/).each{|line| NETINTERFACE = "eth1" top_text=`top -bin2` -exit(-1) if $?!=0 +exit(-1) if $?.exitstatus != 0 top_text.gsub!(/^top.*^top.*?$/m, "") # Strip first top output @@ -72,7 +72,7 @@ $used_memory=tmp[0] $free_memory=tmp[1] net_text=`cat /proc/net/dev` -exit(-1) if $?!=0 +exit(-1) if $?.exitstatus != 0 net_text.split(/\n/).each{|line| if line.match("^ *#{NETINTERFACE}") diff --git a/src/im_mad/remotes/xen.d/xen.rb b/src/im_mad/remotes/xen.d/xen.rb index 0fe19b7673..c979907522 100755 --- a/src/im_mad/remotes/xen.d/xen.rb +++ b/src/im_mad/remotes/xen.d/xen.rb @@ -27,10 +27,10 @@ def print_info(name, value) end xentop_text=`sudo #{XENTOP_PATH} -bi2` -exit(-1) if $?!=0 +exit(-1) if $?.exitstatus != 0 xm_text=`sudo #{XM_PATH} info` -exit(-1) if $?!=0 +exit(-1) if $?.exitstatus != 0 #xentop_text.gsub!(/^xentop.*^xentop.*?$/m, "") # Strip first top output xentop_text.gsub!("no limit", "no_limit") From 32421690f3acefb5a8e0e758a5b8460dbbd9a3b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 16 Sep 2011 15:51:28 +0200 Subject: [PATCH 43/90] Bug #804: Fix core unit tests --- src/image/test/ImagePoolTest.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/image/test/ImagePoolTest.cc b/src/image/test/ImagePoolTest.cc index 6ec2480186..1b61ff193a 100644 --- a/src/image/test/ImagePoolTest.cc +++ b/src/image/test/ImagePoolTest.cc @@ -589,7 +589,7 @@ public: Image * img; VectorAttribute * disk; - int oid_0, oid_1, index; + int oid_0, oid_1, index, img_id; string value; Image::ImageType img_type; @@ -625,7 +625,7 @@ public: disk = new VectorAttribute("DISK"); disk->replace("IMAGE_ID", "0"); - ((ImagePool*)imp)->disk_attribute(disk, 0, &index, &img_type,0); + ((ImagePool*)imp)->disk_attribute(disk, 0, &index, &img_type,0, img_id); value = ""; value = disk->vector_value("TARGET"); @@ -639,7 +639,7 @@ public: disk = new VectorAttribute("DISK"); disk->replace("IMAGE_ID", "1"); - ((ImagePool*)imp)->disk_attribute(disk, 0, &index, &img_type,0); + ((ImagePool*)imp)->disk_attribute(disk, 0, &index, &img_type,0, img_id); value = ""; value = disk->vector_value("TARGET"); From 5cf24e23fc5734d682f08afe556931705ec19bda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 16 Sep 2011 18:09:34 +0200 Subject: [PATCH 44/90] New tests for onedb with mysql backend --- src/onedb/test/2.2/mysqldb.sql | 314 +++++++++++++ src/onedb/test/oned_mysql.conf | 433 ++++++++++++++++++ .../test/{oned.conf => oned_sqlite.conf} | 0 src/onedb/test/test_mysql.sh | 173 +++++++ src/onedb/test/{test.sh => test_sqlite.sh} | 2 +- 5 files changed, 921 insertions(+), 1 deletion(-) create mode 100644 src/onedb/test/2.2/mysqldb.sql create mode 100644 src/onedb/test/oned_mysql.conf rename src/onedb/test/{oned.conf => oned_sqlite.conf} (100%) create mode 100755 src/onedb/test/test_mysql.sh rename src/onedb/test/{test.sh => test_sqlite.sh} (99%) diff --git a/src/onedb/test/2.2/mysqldb.sql b/src/onedb/test/2.2/mysqldb.sql new file mode 100644 index 0000000000..16fb92e86c --- /dev/null +++ b/src/onedb/test/2.2/mysqldb.sql @@ -0,0 +1,314 @@ +-- MySQL dump 10.13 Distrib 5.1.41, for debian-linux-gnu (i486) +-- +-- Host: localhost Database: onedb_test +-- ------------------------------------------------------ +-- Server version 5.1.41-3ubuntu12.10 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `cluster_pool` +-- + +DROP TABLE IF EXISTS `cluster_pool`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `cluster_pool` ( + `oid` int(11) NOT NULL, + `cluster_name` varchar(128) DEFAULT NULL, + PRIMARY KEY (`oid`), + UNIQUE KEY `cluster_name` (`cluster_name`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `cluster_pool` +-- + +LOCK TABLES `cluster_pool` WRITE; +/*!40000 ALTER TABLE `cluster_pool` DISABLE KEYS */; +INSERT INTO `cluster_pool` VALUES (0,'default'); +/*!40000 ALTER TABLE `cluster_pool` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `history` +-- + +DROP TABLE IF EXISTS `history`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `history` ( + `vid` int(11) NOT NULL DEFAULT '0', + `seq` int(11) NOT NULL DEFAULT '0', + `host_name` text, + `vm_dir` text, + `hid` int(11) DEFAULT NULL, + `vm_mad` text, + `tm_mad` text, + `stime` int(11) DEFAULT NULL, + `etime` int(11) DEFAULT NULL, + `pstime` int(11) DEFAULT NULL, + `petime` int(11) DEFAULT NULL, + `rstime` int(11) DEFAULT NULL, + `retime` int(11) DEFAULT NULL, + `estime` int(11) DEFAULT NULL, + `eetime` int(11) DEFAULT NULL, + `reason` int(11) DEFAULT NULL, + PRIMARY KEY (`vid`,`seq`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `history` +-- + +LOCK TABLES `history` WRITE; +/*!40000 ALTER TABLE `history` DISABLE KEYS */; +INSERT INTO `history` VALUES (0,0,'host_0','/home/cmartin/trabajo/opennebula/install/var/',0,'vmm_dummy','tm_dummy',1316187929,1316187934,1316187929,1316187929,1316187929,1316187934,0,0,3),(1,0,'host_1','/home/cmartin/trabajo/opennebula/install/var/',1,'vmm_dummy','tm_dummy',1316187929,1316187935,1316187929,1316187929,1316187929,1316187935,0,0,3),(2,0,'host_2','/home/cmartin/trabajo/opennebula/install/var/',2,'vmm_dummy','tm_dummy',1316187930,1316187940,1316187930,1316187930,1316187930,1316187940,1316187940,1316187940,0),(3,0,'host_3','/home/cmartin/trabajo/opennebula/install/var/',3,'vmm_dummy','tm_dummy',1316187930,1316187941,1316187930,1316187930,1316187930,1316187941,0,0,3),(0,1,'host_1','/home/cmartin/trabajo/opennebula/install/var/',1,'vmm_dummy','tm_dummy',1316187934,0,1316187934,1316187934,1316187934,0,0,0,0),(1,1,'host_2','/home/cmartin/trabajo/opennebula/install/var/',2,'vmm_dummy','tm_dummy',1316187935,1316187936,0,0,1316187935,1316187936,1316187936,1316187936,2),(1,2,'host_0','/home/cmartin/trabajo/opennebula/install/var/',0,'vmm_dummy','tm_dummy',1316187937,1316187938,1316187937,1316187937,1316187937,1316187938,0,0,3),(1,3,'host_3','/home/cmartin/trabajo/opennebula/install/var/',3,'vmm_dummy','tm_dummy',1316187938,1316187939,1316187938,1316187938,1316187938,1316187939,1316187939,1316187939,0); +/*!40000 ALTER TABLE `history` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `host_pool` +-- + +DROP TABLE IF EXISTS `host_pool`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `host_pool` ( + `oid` int(11) NOT NULL, + `host_name` varchar(256) DEFAULT NULL, + `state` int(11) DEFAULT NULL, + `im_mad` varchar(128) DEFAULT NULL, + `vm_mad` varchar(128) DEFAULT NULL, + `tm_mad` varchar(128) DEFAULT NULL, + `last_mon_time` int(11) DEFAULT NULL, + `cluster` varchar(128) DEFAULT NULL, + `template` text, + PRIMARY KEY (`oid`), + UNIQUE KEY `host_name` (`host_name`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `host_pool` +-- + +LOCK TABLES `host_pool` WRITE; +/*!40000 ALTER TABLE `host_pool` DISABLE KEYS */; +INSERT INTO `host_pool` VALUES (1,'host_1',2,'im_dummy','vmm_dummy','tm_dummy',1316187946,'default',''),(3,'host_3',4,'im_dummy','vmm_dummy','tm_dummy',1316187931,'default',''),(4,'host_4',2,'im_dummy','vmm_dummy','tm_dummy',1316187946,'default',''),(0,'host_0',2,'im_dummy','vmm_dummy','tm_dummy',1316187946,'default',''),(2,'host_2',2,'im_dummy','vmm_dummy','tm_dummy',1316187946,'default',''); +/*!40000 ALTER TABLE `host_pool` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `host_shares` +-- + +DROP TABLE IF EXISTS `host_shares`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `host_shares` ( + `hid` int(11) NOT NULL, + `disk_usage` int(11) DEFAULT NULL, + `mem_usage` int(11) DEFAULT NULL, + `cpu_usage` int(11) DEFAULT NULL, + `max_disk` int(11) DEFAULT NULL, + `max_mem` int(11) DEFAULT NULL, + `max_cpu` int(11) DEFAULT NULL, + `free_disk` int(11) DEFAULT NULL, + `free_mem` int(11) DEFAULT NULL, + `free_cpu` int(11) DEFAULT NULL, + `used_disk` int(11) DEFAULT NULL, + `used_mem` int(11) DEFAULT NULL, + `used_cpu` int(11) DEFAULT NULL, + `running_vms` int(11) DEFAULT NULL, + PRIMARY KEY (`hid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `host_shares` +-- + +LOCK TABLES `host_shares` WRITE; +/*!40000 ALTER TABLE `host_shares` DISABLE KEYS */; +INSERT INTO `host_shares` VALUES (0,0,0,0,0,16777216,800,0,16777216,800,0,0,0,0),(1,0,524288,0,0,16777216,800,0,16777216,800,0,0,0,1),(2,0,0,0,0,16777216,800,0,16777216,800,0,0,0,0),(3,0,0,0,0,16777216,800,0,16777216,800,0,0,0,0),(4,0,0,0,0,16777216,800,0,16777216,800,0,0,0,0); +/*!40000 ALTER TABLE `host_shares` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `image_pool` +-- + +DROP TABLE IF EXISTS `image_pool`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `image_pool` ( + `oid` int(11) NOT NULL, + `uid` int(11) DEFAULT NULL, + `name` varchar(128) DEFAULT NULL, + `type` int(11) DEFAULT NULL, + `public` int(11) DEFAULT NULL, + `persistent` int(11) DEFAULT NULL, + `regtime` int(11) DEFAULT NULL, + `source` text, + `state` int(11) DEFAULT NULL, + `running_vms` int(11) DEFAULT NULL, + `template` text, + PRIMARY KEY (`oid`), + UNIQUE KEY `name` (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `image_pool` +-- + +LOCK TABLES `image_pool` WRITE; +/*!40000 ALTER TABLE `image_pool` DISABLE KEYS */; +INSERT INTO `image_pool` VALUES (0,1,'image_0',2,0,0,1316187925,'/home/cmartin/trabajo/opennebula/install/var//images/f4f08f2ad6fcb19432db9da3161d144aa2d5e730',2,1,''),(3,4,'image_3',2,0,1,1316187926,'/home/cmartin/trabajo/opennebula/install/var//images/01a1e990037cabc5419076c78e21f96b8c889dbf',1,0,''),(4,5,'image_4',2,0,0,1316187926,'/home/cmartin/trabajo/opennebula/install/var//images/df76114f6749fb9ef6674649c809f28054c0d125',2,1,''),(1,2,'image_1',2,0,0,1316187925,'/home/cmartin/trabajo/opennebula/install/var//images/1dbcefd204efa3c32280d2c56a2d499f89790bae',1,0,''),(2,3,'image_2',2,0,0,1316187925,'/home/cmartin/trabajo/opennebula/install/var//images/a42e387dcd957218a4f5c86f1b586631ab769c17',1,0,''); +/*!40000 ALTER TABLE `image_pool` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `leases` +-- + +DROP TABLE IF EXISTS `leases`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `leases` ( + `oid` int(11) NOT NULL DEFAULT '0', + `ip` bigint(20) NOT NULL DEFAULT '0', + `mac_prefix` bigint(20) DEFAULT NULL, + `mac_suffix` bigint(20) DEFAULT NULL, + `vid` int(11) DEFAULT NULL, + `used` int(11) DEFAULT NULL, + PRIMARY KEY (`oid`,`ip`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `leases` +-- + +LOCK TABLES `leases` WRITE; +/*!40000 ALTER TABLE `leases` DISABLE KEYS */; +INSERT INTO `leases` VALUES (0,3232235521,512,3232235521,0,1),(0,3232235522,512,3232235522,-1,0),(0,3232235523,512,3232235523,-1,0),(0,3232235524,512,3232235524,-1,0),(0,3232235525,512,3232235525,-1,0),(1,3232235777,512,3232235777,-1,0),(1,3232235778,512,3232235778,-1,0),(1,3232235779,512,3232235779,-1,0),(1,3232235780,512,3232235780,-1,0),(1,3232235781,512,3232235781,-1,0),(2,3232236033,512,3232236033,-1,0),(2,3232236034,512,3232236034,-1,0),(2,3232236035,512,3232236035,-1,0),(2,3232236036,512,3232236036,-1,0),(2,3232236037,512,3232236037,-1,0),(4,3232236545,512,3232236545,4,1); +/*!40000 ALTER TABLE `leases` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `network_pool` +-- + +DROP TABLE IF EXISTS `network_pool`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `network_pool` ( + `oid` int(11) NOT NULL, + `uid` int(11) DEFAULT NULL, + `name` varchar(256) DEFAULT NULL, + `type` int(11) DEFAULT NULL, + `bridge` text, + `public` int(11) DEFAULT NULL, + `template` text, + PRIMARY KEY (`oid`), + UNIQUE KEY `name` (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `network_pool` +-- + +LOCK TABLES `network_pool` WRITE; +/*!40000 ALTER TABLE `network_pool` DISABLE KEYS */; +INSERT INTO `network_pool` VALUES (0,1,'vnet_fixed_0',1,'vbr1',0,''),(1,2,'vnet_fixed_1',1,'vbr1',0,''),(2,3,'vnet_fixed_2',1,'vbr1',1,''),(3,4,'vnet_ranged_3',0,'vbr0',0,''),(4,5,'vnet_ranged_4',0,'vbr0',1,''); +/*!40000 ALTER TABLE `network_pool` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `user_pool` +-- + +DROP TABLE IF EXISTS `user_pool`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `user_pool` ( + `oid` int(11) NOT NULL, + `user_name` varchar(256) DEFAULT NULL, + `password` text, + `enabled` int(11) DEFAULT NULL, + PRIMARY KEY (`oid`), + UNIQUE KEY `user_name` (`user_name`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `user_pool` +-- + +LOCK TABLES `user_pool` WRITE; +/*!40000 ALTER TABLE `user_pool` DISABLE KEYS */; +INSERT INTO `user_pool` VALUES (0,'oneadmin','7bc8559a8fe509e680562b85c337f170956fcb06',1),(1,'user_0','90e3707afc67a2038d1088761fea5cd50bbd08bb',1),(2,'user_1','681aae69de00c2df72381c3e5f9d77e70e7e384c',1),(3,'user_2','a195b95bf777854dfe566d1ffef1b76a34dc15a1',1),(4,'user_3','05bf903dc5ff0f2f69f630d9a59bc0b6df8c1cff',1),(5,'user_4','1a6f9b4e378ab45beee6cde9396df5c6ea9863b8',1); +/*!40000 ALTER TABLE `user_pool` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `vm_pool` +-- + +DROP TABLE IF EXISTS `vm_pool`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `vm_pool` ( + `oid` int(11) NOT NULL, + `uid` int(11) DEFAULT NULL, + `name` text, + `last_poll` int(11) DEFAULT NULL, + `state` int(11) DEFAULT NULL, + `lcm_state` int(11) DEFAULT NULL, + `stime` int(11) DEFAULT NULL, + `etime` int(11) DEFAULT NULL, + `deploy_id` text, + `memory` int(11) DEFAULT NULL, + `cpu` int(11) DEFAULT NULL, + `net_tx` int(11) DEFAULT NULL, + `net_rx` int(11) DEFAULT NULL, + `last_seq` int(11) DEFAULT NULL, + `template` text, + PRIMARY KEY (`oid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `vm_pool` +-- + +LOCK TABLES `vm_pool` WRITE; +/*!40000 ALTER TABLE `vm_pool` DISABLE KEYS */; +INSERT INTO `vm_pool` VALUES (0,1,'one-0',1316187945,3,3,1316187927,0,'dummy',0,0,12345,0,1,''),(1,2,'one-1',1316187930,6,0,1316187927,1316187939,'dummy',0,0,0,0,3,''),(2,3,'one-2',1316187930,6,0,1316187928,1316187940,'dummy',0,0,0,0,0,''),(3,4,'one-3',1316187930,6,0,1316187928,1316187941,'dummy',0,0,0,0,0,''),(4,5,'one-4',0,1,0,1316187928,0,'',0,0,0,0,-1,''); +/*!40000 ALTER TABLE `vm_pool` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2011-09-16 8:45:58 diff --git a/src/onedb/test/oned_mysql.conf b/src/onedb/test/oned_mysql.conf new file mode 100644 index 0000000000..052cb81c03 --- /dev/null +++ b/src/onedb/test/oned_mysql.conf @@ -0,0 +1,433 @@ +#******************************************************************************* +# OpenNebula Configuration file +#******************************************************************************* + +#******************************************************************************* +# Daemon configuration attributes +#------------------------------------------------------------------------------- +# MANAGER_TIMER: Time in seconds the core uses to evaluate periodical functions. +# HOST_MONITORING_INTERVAL and VM_POLLING_INTERVAL can not have smaller values +# than MANAGER_TIMER. +# +# HOST_MONITORING_INTERVAL: Time in seconds between host monitorization. +# +# VM_POLLING_INTERVAL: Time in seconds between virtual machine monitorization. +# (use 0 to disable VM monitoring). +# +# VM_DIR: Remote path to store the VM images, it should be shared between all +# the cluster nodes to perform live migrations. This variable is the default +# for all the hosts in the cluster. VM_DIR IS ONLY FOR THE NODES AND *NOT* THE +# FRONT-END +# +# SCRIPTS_REMOTE_DIR: Remote path to store the monitoring and VM management +# scripts. +# +# PORT: Port where oned will listen for xmlrpc calls. +# +# DB: Configuration attributes for the database backend +# backend : can be sqlite or mysql (default is sqlite) +# server : (mysql) host name or an IP address for the MySQL server +# port : (mysql) port for the connection to the server. +# If set to 0, the default port is used. +# user : (mysql) user's MySQL login ID +# passwd : (mysql) the password for user +# db_name : (mysql) the database name +# +# VNC_BASE_PORT: VNC ports for VMs can be automatically set to VNC_BASE_PORT + +# VMID +# +# DEBUG_LEVEL: 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG +#******************************************************************************* + +#MANAGER_TIMER=30 + +HOST_MONITORING_INTERVAL = 1 + +VM_POLLING_INTERVAL = 1 + +#VM_DIR=/srv/cloud/one/var + +SCRIPTS_REMOTE_DIR=/var/tmp/one + +PORT=2888 + +#DB = [ backend = "sqlite" ] + +# Sample configuration for MySQL +DB = [ backend = "mysql", + server = "localhost", + port = 0, + user = "oneadmin", + passwd = "oneadmin", + db_name = "onedb_test" ] + +VNC_BASE_PORT = 5900 + +DEBUG_LEVEL=3 + +#******************************************************************************* +# Physical Networks configuration +#******************************************************************************* +# NETWORK_SIZE: Here you can define the default size for the virtual networks +# +# MAC_PREFIX: Default MAC prefix to be used to create the auto-generated MAC +# addresses is defined here (this can be overrided by the Virtual Network +# template) +#******************************************************************************* + +NETWORK_SIZE = 254 + +MAC_PREFIX = "02:00" + +#******************************************************************************* +# Image Repository Configuration +#******************************************************************************* +# DEFAULT_IMAGE_TYPE: This can take values +# OS Image file holding an operating system +# CDROM Image file holding a CDROM +# DATABLOCK Image file holding a datablock, +# always created as an empty block +# DEFAULT_DEVICE_PREFIX: This can be set to +# hd IDE prefix +# sd SCSI +# xvd XEN Virtual Disk +# vd KVM virtual disk +#******************************************************************************* +DEFAULT_IMAGE_TYPE = "OS" +DEFAULT_DEVICE_PREFIX = "hd" + +#******************************************************************************* +# Information Driver Configuration +#******************************************************************************* +# You can add more information managers with different configurations but make +# sure it has different names. +# +# name : name for this information manager +# +# executable: path of the information driver executable, can be an +# absolute path or relative to $ONE_LOCATION/lib/mads (or +# /usr/lib/one/mads/ if OpenNebula was installed in /) +# +# arguments : for the driver executable, usually a probe configuration file, +# can be an absolute path or relative to $ONE_LOCATION/etc (or +# /etc/one/ if OpenNebula was installed in /) +#******************************************************************************* + +#------------------------------------------------------------------------------- +# KVM Information Driver Manager Configuration +# -r number of retries when monitoring a host +# -t number of threads, i.e. number of hosts monitored at the same time +#------------------------------------------------------------------------------- +#IM_MAD = [ +# name = "im_kvm", +# executable = "one_im_ssh", +# arguments = "-r 0 -t 15 kvm" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# XEN Information Driver Manager Configuration +# -r number of retries when monitoring a host +# -t number of threads, i.e. number of hosts monitored at the same time +#------------------------------------------------------------------------------- +#IM_MAD = [ +# name = "im_xen", +# executable = "one_im_ssh", +# arguments = "xen" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# EC2 Information Driver Manager Configuration +#------------------------------------------------------------------------------- +#IM_MAD = [ +# name = "im_ec2", +# executable = "one_im_ec2", +# arguments = "im_ec2/im_ec2.conf" ] +#------------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# Ganglia Information Driver Manager Configuration +#----------------------------------------------------------------------------- +#IM_MAD = [ +# name = "im_ganglia", +# executable = "one_im_sh", +# arguments = "ganglia" ] +#----------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# Dummy Information Driver Manager Configuration +#------------------------------------------------------------------------------- +IM_MAD = [ name="im_dummy", executable="one_im_dummy"] +#------------------------------------------------------------------------------- + +#******************************************************************************* +# Virtualization Driver Configuration +#******************************************************************************* +# You can add more virtualization managers with different configurations but +# make sure it has different names. +# +# name : name of the virtual machine manager driver +# +# executable: path of the virtualization driver executable, can be an +# absolute path or relative to $ONE_LOCATION/lib/mads (or +# /usr/lib/one/mads/ if OpenNebula was installed in /) +# +# arguments : for the driver executable +# +# default : default values and configuration parameters for the driver, can +# be an absolute path or relative to $ONE_LOCATION/etc (or +# /etc/one/ if OpenNebula was installed in /) +# +# type : driver type, supported drivers: xen, kvm, xml +#******************************************************************************* + +#------------------------------------------------------------------------------- +# KVM Virtualization Driver Manager Configuration +# -r number of retries when monitoring a host +# -t number of threads, i.e. number of hosts monitored at the same time +# -p name of the poll probe (executed locally) +#------------------------------------------------------------------------------- +#VM_MAD = [ +# name = "vmm_kvm", +# executable = "one_vmm_ssh", +# arguments = "-t 15 -r 0 kvm", +# default = "vmm_ssh/vmm_ssh_kvm.conf", +# type = "kvm" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# XEN Virtualization Driver Manager Configuration +# -r number of retries when monitoring a host +# -t number of threads, i.e. number of hosts monitored at the same time +# -l do not perform the VM polling in the node +# -p name of the poll probe (executed locally) +#------------------------------------------------------------------------------- +#VM_MAD = [ +# name = "vmm_xen", +# executable = "one_vmm_ssh", +# arguments = "xen", +# default = "vmm_ssh/vmm_ssh_xen.conf", +# type = "xen" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# EC2 Virtualization Driver Manager Configuration +# arguments: default values for the EC2 driver, can be an absolute path or +# relative to $ONE_LOCATION/etc (or /etc/one/ if OpenNebula was +# installed in /). +#------------------------------------------------------------------------------- +#VM_MAD = [ +# name = "vmm_ec2", +# executable = "one_vmm_ec2", +# arguments = "vmm_ec2/vmm_ec2.conf", +# type = "xml" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# Dummy Virtualization Driver Configuration +#------------------------------------------------------------------------------- +VM_MAD = [ name="vmm_dummy", executable="one_vmm_dummy", type="xml" ] +#------------------------------------------------------------------------------- + +#******************************************************************************* +# Transfer Manager Driver Configuration +#******************************************************************************* +# You can add more transfer managers with different configurations but make +# sure it has different names. +# name : name for this transfer driver +# +# executable: path of the transfer driver executable, can be an +# absolute path or relative to $ONE_LOCATION/lib/mads (or +# /usr/lib/one/mads/ if OpenNebula was installed in /) +# +# arguments : for the driver executable, usually a commands configuration file +# , can be an absolute path or relative to $ONE_LOCATION/etc (or +# /etc/one/ if OpenNebula was installed in /) +#******************************************************************************* + +#------------------------------------------------------------------------------- +# SHARED Transfer Manager Driver Configuration +#------------------------------------------------------------------------------- +#TM_MAD = [ +# name = "tm_shared", +# executable = "one_tm", +# arguments = "tm_shared/tm_shared.conf" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# SSH Transfer Manager Driver Configuration +#------------------------------------------------------------------------------- +#TM_MAD = [ +# name = "tm_ssh", +# executable = "one_tm", +# arguments = "tm_ssh/tm_ssh.conf" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# Dummy Transfer Manager Driver Configuration +#------------------------------------------------------------------------------- +TM_MAD = [ + name = "tm_dummy", + executable = "one_tm", + arguments = "tm_dummy/tm_dummy.conf" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# LVM Transfer Manager Driver Configuration +#------------------------------------------------------------------------------- +#TM_MAD = [ +# name = "tm_lvm", +# executable = "one_tm", +# arguments = "tm_lvm/tm_lvm.conf" ] +#------------------------------------------------------------------------------- + +#******************************************************************************* +# Image Manager Driver Configuration +#******************************************************************************* +# Drivers to manage the image repository, specialized for the storage backend +# executable: path of the transfer driver executable, can be an +# absolute path or relative to $ONE_LOCATION/lib/mads (or +# /usr/lib/one/mads/ if OpenNebula was installed in /) +# +# arguments : for the driver executable +#******************************************************************************* +#------------------------------------------------------------------------------- +# FS based Image Manager Driver Configuration +# -t number of threads, i.e. number of repo operations at the same time +#------------------------------------------------------------------------------- +IMAGE_MAD = [ + executable = "one_image", + arguments = "fs -t 15" ] +#------------------------------------------------------------------------------- + +#******************************************************************************* +# Hook Manager Configuration +#******************************************************************************* +# The Driver (HM_MAD), used to execute the Hooks +# executable: path of the hook driver executable, can be an +# absolute path or relative to $ONE_LOCATION/lib/mads (or +# /usr/lib/one/mads/ if OpenNebula was installed in /) +# +# arguments : for the driver executable, can be an absolute path or relative +# to $ONE_LOCATION/etc (or /etc/one/ if OpenNebula was installed +# in /) +# +# Virtual Machine Hooks (VM_HOOK) defined by: +# name : for the hook, useful to track the hook (OPTIONAL) +# on : when the hook should be executed, +# - CREATE, when the VM is created (onevm create) +# - RUNNING, after the VM is successfully booted +# - SHUTDOWN, after the VM is shutdown +# - STOP, after the VM is stopped (including VM image transfers) +# - DONE, after the VM is deleted or shutdown +# - FAILED, when the VM enters the failed state +# command : path can be absolute or relative to $ONE_LOCATION/share/hooks +# case of self-contained installation or relative to +# /usr/share/one/hooks in case of system-wide installation +# arguments : for the hook. You can access to VM information with $ +# - $VMID, the ID of the virtual machine +# - $TEMPLATE, the VM template in xml and base64 encoded +# remote : values, +# - YES, The hook is executed in the host where the VM was +# allocated +# - NO, The hook is executed in the OpenNebula server (default) +# +# +# Host Hooks (HOST_HOOK) defined by: +# name : for the hook, useful to track the hook (OPTIONAL) +# on : when the hook should be executed, +# - CREATE, when the Host is created (onehost create) +# - ERROR, when the Host enters the error state +# - DISABLE, when the Host is disabled +# command : path can be absolute or relative to $ONE_LOCATION/share/hooks +# case of self-contained installation or relative to +# /usr/share/one/hooks in case of system-wide installation +# arguments : for the hook. You can use the following Host information: +# - $HID, the ID of the host +# - $TEMPLATE, the Host template in xml and base64 encoded +# remote : values, +# - YES, The hook is executed in the host +# - NO, The hook is executed in the OpenNebula server (default) +#------------------------------------------------------------------------------- + +HM_MAD = [ + executable = "one_hm" ] + +#------------------------------------------------------------------------------- + +#------------------------------ Fault Tolerance Hooks -------------------------- +# This hook is used to perform recovery actions when a host fails. The VMs +# running in the host can be deleted (use -d option) or resubmitted (-r) in +# other host +# Last argument (force) can be "y", so suspended VMs in the host will be +# resubmitted/deleted, or "n", so suspended VMs in the host will be ignored +# +#HOST_HOOK = [ +# name = "error", +# on = "ERROR", +# command = "host_error.rb", +# arguments = "$HID -r n", +# remote = "no" ] +#------------------------------------------------------------------------------- +# This two hooks can be used to automatically delete or resubmit VMs that reach +# the "failed" state. This way, the administrator doesn't have to interact +# manually to release its resources or retry the deployment. +# +# Only one of them should be uncommented. +#------------------------------------------------------------------------------- +# +#VM_HOOK = [ +# name = "on_failure_delete", +# on = "FAILED", +# command = "/usr/bin/env onevm delete", +# arguments = "$VMID" ] +# +#VM_HOOK = [ +# name = "on_failure_resubmit", +# on = "FAILED", +# command = "/usr/bin/env onevm resubmit", +# arguments = "$VMID" ] +#------------------------------------------------------------------------------- + +#-------------------------------- ebtables Hook--------------------------------- +# You can use these two hooks to isolate networks at the ethernet level so the +# traffic generated in different virtual networks can not be seen in others. +# +# All the network configuration will be done in the cluster nodes, these are the +# additional requisites: +# - ebtables package installed +# - sudoers configured so oneadmin can execute ebtables without password +# +# NOTE: Change the first command for ebtables-xen if you are using Xen +# +#VM_HOOK = [ +# name = "ebtables-start", +# on = "running", +# command = "ebtables-kvm", # or ebtables-xen +# arguments = "one-$VMID", +# remote = "yes" ] +# +#VM_HOOK = [ +# name = "ebtables-flush", +# on = "done", +# command = "ebtables-flush", +# arguments = "", +# remote = "yes" ] +#------------------------------------------------------------------------------- + +#******************************************************************************* +# Auth Manager Configuration +#******************************************************************************* +# The Driver (AUTHM_MAD) that will be used to authenticate and authorize +# OpenNebula requests. If not defined OpenNebula will use the built-in auth +# policies +# executable: path of the auth driver executable, can be an +# absolute path or relative to $ONE_LOCATION/lib/mads (or +# /usr/lib/one/mads/ if OpenNebula was installed in /) +# +# arguments : for the driver executable, can be an absolute path or relative +# to $ONE_LOCATION/etc (or /etc/one/ if OpenNebula was installed +# in /) +#------------------------------------------------------------------------------- + +#AUTH_MAD = [ +# executable = "one_auth_mad" ] diff --git a/src/onedb/test/oned.conf b/src/onedb/test/oned_sqlite.conf similarity index 100% rename from src/onedb/test/oned.conf rename to src/onedb/test/oned_sqlite.conf diff --git a/src/onedb/test/test_mysql.sh b/src/onedb/test/test_mysql.sh new file mode 100755 index 0000000000..4cac73d2eb --- /dev/null +++ b/src/onedb/test/test_mysql.sh @@ -0,0 +1,173 @@ +#!/bin/bash + +################################################################################ +# Initialization +################################################################################ + +if [ -z $ONE_LOCATION ]; then + echo "ONE_LOCATION not defined." + exit -1 +fi + +ONEDCONF_LOCATION="$ONE_LOCATION/etc/oned.conf" + +if [ -f $ONEDCONF_LOCATION ]; then + echo "$ONEDCONF_LOCATION has to be overwritten, move it to a safe place." + exit -1 +fi + +VAR_LOCATION="$ONE_LOCATION/var" + + +# Clean DB +mysql -u oneadmin -poneadmin -h localhost -P 0 -e "DROP DATABASE IF EXISTS onedb_test;" + +cp oned_mysql.conf $ONEDCONF_LOCATION + + +echo "oneadmin:oneadmin" > oneadmin_auth +export ONE_XMLRPC=http://localhost:2888/RPC2 +export PATH=$ONE_LOCATION/bin:$PATH +export ONE_AUTH="`pwd`/oneadmin_auth" + + +PID=$$ + +mkdir results + +################################################################################ +# Start OpenNebula and populate a DB +################################################################################ + +echo "Starting oned, some resources will be created" + +oned -f & +sleep 2s; + +./create.sh + +pkill -P $PID oned +sleep 2s; +pkill -9 -P $PID oned + +################################################################################ +# Upgrade the 2.2 sample DB, and compare schemas +################################################################################ + +echo "All resources created, now 2.2 DB will be upgraded." + +# dump current DB and schema +onedb backup results/mysqldb.3.0 +mysqldump -u oneadmin -poneadmin -h localhost -P 0 --no-data onedb_test > results/mysqldb.3.0.tmpschema + +# restore 2.2 +onedb restore -f 2.2/mysqldb.sql +# upgrade +onedb upgrade -v --backup results/mysqldb.backup +# dump upgraded DB schema +mysqldump -u oneadmin -poneadmin -h localhost -P 0 --no-data onedb_test > results/mysqldb.upgraded.tmpschema + +echo "Done. Upgraded DB and the one just created will be compared." + +# Sort the files contents, to avoid false diff errors +sort results/mysqldb.upgraded.tmpschema > results/mysqldb.upgraded.schema +sort results/mysqldb.3.0.tmpschema > results/mysqldb.3.0.schema + +rm results/mysqldb.upgraded.tmpschema +rm results/mysqldb.3.0.tmpschema + + + +# Perform a diff +FILE=results/schema.diff +diff <(grep -v -e "Dump completed on" results/mysqldb.upgraded.schema) <(grep -v -e "Dump completed on" results/mysqldb.3.0.schema) > $FILE + + +if [[ -s $FILE ]] ; then + echo "Error: Schemas do not match. Check file $FILE" + exit -1 +fi + + +################################################################################ +# Start oned using the upgraded DB and compare objects XMLs +################################################################################ + +echo "Schemas match. OpenNebula 3.0 will be started with the upgraded 2.2 DB." + +oned -f & +sleep 2s; + +for obj in host vnet image vm user; do + for i in 0 1 2 3 4; do + one$obj show -x $i > results/xml_files/$obj-$i-upgraded.xml + done +done + +for obj in host vnet image vm acl group user; do + one$obj list a -x > results/xml_files/$obj-pool-upgraded.xml +done + + +pkill -P $PID oned +sleep 2s; +pkill -9 -P $PID oned + +echo "XML output collected. A diff will be performed." + +mkdir results/diff_files + +diff <(grep -v -e "" -e "" -e "NAME>" results/xml_files/host-pool.xml) <(grep -v -e "" -e "" -e "NAME>" results/xml_files/host-pool-upgraded.xml) > results/diff_files/host-pool.diff + +# TODO: fix +# The image-pool.xml files are the same, but for some reason the Images are +# returned in different order. +#diff <(grep -v -e "" -e "" -e "" results/xml_files/image-pool.xml) <(grep -v -e "" -e "" -e "" results/xml_files/image-pool-upgraded.xml) > results/diff_files/image-pool.diff + +diff <(grep -v -e "" -e "TIME>" -e "" -e "" -e "" results/xml_files/vm-pool.xml) <(grep -v -e "" -e "TIME>" -e "" -e "" -e "" results/xml_files/vm-pool-upgraded.xml) > results/diff_files/vm-pool.diff + +for obj in vnet acl group user; do + diff <(cat results/xml_files/$obj-pool.xml) <(cat results/xml_files/$obj-pool-upgraded.xml) > results/diff_files/$obj-pool.diff +done + +for i in 0 1 2 3 4; do + diff <(grep -v -e "" -e "" -e "NAME>" results/xml_files/host-$i.xml) <(grep -v -e "" -e "" -e "NAME>" results/xml_files/host-$i-upgraded.xml) > results/diff_files/host-$i.diff + + diff <(cat results/xml_files/vnet-$i.xml) <(cat results/xml_files/vnet-$i-upgraded.xml) > results/diff_files/vnet-$i.diff + + diff <(grep -v -e "" -e "" -e "" results/xml_files/image-$i.xml) <(grep -v -e "" -e "" -e "" results/xml_files/image-$i-upgraded.xml) > results/diff_files/image-$i.diff + + diff <(grep -v -e "" -e "TIME>" -e "" -e "" -e "" -e "" results/xml_files/vm-$i.xml) <(grep -v -e "" -e "TIME>" -e "" -e "" -e "" -e "" results/xml_files/vm-$i-upgraded.xml) > results/diff_files/vm-$i.diff + + diff <(cat results/xml_files/user-$i.xml) <(cat results/xml_files/user-$i-upgraded.xml) > results/diff_files/user-$i.diff +done + + +CODE=0 + +for obj in host vnet image vm user; do + for i in 0 1 2 3 4; do + FILE=results/diff_files/$obj-$i.diff + if [[ -s $FILE ]] ; then + echo "Error: diff file $FILE is not empty." + CODE=-1 + fi + done +done + +for obj in host vnet image vm acl group user; do + FILE=results/diff_files/$obj-pool.diff + if [[ -s $FILE ]] ; then + echo "Error: diff file $FILE is not empty." + CODE=-1 + fi +done + + +if [ $CODE -eq 0 ]; then + echo "Done, all tests passed." +fi + +rm oneadmin_auth + +exit $CODE diff --git a/src/onedb/test/test.sh b/src/onedb/test/test_sqlite.sh similarity index 99% rename from src/onedb/test/test.sh rename to src/onedb/test/test_sqlite.sh index 5253b93cee..c0ff4d0d0a 100755 --- a/src/onedb/test/test.sh +++ b/src/onedb/test/test_sqlite.sh @@ -24,7 +24,7 @@ if [ -f $VAR_LOCATION/one.db ]; then fi -cp oned.conf $ONEDCONF_LOCATION +cp oned_sqlite.conf $ONEDCONF_LOCATION echo "oneadmin:oneadmin" > oneadmin_auth From 3e8bc8046d763bc53f568d672240050a1be0824b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 16 Sep 2011 18:11:15 +0200 Subject: [PATCH 45/90] Bug #812: Fix onedb sql syntax to work with mysql --- src/onedb/2.0_to_2.9.80.rb | 4 ++-- src/onedb/onedb_backend.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/onedb/2.0_to_2.9.80.rb b/src/onedb/2.0_to_2.9.80.rb index 20d47aeb62..a3e9afe400 100644 --- a/src/onedb/2.0_to_2.9.80.rb +++ b/src/onedb/2.0_to_2.9.80.rb @@ -257,8 +257,8 @@ module Migrator public = row[:public] total_leases = 0 - @db.fetch("SELECT COUNT (ip) FROM old_leases WHERE (oid=#{oid} AND used=1)") do |r| - total_leases = r[:"COUNT (ip)"] + @db.fetch("SELECT COUNT(ip) FROM old_leases WHERE (oid=#{oid} AND used=1)") do |r| + total_leases = r[:"COUNT(ip)"] end diff --git a/src/onedb/onedb_backend.rb b/src/onedb/onedb_backend.rb index cfe079052d..71cbda3324 100644 --- a/src/onedb/onedb_backend.rb +++ b/src/onedb/onedb_backend.rb @@ -177,7 +177,7 @@ class BackEndMySQL < OneDBBacKEnd end create_cmd = mysql_cmd+"-e 'CREATE DATABASE IF NOT EXISTS #{@db_name};'" - rc = system(create_cnd) + rc = system(create_cmd) if !rc raise "Error creating MySQL DB #{@db_name} at #{@server}." end From cbbe638d5b7a0a76ccfa5d92a34d3caccf7ba126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 16 Sep 2011 18:27:56 +0200 Subject: [PATCH 46/90] onedb tests: Set a different port for mysql tests, otherwise there are collisions when hudson launches both onedb tests --- src/onedb/test/oned_mysql.conf | 2 +- src/onedb/test/test_mysql.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/onedb/test/oned_mysql.conf b/src/onedb/test/oned_mysql.conf index 052cb81c03..164abeaf5d 100644 --- a/src/onedb/test/oned_mysql.conf +++ b/src/onedb/test/oned_mysql.conf @@ -49,7 +49,7 @@ VM_POLLING_INTERVAL = 1 SCRIPTS_REMOTE_DIR=/var/tmp/one -PORT=2888 +PORT=2889 #DB = [ backend = "sqlite" ] diff --git a/src/onedb/test/test_mysql.sh b/src/onedb/test/test_mysql.sh index 4cac73d2eb..ac973b72ac 100755 --- a/src/onedb/test/test_mysql.sh +++ b/src/onedb/test/test_mysql.sh @@ -26,7 +26,7 @@ cp oned_mysql.conf $ONEDCONF_LOCATION echo "oneadmin:oneadmin" > oneadmin_auth -export ONE_XMLRPC=http://localhost:2888/RPC2 +export ONE_XMLRPC=http://localhost:2889/RPC2 export PATH=$ONE_LOCATION/bin:$PATH export ONE_AUTH="`pwd`/oneadmin_auth" From f9a4eaf55a211d6f057d71ee1424f77c7a57ca39 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 16 Sep 2011 18:48:46 +0200 Subject: [PATCH 47/90] bug #695: False timeouts are now checked within the Authmanager --- src/authm/AuthManager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/authm/AuthManager.cc b/src/authm/AuthManager.cc index 8ed3a16b9b..384e6d4272 100644 --- a/src/authm/AuthManager.cc +++ b/src/authm/AuthManager.cc @@ -358,7 +358,7 @@ void AuthManager::timer_action() while ( it !=auth_requests.end()) { - if (the_time > it->second->time_out) + if ((it->second->time_out != 0) && (the_time > it->second->time_out)) { AuthRequest * ar = it->second; auth_requests.erase(it++); From 6a8a802e55969761ffc2fe8eb057efb605bcef4a Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Mon, 19 Sep 2011 15:00:41 +0200 Subject: [PATCH 48/90] bugs in install_gems when the distro is not detected --- share/install_gems/install_gems | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/share/install_gems/install_gems b/share/install_gems/install_gems index 8b6758a803..bbdf2c3a6e 100755 --- a/share/install_gems/install_gems +++ b/share/install_gems/install_gems @@ -165,7 +165,8 @@ def install_dependencies(gems, distro) documentation. Press enter to continue... - EOT + EOT + STDIN.readline else puts "Distribution \"#{distro.first}\" detected." deps=get_dependencies(gems, distro.last[:dependencies]) @@ -240,7 +241,7 @@ packages_string=gems_list.join(' ') prefix="" -if dist.last[:gem_env] +if dist && dist.last[:gem_env] prefix=dist.last[:gem_env].collect do |name, value| "#{name}=\"#{value}\"" end.join(' ')+' ' From ad02ac2ad35de9bb3a0861eb0839600b41be0578 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Mon, 19 Sep 2011 16:01:11 +0200 Subject: [PATCH 49/90] bug #815: Fix JSONUtils require(cherry picked from commit cbbf51d13c89937c94937fd23aa74202b240f525) --- src/ozones/Server/models/OzonesServer.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ozones/Server/models/OzonesServer.rb b/src/ozones/Server/models/OzonesServer.rb index 4fdac56b3e..ce085b2054 100644 --- a/src/ozones/Server/models/OzonesServer.rb +++ b/src/ozones/Server/models/OzonesServer.rb @@ -19,8 +19,7 @@ require 'JSONUtils' class OzonesServer - - include JSONUtils + include OpenNebulaJSON::JSONUtils def initialize @ocaInt = OCAInteraction.new From 6adfa7942386159a5199f9829c74247d7710c228 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Mon, 19 Sep 2011 16:01:40 +0200 Subject: [PATCH 50/90] bug #816: Change ozones lock file name(cherry picked from commit 96d789f1adc182daa3aec1596c3d70fa3ffcfb1c) --- src/ozones/Server/bin/ozones-server | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ozones/Server/bin/ozones-server b/src/ozones/Server/bin/ozones-server index ac76d2f6c3..4da44f11e0 100755 --- a/src/ozones/Server/bin/ozones-server +++ b/src/ozones/Server/bin/ozones-server @@ -27,7 +27,7 @@ else OZONES_PID=$ONE_LOCATION/var/ozones.pid OZONES_LOCATION=$ONE_LOCATION/lib/ozones OZONES_SERVER=$OZONES_LOCATION/config.ru - OZONES_LOCK_FILE=$ONE_LOCATION/var/.lock + OZONES_LOCK_FILE=$ONE_LOCATION/var/.ozones.lock OZONES_LOG=$ONE_LOCATION/var/ozones-server.log OZONES_CONF=$ONE_LOCATION/etc/ozones-server.conf fi From a0799ae812b1800c4d63f36de4ce078b827d4e5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Mon, 19 Sep 2011 16:13:30 +0200 Subject: [PATCH 51/90] Better onedb tests --- src/onedb/test/create.sh | 16 +++++++++--- src/onedb/test/test_mysql.sh | 47 +++++++++++++++++++++++++++++------ src/onedb/test/test_sqlite.sh | 25 ++++++++++++++++++- 3 files changed, 76 insertions(+), 12 deletions(-) diff --git a/src/onedb/test/create.sh b/src/onedb/test/create.sh index 6a49a6b070..836229780e 100755 --- a/src/onedb/test/create.sh +++ b/src/onedb/test/create.sh @@ -182,17 +182,27 @@ sleep 3s mkdir -p results/xml_files -for obj in host vnet image vm user; do +for obj in vnet image vm; do one$obj list a -x > results/xml_files/$obj-pool.xml +done +for obj in host user; do + one$obj list -x > results/xml_files/$obj-pool.xml +done + +for obj in host vnet image vm user; do for i in 0 1 2 3 4; do one$obj show -x $i > results/xml_files/$obj-$i.xml done done if [ $TWO_SERIES == "no" ]; then - oneacl list a -x > results/xml_files/acl-pool.xml - onegroup list a -x > results/xml_files/group-pool.xml + oneacl list -x > results/xml_files/acl-pool.xml + onegroup list -x > results/xml_files/group-pool.xml + + for i in 0 1; do + onegroup show -x $i > results/xml_files/group-$i.xml + done fi # Clean one auth files diff --git a/src/onedb/test/test_mysql.sh b/src/onedb/test/test_mysql.sh index ac973b72ac..8b07053057 100755 --- a/src/onedb/test/test_mysql.sh +++ b/src/onedb/test/test_mysql.sh @@ -57,13 +57,28 @@ pkill -9 -P $PID oned echo "All resources created, now 2.2 DB will be upgraded." # dump current DB and schema -onedb backup results/mysqldb.3.0 +onedb backup results/mysqldb.3.0 -v +if [ $? -ne 0 ]; then + exit -1 +fi + mysqldump -u oneadmin -poneadmin -h localhost -P 0 --no-data onedb_test > results/mysqldb.3.0.tmpschema +if [ $? -ne 0 ]; then + exit -1 +fi # restore 2.2 -onedb restore -f 2.2/mysqldb.sql +onedb restore -v -f 2.2/mysqldb.sql +if [ $? -ne 0 ]; then + exit -1 +fi + # upgrade onedb upgrade -v --backup results/mysqldb.backup +if [ $? -ne 0 ]; then + exit -1 +fi + # dump upgraded DB schema mysqldump -u oneadmin -poneadmin -h localhost -P 0 --no-data onedb_test > results/mysqldb.upgraded.tmpschema @@ -104,10 +119,18 @@ for obj in host vnet image vm user; do done done -for obj in host vnet image vm acl group user; do +for i in 0 1; do + onegroup show -x $i > results/xml_files/group-$i-upgraded.xml +done + + +for obj in vnet image vm; do one$obj list a -x > results/xml_files/$obj-pool-upgraded.xml done +for obj in host acl group user; do + one$obj list -x > results/xml_files/$obj-pool-upgraded.xml +done pkill -P $PID oned sleep 2s; @@ -117,11 +140,8 @@ echo "XML output collected. A diff will be performed." mkdir results/diff_files -diff <(grep -v -e "" -e "" -e "NAME>" results/xml_files/host-pool.xml) <(grep -v -e "" -e "" -e "NAME>" results/xml_files/host-pool-upgraded.xml) > results/diff_files/host-pool.diff - -# TODO: fix -# The image-pool.xml files are the same, but for some reason the Images are -# returned in different order. +# TODO: fix. The pool elements are returned in different order. +#diff <(grep -v -e "" -e "" -e "NAME>" results/xml_files/host-pool.xml) <(grep -v -e "" -e "" -e "NAME>" results/xml_files/host-pool-upgraded.xml) > results/diff_files/host-pool.diff #diff <(grep -v -e "" -e "" -e "" results/xml_files/image-pool.xml) <(grep -v -e "" -e "" -e "" results/xml_files/image-pool-upgraded.xml) > results/diff_files/image-pool.diff diff <(grep -v -e "" -e "TIME>" -e "" -e "" -e "" results/xml_files/vm-pool.xml) <(grep -v -e "" -e "TIME>" -e "" -e "" -e "" results/xml_files/vm-pool-upgraded.xml) > results/diff_files/vm-pool.diff @@ -142,6 +162,9 @@ for i in 0 1 2 3 4; do diff <(cat results/xml_files/user-$i.xml) <(cat results/xml_files/user-$i-upgraded.xml) > results/diff_files/user-$i.diff done +for i in 0 1; do + diff <(cat results/xml_files/group-$i.xml) <(cat results/xml_files/group-$i-upgraded.xml) > results/diff_files/group-$i.diff +done CODE=0 @@ -155,6 +178,14 @@ for obj in host vnet image vm user; do done done +for i in 0 1; do + FILE=results/diff_files/group-$i.diff + if [[ -s $FILE ]] ; then + echo "Error: diff file $FILE is not empty." + CODE=-1 + fi +done + for obj in host vnet image vm acl group user; do FILE=results/diff_files/$obj-pool.diff if [[ -s $FILE ]] ; then diff --git a/src/onedb/test/test_sqlite.sh b/src/onedb/test/test_sqlite.sh index c0ff4d0d0a..08255d13a0 100755 --- a/src/onedb/test/test_sqlite.sh +++ b/src/onedb/test/test_sqlite.sh @@ -63,6 +63,10 @@ cp 2.2/one.db results/one.db.upgraded onedb upgrade -v --sqlite results/one.db.upgraded --backup results/one.db.backup +if [ $? -ne 0 ]; then + exit -1 +fi + echo "Done. Upgraded DB and the one just created will be compared." # Dump both DB schemas @@ -106,10 +110,18 @@ for obj in host vnet image vm user; do done done -for obj in host vnet image vm acl group user; do +for i in 0 1; do + onegroup show -x $i > results/xml_files/group-$i-upgraded.xml +done + + +for obj in vnet image vm; do one$obj list a -x > results/xml_files/$obj-pool-upgraded.xml done +for obj in host acl group user; do + one$obj list -x > results/xml_files/$obj-pool-upgraded.xml +done pkill -P $PID oned sleep 2s; @@ -139,6 +151,9 @@ for i in 0 1 2 3 4; do diff <(cat results/xml_files/user-$i.xml) <(cat results/xml_files/user-$i-upgraded.xml) > results/diff_files/user-$i.diff done +for i in 0 1; do + diff <(cat results/xml_files/group-$i.xml) <(cat results/xml_files/group-$i-upgraded.xml) > results/diff_files/group-$i.diff +done CODE=0 @@ -152,6 +167,14 @@ for obj in host vnet image vm user; do done done +for i in 0 1; do + FILE=results/diff_files/group-$i.diff + if [[ -s $FILE ]] ; then + echo "Error: diff file $FILE is not empty." + CODE=-1 + fi +done + for obj in host vnet image vm acl group user; do FILE=results/diff_files/$obj-pool.diff if [[ -s $FILE ]] ; then From 9fed5416259328fb83dc66e24c662ffc43a3c0d6 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Tue, 20 Sep 2011 16:04:31 +0200 Subject: [PATCH 52/90] Fix for SAVE_AS bug through the OCCI interface --- src/cloud/occi/lib/OCCIServer.rb | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/cloud/occi/lib/OCCIServer.rb b/src/cloud/occi/lib/OCCIServer.rb index 9ba674a869..ce24fc93b3 100755 --- a/src/cloud/occi/lib/OCCIServer.rb +++ b/src/cloud/occi/lib/OCCIServer.rb @@ -325,20 +325,7 @@ class OCCIServer < CloudServer return OpenNebula::Error.new(error_msg), 400 end - # Create a new Image to save the disk - template = "NAME=\"#{image_name}\"\n" - if image_type - template << "TYPE=\"#{image_type}\"\n" - else - template << "TYPE=\"OS\"\n" - end - - image = Image.new(Image.build_xml, one_client) - - rc = image.allocate(template) - return rc, 400 if OpenNebula.is_error?(rc) - - rc = vm.save_as(disk_id, image.id) + rc = vm.save_as(disk_id, image_name) if OpenNebula.is_error?(rc) image.delete return rc, 400 From f97ef6be7bd222795626b4e7a781ddbf385a2a5f Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Tue, 20 Sep 2011 18:24:51 +0200 Subject: [PATCH 53/90] feature #795: Add new Cloud Auth system --- src/cloud/common/CloudAuth.rb | 37 ++++++ src/cloud/common/CloudAuth/BasicCloudAuth.rb | 20 +++ src/cloud/common/CloudAuth/EC2CloudAuth.rb | 76 +++++++++++ src/cloud/common/CloudAuth/X509CloudAuth.rb | 87 +++++++++++++ src/cloud/common/CloudServer.rb | 126 +++++-------------- 5 files changed, 253 insertions(+), 93 deletions(-) create mode 100644 src/cloud/common/CloudAuth.rb create mode 100644 src/cloud/common/CloudAuth/BasicCloudAuth.rb create mode 100644 src/cloud/common/CloudAuth/EC2CloudAuth.rb create mode 100644 src/cloud/common/CloudAuth/X509CloudAuth.rb diff --git a/src/cloud/common/CloudAuth.rb b/src/cloud/common/CloudAuth.rb new file mode 100644 index 0000000000..0dae4b76d9 --- /dev/null +++ b/src/cloud/common/CloudAuth.rb @@ -0,0 +1,37 @@ +class CloudAuth + AUTH_MODULES = { + "basic" => 'BasicCloudAuth', + "ec2" => 'EC2CloudAuth', + "x509" => 'X509CloudAuth' + } + + attr_reader :client, :token + + def initialize(conf) + @xmlrpc = conf[:one_xmlrpc] + + if AUTH_MODULES.include?(conf[:auth]) + require 'CloudAuth/' + AUTH_MODULES[conf[:auth]] + extend Kernel.const_get(AUTH_MODULES[conf[:auth]]) + else + raise "Auth module not specified" + end + end + + protected + + def get_password(username) + @oneadmin_client ||= OpenNebula::Client.new(nil, @xmlrpc) + + if @user_pool.nil? + @user_pool ||= OpenNebula::UserPool.new(@oneadmin_client) + + rc = @user_pool.info + if OpenNebula.is_error?(rc) + raise rc.message + end + end + + return @user_pool["USER[NAME=\"#{username}\"]/PASSWORD"] + end +end \ No newline at end of file diff --git a/src/cloud/common/CloudAuth/BasicCloudAuth.rb b/src/cloud/common/CloudAuth/BasicCloudAuth.rb new file mode 100644 index 0000000000..c4d53e8c03 --- /dev/null +++ b/src/cloud/common/CloudAuth/BasicCloudAuth.rb @@ -0,0 +1,20 @@ +module BasicCloudAuth + def auth(env, params={}) + auth = Rack::Auth::Basic::Request.new(env) + + if auth.provided? && auth.basic? + username, password = auth.credentials + + one_pass = get_password(username) + if one_pass && one_pass == password + @token = "#{username}:#{password}" + @client = Client.new(@token, @xmlrpc, false) + return nil + else + return "Authentication failure" + end + else + return "Basic auth not provided" + end + end +end \ No newline at end of file diff --git a/src/cloud/common/CloudAuth/EC2CloudAuth.rb b/src/cloud/common/CloudAuth/EC2CloudAuth.rb new file mode 100644 index 0000000000..2842d8c940 --- /dev/null +++ b/src/cloud/common/CloudAuth/EC2CloudAuth.rb @@ -0,0 +1,76 @@ +module EC2CloudAuth + def auth(env, params={}) + username = params['AWSAccessKeyId'] + one_pass = get_password(username) + return "Invalid credentials" unless one_pass + + signature = case params['SignatureVersion'] + when "1" then signature_v1(params.clone,one_pass) + when "2" then signature_v2(params.clone,one_pass,env,true,false) + end + + if params['Signature'] != signature + if params['SignatureVersion']=="2" + signature = signature_v2(params.clone,one_pass,env,false,false) + if params['Signature'] != signature + return "Invalid Credentials" + end + else + return "Invalid Credentials" + end + end + + @token = "#{username}:#{one_pass}" + @client = Client.new(@token, @xmlrpc, false) + return nil + end + + private + + # Calculates signature version 1 + def signature_v1(params, secret_key, digest='sha1') + params.delete('Signature') + req_desc = params.sort {|x,y| x[0].downcase <=> y[0].downcase}.to_s + + digest_generator = OpenSSL::Digest::Digest.new(digest) + digest = OpenSSL::HMAC.digest(digest_generator, secret_key, req_desc) + b64sig = Base64.b64encode(digest) + return b64sig.strip + end + + # Calculates signature version 2 + def signature_v2(params, secret_key, env, include_port=true, urlencode=true) + params.delete('Signature') + params.delete('file') + + server_host = params.delete(:econe_host) + server_port = params.delete(:econe_port) + if include_port + server_str = "#{server_host}:#{server_port}" + else + server_str = server_host + end + + canonical_str = AWS.canonical_string( + params, + server_str, + env['REQUEST_METHOD']) + + # Use the correct signature strength + sha_strength = case params['SignatureMethod'] + when "HmacSHA1" then 'sha1' + when "HmacSHA256" then 'sha256' + else 'sha1' + end + + digest = OpenSSL::Digest::Digest.new(sha_strength) + hmac = OpenSSL::HMAC.digest(digest, secret_key, canonical_str) + b64hmac = Base64.encode64(hmac).gsub("\n","") + + if urlencode + return CGI::escape(b64hmac) + else + return b64hmac + end + end +end \ No newline at end of file diff --git a/src/cloud/common/CloudAuth/X509CloudAuth.rb b/src/cloud/common/CloudAuth/X509CloudAuth.rb new file mode 100644 index 0000000000..6488b7999e --- /dev/null +++ b/src/cloud/common/CloudAuth/X509CloudAuth.rb @@ -0,0 +1,87 @@ +module X509CloudAuth + # TBD Adapt to the new CloudAuth system + + # Gets the username associated with a password + # password:: _String_ the password + # [return] _Hash_ with the username + def get_username(password) + @user_pool.info + #STDERR.puts 'the password is ' + password + #STDERR.puts @user_pool["User[PASSWORD=\"#{password}\"]"] + username = @user_pool["User[PASSWORD=\"#{password}\"]/NAME"] + return username if (username != nil) + + # Check if the DN is part of a |-separted multi-DN password + user_elts = Array.new + @user_pool.each {|e| user_elts << e['PASSWORD']} + multiple_users = user_elts.select {|e| e=~ /\|/ } + matched = nil + multiple_users.each do |e| + e.to_s.split('|').each do |w| + if (w == password) + matched=e + break + end + end + break if matched + end + if matched + password = matched.to_s + end + puts("The password is " + password) + return @user_pool["USER[PASSWORD=\"#{password}\"]/NAME"] + end + + def auth(env, params={}) + failed = 'Authentication failed. ' + # For https, the web service should be set to include the user cert in the environment. + cert_line = env['HTTP_SSL_CLIENT_CERT'] + cert_line = nil if cert_line == '(null)' # For Apache mod_ssl + + # Use the https credentials for authentication + require 'server_auth' + while cert_line + begin + cert_array=cert_line.scan(/([^\s]*)\s/) + cert_array = cert_array[2..-3] + cert_array.unshift('-----BEGIN CERTIFICATE-----') + cert_array.push('-----END CERTIFICATE-----') + cert_pem = cert_array.join("\n") + cert = OpenSSL::X509::Certificate.new(cert_pem) + rescue + raise failed + "Could not create X509 certificate from " + cert_line + end + + # Password should be DN with whitespace removed. + subjectname = cert.subject.to_s.delete("\s") + begin + username = get_username(subjectname) + rescue + username = nil + end + + break if username + + chain_dn = (!chain_dn ? "" : chain_dn) + "\n" + subjectname + chain_index = !chain_index ? 0 : chain_index + 1 + cert_line = env["HTTP_SSL_CLIENT_CERT_CHAIN_#{chain_index}"] + cert_line = nil if cert_line == '(null)' # For Apache mod_ssl + end + + if !cert_line + msg = "" + msg << failed + msg << "Username not found in certificate chain " + msg << chain_dn + raise msg + end + + auth = ServerAuth.new + + login = auth.login_token(username, subjectname, 300) + + STDERR.puts login + + return one_client_user("dummy", login) + end +end \ No newline at end of file diff --git a/src/cloud/common/CloudServer.rb b/src/cloud/common/CloudServer.rb index 070ae9d59d..b5abc10ca2 100755 --- a/src/cloud/common/CloudServer.rb +++ b/src/cloud/common/CloudServer.rb @@ -14,9 +14,8 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -require 'Configuration' require 'OpenNebula' -require 'pp' +require 'CloudAuth' ############################################################################## # This class represents a generic Cloud Server using the OpenNebula Cloud @@ -28,115 +27,39 @@ class CloudServer # Public attributes ########################################################################## attr_reader :config - attr_reader :one_client # Initializes the Cloud server based on a config file # config_file:: _String_ for the server. MUST include the following # variables: - # USER - # PASSWORD + # AUTH # VM_TYPE - # IMAGE_DIR - # DATABASE - def initialize(config_file) - + # XMLRPC + def initialize(config) # --- Load the Cloud Server configuration file --- + @config = config + @cloud_auth = CloudAuth.new(@config) + end - @config = Configuration.new(config_file) + def authenticate(env, params={}) + @cloud_auth.auth(env, params) + end - if @config[:vm_type] == nil - raise "No VM_TYPE defined." - end - - @instance_types = Hash.new - - if @config[:vm_type].kind_of?(Array) - @config[:vm_type].each {|type| - @instance_types[type['NAME']]=type - } - else - @instance_types[@config[:vm_type]['NAME']]=@config[:vm_type] - end - - # --- Start an OpenNebula Session --- - - @one_client = Client.new(nil,@config[:one_xmlrpc]) - @user_pool = UserPool.new(@one_client) + def client + @cloud_auth.client end # # Prints the configuration of the server # - def print_configuration + def self.print_configuration(config) puts "--------------------------------------" puts " Server configuration " puts "--------------------------------------" - pp @config + pp config - puts "--------------------------------------" - puts " Registered Instance Types " - puts "--------------------------------------" - pp @instance_types + STDOUT.flush end - ########################################################################### - # USER and OpenNebula Session Methods - ########################################################################### - - # Generates an OpenNebula Session for the given user - # user:: _Hash_ the user information - # [return] an OpenNebula client session - def one_client_user(name, password) - client = Client.new("dummy:dummy") - if name=="dummy" - #STDERR.puts "#{password}" - client.one_auth = "#{password}" - else - client.one_auth = "#{name}:#{password}" - end - - return client - end - - # Gets the data associated with a user - # name:: _String_ the name of the user - # [return] _Hash_ with the user data - def get_user_password(name) - @user_pool.info - return @user_pool["USER[NAME=\"#{name}\"]/PASSWORD"] - end - - # Gets the username associated with a password - # password:: _String_ the password - # [return] _Hash_ with the username - def get_username(password) - @user_pool.info - #STDERR.puts 'the password is ' + password - #STDERR.puts @user_pool["User[PASSWORD=\"#{password}\"]"] - username = @user_pool["User[PASSWORD=\"#{password}\"]/NAME"] - return username if (username != nil) - - # Check if the DN is part of a |-separted multi-DN password - user_elts = Array.new - @user_pool.each {|e| user_elts << e['PASSWORD']} - multiple_users = user_elts.select {|e| e=~ /\|/ } - matched = nil - multiple_users.each do |e| - e.to_s.split('|').each do |w| - if (w == password) - matched=e - break - end - end - break if matched - end - if matched - password = matched.to_s - end - puts("The password is " + password) - return @user_pool["USER[PASSWORD=\"#{password}\"]/NAME"] - end - # Finds out if a port is available on ip # ip:: _String_ IP address where the port to check is # port:: _String_ port to find out whether is open @@ -157,5 +80,22 @@ class CloudServer return false end -end + def self.get_instance_types(config) + if config[:vm_type] == nil + raise "No VM_TYPE defined." + end + + instance_types = Hash.new + + if config[:vm_type].kind_of?(Array) + config[:vm_type].each {|type| + instance_types[type['NAME']]=type + } + else + instance_types[config[:vm_type]['NAME']]=config[:vm_type] + end + + instance_types + end +end From afdf9d23c529de3e06c1a123fda560f6297d7a6c Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Tue, 20 Sep 2011 18:25:23 +0200 Subject: [PATCH 54/90] feature #795: Adapt EC2 to the new Cloud Auth system --- src/cloud/ec2/etc/econe.conf | 2 + src/cloud/ec2/lib/EC2QueryServer.rb | 186 ++++------------------------ src/cloud/ec2/lib/econe-server.rb | 77 ++++++------ 3 files changed, 64 insertions(+), 201 deletions(-) diff --git a/src/cloud/ec2/etc/econe.conf b/src/cloud/ec2/etc/econe.conf index ca77a3ee8f..5b77f70931 100644 --- a/src/cloud/ec2/etc/econe.conf +++ b/src/cloud/ec2/etc/econe.conf @@ -24,5 +24,7 @@ PORT=4567 # SSL proxy that serves the API (set if is being used) #SSL_SERVER=fqdm.of.the.server +AUTH=ec2 + # VM types allowed and its template file (inside templates directory) VM_TYPE=[NAME=m1.small, TEMPLATE=m1.small.erb] diff --git a/src/cloud/ec2/lib/EC2QueryServer.rb b/src/cloud/ec2/lib/EC2QueryServer.rb index b4845a5805..5240d73be8 100644 --- a/src/cloud/ec2/lib/EC2QueryServer.rb +++ b/src/cloud/ec2/lib/EC2QueryServer.rb @@ -15,7 +15,6 @@ #--------------------------------------------------------------------------- # require 'rubygems' -require 'sinatra' require 'erb' require 'time' require 'AWS' @@ -62,118 +61,26 @@ class EC2QueryServer < CloudServer ########################################################################### - def initialize(config_file,template,views) - super(config_file) - @config.add_configuration_value("TEMPLATE_LOCATION",template) - @config.add_configuration_value("VIEWS",views) - - if @config[:ssl_server] - @server_host=@config[:ssl_server] - else - @server_host=@config[:server] - end - - @server_port=@config[:port] - - print_configuration + def initialize(config) + super(config) end - - ########################################################################### - # Authentication functions - ########################################################################### - - # EC2 protocol authentication function - # params:: of the request - # [return] true if authenticated - def authenticate(params,env) - failed = 'Authentication failed. ' - - # For https, the web service should be set to include the user cert in the environment. - cert_line = env['HTTP_SSL_CLIENT_CERT'] - cert_line = nil if cert_line == '(null)' # For Apache mod_ssl - - if cert_line == nil - # Use the secret key for authentication. - - password = get_user_password(params['AWSAccessKeyId']) - return nil if !password + def authenticate(env, params) + econe_host = @config[:ssl_server] + econe_host ||= @config[:server] - signature = case params['SignatureVersion'] - when "1" then signature_version_1(params.clone, password) - when "2" then signature_version_2(params, - password, - env, - true, - false) - end + econe_port = @config[:port] - if params['Signature']==signature - return one_client_user(params['AWSAccessKeyId'], password) - else - if params['SignatureVersion']=="2" - signature = signature_version_2(params, - password, - env, - false, - false) - if params['Signature']==signature - return one_client_user(params['AWSAccessKeyId'], password) - end - end - end - - return nil - else - # Use the https credentials for authentication - require 'server_auth' - while cert_line - begin - cert_array=cert_line.scan(/([^\s]*)\s/) - cert_array = cert_array[2..-3] - cert_array.unshift('-----BEGIN CERTIFICATE-----') - cert_array.push('-----END CERTIFICATE-----') - cert_pem = cert_array.join("\n") - cert = OpenSSL::X509::Certificate.new(cert_pem) - rescue - raise failed + "Could not create X509 certificate from " + cert_line - end - # Password should be DN with whitespace removed. - subjectname = cert.subject.to_s.delete("\s") - begin - username = get_username(subjectname) - rescue - username = nil - end - break if username - chain_dn = (!chain_dn ? "" : chain_dn) + "\n" + subjectname - chain_index = !chain_index ? 0 : chain_index + 1 - cert_line = env["HTTP_SSL_CLIENT_CERT_CHAIN_#{chain_index}"] - cert_line = nil if cert_line == '(null)' # For Apache mod_ssl - end - - if !cert_line - raise failed + "Username not found in certificate chain " + chain_dn - end - - auth = ServerAuth.new - - login = auth.login_token(username, subjectname, 300) - - STDERR.puts login - - return one_client_user("dummy", login) - - end + params.merge!({:econe_host => econe_host, :econe_port => econe_port}) + super(env, params) end - ########################################################################### # Repository Interface ########################################################################### - def upload_image(params, one_client) - image = ImageEC2.new(Image.build_xml, one_client, params['file']) + def upload_image(params) + image = ImageEC2.new(Image.build_xml, self.client, params['file']) template = image.to_one_template if OpenNebula.is_error?(template) @@ -191,11 +98,11 @@ class EC2QueryServer < CloudServer return response.result(binding), 200 end - def register_image(params, one_client) + def register_image(params) # Get the Image ID tmp, img=params['ImageLocation'].split('-') - image = Image.new(Image.build_xml(img.to_i), one_client) + image = Image.new(Image.build_xml(img.to_i), self.client) # Enable the new Image rc = image.info @@ -211,9 +118,9 @@ class EC2QueryServer < CloudServer return response.result(binding), 200 end - def describe_images(params, one_client) + def describe_images(params) user_flag = OpenNebula::Pool::INFO_GROUP - impool = ImagePool.new(one_client, user_flag) + impool = ImagePool.new(self.client, user_flag) impool.info erb_version = params['Version'] @@ -226,11 +133,11 @@ class EC2QueryServer < CloudServer # Instance Interface ########################################################################### - def run_instances(params, one_client) + def run_instances(params) # Get the instance type and path if params['InstanceType'] != nil instance_type_name = params['InstanceType'] - instance_type = @instance_types[instance_type_name] + instance_type = @config[:instance_types][instance_type_name] if instance_type != nil path = @config[:template_location] + "/#{instance_type['TEMPLATE']}" @@ -252,7 +159,7 @@ class EC2QueryServer < CloudServer template_text = template.result(binding) # Start the VM. - vm = VirtualMachine.new(VirtualMachine.build_xml, one_client) + vm = VirtualMachine.new(VirtualMachine.build_xml, self.client) rc = vm.allocate(template_text) if OpenNebula::is_error?(rc) @@ -270,26 +177,26 @@ class EC2QueryServer < CloudServer return response.result(binding), 200 end - def describe_instances(params, one_client) + def describe_instances(params) user_flag = OpenNebula::Pool::INFO_MINE - vmpool = VirtualMachinePool.new(one_client, user_flag) + vmpool = VirtualMachinePool.new(self.client, user_flag) vmpool.info erb_version = params['Version'] erb_user_name = params['AWSAccessKeyId'] - + response = ERB.new(File.read(@config[:views]+"/describe_instances.erb")) return response.result(binding), 200 end - def terminate_instances(params, one_client) + def terminate_instances(params) # Get the VM ID vmid=params['InstanceId.1'] vmid=params['InstanceId.01'] if !vmid tmp, vmid=vmid.split('-') if vmid[0]==?i - vm = VirtualMachine.new(VirtualMachine.build_xml(vmid),one_client) + vm = VirtualMachine.new(VirtualMachine.build_xml(vmid),self.client) rc = vm.info return OpenNebula::Error.new('Unsupported'),400 if OpenNebula::is_error?(rc) @@ -308,55 +215,6 @@ class EC2QueryServer < CloudServer return response.result(binding), 200 end -private - - # Calculates signature version 1 - def signature_version_1(params, secret_key, digest='sha1') - params.delete('Signature') - req_desc = params.sort {|x,y| x[0].downcase <=> y[0].downcase}.to_s - - digest_generator = OpenSSL::Digest::Digest.new(digest) - digest = OpenSSL::HMAC.digest(digest_generator, - secret_key, - req_desc) - b64sig = Base64.b64encode(digest) - return b64sig.strip - end - - # Calculates signature version 2 - def signature_version_2(params, secret_key, env, includeport=true, urlencode=true) - signature_params = params.reject { |key,value| - key=='Signature' or key=='file' } - - if includeport - server_str = @server_host + ':' + @server_port - else - server_str = @server_host - end - - canonical_str = AWS.canonical_string(signature_params, - server_str, - env['REQUEST_METHOD']) - - # Use the correct signature strength - sha_strength = case params['SignatureMethod'] - when "HmacSHA1" then 'sha1' - when "HmacSHA256" then 'sha256' - else 'sha1' - end - - digest = OpenSSL::Digest::Digest.new(sha_strength) - b64hmac = - Base64.encode64( - OpenSSL::HMAC.digest(digest, secret_key, canonical_str)).gsub("\n","") - - if urlencode - return CGI::escape(b64hmac) - else - return b64hmac - end - end - ########################################################################### # Helper functions ########################################################################### diff --git a/src/cloud/ec2/lib/econe-server.rb b/src/cloud/ec2/lib/econe-server.rb index c9ac018571..def4803bb5 100644 --- a/src/cloud/ec2/lib/econe-server.rb +++ b/src/cloud/ec2/lib/econe-server.rb @@ -42,19 +42,28 @@ require 'rubygems' require 'sinatra' require 'EC2QueryServer' +require 'Configuration' include OpenNebula begin - $econe_server = EC2QueryServer.new(CONFIGURATION_FILE, - TEMPLATE_LOCATION, VIEWS_LOCATION) + config = Configuration.new(CONFIGURATION_FILE) + config.add_configuration_value("TEMPLATE_LOCATION", TEMPLATE_LOCATION) + config.add_configuration_value("VIEWS", VIEWS_LOCATION) + + instance_types = CloudServer.get_instance_types(config) + config.add_configuration_value("INSTANCE_TYPES", instance_types) + + CloudServer.print_configuration(config) + + set :config, config rescue Exception => e puts "Error starting server: #{e}" exit(-1) end -if CloudServer.is_port_open?($econe_server.config[:server], - $econe_server.config[:port]) +if CloudServer.is_port_open?(settings.config[:server], + settings.config[:port]) puts "Port busy, please shutdown the service or move econe server port." exit end @@ -62,23 +71,18 @@ end ############################################################################## # Sinatra Configuration ############################################################################## -set :host, $econe_server.config[:server] -set :port, $econe_server.config[:port] +set :host, settings.config[:server] +set :port, settings.config[:port] ############################################################################## # Actions ############################################################################## before do - #STDERR.puts Time.now.strftime("%d/%b/%Y %H:%M:%S") - begin - @client = $econe_server.authenticate(params,env) - rescue => e - #STDERR.puts Time.now.strftime("%d/%b/%Y %H:%M:%S") + ' Exception in authentication. ' + e.to_s - @client = nil - end - - if @client.nil? + @econe_server = EC2QueryServer.new(settings.config) + result = @econe_server.authenticate(request.env, params) + if result + # Add a log message error 400, error_xml("AuthFailure", 0) end end @@ -86,7 +90,7 @@ end helpers do def error_xml(code,id) message = '' - + case code when 'AuthFailure' message = 'User not authorized' @@ -94,45 +98,44 @@ helpers do message = 'Specified AMI ID does not exist' when 'Unsupported' message = 'The instance type or feature is not supported in your requested Availability Zone.' - else + else message = code end - + xml = ""+ - code + - "" + - message + - "" + - id.to_s + + code + + "" + + message + + "" + + id.to_s + "" - - return xml - end + + return xml + end end post '/' do - do_http_request(params, @client) + do_http_request(params) end get '/' do - do_http_request(params, @client) + do_http_request(params) end -def do_http_request(params, client) - +def do_http_request(params) case params['Action'] when 'UploadImage' - result,rc = $econe_server.upload_image(params, client) + result,rc = @econe_server.upload_image(params) when 'RegisterImage' - result,rc = $econe_server.register_image(params, client) + result,rc = @econe_server.register_image(params) when 'DescribeImages' - result,rc = $econe_server.describe_images(params, client) + result,rc = @econe_server.describe_images(params) when 'RunInstances' - result,rc = $econe_server.run_instances(params, client) + result,rc = @econe_server.run_instances(params) when 'DescribeInstances' - result,rc = $econe_server.describe_instances(params, client) + result,rc = @econe_server.describe_instances(params) when 'TerminateInstances' - result,rc = $econe_server.terminate_instances(params, client) + result,rc = @econe_server.terminate_instances(params) end if OpenNebula::is_error?(result) @@ -141,5 +144,5 @@ def do_http_request(params, client) headers['Content-Type'] = 'application/xml' - result + result end From 196c021cafe0701e67cd05ad0787876df6fb8911 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Tue, 20 Sep 2011 18:25:57 +0200 Subject: [PATCH 55/90] feature #795: Adapt OCCI to the new Cloud Auth system --- src/cloud/occi/etc/occi-server.conf | 2 + src/cloud/occi/lib/OCCIServer.rb | 140 +++++----------------------- src/cloud/occi/lib/occi-server.rb | 60 +++++++----- 3 files changed, 62 insertions(+), 140 deletions(-) diff --git a/src/cloud/occi/etc/occi-server.conf b/src/cloud/occi/etc/occi-server.conf index 2eddedc706..a92f46ce2a 100644 --- a/src/cloud/occi/etc/occi-server.conf +++ b/src/cloud/occi/etc/occi-server.conf @@ -24,6 +24,8 @@ PORT=4567 # SSL proxy that serves the API (set if is being used) #SSL_SERVER=https://localhost:443 +AUTH=basic + # Configuration for OpenNebula's Virtual Networks BRIDGE= diff --git a/src/cloud/occi/lib/OCCIServer.rb b/src/cloud/occi/lib/OCCIServer.rb index f86f90dda5..dc2f54caa0 100755 --- a/src/cloud/occi/lib/OCCIServer.rb +++ b/src/cloud/occi/lib/OCCIServer.rb @@ -15,12 +15,9 @@ #--------------------------------------------------------------------------- # # Common cloud libs -require 'rubygems' -require 'sinatra' require 'CloudServer' # OCA -require 'OpenNebula' include OpenNebula # OCCI libs @@ -43,29 +40,13 @@ class OCCIServer < CloudServer # Server initializer # config_file:: _String_ path of the config file # template:: _String_ path to the location of the templates - def initialize(config_file,template) - super(config_file) + def initialize(config) + super(config) - @config.add_configuration_value("TEMPLATE_LOCATION",template) - - if @config[:ssl_server] - @base_url=@config[:ssl_server] + if config[:ssl_server] + @base_url=config[:ssl_server] else - @base_url="http://#{@config[:server]}:#{@config[:port]}" - end - - print_configuration - end - - # Retrieve a client with the user credentials - # requestenv:: _Hash_ Hash containing the environment of the request - # [return] _Client_ client with the user credentials - def get_client(requestenv) - auth = Rack::Auth::Basic::Request.new(requestenv) - if auth - return one_client_user(auth.credentials[0], auth.credentials[1]) - else - return nil + @base_url="http://#{config[:server]}:#{config[:port]}" end end @@ -92,13 +73,8 @@ class OCCIServer < CloudServer # --- Get User's VMs --- user_flag = -1 - one_client = get_client(request.env) - if !one_client - return "No authorization data present", 401 - end - vmpool = VirtualMachinePoolOCCI.new( - one_client, + self.client, user_flag) # --- Prepare XML Response --- @@ -124,13 +100,8 @@ class OCCIServer < CloudServer # --- Get User's VNETs --- user_flag = -1 - one_client = get_client(request.env) - if !one_client - return "No authorization data present", 401 - end - network_pool = VirtualNetworkPoolOCCI.new( - one_client, + self.client, user_flag) # --- Prepare XML Response --- @@ -155,13 +126,8 @@ class OCCIServer < CloudServer # --- Get User's Images --- user_flag = -1 - one_client = get_client(request.env) - if !one_client - return "No authorization data present", 401 - end - image_pool = ImagePoolOCCI.new( - one_client, + self.client, user_flag) # --- Prepare XML Response --- @@ -193,16 +159,11 @@ class OCCIServer < CloudServer # [return] _String_,_Integer_ COMPUTE Representation or error, status code def post_compute(request) # --- Create the new Instance --- - one_client = get_client(request.env) - if !one_client - return "No authorization data present", 401 - end - vm = VirtualMachineOCCI.new( VirtualMachine.build_xml, - one_client, + self.client, request.body.read, - @instance_types, + @config[:instance_types], @config[:template_location]) # --- Generate the template and Allocate the new Instance --- @@ -223,14 +184,9 @@ class OCCIServer < CloudServer # status code def get_compute(request, params) # --- Get the VM --- - one_client = get_client(request.env) - if !one_client - return "No authorization data present", 401 - end - vm = VirtualMachineOCCI.new( VirtualMachine.build_xml(params[:id]), - one_client) + self.client) # --- Prepare XML Response --- rc = vm.info @@ -253,14 +209,9 @@ class OCCIServer < CloudServer # status code def delete_compute(request, params) # --- Get the VM --- - one_client = get_client(request.env) - if !one_client - return "No authorization data present", 401 - end - vm = VirtualMachineOCCI.new( VirtualMachine.build_xml(params[:id]), - one_client) + self.client) rc = vm.info return rc, 404 if OpenNebula::is_error?(rc) @@ -278,14 +229,9 @@ class OCCIServer < CloudServer # status code def put_compute(request, params) # --- Get the VM --- - one_client = get_client(request.env) - if !one_client - return "No authorization data present", 401 - end - vm = VirtualMachineOCCI.new( VirtualMachine.build_xml(params[:id]), - one_client) + self.client) rc = vm.info return rc, 400 if OpenNebula.is_error?(rc) @@ -362,14 +308,9 @@ class OCCIServer < CloudServer # [return] _String_,_Integer_ Network Representation or error, status code def post_network(request) # --- Create the new Instance --- - one_client = get_client(request.env) - if !one_client - return "No authorization data present", 401 - end - network = VirtualNetworkOCCI.new( VirtualNetwork.build_xml, - one_client, + self.client, request.body, @config[:bridge]) @@ -390,15 +331,9 @@ class OCCIServer < CloudServer # [return] _String_,_Integer_ NETWORK occi representation or error, # status code def get_network(request, params) - # --- Get the VNET --- - one_client = get_client(request.env) - if !one_client - return "No authorization data present", 401 - end - network = VirtualNetworkOCCI.new( VirtualNetwork.build_xml(params[:id]), - one_client) + self.client) # --- Prepare XML Response --- rc = network.info @@ -419,15 +354,9 @@ class OCCIServer < CloudServer # [return] _String_,_Integer_ Delete confirmation msg or error, # status code def delete_network(request, params) - # --- Get the VNET --- - one_client = get_client(request.env) - if !one_client - return "No authorization data present", 401 - end - network = VirtualNetworkOCCI.new( VirtualNetwork.build_xml(params[:id]), - one_client) + self.client) rc = network.info return rc, 404 if OpenNebula::is_error?(rc) @@ -446,15 +375,10 @@ class OCCIServer < CloudServer def put_network(request, params) xmldoc = XMLElement.build_xml(request.body, 'NETWORK') vnet_info = XMLElement.new(xmldoc) if xmldoc != nil - - one_client = get_client(request.env) - if !one_client - return "No authorization data present", 401 - end vnet = VirtualNetworkOCCI.new( VirtualNetwork.build_xml(params[:id]), - one_client) + self.client) rc = vnet.info return rc, 400 if OpenNebula.is_error?(rc) @@ -487,11 +411,6 @@ class OCCIServer < CloudServer error = OpenNebula::Error.new(error_msg) return error, 400 end - - one_client = get_client(request.env) - if !one_client - return "No authorization data present", 401 - end # --- Create and Add the new Image --- occixml = request.params['occixml'] @@ -499,7 +418,7 @@ class OCCIServer < CloudServer image = ImageOCCI.new( Image.build_xml, - one_client, + self.client, occixml, request.params['file']) @@ -521,14 +440,9 @@ class OCCIServer < CloudServer # status code def get_storage(request, params) # --- Get the Image --- - one_client = get_client(request.env) - if !one_client - return "No authorization data present", 401 - end - image = ImageOCCI.new( Image.build_xml(params[:id]), - one_client) + self.client) rc = image.info @@ -550,20 +464,15 @@ class OCCIServer < CloudServer # status code def delete_storage(request, params) # --- Get the Image --- - one_client = get_client(request.env) - if !one_client - return "No authorization data present", 401 - end - image = ImageOCCI.new( Image.build_xml(params[:id]), - one_client) + self.client) rc = image.info return rc, 404 if OpenNebula::is_error?(rc) # --- Delete the Image --- - rc = @img_repo.delete(image) + rc = image.delete return rc, 500 if OpenNebula::is_error?(rc) return "", 204 @@ -576,15 +485,10 @@ class OCCIServer < CloudServer def put_storage(request, params) xmldoc = XMLElement.build_xml(request.body, 'STORAGE') image_info = XMLElement.new(xmldoc) if xmldoc != nil - - one_client = get_client(request.env) - if !one_client - return "No authorization data present", 401 - end image = ImageOCCI.new( Image.build_xml(params[:id]), - one_client) + self.client) rc = image.info return rc, 400 if OpenNebula.is_error?(rc) diff --git a/src/cloud/occi/lib/occi-server.rb b/src/cloud/occi/lib/occi-server.rb index 136bfd482c..81950cc5ae 100755 --- a/src/cloud/occi/lib/occi-server.rb +++ b/src/cloud/occi/lib/occi-server.rb @@ -43,21 +43,29 @@ $: << RUBY_LIB_LOCATION+"/cloud" # For the Repository Manager ################################################ require 'rubygems' require 'sinatra' -require 'OCCIServer' -require 'OpenNebula' +require 'OCCIServer' +require 'Configuration' include OpenNebula begin - $occi_server = OCCIServer.new(CONFIGURATION_FILE, TEMPLATE_LOCATION) + config = Configuration.new(CONFIGURATION_FILE) + config.add_configuration_value("TEMPLATE_LOCATION", TEMPLATE_LOCATION) + + instance_types = CloudServer.get_instance_types(config) + config.add_configuration_value("INSTANCE_TYPES", instance_types) + + CloudServer.print_configuration(config) + + set :config, config rescue Exception => e puts "Error starting server: #{e}" exit(-1) end -if CloudServer.is_port_open?($occi_server.config[:server], - $occi_server.config[:port]) +if CloudServer.is_port_open?(settings.config[:server], + settings.config[:port]) puts "Port busy, please shutdown the service or move occi server port." exit end @@ -65,13 +73,21 @@ end ############################################################################## # Sinatra Configuration ############################################################################## -set :host, $occi_server.config[:server] -set :port, $occi_server.config[:port] +set :host, settings.config[:server] +set :port, settings.config[:port] ############################################################################## # Helpers ############################################################################## +before do + @occi_server = OCCIServer.new(settings.config) + result = @occi_server.authenticate(request.env) + if result + error 401, result + end +end + # Response treatment helpers do def treat_response(result,rc) @@ -93,32 +109,32 @@ end ################################################### post '/compute' do - result,rc = $occi_server.post_compute(request) + result,rc = @occi_server.post_compute(request) treat_response(result,rc) end get '/compute' do - result,rc = $occi_server.get_computes(request) + result,rc = @occi_server.get_computes(request) treat_response(result,rc) end post '/network' do - result,rc = $occi_server.post_network(request) + result,rc = @occi_server.post_network(request) treat_response(result,rc) end get '/network' do - result,rc = $occi_server.get_networks(request) + result,rc = @occi_server.get_networks(request) treat_response(result,rc) end post '/storage' do - result,rc = $occi_server.post_storage(request) + result,rc = @occi_server.post_storage(request) treat_response(result,rc) end get '/storage' do - result,rc = $occi_server.get_storages(request) + result,rc = @occi_server.get_storages(request) treat_response(result,rc) end @@ -127,46 +143,46 @@ end ################################################### get '/compute/:id' do - result,rc = $occi_server.get_compute(request, params) + result,rc = @occi_server.get_compute(request, params) treat_response(result,rc) end delete '/compute/:id' do - result,rc = $occi_server.delete_compute(request, params) + result,rc = @occi_server.delete_compute(request, params) treat_response(result,rc) end put '/compute/:id' do - result,rc = $occi_server.put_compute(request, params) + result,rc = @occi_server.put_compute(request, params) treat_response(result,rc) end get '/network/:id' do - result,rc = $occi_server.get_network(request, params) + result,rc = @occi_server.get_network(request, params) treat_response(result,rc) end delete '/network/:id' do - result,rc = $occi_server.delete_network(request, params) + result,rc = @occi_server.delete_network(request, params) treat_response(result,rc) end put '/network/:id' do - result,rc = $occi_server.put_network(request, params) + result,rc = @occi_server.put_network(request, params) treat_response(result,rc) end get '/storage/:id' do - result,rc = $occi_server.get_storage(request, params) + result,rc = @occi_server.get_storage(request, params) treat_response(result,rc) end delete '/storage/:id' do - result,rc = $occi_server.delete_storage(request, params) + result,rc = @occi_server.delete_storage(request, params) treat_response(result,rc) end put '/storage/:id' do - result,rc = $occi_server.put_storage(request, params) + result,rc = @occi_server.put_storage(request, params) treat_response(result,rc) end From 96db2d58443e2fc2dbed143539363db4955a7a81 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Tue, 20 Sep 2011 18:27:36 +0200 Subject: [PATCH 56/90] feature #795: Adapt Sunstone to the new Cloud Auth system --- src/sunstone/etc/sunstone-server.conf | 5 +++ src/sunstone/models/SunstoneServer.rb | 33 +--------------- src/sunstone/sunstone-server.rb | 54 +++++++++++++++------------ 3 files changed, 37 insertions(+), 55 deletions(-) diff --git a/src/sunstone/etc/sunstone-server.conf b/src/sunstone/etc/sunstone-server.conf index 37ff230bdc..87e53d4047 100644 --- a/src/sunstone/etc/sunstone-server.conf +++ b/src/sunstone/etc/sunstone-server.conf @@ -1,7 +1,12 @@ +# OpenNebula sever contact information +ONE_XMLRPC=http://localhost:2633/RPC2 + # Server Configuration HOST=127.0.0.1 PORT=9869 +AUTH=basic + # VNC Configuration VNC_PROXY_BASE_PORT=29876 NOVNC_PATH= diff --git a/src/sunstone/models/SunstoneServer.rb b/src/sunstone/models/SunstoneServer.rb index fc09d4632f..02283816a4 100644 --- a/src/sunstone/models/SunstoneServer.rb +++ b/src/sunstone/models/SunstoneServer.rb @@ -23,37 +23,8 @@ class SunstoneServer # FLAG that will filter the elements retrieved from the Pools POOL_FILTER = Pool::INFO_GROUP - def initialize(username, password) - # TBD one_client_user(name) from CloudServer - @client = Client.new("dummy:dummy") - @client.one_auth = "#{username}:#{password}" - end - - ############################################################################ - # - ############################################################################ - def self.authorize(user="", sha1_pass="") - if user.empty? || sha1_pass.empty? - return [401, false] - end - - # TBD get_user_password(name) from CloudServer - user_pool = UserPool.new(Client.new) - rc = user_pool.info - if OpenNebula.is_error?(rc) - return [500, false] - end - - user_pass = user_pool["USER[NAME=\"#{user}\"]/PASSWORD"] - user_id = user_pool["USER[NAME=\"#{user}\"]/ID"] - user_gid = user_pool["USER[NAME=\"#{user}\"]/GID"] - user_gname = user_pool["USER[NAME=\"#{user}\"]/GNAME"] - - if user_pass == sha1_pass - return [204, [user_id, user_gid, user_gname]] - else - return [401, nil] - end + def initialize(token, xmlrpc) + @client = Client.new(token, xmlrpc, false) end ############################################################################ diff --git a/src/sunstone/sunstone-server.rb b/src/sunstone/sunstone-server.rb index d348cf41f1..c4935e8b61 100755 --- a/src/sunstone/sunstone-server.rb +++ b/src/sunstone/sunstone-server.rb @@ -36,6 +36,7 @@ end SUNSTONE_ROOT_DIR = File.dirname(__FILE__) $: << RUBY_LIB_LOCATION +$: << RUBY_LIB_LOCATION+'/cloud' $: << SUNSTONE_ROOT_DIR+'/models' ############################################################################## @@ -45,7 +46,7 @@ require 'rubygems' require 'sinatra' require 'erb' -require 'cloud/Configuration' +require 'Configuration' require 'SunstoneServer' require 'SunstonePlugins' @@ -67,32 +68,35 @@ helpers do end def build_session - auth = Rack::Auth::Basic::Request.new(request.env) - if auth.provided? && auth.basic? && auth.credentials - user = auth.credentials[0] - sha1_pass = Digest::SHA1.hexdigest(auth.credentials[1]) + cloud_auth = CloudAuth.new(settings.config) - rc = SunstoneServer.authorize(user, sha1_pass) - if rc[1] - session[:user] = user - session[:user_id] = rc[1][0] - session[:user_gid] = rc[1][1] - session[:user_gname] = rc[1][2] - session[:password] = sha1_pass - session[:ip] = request.ip - session[:remember] = params[:remember] + result = cloud_auth.auth(request.env, params) + if result + return [401, ""] + else + user_id = OpenNebula::User::SELF + user = OpenNebula::User.new_with_id(user_id, cloud_auth.client) - if params[:remember] - env['rack.session.options'][:expire_after] = 30*60*60*24 - end - - return [204, ""] - else - return [rc.first, ""] + rc = user.info + if OpenNebula.is_error?(rc) + # Add a log message + return [500, ""] end - end + + session[:user] = user['NAME'] + session[:user_id] = user['ID'] + session[:user_gid] = user['GID'] + session[:user_gname] = user['GNAME'] + session[:token] = cloud_auth.token + session[:ip] = request.ip + session[:remember] = params[:remember] - return [401, ""] + if params[:remember] + env['rack.session.options'][:expire_after] = 30*60*60*24 + end + + return [204, ""] + end end def destroy_session @@ -105,7 +109,9 @@ before do unless request.path=='/login' || request.path=='/' halt 401 unless authorized? - @SunstoneServer = SunstoneServer.new(session[:user], session[:password]) + @SunstoneServer = SunstoneServer.new( + session[:token], + settings.config[:one_xmlrpc]) end end From 1b20904032571d03af70210d9f679bca9f359dcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 21 Sep 2011 04:16:27 -0700 Subject: [PATCH 57/90] Bug #820: Execute the ALLOCATE hooks only if the allocation is successful --- src/pool/PoolSQL.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pool/PoolSQL.cc b/src/pool/PoolSQL.cc index 175db7be9f..d615d9dce0 100644 --- a/src/pool/PoolSQL.cc +++ b/src/pool/PoolSQL.cc @@ -122,10 +122,9 @@ int PoolSQL::allocate( else { rc = lastOID; + do_hooks(objsql, Hook::ALLOCATE); } - do_hooks(objsql, Hook::ALLOCATE); - objsql->unlock(); delete objsql; From 77cf88ca5d256a5fd3aa2489d341de455f79c73c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 21 Sep 2011 16:13:04 +0200 Subject: [PATCH 58/90] Clean some TODOs in core --- include/Nebula.h | 14 +++++++++----- include/RequestManagerChown.h | 9 +++++++++ src/rm/RequestManagerChown.cc | 9 --------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/include/Nebula.h b/include/Nebula.h index 0f7e4de8e7..c242e56644 100644 --- a/include/Nebula.h +++ b/include/Nebula.h @@ -449,8 +449,9 @@ private: void bootstrap(); /** - * Callback function to TODO - * @param _loaded_db_version TODO + * Callback function for the check_db_version method. Stores the read + * version in loaded_db_version + * @param _loaded_db_version returned columns * @param num the number of columns read from the DB * @param names the column names * @param vaues the column values @@ -459,9 +460,12 @@ private: int select_cb(void *_loaded_db_version, int num, char **values, char **names); - /* - * TODO - * @return 0 ok, -1 version mismatch, -2 needs bootstrap + /** + * Reads the current DB version. + * + * @return 0 on success, + * -1 if there is a version mismatch, + * -2 if the DB needs a bootstrap */ int check_db_version(); }; diff --git a/include/RequestManagerChown.h b/include/RequestManagerChown.h index 6632900d97..5dff310e4e 100644 --- a/include/RequestManagerChown.h +++ b/include/RequestManagerChown.h @@ -35,12 +35,21 @@ protected: :Request(method_name,params,help) { auth_op = AuthRequest::CHOWN; + + Nebula& nd = Nebula::instance(); + gpool = nd.get_gpool(); + upool = nd.get_upool(); }; ~RequestManagerChown(){}; /* -------------------------------------------------------------------- */ + GroupPool * gpool; + UserPool * upool; + + /* -------------------------------------------------------------------- */ + virtual void request_execute(xmlrpc_c::paramList const& _paramList, RequestAttributes& att); }; diff --git a/src/rm/RequestManagerChown.cc b/src/rm/RequestManagerChown.cc index 6f311dffb3..0364ea0bc3 100644 --- a/src/rm/RequestManagerChown.cc +++ b/src/rm/RequestManagerChown.cc @@ -32,11 +32,6 @@ void RequestManagerChown::request_execute(xmlrpc_c::paramList const& paramList, string nuname; string ngname; - // TODO: Move these to constructor? - Nebula& nd = Nebula::instance(); - GroupPool * gpool = nd.get_gpool(); - UserPool * upool = nd.get_upool(); - PoolObjectSQL * object; if ( basic_authorization(oid, att) == false ) @@ -123,10 +118,6 @@ void UserChown::request_execute(xmlrpc_c::paramList const& paramList, string ngname; - Nebula& nd = Nebula::instance(); - GroupPool * gpool = nd.get_gpool(); - UserPool * upool = static_cast(pool); - User * user; Group * group; From 54f769170dd2fb4afdd34090f0a2d5fec5b19e3c Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 21 Sep 2011 18:59:13 +0200 Subject: [PATCH 59/90] feature #795: Add new Cloud Auth files to install.sh --- install.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/install.sh b/install.sh index 8a28e0d9cd..a32946f643 100755 --- a/install.sh +++ b/install.sh @@ -202,6 +202,7 @@ LIB_DIRS="$LIB_LOCATION/ruby \ $LIB_LOCATION/ruby/cloud/econe \ $LIB_LOCATION/ruby/cloud/econe/views \ $LIB_LOCATION/ruby/cloud/occi \ + $LIB_LOCATION/ruby/cloud/CloudAuth \ $LIB_LOCATION/ruby/onedb \ $LIB_LOCATION/tm_commands \ $LIB_LOCATION/tm_commands/nfs \ @@ -349,6 +350,7 @@ INSTALL_FILES=( HOOK_FT_FILES:$VAR_LOCATION/remotes/hooks/ft HOOK_NETWORK_FILES:$VAR_LOCATION/remotes/hooks/vnm COMMON_CLOUD_LIB_FILES:$LIB_LOCATION/ruby/cloud + CLOUD_AUTH_LIB_FILES:$LIB_LOCATION/ruby/cloud/CloudAuth ECO_LIB_FILES:$LIB_LOCATION/ruby/cloud/econe ECO_LIB_VIEW_FILES:$LIB_LOCATION/ruby/cloud/econe/views ECO_BIN_FILES:$BIN_LOCATION @@ -796,10 +798,15 @@ RUBY_OPENNEBULA_LIB_FILES="src/oca/ruby/OpenNebula/Host.rb \ COMMON_CLOUD_LIB_FILES="src/cloud/common/CloudServer.rb \ src/cloud/common/CloudClient.rb \ + src/cloud/common/CloudAuth.rb src/cloud/common/Configuration.rb" COMMON_CLOUD_CLIENT_LIB_FILES="src/cloud/common/CloudClient.rb" +CLOUD_AUTH_LIB_FILES="src/cloud/common/CloudAuth/BasicCloudAuth.rb \ + src/cloud/common/CloudAuth/EC2CloudAuth.rb \ + src/cloud/common/CloudAuth/X509CloudAuth.rb" + #------------------------------------------------------------------------------- # EC2 Query for OpenNebula #------------------------------------------------------------------------------- From 9419406f6e7cfd867e968392bba2b63b74d507c9 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 21 Sep 2011 19:00:49 +0200 Subject: [PATCH 60/90] feature #795: Add conf variable for Cloud Auth --- src/cloud/common/CloudAuth.rb | 10 +++++----- src/cloud/common/CloudServer.rb | 18 ------------------ 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/src/cloud/common/CloudAuth.rb b/src/cloud/common/CloudAuth.rb index 0dae4b76d9..292c5718e4 100644 --- a/src/cloud/common/CloudAuth.rb +++ b/src/cloud/common/CloudAuth.rb @@ -8,11 +8,11 @@ class CloudAuth attr_reader :client, :token def initialize(conf) - @xmlrpc = conf[:one_xmlrpc] + @conf = conf - if AUTH_MODULES.include?(conf[:auth]) - require 'CloudAuth/' + AUTH_MODULES[conf[:auth]] - extend Kernel.const_get(AUTH_MODULES[conf[:auth]]) + if AUTH_MODULES.include?(@conf[:auth]) + require 'CloudAuth/' + AUTH_MODULES[@conf[:auth]] + extend Kernel.const_get(AUTH_MODULES[@conf[:auth]]) else raise "Auth module not specified" end @@ -21,7 +21,7 @@ class CloudAuth protected def get_password(username) - @oneadmin_client ||= OpenNebula::Client.new(nil, @xmlrpc) + @oneadmin_client ||= OpenNebula::Client.new(nil, @conf[:one_xmlrpc]) if @user_pool.nil? @user_pool ||= OpenNebula::UserPool.new(@oneadmin_client) diff --git a/src/cloud/common/CloudServer.rb b/src/cloud/common/CloudServer.rb index b5abc10ca2..91c5335701 100755 --- a/src/cloud/common/CloudServer.rb +++ b/src/cloud/common/CloudServer.rb @@ -80,22 +80,4 @@ class CloudServer return false end - - def self.get_instance_types(config) - if config[:vm_type] == nil - raise "No VM_TYPE defined." - end - - instance_types = Hash.new - - if config[:vm_type].kind_of?(Array) - config[:vm_type].each {|type| - instance_types[type['NAME']]=type - } - else - instance_types[config[:vm_type]['NAME']]=config[:vm_type] - end - - instance_types - end end From 2be5ec56942c1d9b9a23f68b8d7e8fd433670a00 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 21 Sep 2011 19:01:31 +0200 Subject: [PATCH 61/90] feature #795: Use yaml conf file in EC2 --- src/cloud/ec2/lib/EC2QueryServer.rb | 4 ++-- src/cloud/ec2/lib/econe-server.rb | 34 ++++++++++++++--------------- src/cloud/occi/etc/occi-server.conf | 32 ++++++++++++++++----------- 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/src/cloud/ec2/lib/EC2QueryServer.rb b/src/cloud/ec2/lib/EC2QueryServer.rb index 5240d73be8..0783f3da34 100644 --- a/src/cloud/ec2/lib/EC2QueryServer.rb +++ b/src/cloud/ec2/lib/EC2QueryServer.rb @@ -137,10 +137,10 @@ class EC2QueryServer < CloudServer # Get the instance type and path if params['InstanceType'] != nil instance_type_name = params['InstanceType'] - instance_type = @config[:instance_types][instance_type_name] + instance_type = @config[:instance_types][instance_type_name.to_sym] if instance_type != nil - path = @config[:template_location] + "/#{instance_type['TEMPLATE']}" + path = @config[:template_location] + "/#{instance_type[:template]}" end end diff --git a/src/cloud/ec2/lib/econe-server.rb b/src/cloud/ec2/lib/econe-server.rb index def4803bb5..a3f9da84e7 100644 --- a/src/cloud/ec2/lib/econe-server.rb +++ b/src/cloud/ec2/lib/econe-server.rb @@ -46,34 +46,34 @@ require 'Configuration' include OpenNebula +############################################################################## +# Parse Configuration file +############################################################################## begin - config = Configuration.new(CONFIGURATION_FILE) - config.add_configuration_value("TEMPLATE_LOCATION", TEMPLATE_LOCATION) - config.add_configuration_value("VIEWS", VIEWS_LOCATION) - - instance_types = CloudServer.get_instance_types(config) - config.add_configuration_value("INSTANCE_TYPES", instance_types) - - CloudServer.print_configuration(config) - - set :config, config + conf = YAML.load_file(CONFIGURATION_FILE) rescue Exception => e - puts "Error starting server: #{e}" - exit(-1) + puts "Error parsing config file #{CONFIGURATION_FILE}: #{e.message}" + exit 1 end -if CloudServer.is_port_open?(settings.config[:server], - settings.config[:port]) - puts "Port busy, please shutdown the service or move econe server port." - exit -end +conf[:template_location] = TEMPLATE_LOCATION +conf[:views] = VIEWS_LOCATION + +CloudServer.print_configuration(conf) ############################################################################## # Sinatra Configuration ############################################################################## +set :config, conf set :host, settings.config[:server] set :port, settings.config[:port] +if CloudServer.is_port_open?(settings.config[:server], + settings.config[:port]) + puts "Port busy, please shutdown the service or move econe server port." + exit 1 +end + ############################################################################## # Actions ############################################################################## diff --git a/src/cloud/occi/etc/occi-server.conf b/src/cloud/occi/etc/occi-server.conf index a92f46ce2a..ec74643b19 100644 --- a/src/cloud/occi/etc/occi-server.conf +++ b/src/cloud/occi/etc/occi-server.conf @@ -14,23 +14,29 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -# OpenNebula server contact information -ONE_XMLRPC=http://localhost:2633/RPC2 +# OpenNebula sever contact information +:one_xmlrpc: http://localhost:2633/RPC2 -# Host and port where the occi server will run -SERVER= -PORT=4567 +# Host and port where econe server will run +:server: localhost +:port: 4567 # SSL proxy that serves the API (set if is being used) -#SSL_SERVER=https://localhost:443 - -AUTH=basic +#:ssl_server: fqdm.of.the.server # Configuration for OpenNebula's Virtual Networks -BRIDGE= +#:bridge: +:bridge: vbr1 + +:auth: basic # VM types allowed and its template file (inside templates directory) -VM_TYPE=[NAME=custom, TEMPLATE=custom.erb] -VM_TYPE=[NAME=small, TEMPLATE=small.erb] -VM_TYPE=[NAME=medium, TEMPLATE=medium.erb] -VM_TYPE=[NAME=large, TEMPLATE=large.erb] +:instance_types: + :custom: + :template: custom.erb + :small: + :template: small.erb + :medium: + :template: medium.erb + :large: + :template: large.erb From 3276069da2cbfeed8f88cedec5490e476007f513 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 21 Sep 2011 19:02:30 +0200 Subject: [PATCH 62/90] feature #795: Use yaml conf file in OCCI --- src/cloud/occi/lib/VirtualMachineOCCI.rb | 4 ++-- src/cloud/occi/lib/occi-server.rb | 30 ++++++++++++------------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/cloud/occi/lib/VirtualMachineOCCI.rb b/src/cloud/occi/lib/VirtualMachineOCCI.rb index 6d62bfe724..7ed361cc00 100755 --- a/src/cloud/occi/lib/VirtualMachineOCCI.rb +++ b/src/cloud/occi/lib/VirtualMachineOCCI.rb @@ -77,8 +77,8 @@ class VirtualMachineOCCI < VirtualMachine if @vm_info != nil itype = @vm_info['INSTANCE_TYPE'] - if itype != nil and types[itype] != nil - @template = base + "/#{types[itype]['TEMPLATE']}" + if itype != nil and types[itype.to_sym] != nil + @template = base + "/#{types[itype.to_sym][:template]}" end end diff --git a/src/cloud/occi/lib/occi-server.rb b/src/cloud/occi/lib/occi-server.rb index 81950cc5ae..012dcb5912 100755 --- a/src/cloud/occi/lib/occi-server.rb +++ b/src/cloud/occi/lib/occi-server.rb @@ -45,34 +45,34 @@ require 'rubygems' require 'sinatra' require 'OCCIServer' -require 'Configuration' include OpenNebula +############################################################################## +# Parse Configuration file +############################################################################## begin - config = Configuration.new(CONFIGURATION_FILE) - config.add_configuration_value("TEMPLATE_LOCATION", TEMPLATE_LOCATION) - - instance_types = CloudServer.get_instance_types(config) - config.add_configuration_value("INSTANCE_TYPES", instance_types) - - CloudServer.print_configuration(config) - - set :config, config + conf = YAML.load_file(CONFIGURATION_FILE) rescue Exception => e - puts "Error starting server: #{e}" - exit(-1) + puts "Error parsing config file #{CONFIGURATION_FILE}: #{e.message}" + exit 1 end +conf[:template_location] = TEMPLATE_LOCATION + +CloudServer.print_configuration(conf) + +############################################################################## +# Sinatra Configuration +############################################################################## +set :config, conf + if CloudServer.is_port_open?(settings.config[:server], settings.config[:port]) puts "Port busy, please shutdown the service or move occi server port." exit end -############################################################################## -# Sinatra Configuration -############################################################################## set :host, settings.config[:server] set :port, settings.config[:port] From 1ae44ee2bc1550b00da8662437830c8628d71327 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 21 Sep 2011 19:08:41 +0200 Subject: [PATCH 63/90] feature #795: Change sunstone init script --- src/sunstone/bin/sunstone-server | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/sunstone/bin/sunstone-server b/src/sunstone/bin/sunstone-server index 74ad261176..8afe86013f 100755 --- a/src/sunstone/bin/sunstone-server +++ b/src/sunstone/bin/sunstone-server @@ -19,13 +19,13 @@ if [ -z "$ONE_LOCATION" ]; then SUNSTONE_PID=/var/run/one/sunstone.pid - SUNSTONE_SERVER=/usr/lib/one/sunstone/config.ru + SUNSTONE_SERVER=/usr/lib/one/sunstone/sunstone-server.rb SUNSTONE_LOCK_FILE=/var/lock/one/.sunstone.lock SUNSTONE_LOG=/var/log/one/sunstone.log SUNSTONE_CONF=/etc/one/sunstone-server.conf else SUNSTONE_PID=$ONE_LOCATION/var/sunstone.pid - SUNSTONE_SERVER=$ONE_LOCATION/lib/sunstone/config.ru + SUNSTONE_SERVER=$ONE_LOCATION/lib/sunstone/sunstone-server.rb SUNSTONE_LOCK_FILE=$ONE_LOCATION/var/.sunstone.lock SUNSTONE_LOG=$ONE_LOCATION/var/sunstone.log SUNSTONE_CONF=$ONE_LOCATION/etc/sunstone-server.conf @@ -56,23 +56,16 @@ start() echo "Can not find $SUNSTONE_SERVER." exit 1 fi - - source $SUNSTONE_CONF - - lsof -i:$PORT &> /dev/null - if [ $? -eq 0 ]; then - echo "The port $PORT is being used. Please specify a different one." - exit 1 - fi # Start the sunstone daemon touch $SUNSTONE_LOCK_FILE - rackup $SUNSTONE_SERVER -s thin -p $PORT -o $HOST \ - -P $SUNSTONE_PID &> $SUNSTONE_LOG & + ruby $SUNSTONE_SERVER > $SUNSTONE_LOG 2>&1 & LASTPID=$! if [ $? -ne 0 ]; then echo "Error executing $SUNSTONE_SERVER, please check the log $SUNSTONE_LOG" exit 1 + else + echo $LASTPID > $SUNSTONE_PID fi sleep 1 @@ -83,7 +76,7 @@ start() exit 1 fi - echo "sunstone-server listening on $HOST:$PORT" + echo "sunstone-server started" } # From 9e3c3cb8982b09433154c0b00a3b437b3e9879d6 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 21 Sep 2011 19:09:23 +0200 Subject: [PATCH 64/90] feature #795: Add hash_passwords option --- src/cloud/common/CloudAuth/BasicCloudAuth.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cloud/common/CloudAuth/BasicCloudAuth.rb b/src/cloud/common/CloudAuth/BasicCloudAuth.rb index c4d53e8c03..63a60369d1 100644 --- a/src/cloud/common/CloudAuth/BasicCloudAuth.rb +++ b/src/cloud/common/CloudAuth/BasicCloudAuth.rb @@ -5,6 +5,10 @@ module BasicCloudAuth if auth.provided? && auth.basic? username, password = auth.credentials + if @conf[:hash_passwords] + password = Digest::SHA1.hexdigest(password) + end + one_pass = get_password(username) if one_pass && one_pass == password @token = "#{username}:#{password}" From b52e99c0dd408a18c6035b5bd1248ff744fad14c Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 21 Sep 2011 19:10:17 +0200 Subject: [PATCH 65/90] feature #795: Add econe.conf yaml --- src/cloud/ec2/etc/econe.conf | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/cloud/ec2/etc/econe.conf b/src/cloud/ec2/etc/econe.conf index 5b77f70931..6d71e86e56 100644 --- a/src/cloud/ec2/etc/econe.conf +++ b/src/cloud/ec2/etc/econe.conf @@ -15,16 +15,18 @@ #--------------------------------------------------------------------------- # # OpenNebula sever contact information -ONE_XMLRPC=http://localhost:2633/RPC2 +:one_xmlrpc: http://localhost:2633/RPC2 # Host and port where econe server will run -SERVER= -PORT=4567 +:server: localhost +:port: 4567 # SSL proxy that serves the API (set if is being used) -#SSL_SERVER=fqdm.of.the.server +#:ssl_server: fqdm.of.the.server -AUTH=ec2 +:auth: ec2 # VM types allowed and its template file (inside templates directory) -VM_TYPE=[NAME=m1.small, TEMPLATE=m1.small.erb] +:instance_types: + :m1.small: + :template: m1.small.erb From 4623bdc264c394c185eb1126fb1d2ead43e9a43b Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 21 Sep 2011 19:10:49 +0200 Subject: [PATCH 66/90] feature #795: Use yaml conf file in Sunstone --- src/sunstone/etc/sunstone-server.conf | 12 ++++++------ src/sunstone/sunstone-server.rb | 14 +++++++++++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/sunstone/etc/sunstone-server.conf b/src/sunstone/etc/sunstone-server.conf index 87e53d4047..b15fb6941d 100644 --- a/src/sunstone/etc/sunstone-server.conf +++ b/src/sunstone/etc/sunstone-server.conf @@ -1,12 +1,12 @@ # OpenNebula sever contact information -ONE_XMLRPC=http://localhost:2633/RPC2 +:one_xmlrpc: http://localhost:2633/RPC2 # Server Configuration -HOST=127.0.0.1 -PORT=9869 +:host: 127.0.0.1 +:port: 9869 -AUTH=basic +:auth: basic # VNC Configuration -VNC_PROXY_BASE_PORT=29876 -NOVNC_PATH= +:vnc_proxy_base_port: 29876 +:novnc_path: diff --git a/src/sunstone/sunstone-server.rb b/src/sunstone/sunstone-server.rb index c4935e8b61..99ddb7f862 100755 --- a/src/sunstone/sunstone-server.rb +++ b/src/sunstone/sunstone-server.rb @@ -46,16 +46,24 @@ require 'rubygems' require 'sinatra' require 'erb' -require 'Configuration' +require 'CloudAuth' require 'SunstoneServer' require 'SunstonePlugins' -set :config, Configuration.new(CONFIGURATION_FILE) +begin + conf = YAML.load_file(CONFIGURATION_FILE) +rescue Exception => e + puts "Error parsing config file #{CONFIGURATION_FILE}: #{e.message}" + exit 1 +end + +conf[:hash_passwords] = true ############################################################################## # Sinatra Configuration ############################################################################## use Rack::Session::Pool, :key => 'sunstone' +set :config, conf set :host, settings.config[:host] set :port, settings.config[:port] @@ -82,7 +90,7 @@ helpers do # Add a log message return [500, ""] end - + session[:user] = user['NAME'] session[:user_id] = user['ID'] session[:user_gid] = user['GID'] From 425b4bac315492855727e0de2e71aaad28e5170b Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Thu, 22 Sep 2011 12:03:03 +0200 Subject: [PATCH 67/90] Bug #798: Image drivers can't find 'du' command --- src/mad/sh/scripts_common.sh | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/mad/sh/scripts_common.sh b/src/mad/sh/scripts_common.sh index 61ba330d0d..5730e0b99c 100755 --- a/src/mad/sh/scripts_common.sh +++ b/src/mad/sh/scripts_common.sh @@ -15,25 +15,26 @@ #--------------------------------------------------------------------------- # # Paths for utilities +export PATH=/bin:/sbin:/usr/bin:$PATH AWK=awk -BASH=/bin/bash +BASH=bash CUT=cut -DATE=/bin/date -DD=/bin/dd -DU=/usr/bin/du -LVCREATE=/sbin/lvcreate -LVREMOVE=/sbin/lvremove -LVS=/sbin/lvs -MD5SUM=/usr/bin/md5sum -MKFS=/sbin/mkfs -MKISOFS=/usr/bin/mkisofs -MKSWAP=/sbin/mkswap -SCP=/usr/bin/scp -SED=/bin/sed -SSH=/usr/bin/ssh -SUDO=/usr/bin/sudo -WGET=/usr/bin/wget -READLINK=/bin/readlink +DATE=date +DD=dd +DU=du +LVCREATE=lvcreate +LVREMOVE=lvremove +LVS=lvs +MD5SUM=md5sum +MKFS=mkfs +MKISOFS=mkisofs +MKSWAP=mkswap +SCP=scp +SED=sed +SSH=ssh +SUDO=sudo +WGET=wget +READLINK=readlink # Used for log messages SCRIPT_NAME=`basename $0` From 653f55b69aba26f28e2c6800ee2c6d67e066f5da Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Thu, 22 Sep 2011 12:51:24 +0200 Subject: [PATCH 68/90] bug #819: Fix ozones id_to_name method --- src/ozones/Server/models/OCAInteraction.rb | 129 ++++++++++++--------- src/ozones/Server/ozones-server.rb | 1 - 2 files changed, 74 insertions(+), 56 deletions(-) diff --git a/src/ozones/Server/models/OCAInteraction.rb b/src/ozones/Server/models/OCAInteraction.rb index 69da35a93f..5324ed83e0 100644 --- a/src/ozones/Server/models/OCAInteraction.rb +++ b/src/ozones/Server/models/OCAInteraction.rb @@ -17,72 +17,72 @@ require 'OpenNebula' class OCAInteraction - + # Creates a VDC (user, group, hosts) def create_vdc_in_zone(zone,vdc,adminname, adminpass) # Create a new client to interact with the zone client = OpenNebula::Client.new(zone.onename + ":" + zone.onepass, zone.endpoint, false) - + # Create a group in the zone with the VDC name group = OpenNebula::Group.new(OpenNebula::Group.build_xml, client) result = group.allocate(vdc.name) return result if OpenNebula.is_error?(result) - + # Create the VDC admin user in the Zone user=OpenNebula::User.new(OpenNebula::User.build_xml, client) result=user.allocate(adminname, adminpass) - return rollback(client, group, + return rollback(client, group, result, user) if OpenNebula.is_error?(result) # Change primary group of the admin user to the VDC group result = user.chgrp(group.id) - return rollback(client, group, + return rollback(client, group, result, user) if OpenNebula.is_error?(result) # Add ACLs - aclp = OpenNebula::AclPool.new client - + aclp = OpenNebula::AclPool.new client + # Grant permissions to the group - rule_str = "@#{group.id} VM+NET+IMAGE+TEMPLATE/* " + - "CREATE+INFO_POOL_MINE" - acl = OpenNebula::Acl.new(OpenNebula::Acl.build_xml,client) + rule_str = "@#{group.id} VM+NET+IMAGE+TEMPLATE/* " + + "CREATE+INFO_POOL_MINE" + acl = OpenNebula::Acl.new(OpenNebula::Acl.build_xml,client) result = acl.allocate(*OpenNebula::Acl.parse_rule(rule_str)) - return rollback(client, group, + return rollback(client, group, result, user) if OpenNebula.is_error?(result) acls_str = acl.id.to_s + "," - + # Grant permissions to the vdc admin - rule_str = "##{user.id} USER/* CREATE" - acl = OpenNebula::Acl.new(OpenNebula::Acl.build_xml,client) + rule_str = "##{user.id} USER/* CREATE" + acl = OpenNebula::Acl.new(OpenNebula::Acl.build_xml,client) result = acl.allocate(*OpenNebula::Acl.parse_rule(rule_str)) - return rollback(client, group, + return rollback(client, group, result,user,acls_str) if OpenNebula.is_error?(result) acls_str += acl.id.to_s + "," - - rule_str = "##{user.id} USER/@#{group.id} MANAGE+DELETE+INFO" - acl = OpenNebula::Acl.new(OpenNebula::Acl.build_xml,client) + + rule_str = "##{user.id} USER/@#{group.id} MANAGE+DELETE+INFO" + acl = OpenNebula::Acl.new(OpenNebula::Acl.build_xml,client) result = acl.allocate(*OpenNebula::Acl.parse_rule(rule_str)) - return rollback(client, group, + return rollback(client, group, result,user,acls_str) if OpenNebula.is_error?(result) acls_str += acl.id.to_s + "," - + # Grant permissions to use the vdc hosts vdc.hosts.split(",").each{|hostid| - rule_str = "@#{group.id} HOST/##{hostid} USE" - acl = OpenNebula::Acl.new(OpenNebula::Acl.build_xml,client) + rule_str = "@#{group.id} HOST/##{hostid} USE" + acl = OpenNebula::Acl.new(OpenNebula::Acl.build_xml,client) result = acl.allocate(*OpenNebula::Acl.parse_rule(rule_str)) - if OpenNebula.is_error?(result) + if OpenNebula.is_error?(result) return rollback(client, group, result, user, acls_str) end acls_str += acl.id.to_s + "," - } + } return acls_str.chop end - + def delete_vdc_in_zone(id) vdc = OZones::Vdc.get(id) zone= OZones::Zones.get(vdc.zones_id) @@ -91,38 +91,38 @@ class OCAInteraction client = OpenNebula::Client.new(zone.onename + ":" + zone.onepass, zone.endpoint, false) - - # Get the id of vdcadmin - vdcgroupid = OpenNebulaHelper::OneHelper.id_to_name(vdc.name, - OpenNebula::GroupPool.new(client), - "GROUP")[1].to_i + + vdcgroupid = vdc_group_id(vdc.name, sclient) + if OpenNebula.is_error?(vdcgroupid) + return vdcgroupid + end # Delete the resources from the VDC delete_images(vdcgroupid, client) delete_templates(vdcgroupid, client) delete_vms(vdcgroupid, client) - delete_vns(vdcgroupid, client) - + delete_vns(vdcgroupid, client) + # Delete ACLs - delete_acls(vdc.acls, client) - + delete_acls(vdc.acls, client) + # Delete users from a group up = OpenNebula::UserPool.new(client) up.info - up.each{|user| + up.each{|user| if user['GID'].to_i == vdcgroupid - OpenNebula::User.new_with_id(user['ID'], client).delete + OpenNebula::User.new_with_id(user['ID'], client).delete end } - + # Delete the group rc = OpenNebula::Group.new_with_id(vdcgroupid, client).delete if OpenNebula.is_error?(rc) - return rc - else + return rc + else return nil - end + end end # Creates a VDC (user, group, hosts) @@ -148,7 +148,7 @@ class OCAInteraction acls_str.chop.split(",").each{|acl_id| OpenNebula::Acl.new_with_id(acl_id, client).delete } - + return result end @@ -156,51 +156,70 @@ class OCAInteraction def delete_images(groupid, client) ip = OpenNebula::ImagePool.new(client) ip.info - ip.each{|image| + ip.each{|image| if image['GID'].to_i == groupid - OpenNebula::Image.new_with_id(image['ID'], client).delete + OpenNebula::Image.new_with_id(image['ID'], client).delete end } end - + # Deletes templates from a group def delete_templates(groupid, client) tp = OpenNebula::TemplatePool.new(client) tp.info - tp.each{|template| + tp.each{|template| if template['GID'].to_i == groupid - OpenNebula::Image.new_with_id(template['ID'], client).delete + OpenNebula::Image.new_with_id(template['ID'], client).delete end } end - + # Deletes VMs from a group def delete_vms(groupid, client) vmp = OpenNebula::VirtualMachinePool.new(client) vmp.info - vmp.each{|vm| + vmp.each{|vm| if vm['GID'].to_i == groupid - OpenNebula::VirtualMachine.new_with_id(vm['ID'], client).delete + OpenNebula::VirtualMachine.new_with_id(vm['ID'], client).delete end } end - + # Deletes VNs from a group def delete_vns(groupid, client) vnp = OpenNebula::VirtualNetworkPool.new(client) vnp.info - vnp.each{|vn| + vnp.each{|vn| if vn['GID'].to_i == groupid - OpenNebula::VirtualNetwork.new_with_id(vn['ID'], client).delete + OpenNebula::VirtualNetwork.new_with_id(vn['ID'], client).delete end } end - + # Delete ACLs from a group - def delete_acls(acls_str, client) + def delete_acls(acls_str, client) acls_str.split(",").each{|acl_id| OpenNebula::Acl.new_with_id(acl_id, client).delete } end + + private + + def vdc_group_id(name, client) + groups = OpenNebula::GroupPool.new(client) + + rc = groups.info + if OpenNebula.is_error?(rc) + return rc + end + + group_id = groups["GROUP[NAME=#{name}]/ID"] + + if group_id + return group_id.to_i + else + return OpenNebula::Error.new("There is no GROUP called #{name}") + end + end end - + diff --git a/src/ozones/Server/ozones-server.rb b/src/ozones/Server/ozones-server.rb index 93edfd2dc0..f30607b34c 100755 --- a/src/ozones/Server/ozones-server.rb +++ b/src/ozones/Server/ozones-server.rb @@ -48,7 +48,6 @@ require 'rubygems' require 'data_mapper' require 'digest/sha1' require 'OzonesServer' -require 'one_helper' ############################################################################## # Read configuration From 7538bc7d5eb2b4c356346e24179d810594f94dde Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Thu, 22 Sep 2011 13:09:25 +0200 Subject: [PATCH 69/90] bug #819: Fix typo in client(cherry picked from commit b5d4a0782bc911e00256c5ec1db7097fa15e96d1) --- src/ozones/Server/models/OCAInteraction.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ozones/Server/models/OCAInteraction.rb b/src/ozones/Server/models/OCAInteraction.rb index 5324ed83e0..2a1454662d 100644 --- a/src/ozones/Server/models/OCAInteraction.rb +++ b/src/ozones/Server/models/OCAInteraction.rb @@ -92,7 +92,7 @@ class OCAInteraction zone.endpoint, false) - vdcgroupid = vdc_group_id(vdc.name, sclient) + vdcgroupid = vdc_group_id(vdc.name, client) if OpenNebula.is_error?(vdcgroupid) return vdcgroupid end From 7e6c4eb33341558db2cd1f76a16fb499b3155eee Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Thu, 22 Sep 2011 13:16:59 +0200 Subject: [PATCH 70/90] feature #795: Check server error when authenticating --- src/cloud/ec2/lib/econe-server.rb | 8 +++++++- src/cloud/occi/lib/occi-server.rb | 7 ++++++- src/sunstone/sunstone-server.rb | 7 ++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/cloud/ec2/lib/econe-server.rb b/src/cloud/ec2/lib/econe-server.rb index a3f9da84e7..2bc6f047c1 100644 --- a/src/cloud/ec2/lib/econe-server.rb +++ b/src/cloud/ec2/lib/econe-server.rb @@ -80,7 +80,13 @@ end before do @econe_server = EC2QueryServer.new(settings.config) - result = @econe_server.authenticate(request.env, params) + + begin + result = @econe_server.authenticate(request.env, params) + rescue Exception => e + error 500, e.message + end + if result # Add a log message error 400, error_xml("AuthFailure", 0) diff --git a/src/cloud/occi/lib/occi-server.rb b/src/cloud/occi/lib/occi-server.rb index 012dcb5912..161f0afc4c 100755 --- a/src/cloud/occi/lib/occi-server.rb +++ b/src/cloud/occi/lib/occi-server.rb @@ -82,7 +82,12 @@ set :port, settings.config[:port] before do @occi_server = OCCIServer.new(settings.config) - result = @occi_server.authenticate(request.env) + begin + result = @occi_server.authenticate(request.env) + rescue Exception => e + error 500, e.message + end + if result error 401, result end diff --git a/src/sunstone/sunstone-server.rb b/src/sunstone/sunstone-server.rb index 99ddb7f862..49e99f831b 100755 --- a/src/sunstone/sunstone-server.rb +++ b/src/sunstone/sunstone-server.rb @@ -78,7 +78,12 @@ helpers do def build_session cloud_auth = CloudAuth.new(settings.config) - result = cloud_auth.auth(request.env, params) + begin + result = cloud_auth.auth(request.env, params) + rescue Exception => e + error 500, e.message + end + if result return [401, ""] else From 4709f6ddb0ade0ade658e83d65f270b5e3a5cacc Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Thu, 22 Sep 2011 13:19:23 +0200 Subject: [PATCH 71/90] Feature #790: Host uniqueness is now checked by default. It can be forced with FORCE=yes Feature #817: Server side completed, needs testing (cherry picked from commit 9e2eedd45c315898da6cc1fa9d529db2d96ef819) --- src/ozones/Server/models/OCAInteraction.rb | 21 ++++ src/ozones/Server/models/OzonesServer.rb | 115 +++++++++++++++--- src/ozones/Server/ozones-server.rb | 20 +-- src/ozones/Server/test/examples/vdc/vdc0.json | 2 +- .../Server/test/examples/vdc/vdc0.template | 1 + .../Server/test/examples/vdc/vdc1.template | 2 +- .../test/examples/vdc/vdc2nozone.template | 2 +- 7 files changed, 139 insertions(+), 24 deletions(-) diff --git a/src/ozones/Server/models/OCAInteraction.rb b/src/ozones/Server/models/OCAInteraction.rb index 2a1454662d..b93fdb4711 100644 --- a/src/ozones/Server/models/OCAInteraction.rb +++ b/src/ozones/Server/models/OCAInteraction.rb @@ -124,6 +124,27 @@ class OCAInteraction return nil end end + + def update_vdc_hosts(zone, host_list, acl_list) + # Create a new client to interact with the zone + client = OpenNebula::Client.new(zone.onename + ":" + zone.onepass, + zone.endpoint, + false) + # Delete existing ACLs + delete_acls(acl_list, client) + + # Create new ACLs + acls_str = "" + host_list.split(",").each{|hostid| + rule_str = "@#{group.id} HOST/##{hostid} USE" + acl = OpenNebula::Acl.new(OpenNebula::Acl.build_xml,client) + result = acl.allocate(*OpenNebula::Acl.parse_rule(rule_str)) + return result if OpenNebula.is_error?(result) + acls_str += acl.id.to_s + "," + } + + return acls_str.chop + end # Creates a VDC (user, group, hosts) def check_oneadmin(oneadminname, oneadminpass, endpoint) diff --git a/src/ozones/Server/models/OzonesServer.rb b/src/ozones/Server/models/OzonesServer.rb index ce085b2054..0092554803 100644 --- a/src/ozones/Server/models/OzonesServer.rb +++ b/src/ozones/Server/models/OzonesServer.rb @@ -161,6 +161,15 @@ class OzonesServer "#{vdc_data[:zoneid]} not found, cannot create Vdc.") return [404, error.to_json] end + + if (!defined? vdc_data[:force] or + (defined? vdc_data[:force] and vdc_data[:force]!="yes")) and + !host_uniqueness?(zone, vdc_data[:hosts]) + return [403, OZones::Error.new( + "Error: Couldn't create resource #{kind}. " + + "Hosts are not unique, and no force option " + + " were given.").to_json] + end vdcadminname = vdc_data[:vdcadminname] vdcadminpass = vdc_data[:vdcadminpass] @@ -241,6 +250,84 @@ class OzonesServer return [404, error.to_json] end end + + ############################################################################ + # Update resources + ############################################################################ + # Updates a resource of a kind, and updates the Proxy Rules if needed + def update_resource(kind, data, body, pr) + + if body.size > 0 + result = parse_json(body,kind) + data = result if !OpenNebula.is_error?(result) + end + + resource = case kind + when "vdc" then + vdc_data=Hash.new + vdc_id = nil + data.each{|key,value| + vdc_data[key.downcase.to_sym]=value if key!="id" + vdc_id = value if key=="id" + } + + # Check parameters + if !vdc_data[:hosts] || !vdc_id + return [400, OZones::Error.new( + "Error: Couldn't update resource #{kind}. " + + "Need ID and HOSTS to update.").to_json] + end + + # Check if the referenced Vdc exists + vdc=OZones::Vdc.get(vdc_id) + if !vdc + error = OZones::Error.new("Error: Vdc " + + "#{vdc_id} not found, cannot update Vdc.") + return [404, error.to_json] + end + + # Get the zone where the Vdc belongs + zone=OZones::Zones.get(vdc.zoneid) + if !zone + error = OZones::Error.new("Error: Zone " + + "#{vdc.zoneid} not found, cannot update Vdc.") + return [404, error.to_json] + end + + if (!defined? vdc_data[:force] or + (defined? vdc_data[:force] and vdc_data[:force]!="yes")) and + !host_uniqueness?(zone, vdc_data[:hosts]) + return [403, OZones::Error.new( + "Error: Couldn't update resource #{kind}. " + + "Hosts are not unique, and no force option " + + " were given.").to_json] + end + + rc = @ocaInt.update_vdc_hosts(zone, vdc_data[:hosts], vdc.acls) + + if !OpenNebula.is_error?(rc) + vdc.hosts = vdc_data[:hosts] + vdc.acls = rc + vdc.save + + if vdc.saved? + return [200, vdc.to_json] + else + return [500, OZones::Error.new( + "Error: Couldn't update resource #{kind}.").to_json] + end + + else + return [500, OZones::Error.new( + "Error: Couldn't update resource #{kind.upcase}." + + " Failed to update ACLs").to_json] + end + else + error = OZones::Error.new( + "Error: #{kind.upcase} resource update not supported") + return [404, error.to_json] + end + end ############################################################################ # Delete resources @@ -272,20 +359,20 @@ class OzonesServer end ############################################################################ - # TODO - ############################################################################ - def perform_action(kind, id, action_json) - resource = retrieve_resource(kind, id) - if OpenNebula.is_error?(resource) - return [404, resource.to_json] - end - - rc = resource.perform_action(action_json) - if OpenNebula.is_error?(rc) - return [500, rc.to_json] - else - return [204, resource.to_json] - end + # Helper functions + ########################################################################## + + # Check if hosts are already include in any Vdc of the zone + def host_uniqueness?(zone, host_list) + all_hosts = "" + zone.vdcs.all.each{|vdc| all_hosts += vdcs.hosts} + all_hosts = all_hosts.split(",").compact.reject{|host| host.empty?} + + host_list.split(",").each{|host| + return false if all_hosts.include?(host) + } + return true end + end diff --git a/src/ozones/Server/ozones-server.rb b/src/ozones/Server/ozones-server.rb index f30607b34c..c3b19612b5 100755 --- a/src/ozones/Server/ozones-server.rb +++ b/src/ozones/Server/ozones-server.rb @@ -240,7 +240,20 @@ get '/:pool/:aggpool' do @OzonesServer.get_aggregated_pool(params[:pool], params[:aggpool]) end +############################################################################## +# Create a new Resource +############################################################################## +post '/:pool' do + @OzonesServer.create_resource(params[:pool], params, request.body.read, @pr) +end +############################################################################## +# Update Resource +############################################################################## +put '/:resource/:id' do + @OzonesServer.update_resource(params[:resource], params, + request.body.read, @pr) +end ############################################################################## # Delete Resource @@ -249,12 +262,5 @@ delete '/:resource/:id' do @OzonesServer.delete_resource(params[:resource], params[:id], @pr) end -############################################################################## -# Create a new Resource -############################################################################## -post '/:pool' do - @OzonesServer.create_resource(params[:pool], params, request.body.read, @pr) -end - diff --git a/src/ozones/Server/test/examples/vdc/vdc0.json b/src/ozones/Server/test/examples/vdc/vdc0.json index 1d6813e035..6deb95903d 100644 --- a/src/ozones/Server/test/examples/vdc/vdc0.json +++ b/src/ozones/Server/test/examples/vdc/vdc0.json @@ -1,6 +1,6 @@ { "vdc": { - "hosts": "testhostvdc0n0,testhostvdc0n1,testhostvdc0n2", + "hosts": "5,7,9", "zones_id": 1, "name": "testvdc0", "id": 1 diff --git a/src/ozones/Server/test/examples/vdc/vdc0.template b/src/ozones/Server/test/examples/vdc/vdc0.template index c14cbe9527..b2e7e3d4f3 100644 --- a/src/ozones/Server/test/examples/vdc/vdc0.template +++ b/src/ozones/Server/test/examples/vdc/vdc0.template @@ -1,4 +1,5 @@ NAME=testvdc0 ZONEID=1 +HOSTS=5,7,9 VDCADMINNAME=adminname VDCADMINPASS=adminpass diff --git a/src/ozones/Server/test/examples/vdc/vdc1.template b/src/ozones/Server/test/examples/vdc/vdc1.template index afdba5ddcd..4566505bbb 100644 --- a/src/ozones/Server/test/examples/vdc/vdc1.template +++ b/src/ozones/Server/test/examples/vdc/vdc1.template @@ -1,5 +1,5 @@ NAME=testvdc1 -HOSTS=testhostvdc1n0 +HOSTS=8 ZONEID=1 VDCADMINNAME=othername VDCADMINPASS=otherpass \ No newline at end of file diff --git a/src/ozones/Server/test/examples/vdc/vdc2nozone.template b/src/ozones/Server/test/examples/vdc/vdc2nozone.template index 4279b5733c..946c43c46c 100644 --- a/src/ozones/Server/test/examples/vdc/vdc2nozone.template +++ b/src/ozones/Server/test/examples/vdc/vdc2nozone.template @@ -1,3 +1,3 @@ NAME=testvdcnozone -HOSTS=testhostvdcnozone,bogushost +HOSTS=3,7 ZONEID=5 \ No newline at end of file From df4774562bc002b76c85fe6b939017e89008cd78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 22 Sep 2011 15:29:05 +0200 Subject: [PATCH 72/90] Feature #795: Add comments to occi-server.conf, leave the bridge unset by default --- src/cloud/occi/etc/occi-server.conf | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cloud/occi/etc/occi-server.conf b/src/cloud/occi/etc/occi-server.conf index ec74643b19..2bf8516b9f 100644 --- a/src/cloud/occi/etc/occi-server.conf +++ b/src/cloud/occi/etc/occi-server.conf @@ -17,7 +17,7 @@ # OpenNebula sever contact information :one_xmlrpc: http://localhost:2633/RPC2 -# Host and port where econe server will run +# Host and port where OCCI server will run :server: localhost :port: 4567 @@ -25,9 +25,11 @@ #:ssl_server: fqdm.of.the.server # Configuration for OpenNebula's Virtual Networks -#:bridge: -:bridge: vbr1 +#:bridge: NAME_OF_DEFAULT_BRIDGE +# Authentication protocol for the OCCI server: +# basic, for OpenNebula's user-password scheme +# x509, for x509 certificates based authentication :auth: basic # VM types allowed and its template file (inside templates directory) From 91a7f0015bf69fe0a0895f1d04208eaaf22d18f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 22 Sep 2011 08:57:59 -0700 Subject: [PATCH 73/90] Feature #795: Add comments to econe.conf --- src/cloud/ec2/etc/econe.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cloud/ec2/etc/econe.conf b/src/cloud/ec2/etc/econe.conf index 6d71e86e56..151279862d 100644 --- a/src/cloud/ec2/etc/econe.conf +++ b/src/cloud/ec2/etc/econe.conf @@ -24,6 +24,9 @@ # SSL proxy that serves the API (set if is being used) #:ssl_server: fqdm.of.the.server +# Authentication protocol for the econe server: +# ec2, default Acess key and Secret key scheme +# x509, for x509 certificates based authentication :auth: ec2 # VM types allowed and its template file (inside templates directory) From f95f85ba32a004b7951b8280fb1d14931402957a Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 22 Sep 2011 20:03:07 +0200 Subject: [PATCH 74/90] feature #817: Refactor of update functionality and VDC-OCA interaction. Fixes bugs in host_uniqueness. --- .../lib/cli/ozones_helper/vdc_helper.rb | 1 + src/ozones/Server/lib/OZones/VDC.rb | 80 ++++++++++- src/ozones/Server/models/OCAInteraction.rb | 134 ++++++------------ src/ozones/Server/models/OzonesServer.rb | 19 ++- 4 files changed, 135 insertions(+), 99 deletions(-) diff --git a/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb b/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb index ea7e0b115b..e2446889eb 100644 --- a/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb +++ b/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb @@ -34,6 +34,7 @@ class VDCHelper < OZonesHelper::OZHelper puts str % ["ID ", vdc['id'].to_s] puts str % ["NAME ", vdc['name'].to_s] + puts str % ["GROUP_ID ", vdc['group_id'].to_s] puts str % ["ZONEID ", vdc['zones_id'].to_s] puts str % ["VDCADMIN ", vdc['vdcadminname'].to_s] puts str % ["HOST IDs ", vdc['hosts'].to_s] diff --git a/src/ozones/Server/lib/OZones/VDC.rb b/src/ozones/Server/lib/OZones/VDC.rb index 67127bda96..60b734f828 100644 --- a/src/ozones/Server/lib/OZones/VDC.rb +++ b/src/ozones/Server/lib/OZones/VDC.rb @@ -21,11 +21,12 @@ module OZones include OpenNebulaJSON::JSONUtils extend OpenNebulaJSON::JSONUtils - property :id, Serial - property :name, String, :required => true, :unique => true - property :vdcadminname, String, :required => true - property :acls, String - property :hosts, String + property :id, Serial + property :name, String, :required => true, :unique => true + property :group_id, Integer + property :vdcadminname, String, :required => true + property :acls, String + property :hosts, String belongs_to :zones @@ -44,6 +45,73 @@ module OZones vdc_attributes["VDC"] = attributes return vdc_attributes end + + ####################################################################### + # Methods to handle the ACL list + ####################################################################### + # The ID of the first host ACL + HOST_ACL_FIRST_ID = 3 + + # This method returns an Array of ACL strings to create them + # in the target zone + def get_vdc_acls_str(user_id, group_id) + rule_str = Array.new + + # Grant permissions to the group + rule_str << "@#{group_id} VM+NET+IMAGE+TEMPLATE/* " \ + "CREATE+INFO_POOL_MINE" + + # Grant permissions to the vdc admin + rule_str << "##{user_id} USER/* CREATE" + rule_str << "##{user_id} USER/@#{group_id} MANAGE+DELETE+INFO" + + ############################################################### + #When more rules are added the class constant HOST_ACL_FIRST_ID + #must be modified + ############################################################### + + puts get_host_acls_str(group_id) + + rule_str.concat(self.get_host_acls_str(group_id)) + end + + def get_host_acls_str(group_id, host_list = nil) + rule_str = Array.new + + if host_list == nil + host_list = self.hosts + end + + # Grant permissions to use the vdc hosts + host_list.split(',').each{|hostid| + puts hostid + rule_str << "@#{group_id} HOST/##{hostid} USE" + } + + return rule_str + end + + def get_host_acls + self.acls.split(',')[HOST_ACL_FIRST_ID..-1].collect!{|x| x.to_i} + end + + # Returns the host acls as an array of strings. + # The acls of the VDC are updated and the host acl ids removed + def get_host_acls!(new_host_acls = nil) + acl_ids = self.acls.split(',') + vdc_acl = acl_ids.slice!(0,HOST_ACL_FIRST_ID) + + newacl = "" + vdc_acl.each{|id| + newacl << id << ',' + } + + newacl.chomp + newacl << new_host_acls if new_host_acls + + self.acls = newacl + + return acl_ids + end end - end diff --git a/src/ozones/Server/models/OCAInteraction.rb b/src/ozones/Server/models/OCAInteraction.rb index b93fdb4711..1b61136ae2 100644 --- a/src/ozones/Server/models/OCAInteraction.rb +++ b/src/ozones/Server/models/OCAInteraction.rb @@ -19,7 +19,7 @@ require 'OpenNebula' class OCAInteraction # Creates a VDC (user, group, hosts) - def create_vdc_in_zone(zone,vdc,adminname, adminpass) + def create_vdc_in_zone(zone, vdc, adminname, adminpass) # Create a new client to interact with the zone client = OpenNebula::Client.new(zone.onename + ":" + zone.onepass, zone.endpoint, @@ -31,8 +31,8 @@ class OCAInteraction return result if OpenNebula.is_error?(result) # Create the VDC admin user in the Zone - user=OpenNebula::User.new(OpenNebula::User.build_xml, client) - result=user.allocate(adminname, adminpass) + user = OpenNebula::User.new(OpenNebula::User.build_xml, client) + result = user.allocate(adminname, adminpass) return rollback(client, group, result, user) if OpenNebula.is_error?(result) @@ -42,45 +42,23 @@ class OCAInteraction result, user) if OpenNebula.is_error?(result) # Add ACLs - aclp = OpenNebula::AclPool.new client + aclp = OpenNebula::AclPool.new client + rules = vdc.get_vdc_acls_str(user.id, group.id) - # Grant permissions to the group - rule_str = "@#{group.id} VM+NET+IMAGE+TEMPLATE/* " + - "CREATE+INFO_POOL_MINE" - acl = OpenNebula::Acl.new(OpenNebula::Acl.build_xml,client) - result = acl.allocate(*OpenNebula::Acl.parse_rule(rule_str)) - return rollback(client, group, - result, user) if OpenNebula.is_error?(result) - acls_str = acl.id.to_s + "," + acls_str = "" - # Grant permissions to the vdc admin - rule_str = "##{user.id} USER/* CREATE" - acl = OpenNebula::Acl.new(OpenNebula::Acl.build_xml,client) - result = acl.allocate(*OpenNebula::Acl.parse_rule(rule_str)) - return rollback(client, group, - result,user,acls_str) if OpenNebula.is_error?(result) - acls_str += acl.id.to_s + "," + rules.each{ |rule_str| + acl = OpenNebula::Acl.new(OpenNebula::Acl.build_xml,client) + rc = acl.allocate(*OpenNebula::Acl.parse_rule(rule_str)) - rule_str = "##{user.id} USER/@#{group.id} MANAGE+DELETE+INFO" - acl = OpenNebula::Acl.new(OpenNebula::Acl.build_xml,client) - result = acl.allocate(*OpenNebula::Acl.parse_rule(rule_str)) - return rollback(client, group, - result,user,acls_str) if OpenNebula.is_error?(result) - acls_str += acl.id.to_s + "," + if OpenNebula.is_error?(rc) + return rollback(client, group, rc, user, acls_str) + end - # Grant permissions to use the vdc hosts - - vdc.hosts.split(",").each{|hostid| - rule_str = "@#{group.id} HOST/##{hostid} USE" - acl = OpenNebula::Acl.new(OpenNebula::Acl.build_xml,client) - result = acl.allocate(*OpenNebula::Acl.parse_rule(rule_str)) - if OpenNebula.is_error?(result) - return rollback(client, group, result, user, acls_str) - end - acls_str += acl.id.to_s + "," - } - - return acls_str.chop + acls_str << acl.id.to_s << "," + } + + return acls_str.chop, group.id end def delete_vdc_in_zone(id) @@ -92,16 +70,11 @@ class OCAInteraction zone.endpoint, false) - vdcgroupid = vdc_group_id(vdc.name, client) - if OpenNebula.is_error?(vdcgroupid) - return vdcgroupid - end - # Delete the resources from the VDC - delete_images(vdcgroupid, client) - delete_templates(vdcgroupid, client) - delete_vms(vdcgroupid, client) - delete_vns(vdcgroupid, client) + delete_images(vdc.group_id, client) + delete_templates(vdc.group_id, client) + delete_vms(vdc.group_id, client) + delete_vns(vdc.group_id, client) # Delete ACLs delete_acls(vdc.acls, client) @@ -110,13 +83,13 @@ class OCAInteraction up = OpenNebula::UserPool.new(client) up.info up.each{|user| - if user['GID'].to_i == vdcgroupid + if user['GID'].to_i == vdc.group_id OpenNebula::User.new_with_id(user['ID'], client).delete end } # Delete the group - rc = OpenNebula::Group.new_with_id(vdcgroupid, client).delete + rc = OpenNebula::Group.new_with_id(vdc.group_id, client).delete if OpenNebula.is_error?(rc) return rc @@ -125,21 +98,29 @@ class OCAInteraction end end - def update_vdc_hosts(zone, host_list, acl_list) + def update_vdc_hosts(zone, vdc, host_list) # Create a new client to interact with the zone client = OpenNebula::Client.new(zone.onename + ":" + zone.onepass, zone.endpoint, false) - # Delete existing ACLs - delete_acls(acl_list, client) - + # Delete existing host ACLs + vdc.get_host_acls.each{|acl_id| + OpenNebula::Acl.new_with_id(acl_id, client).delete + } + # Create new ACLs - acls_str = "" - host_list.split(",").each{|hostid| - rule_str = "@#{group.id} HOST/##{hostid} USE" - acl = OpenNebula::Acl.new(OpenNebula::Acl.build_xml,client) - result = acl.allocate(*OpenNebula::Acl.parse_rule(rule_str)) - return result if OpenNebula.is_error?(result) + acls_str = "" + host_acls = vdc.get_host_acls_str(vdc.group_id, host_list) + + host_acls.each{|rule| + acl = OpenNebula::Acl.new(OpenNebula::Acl.build_xml,client) + rc = acl.allocate(*OpenNebula::Acl.parse_rule(rule)) + + + if OpenNebula.is_error?(rc) + return rc + end + acls_str += acl.id.to_s + "," } @@ -161,14 +142,10 @@ class OCAInteraction # Deletes resources from failed created VDC def rollback(client, group, result, user=nil, acls_str=nil) - user.delete if user + user.delete if user group.delete - - return result if !acls_str - - acls_str.chop.split(",").each{|acl_id| - OpenNebula::Acl.new_with_id(acl_id, client).delete - } + + delete_acls(acls_str, client) return result end @@ -219,27 +196,10 @@ class OCAInteraction # Delete ACLs from a group def delete_acls(acls_str, client) - acls_str.split(",").each{|acl_id| - OpenNebula::Acl.new_with_id(acl_id, client).delete - } - end - - private - - def vdc_group_id(name, client) - groups = OpenNebula::GroupPool.new(client) - - rc = groups.info - if OpenNebula.is_error?(rc) - return rc - end - - group_id = groups["GROUP[NAME=#{name}]/ID"] - - if group_id - return group_id.to_i - else - return OpenNebula::Error.new("There is no GROUP called #{name}") + if acls_str != nil && !acls_str.empty? + acls_str.split(",").each{|acl_id| + OpenNebula::Acl.new_with_id(acl_id.to_i, client).delete + } end end end diff --git a/src/ozones/Server/models/OzonesServer.rb b/src/ozones/Server/models/OzonesServer.rb index 0092554803..36dfd4a74c 100644 --- a/src/ozones/Server/models/OzonesServer.rb +++ b/src/ozones/Server/models/OzonesServer.rb @@ -193,8 +193,10 @@ class OzonesServer "Error: Couldn't create #{kind}. Reason: " + rc.message).to_json] else - vdc.acls = rc + vdc.acls = rc[0] + vdc.group_id = rc[1] vdc.save + pr.update # Rewrite proxy conf file return [200, vdc.to_json] end @@ -262,6 +264,8 @@ class OzonesServer data = result if !OpenNebula.is_error?(result) end + puts data + resource = case kind when "vdc" then vdc_data=Hash.new @@ -271,6 +275,8 @@ class OzonesServer vdc_id = value if key=="id" } + puts vdc_data + # Check parameters if !vdc_data[:hosts] || !vdc_id return [400, OZones::Error.new( @@ -287,10 +293,10 @@ class OzonesServer end # Get the zone where the Vdc belongs - zone=OZones::Zones.get(vdc.zoneid) + zone=OZones::Zones.get(vdc.zones.id) if !zone error = OZones::Error.new("Error: Zone " + - "#{vdc.zoneid} not found, cannot update Vdc.") + "#{vdc.zones.id} not found, cannot update Vdc.") return [404, error.to_json] end @@ -303,11 +309,12 @@ class OzonesServer " were given.").to_json] end - rc = @ocaInt.update_vdc_hosts(zone, vdc_data[:hosts], vdc.acls) + rc = @ocaInt.update_vdc_hosts(zone, vdc, vdc_data[:hosts]) if !OpenNebula.is_error?(rc) vdc.hosts = vdc_data[:hosts] - vdc.acls = rc + vdc.get_host_acls!(rc) + vdc.save if vdc.saved? @@ -365,7 +372,7 @@ class OzonesServer # Check if hosts are already include in any Vdc of the zone def host_uniqueness?(zone, host_list) all_hosts = "" - zone.vdcs.all.each{|vdc| all_hosts += vdcs.hosts} + zone.vdcs.all.each{|vdc| all_hosts += vdc.hosts} all_hosts = all_hosts.split(",").compact.reject{|host| host.empty?} host_list.split(",").each{|host| From 0793eabd511ad42f633585ebfd882bdbfb5e501f Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 22 Sep 2011 23:24:19 +0200 Subject: [PATCH 75/90] feature #817:Host uniqueness for VDCs does not check own hosts (cherry picked from commit 3edd8a778016d0f1405f6541442b2f9aa059670c) --- src/ozones/Server/models/OzonesServer.rb | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/ozones/Server/models/OzonesServer.rb b/src/ozones/Server/models/OzonesServer.rb index 36dfd4a74c..687fe5aee5 100644 --- a/src/ozones/Server/models/OzonesServer.rb +++ b/src/ozones/Server/models/OzonesServer.rb @@ -136,12 +136,12 @@ class OzonesServer if body.size > 0 result = parse_json(body,kind) - data = result if !OpenNebula.is_error?(result) + data = result if !OpenNebula.is_error?(result) end resource = case kind when "vdc" then - vdc_data=Hash.new + vdc_data = Hash.new data.each{|key,value| vdc_data[key.downcase.to_sym]=value if key!="pool" } @@ -275,8 +275,6 @@ class OzonesServer vdc_id = value if key=="id" } - puts vdc_data - # Check parameters if !vdc_data[:hosts] || !vdc_id return [400, OZones::Error.new( @@ -302,7 +300,7 @@ class OzonesServer if (!defined? vdc_data[:force] or (defined? vdc_data[:force] and vdc_data[:force]!="yes")) and - !host_uniqueness?(zone, vdc_data[:hosts]) + !host_uniqueness?(zone, vdc_data[:hosts], vdc_id.to_i) return [403, OZones::Error.new( "Error: Couldn't update resource #{kind}. " + "Hosts are not unique, and no force option " + @@ -367,17 +365,23 @@ class OzonesServer ############################################################################ # Helper functions - ########################################################################## + ############################################################################ # Check if hosts are already include in any Vdc of the zone - def host_uniqueness?(zone, host_list) + def host_uniqueness?(zone, host_list, vdc_id = -1) all_hosts = "" - zone.vdcs.all.each{|vdc| all_hosts += vdc.hosts} - all_hosts = all_hosts.split(",").compact.reject{|host| host.empty?} - + zone.vdcs.all.each{|vdc| + if vdc.hosts != nil and !vdc.hosts.empty? and vdc.id != vdc_id + all_hosts << vdc.hosts + end + } + + all_hosts = all_hosts.split(",") + host_list.split(",").each{|host| return false if all_hosts.include?(host) } + return true end From 9a493620b11dc50159097138530829deeb30a8f7 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 22 Sep 2011 23:47:36 +0200 Subject: [PATCH 76/90] feature #817: Fixes host uniqueness --- src/ozones/Server/lib/OZones/VDC.rb | 3 --- src/ozones/Server/models/OzonesServer.rb | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/ozones/Server/lib/OZones/VDC.rb b/src/ozones/Server/lib/OZones/VDC.rb index 60b734f828..bdc23b1ae7 100644 --- a/src/ozones/Server/lib/OZones/VDC.rb +++ b/src/ozones/Server/lib/OZones/VDC.rb @@ -69,8 +69,6 @@ module OZones #When more rules are added the class constant HOST_ACL_FIRST_ID #must be modified ############################################################### - - puts get_host_acls_str(group_id) rule_str.concat(self.get_host_acls_str(group_id)) end @@ -84,7 +82,6 @@ module OZones # Grant permissions to use the vdc hosts host_list.split(',').each{|hostid| - puts hostid rule_str << "@#{group_id} HOST/##{hostid} USE" } diff --git a/src/ozones/Server/models/OzonesServer.rb b/src/ozones/Server/models/OzonesServer.rb index 687fe5aee5..e8015b9dc2 100644 --- a/src/ozones/Server/models/OzonesServer.rb +++ b/src/ozones/Server/models/OzonesServer.rb @@ -372,11 +372,11 @@ class OzonesServer all_hosts = "" zone.vdcs.all.each{|vdc| if vdc.hosts != nil and !vdc.hosts.empty? and vdc.id != vdc_id - all_hosts << vdc.hosts + all_hosts << ',' << vdc.hosts end } - all_hosts = all_hosts.split(",") + all_hosts = all_hosts.split(',') host_list.split(",").each{|host| return false if all_hosts.include?(host) From 72e55b394f669081425063dbeba718d183c0ec27 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 22 Sep 2011 23:50:13 +0200 Subject: [PATCH 77/90] missing license files --- src/ozones/Client/bin/onezone | 16 ++++++++++++++++ src/ozones/Client/lib/cli/ozones_helper.rb | 18 +++++++++++++++++- .../Client/lib/cli/ozones_helper/vdc_helper.rb | 16 ++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/ozones/Client/bin/onezone b/src/ozones/Client/bin/onezone index ff97efa6f7..33e9b96ad8 100755 --- a/src/ozones/Client/bin/onezone +++ b/src/ozones/Client/bin/onezone @@ -1,5 +1,21 @@ #!/usr/bin/env ruby +# -------------------------------------------------------------------------- # +# 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. # +#--------------------------------------------------------------------------- # + ONE_LOCATION=ENV["ONE_LOCATION"] if !ONE_LOCATION diff --git a/src/ozones/Client/lib/cli/ozones_helper.rb b/src/ozones/Client/lib/cli/ozones_helper.rb index 160062c791..44d212c68c 100644 --- a/src/ozones/Client/lib/cli/ozones_helper.rb +++ b/src/ozones/Client/lib/cli/ozones_helper.rb @@ -1,3 +1,19 @@ +# -------------------------------------------------------------------------- # +# 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 'OZonesClient' module OZonesHelper @@ -60,4 +76,4 @@ module OZonesHelper end end -end \ No newline at end of file +end diff --git a/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb b/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb index e2446889eb..1c7dbf4906 100644 --- a/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb +++ b/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb @@ -1,3 +1,19 @@ +# -------------------------------------------------------------------------- # +# 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 'cli/ozones_helper' require 'cli/one_helper' From 41cc2bbb161a7ac06ba6069e030857146326c189 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Fri, 23 Sep 2011 01:14:53 +0200 Subject: [PATCH 78/90] feature #795: Fix bugs in X509CloudAuth --- src/cloud/common/CloudAuth/BasicCloudAuth.rb | 4 +-- src/cloud/common/CloudAuth/EC2CloudAuth.rb | 4 +-- src/cloud/common/CloudAuth/X509CloudAuth.rb | 33 +++++++++++--------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/cloud/common/CloudAuth/BasicCloudAuth.rb b/src/cloud/common/CloudAuth/BasicCloudAuth.rb index 63a60369d1..0bea9ecda1 100644 --- a/src/cloud/common/CloudAuth/BasicCloudAuth.rb +++ b/src/cloud/common/CloudAuth/BasicCloudAuth.rb @@ -12,7 +12,7 @@ module BasicCloudAuth one_pass = get_password(username) if one_pass && one_pass == password @token = "#{username}:#{password}" - @client = Client.new(@token, @xmlrpc, false) + @client = Client.new(@token, @conf[:one_xmlrpc], false) return nil else return "Authentication failure" @@ -21,4 +21,4 @@ module BasicCloudAuth return "Basic auth not provided" end end -end \ No newline at end of file +end diff --git a/src/cloud/common/CloudAuth/EC2CloudAuth.rb b/src/cloud/common/CloudAuth/EC2CloudAuth.rb index 2842d8c940..c47514ea16 100644 --- a/src/cloud/common/CloudAuth/EC2CloudAuth.rb +++ b/src/cloud/common/CloudAuth/EC2CloudAuth.rb @@ -21,7 +21,7 @@ module EC2CloudAuth end @token = "#{username}:#{one_pass}" - @client = Client.new(@token, @xmlrpc, false) + @client = Client.new(@token, @conf[:one_xmlrpc], false) return nil end @@ -73,4 +73,4 @@ module EC2CloudAuth return b64hmac end end -end \ No newline at end of file +end diff --git a/src/cloud/common/CloudAuth/X509CloudAuth.rb b/src/cloud/common/CloudAuth/X509CloudAuth.rb index 6488b7999e..835d65a565 100644 --- a/src/cloud/common/CloudAuth/X509CloudAuth.rb +++ b/src/cloud/common/CloudAuth/X509CloudAuth.rb @@ -1,14 +1,20 @@ module X509CloudAuth - # TBD Adapt to the new CloudAuth system - # Gets the username associated with a password # password:: _String_ the password # [return] _Hash_ with the username def get_username(password) - @user_pool.info - #STDERR.puts 'the password is ' + password - #STDERR.puts @user_pool["User[PASSWORD=\"#{password}\"]"] - username = @user_pool["User[PASSWORD=\"#{password}\"]/NAME"] + @oneadmin_client ||= OpenNebula::Client.new(nil, @conf[:one_xmlrpc]) + + if @user_pool.nil? + @user_pool ||= OpenNebula::UserPool.new(@oneadmin_client) + + rc = @user_pool.info + if OpenNebula.is_error?(rc) + raise rc.message + end + end + + username = @user_pool["USER[PASSWORD=\"#{password}\"]/NAME"] return username if (username != nil) # Check if the DN is part of a |-separted multi-DN password @@ -28,7 +34,7 @@ module X509CloudAuth if matched password = matched.to_s end - puts("The password is " + password) + return @user_pool["USER[PASSWORD=\"#{password}\"]/NAME"] end @@ -43,7 +49,7 @@ module X509CloudAuth while cert_line begin cert_array=cert_line.scan(/([^\s]*)\s/) - cert_array = cert_array[2..-3] + cert_array = cert_array[2..-2] cert_array.unshift('-----BEGIN CERTIFICATE-----') cert_array.push('-----END CERTIFICATE-----') cert_pem = cert_array.join("\n") @@ -72,16 +78,15 @@ module X509CloudAuth msg = "" msg << failed msg << "Username not found in certificate chain " - msg << chain_dn + msg << chain_dn if chain_dn raise msg end auth = ServerAuth.new - login = auth.login_token(username, subjectname, 300) + @token = auth.login_token(username, subjectname, 300) + @client = Client.new(@token, @conf[:one_xmlrpc], false) - STDERR.puts login - - return one_client_user("dummy", login) + return nil end -end \ No newline at end of file +end From 82d94ce496c271de814c3a263e139849fc599a7a Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 23 Sep 2011 01:22:54 +0200 Subject: [PATCH 79/90] feature #817: Command line options addhost, delhost for onevdc (cherry picked from commit c42545943ed2dd77d592a15720a766047a6099e9) --- src/ozones/Client/bin/onevdc | 10 ++++ src/ozones/Client/lib/OZonesClient.rb | 51 +++++++++++++------ .../lib/cli/ozones_helper/vdc_helper.rb | 47 +++++++++++++++++ 3 files changed, 92 insertions(+), 16 deletions(-) diff --git a/src/ozones/Client/bin/onevdc b/src/ozones/Client/bin/onevdc index e93478416e..dfff6750d9 100755 --- a/src/ozones/Client/bin/onevdc +++ b/src/ozones/Client/bin/onevdc @@ -50,4 +50,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do command :delete, 'Deletes a VDC', :vdcid do helper.delete_resource(args[0],options) end + + command :addhost, 'Adds the set of hosts to the VDC', + :vdcid, :range do + helper.addhost(args[0], args[1], options) + end + + command :delhost, 'Deletes the set of hosts to the VDC', + :vdcid, :range do + helper.delhost(args[0], args[1], options) + end end diff --git a/src/ozones/Client/lib/OZonesClient.rb b/src/ozones/Client/lib/OZonesClient.rb index bc8294259d..551d4628c7 100644 --- a/src/ozones/Client/lib/OZonesClient.rb +++ b/src/ozones/Client/lib/OZonesClient.rb @@ -90,19 +90,10 @@ EOT # :zonetemplate ###################################################################### def post_resource(kind, template) - template=File.read(template) - - body_str = "" - - template.strip.each_line{|line| - line.strip! - key,value = line.split("=") - body_str = body_str + key + "=" + URI.escape(value) + "&" - } - - body_str = body_str[0..-1] - - url = URI.parse(@endpoint+"/"+kind) + tmpl_str = File.read(template) + body_str = OzonesClient::to_body(tmpl_str) + + url = URI.parse("#{@endpoint}/#{kind}") req = Net::HTTP::Post.new(url.path) req.body=body_str @@ -116,9 +107,25 @@ EOT return OZonesClient::parse_error(res, kind) end + def put_resource(kind, id, tmpl_str) + body_str = OZonesClient::to_body(tmpl_str) + + url = URI.parse("#{@endpoint}/#{kind}/#{id}") + + req = Net::HTTP::Put.new(url.path) + req.body=body_str + + req.basic_auth @ozonesauth[0], @ozonesauth[1] + + res = OZonesClient::http_start(url, @timeout) do |http| + http.request(req) + end + + return OZonesClient::parse_error(res, kind) + end def get_resource(kind, id) - url = URI.parse(@endpoint+"/#{kind}/" + id.to_s) + url = URI.parse("#{@endpoint}/#{kind}/#{id}") req = Net::HTTP::Get.new(url.path) req.basic_auth @ozonesauth[0], @ozonesauth[1] @@ -131,7 +138,7 @@ EOT end def delete_resource(kind, id) - url = URI.parse(@endpoint+"/#{kind}/" + id.to_s) + url = URI.parse("#{@endpoint}/#{kind}/#{id}") req = Net::HTTP::Delete.new(url.path) req.basic_auth @ozonesauth[0], @ozonesauth[1] @@ -237,8 +244,20 @@ EOT end ########################################################################## - # JSON utils + # JSON & Template utils ########################################################################## + + def self.to_body(tmpl_str) + body_str = "" + + tmpl_str.strip.each_line{|line| + line.strip! + key,value = line.split("=") + body_str = body_str + key + "=" + URI.escape(value) + "&" + } + + body_str = body_str[0..-1] + end def self.parse_json(json_str, root_element) begin diff --git a/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb b/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb index 1c7dbf4906..9f82bd6d83 100644 --- a/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb +++ b/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb @@ -39,7 +39,54 @@ class VDCHelper < OZonesHelper::OZHelper def delete_resource(id, options) super(@vdc_str,id, options) end + + def addhost(id, host_array, options) + rc = @client.get_resource(@vdc_str, id) + if OZonesClient::is_error?(rc) + return [-1, rc.message] + else + vdc = OZonesClient::parse_json(rc.body, @vdc_str.upcase) + end + + hosts = vdc['hosts'].split(',').collect!{|x| x.to_i} + host_array.concat(hosts).uniq! + + new_host = host_array.join(',') + template = "ID=#{id}\nHOSTS=#{new_host}\n" + + rc = @client.put_resource(@vdc_str, id, template) + + if OZonesClient::is_error?(rc) + return [-1, rc.message] + end + + [0, ""] + end + + def delhost(id, host_array, options) + rc = @client.get_resource(@vdc_str, id) + + if OZonesClient::is_error?(rc) + return [-1, rc.message] + else + vdc = OZonesClient::parse_json(rc.body, @vdc_str.upcase) + end + + hosts = vdc['hosts'].split(',').collect!{|x| x.to_i} + + new_host = (hosts - host_array).join(',') + template = "ID=#{id}\nHOSTS=#{new_host}\n" + + rc = @client.put_resource(@vdc_str, id, template) + + if OZonesClient::is_error?(rc) + return [-1, rc.message] + end + + [0, ""] + end + private def format_resource(vdc, options) From c862c82da83a788bb53395d1cade7facb659a7eb Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 23 Sep 2011 11:58:25 +0200 Subject: [PATCH 80/90] bug: Fixes misspelled class --- src/ozones/Client/lib/OZonesClient.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ozones/Client/lib/OZonesClient.rb b/src/ozones/Client/lib/OZonesClient.rb index 551d4628c7..b8aff94a66 100644 --- a/src/ozones/Client/lib/OZonesClient.rb +++ b/src/ozones/Client/lib/OZonesClient.rb @@ -91,7 +91,7 @@ EOT ###################################################################### def post_resource(kind, template) tmpl_str = File.read(template) - body_str = OzonesClient::to_body(tmpl_str) + body_str = OZonesClient::to_body(tmpl_str) url = URI.parse("#{@endpoint}/#{kind}") From 8f5c175880137cb1a15517c734c042b813748ccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 23 Sep 2011 12:09:37 +0200 Subject: [PATCH 81/90] Feature #817: Fix bad http error detection --- src/ozones/Client/bin/onevdc | 2 +- src/ozones/Client/lib/OZonesClient.rb | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/ozones/Client/bin/onevdc b/src/ozones/Client/bin/onevdc index dfff6750d9..fcfc31a725 100755 --- a/src/ozones/Client/bin/onevdc +++ b/src/ozones/Client/bin/onevdc @@ -56,7 +56,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do helper.addhost(args[0], args[1], options) end - command :delhost, 'Deletes the set of hosts to the VDC', + command :delhost, 'Deletes the set of hosts from the VDC', :vdcid, :range do helper.delhost(args[0], args[1], options) end diff --git a/src/ozones/Client/lib/OZonesClient.rb b/src/ozones/Client/lib/OZonesClient.rb index b8aff94a66..511479ecd9 100644 --- a/src/ozones/Client/lib/OZonesClient.rb +++ b/src/ozones/Client/lib/OZonesClient.rb @@ -176,10 +176,7 @@ EOT end def self.is_http_error?(value) - value.class == Net::HTTPInternalServerError || - value.class == Net::HTTPBadRequest || - value.class == Net::HTTPNotFound || - value.class == Net::HTTPUnauthorized + value.class != Net::HTTPOK end def self.parse_error(value, kind) From 6ba6619c93a2fe247782d0c04d89d20cddc1b781 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Fri, 23 Sep 2011 13:04:32 +0200 Subject: [PATCH 82/90] oZones server refuses to start if htaccess is not writable --- src/ozones/Server/etc/ozones-server.conf | 2 +- src/ozones/Server/lib/OZones/ApacheWritter.rb | 5 +++++ src/ozones/Server/lib/OZones/ProxyRules.rb | 9 +++++++-- src/ozones/Server/ozones-server.rb | 7 +++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/ozones/Server/etc/ozones-server.conf b/src/ozones/Server/etc/ozones-server.conf index c59c7efddc..4d4e79aeaa 100644 --- a/src/ozones/Server/etc/ozones-server.conf +++ b/src/ozones/Server/etc/ozones-server.conf @@ -24,7 +24,7 @@ :databasetype: sqlite #:htaccess: /var/www/.htaccess -:dbdebug: yes +:dbdebug: no ##################### # Server Configuration diff --git a/src/ozones/Server/lib/OZones/ApacheWritter.rb b/src/ozones/Server/lib/OZones/ApacheWritter.rb index 68678889a3..b33e9088e2 100644 --- a/src/ozones/Server/lib/OZones/ApacheWritter.rb +++ b/src/ozones/Server/lib/OZones/ApacheWritter.rb @@ -19,6 +19,11 @@ module OZones class ApacheWritter def initialize(file_path) @file_path = file_path + + File.open(@file_path, 'w') {|f| + f.flock(File::LOCK_EX) + f.write(htaccess) + } end def update diff --git a/src/ozones/Server/lib/OZones/ProxyRules.rb b/src/ozones/Server/lib/OZones/ProxyRules.rb index 1d38cef9a3..cabae51c66 100644 --- a/src/ozones/Server/lib/OZones/ProxyRules.rb +++ b/src/ozones/Server/lib/OZones/ProxyRules.rb @@ -23,11 +23,16 @@ module OZones @file_path = file_path else if !ENV["ONE_LOCATION"] - @file_path="/usr/lib/one/ozones/htaccess" + @file_path="/var/lib/one/.htaccess" else - @file_path=ENV["ONE_LOCATION"]+"/lib/ozones/htaccess" + @file_path=ENV["ONE_LOCATION"]+"/var/.htaccess" end end + + # Let's check for file permissions + if !File.writable?(File.dirname(@file_path)) + raise "#{@file_path} is not writable" + end end def update diff --git a/src/ozones/Server/ozones-server.rb b/src/ozones/Server/ozones-server.rb index c3b19612b5..afb31e9f50 100755 --- a/src/ozones/Server/ozones-server.rb +++ b/src/ozones/Server/ozones-server.rb @@ -97,6 +97,13 @@ end ADMIN_NAME = @auth.name ADMIN_PASS = @auth.password +begin + OZones::ProxyRules.new("apache",config[:htaccess]) +rescue Exception => e + warn e.message + exit -1 +end + ############################################################################## # Sinatra Configuration From 1b1ad95275215951c6b1cda3c4ba08c7e1c7b93b Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Fri, 23 Sep 2011 13:26:07 +0200 Subject: [PATCH 83/90] Now .htaccess can be precreated and owned by oneadmin (cherry picked from commit baa6a8037178eaf4fec7fa69ba5a77876afd01d9) --- src/ozones/Server/lib/OZones/ProxyRules.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ozones/Server/lib/OZones/ProxyRules.rb b/src/ozones/Server/lib/OZones/ProxyRules.rb index cabae51c66..2b3cfe0689 100644 --- a/src/ozones/Server/lib/OZones/ProxyRules.rb +++ b/src/ozones/Server/lib/OZones/ProxyRules.rb @@ -30,7 +30,8 @@ module OZones end # Let's check for file permissions - if !File.writable?(File.dirname(@file_path)) + if !File.writable?(@file_path) and + !File.writable?(File.dirname(@file_path)) raise "#{@file_path} is not writable" end end From 8729149cdcc806ea555804a405d9692bfcc564d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 23 Sep 2011 14:51:05 +0200 Subject: [PATCH 84/90] Feature #817: Fix "force" attribute management in Server. Better handling of missing attributes --- src/ozones/Server/models/OzonesServer.rb | 62 ++++++++++++++---------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/src/ozones/Server/models/OzonesServer.rb b/src/ozones/Server/models/OzonesServer.rb index e8015b9dc2..388cdfc75e 100644 --- a/src/ozones/Server/models/OzonesServer.rb +++ b/src/ozones/Server/models/OzonesServer.rb @@ -146,13 +146,16 @@ class OzonesServer vdc_data[key.downcase.to_sym]=value if key!="pool" } - # Check parameters - if !vdc_data[:vdcadminname] || !vdc_data[:vdcadminpass] || - !vdc_data[:zoneid] || !vdc_data[:name] || !vdc_data[:hosts] - return [400, OZones::Error.new( - "Error: Couldn't create resource #{kind}. " + - "Not enough information on the template").to_json] - end + mandatory_params = [:vdcadminname, :vdcadminpass, + :zoneid, :name, :hosts] + + mandatory_params.each { |param| + if !vdc_data[param] + return [400, OZones::Error.new( + "Error: Couldn't create resource #{kind}. " + + "Mandatory attribute '#{param}' is missing.").to_json] + end + } # Check if the referenced zone exists zone=OZones::Zones.get(vdc_data[:zoneid]) @@ -161,22 +164,30 @@ class OzonesServer "#{vdc_data[:zoneid]} not found, cannot create Vdc.") return [404, error.to_json] end - - if (!defined? vdc_data[:force] or - (defined? vdc_data[:force] and vdc_data[:force]!="yes")) and - !host_uniqueness?(zone, vdc_data[:hosts]) + + if (!vdc_data[:force] or vdc_data[:force].upcase!="YES") and + !host_uniqueness?(zone, vdc_data[:hosts]) return [403, OZones::Error.new( "Error: Couldn't create resource #{kind}. " + - "Hosts are not unique, and no force option " + - " were given.").to_json] + "Hosts are not unique, and no force option" + + " was given.").to_json] end vdcadminname = vdc_data[:vdcadminname] vdcadminpass = vdc_data[:vdcadminpass] vdc_data.delete(:zoneid) vdc_data.delete(:vdcadminpass) + vdc_data.delete(:force) - vdc = OZones::Vdc.create(vdc_data) + begin + vdc = OZones::Vdc.create(vdc_data) + rescue Exception => e + msg = e.message + msg["accessible in OZones::Vdc"] = "supported." + return [400, OZones::Error.new( + "Error: Couldn't create resource #{kind}." + + " #{msg}").to_json] + end zone.vdcs << vdc zone.save @@ -212,13 +223,15 @@ class OzonesServer zone_data[key.downcase.to_sym]=value if key!="pool" } - # Check parameters - if !zone_data[:onename] || !zone_data[:onepass] || - !zone_data[:endpoint] || !zone_data[:name] - return [400, OZones::Error.new( - "Error: Couldn't create resource #{kind}. " + - "Not enough information on the template").to_json] - end + mandatory_params = [:onename, :onepass, :endpoint, :name] + + mandatory_params.each { |param| + if !vdc_data[param] + return [400, OZones::Error.new( + "Error: Couldn't create resource #{kind}. " + + "Mandatory attribute '#{param}' is missing.").to_json] + end + } # Digest and check credentials zone_data[:onepass] = @@ -298,13 +311,12 @@ class OzonesServer return [404, error.to_json] end - if (!defined? vdc_data[:force] or - (defined? vdc_data[:force] and vdc_data[:force]!="yes")) and + if (!vdc_data[:force] or vdc_data[:force].upcase!="YES") and !host_uniqueness?(zone, vdc_data[:hosts], vdc_id.to_i) return [403, OZones::Error.new( "Error: Couldn't update resource #{kind}. " + - "Hosts are not unique, and no force option " + - " were given.").to_json] + "Hosts are not unique, and no force option" + + " was given.").to_json] end rc = @ocaInt.update_vdc_hosts(zone, vdc, vdc_data[:hosts]) From 1943ce6206ca21ce5e453d817022af14b098e4f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 23 Sep 2011 14:53:20 +0200 Subject: [PATCH 85/90] Feature #817: Add support for --force option in onevdc command --- src/ozones/Client/bin/onevdc | 17 +++++++--- src/ozones/Client/lib/OZonesClient.rb | 4 +++ src/ozones/Client/lib/cli/ozones_helper.rb | 22 +++++++++---- .../lib/cli/ozones_helper/vdc_helper.rb | 31 ++++++++++++++++--- 4 files changed, 58 insertions(+), 16 deletions(-) diff --git a/src/ozones/Client/bin/onevdc b/src/ozones/Client/bin/onevdc index fcfc31a725..0ad2e6c85b 100755 --- a/src/ozones/Client/bin/onevdc +++ b/src/ozones/Client/bin/onevdc @@ -26,7 +26,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do # Global Options ######################################################################## set :option, CommandParser::OPTIONS - + + FORCE={ + :name => "force", + :short => "-f", + :large => "--force", + :description => "Force the usage of Hosts in more than one VDC" + } + begin helper = VDCHelper.new "vdc" rescue Exception => e @@ -34,8 +41,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do exit -1 end - command :create, 'Create a new VDC', :file do - helper.create_resource(args[0]) + command :create, 'Create a new VDC', :file, :options=>[FORCE] do + helper.create_resource(args[0], options) end command :show, 'Show information of a particular VDC', :vdcid do @@ -52,12 +59,12 @@ cmd=CommandParser::CmdParser.new(ARGV) do end command :addhost, 'Adds the set of hosts to the VDC', - :vdcid, :range do + :vdcid, :range, :options=>[FORCE] do helper.addhost(args[0], args[1], options) end command :delhost, 'Deletes the set of hosts from the VDC', - :vdcid, :range do + :vdcid, :range, :options=>[FORCE] do helper.delhost(args[0], args[1], options) end end diff --git a/src/ozones/Client/lib/OZonesClient.rb b/src/ozones/Client/lib/OZonesClient.rb index 511479ecd9..9587ea5b1f 100644 --- a/src/ozones/Client/lib/OZonesClient.rb +++ b/src/ozones/Client/lib/OZonesClient.rb @@ -91,6 +91,10 @@ EOT ###################################################################### def post_resource(kind, template) tmpl_str = File.read(template) + post_resource_str(kind, tmpl_str) + end + + def post_resource_str(kind, tmpl_str) body_str = OZonesClient::to_body(tmpl_str) url = URI.parse("#{@endpoint}/#{kind}") diff --git a/src/ozones/Client/lib/cli/ozones_helper.rb b/src/ozones/Client/lib/cli/ozones_helper.rb index 44d212c68c..6363e1f7fb 100644 --- a/src/ozones/Client/lib/cli/ozones_helper.rb +++ b/src/ozones/Client/lib/cli/ozones_helper.rb @@ -34,11 +34,8 @@ module OZonesHelper if OZonesClient::is_error?(rc) [-1, rc.message] else - id=rc.body.match('\"id\":(.*)$')[1].strip - if id[-1..-1] == "," - id = id[0..id.size-2] - end - [0, "ID: #{id}"] + id = get_id(rc) + [0, "ID: #{id}"] end end @@ -74,6 +71,19 @@ module OZonesHelper [0, "#{message}"] end end - + + ######################################################################## + # Helpers + ######################################################################## + + + def get_id(rc) + id = rc.body.match('\"id\":(.*)$')[1].strip + if id[-1..-1] == "," + id = id[0..id.size-2] + end + + return id + end end end diff --git a/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb b/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb index 9f82bd6d83..b3d56bdd2c 100644 --- a/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb +++ b/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb @@ -24,8 +24,21 @@ class VDCHelper < OZonesHelper::OZHelper super(user, pass, endpoint_str, timeout, debug_flag) end - def create_resource(template) - super(@vdc_str,template) + def create_resource(template, options) + tmpl_str = File.read(template) + + if options[:force] + tmpl_str << "FORCE=YES\n" + end + + rc = @client.post_resource_str(@vdc_str, tmpl_str) + + if OZonesClient::is_error?(rc) + [-1, rc.message] + else + id = get_id(rc) + [0, "ID: #{id}"] + end end def list_pool(options) @@ -42,7 +55,7 @@ class VDCHelper < OZonesHelper::OZHelper def addhost(id, host_array, options) rc = @client.get_resource(@vdc_str, id) - + if OZonesClient::is_error?(rc) return [-1, rc.message] else @@ -54,7 +67,11 @@ class VDCHelper < OZonesHelper::OZHelper new_host = host_array.join(',') template = "ID=#{id}\nHOSTS=#{new_host}\n" - + + if options[:force] + template << "FORCE=YES\n" + end + rc = @client.put_resource(@vdc_str, id, template) if OZonesClient::is_error?(rc) @@ -77,7 +94,11 @@ class VDCHelper < OZonesHelper::OZHelper new_host = (hosts - host_array).join(',') template = "ID=#{id}\nHOSTS=#{new_host}\n" - + + if options[:force] + template << "FORCE=YES\n" + end + rc = @client.put_resource(@vdc_str, id, template) if OZonesClient::is_error?(rc) From b9c86afd38e95fa6b21eef77164c1069f31dc076 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Fri, 23 Sep 2011 11:20:19 +0200 Subject: [PATCH 86/90] Feature #795: Added special x509 sunstone login screen. Does not show username field and password field. (cherry picked from commit 015df5c95648680d225fc7f5e6683fdade48c7c5) --- src/sunstone/public/images/panel_short.png | Bin 0 -> 1825 bytes src/sunstone/sunstone-server.rb | 15 ++++--- src/sunstone/templates/login_x509.html | 47 +++++++++++++++++++++ 3 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 src/sunstone/public/images/panel_short.png create mode 100644 src/sunstone/templates/login_x509.html diff --git a/src/sunstone/public/images/panel_short.png b/src/sunstone/public/images/panel_short.png new file mode 100644 index 0000000000000000000000000000000000000000..2eb300fe1fbc9ce1782fd1be8375fe607eb30578 GIT binary patch literal 1825 zcmb`IZB)`(8o>W#`IhFAr==`)hOu?B#%#^dP_g9)qd~+q$z2O6-y#r6l#~p74YZM1n)y8QW#-;<@9*B{-20s0hkKq| z{3QY7?&{?V0DwC-1|$Liglb=NogMA-1e9p819Fy#IS2^)w;AjkNAh6|2-rUMTaw0d zd&GqnlW-OQ)_Z;&5TN?zW_!@-92SpuQoF!h{uDwv^8IW3#X2l_AU<1V)SxoT4c=Yz z+EdbEPv--a5F&TYH)6eC-@V>u*;s6w|S*Y|IH-lWy1^JON zucp)D%2>Hd;;`$;!!z%=(YG_H`T48&xm<28=$4vrEj8gUDnRpXwO@i*Lq*(>S2Q#< z=nVz~lF#R#f(mO}$hpt^c=t44jQ%e&PW33~t_Pk#V6y0RGrzdFc=zDm2;EW09KF50 zz1qVk{MhyC>K~aiBh4%{7!0qS;%`DulpB>H`*JkvWH_eEr|(fgDwS&DR8>`JOG`?u zKMaEjl&|XEeE*Zqo6q+t}>?BmF*45R0CJdhc zJbGkU(oNbSL!RF2HPw-~_7=*~$;m_U^yz94U9fvZr!Vr^*|MH7Z%qe>uK1!pG&QfC z<{fDy;3uC43J}*kh9fZB(W0G28@&IjcAUO_8&k^MxEob-A~s5wF1ZXzDoII6zFz8PjmPK>5TX#-|weg&F?9u`AD+ zk(LL%-;FK1Gc=yTD7Ea*O-M@mX=LA;CB_3w}-xF+a0-FKGl20`zQV5$B$8PT_zaLVW;hww7(wXD!cRHy?YD!IXNq* z)Go9+lSXWrDk&+UK!sdhJ7Pj#*f+h&q>CBrUoT~@EaN?EH|Lp8m!I zD)fRX79G#@3K$jf$%|eU$}KniJbWWZ!*doUCBc;b)o^UtkagoB$qXgp!fLd?l~~Uw znH=six;WX4BvRbV*^MSDG>%@=2T>+>aH1GG_YV_F7O+(>Z3`4E^?&>}uxJ7(IQaK( F{|`jgVDA6` literal 0 HcmV?d00001 diff --git a/src/sunstone/sunstone-server.rb b/src/sunstone/sunstone-server.rb index 49e99f831b..e2bc06ab93 100755 --- a/src/sunstone/sunstone-server.rb +++ b/src/sunstone/sunstone-server.rb @@ -52,13 +52,12 @@ require 'SunstonePlugins' begin conf = YAML.load_file(CONFIGURATION_FILE) + conf[:hash_passwords] = true rescue Exception => e puts "Error parsing config file #{CONFIGURATION_FILE}: #{e.message}" exit 1 end -conf[:hash_passwords] = true - ############################################################################## # Sinatra Configuration ############################################################################## @@ -144,9 +143,10 @@ end # HTML Requests ############################################################################## get '/' do - return File.read(File.dirname(__FILE__)+ - '/templates/login.html') unless authorized? - + if !authorized? + templ = settings.config[:auth]=="basic"? "login.html" : "login_x509.html" + return File.read(File.dirname(__FILE__)+'/templates/'+templ) + end time = Time.now + 60 response.set_cookie("one-user", :value=>"#{session[:user]}", @@ -165,7 +165,10 @@ get '/' do end get '/login' do - File.read(SUNSTONE_ROOT_DIR+'/templates/login.html') + if !authorized? + templ = settings.confing[:auth]=="basic"? "login.html" : "login_x509.html" + return File.read(File.dirname(__FILE__)+'/templates/'+templ) + end end ############################################################################## diff --git a/src/sunstone/templates/login_x509.html b/src/sunstone/templates/login_x509.html new file mode 100644 index 0000000000..790e52028c --- /dev/null +++ b/src/sunstone/templates/login_x509.html @@ -0,0 +1,47 @@ + + + + OpenNebula Sunstone Login + + + + + + + + + + + + + + + +
+
+
+ +
+ Invalid username or password +
+
+ OpenNebula is not running +
+ +
+
+
+ + + + +
+
+
+
+ + From 0e002c67fbf2b3f86051c4a5594300fc225ef855 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Fri, 23 Sep 2011 15:20:19 +0200 Subject: [PATCH 87/90] feature #795: Update install.sh sunstone x509 login --- install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index a32946f643..31643fff96 100755 --- a/install.sh +++ b/install.sh @@ -940,7 +940,8 @@ SUNSTONE_MODELS_JSON_FILES="src/sunstone/models/OpenNebulaJSON/HostJSON.rb \ src/sunstone/models/OpenNebulaJSON/AclJSON.rb \ src/sunstone/models/OpenNebulaJSON/VirtualNetworkJSON.rb" -SUNSTONE_TEMPLATE_FILES="src/sunstone/templates/login.html" +SUNSTONE_TEMPLATE_FILES="src/sunstone/templates/login.html \ + src/sunstone/templates/login_x509.html" SUNSTONE_VIEWS_FILES="src/sunstone/views/index.erb" @@ -1021,6 +1022,7 @@ SUNSTONE_PUBLIC_IMAGES_FILES="src/sunstone/public/images/ajax-loader.gif \ src/sunstone/public/images/opennebula-sunstone-big.png \ src/sunstone/public/images/opennebula-sunstone-small.png \ src/sunstone/public/images/panel.png \ + src/sunstone/public/images/panel_short.png \ src/sunstone/public/images/pbar.gif \ src/sunstone/public/images/Refresh-icon.png \ src/sunstone/public/images/vnc_off.png \ From 9ae26c552632dcc49f1e8b46bf01ec9d0c807d3a Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Fri, 23 Sep 2011 15:20:57 +0200 Subject: [PATCH 88/90] feature #795: Fix format in econe authentication error --- src/cloud/ec2/lib/econe-server.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cloud/ec2/lib/econe-server.rb b/src/cloud/ec2/lib/econe-server.rb index 2bc6f047c1..fc3e8413f1 100644 --- a/src/cloud/ec2/lib/econe-server.rb +++ b/src/cloud/ec2/lib/econe-server.rb @@ -84,7 +84,8 @@ before do begin result = @econe_server.authenticate(request.env, params) rescue Exception => e - error 500, e.message + # Add a log message + error 500, error_xml("AuthFailure", 0) end if result From 4f2008fc1faf9fb09af00198606e6fa35eb96065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 23 Sep 2011 15:29:06 +0200 Subject: [PATCH 89/90] Fix bugs in Zone creation --- src/ozones/Server/lib/OZones/ApacheWritter.rb | 5 ----- src/ozones/Server/models/OzonesServer.rb | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/ozones/Server/lib/OZones/ApacheWritter.rb b/src/ozones/Server/lib/OZones/ApacheWritter.rb index b33e9088e2..68678889a3 100644 --- a/src/ozones/Server/lib/OZones/ApacheWritter.rb +++ b/src/ozones/Server/lib/OZones/ApacheWritter.rb @@ -19,11 +19,6 @@ module OZones class ApacheWritter def initialize(file_path) @file_path = file_path - - File.open(@file_path, 'w') {|f| - f.flock(File::LOCK_EX) - f.write(htaccess) - } end def update diff --git a/src/ozones/Server/models/OzonesServer.rb b/src/ozones/Server/models/OzonesServer.rb index 388cdfc75e..25eeed4204 100644 --- a/src/ozones/Server/models/OzonesServer.rb +++ b/src/ozones/Server/models/OzonesServer.rb @@ -226,7 +226,7 @@ class OzonesServer mandatory_params = [:onename, :onepass, :endpoint, :name] mandatory_params.each { |param| - if !vdc_data[param] + if !zone_data[param] return [400, OZones::Error.new( "Error: Couldn't create resource #{kind}. " + "Mandatory attribute '#{param}' is missing.").to_json] From 1257296e84a1eb04a4e65dc0b1acf23e16a0af56 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Fri, 23 Sep 2011 16:19:50 +0200 Subject: [PATCH 90/90] feature #795: Add LICENSE headers --- src/cloud/common/CloudAuth.rb | 16 ++++++++++++++++ src/cloud/common/CloudAuth/BasicCloudAuth.rb | 16 ++++++++++++++++ src/cloud/common/CloudAuth/EC2CloudAuth.rb | 16 ++++++++++++++++ src/cloud/common/CloudAuth/X509CloudAuth.rb | 16 ++++++++++++++++ 4 files changed, 64 insertions(+) diff --git a/src/cloud/common/CloudAuth.rb b/src/cloud/common/CloudAuth.rb index 292c5718e4..859e4bea39 100644 --- a/src/cloud/common/CloudAuth.rb +++ b/src/cloud/common/CloudAuth.rb @@ -1,3 +1,19 @@ +# -------------------------------------------------------------------------- # +# 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. # +#--------------------------------------------------------------------------- # + class CloudAuth AUTH_MODULES = { "basic" => 'BasicCloudAuth', diff --git a/src/cloud/common/CloudAuth/BasicCloudAuth.rb b/src/cloud/common/CloudAuth/BasicCloudAuth.rb index 0bea9ecda1..ea6e703f0d 100644 --- a/src/cloud/common/CloudAuth/BasicCloudAuth.rb +++ b/src/cloud/common/CloudAuth/BasicCloudAuth.rb @@ -1,3 +1,19 @@ +# -------------------------------------------------------------------------- # +# 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. # +#--------------------------------------------------------------------------- # + module BasicCloudAuth def auth(env, params={}) auth = Rack::Auth::Basic::Request.new(env) diff --git a/src/cloud/common/CloudAuth/EC2CloudAuth.rb b/src/cloud/common/CloudAuth/EC2CloudAuth.rb index c47514ea16..fe8321f14c 100644 --- a/src/cloud/common/CloudAuth/EC2CloudAuth.rb +++ b/src/cloud/common/CloudAuth/EC2CloudAuth.rb @@ -1,3 +1,19 @@ +# -------------------------------------------------------------------------- # +# 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. # +#--------------------------------------------------------------------------- # + module EC2CloudAuth def auth(env, params={}) username = params['AWSAccessKeyId'] diff --git a/src/cloud/common/CloudAuth/X509CloudAuth.rb b/src/cloud/common/CloudAuth/X509CloudAuth.rb index 835d65a565..4348ee7e9b 100644 --- a/src/cloud/common/CloudAuth/X509CloudAuth.rb +++ b/src/cloud/common/CloudAuth/X509CloudAuth.rb @@ -1,3 +1,19 @@ +# -------------------------------------------------------------------------- # +# 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. # +#--------------------------------------------------------------------------- # + module X509CloudAuth # Gets the username associated with a password # password:: _String_ the password