diff --git a/include/Nebula.h b/include/Nebula.h index b16c8f3fc0..d90ead90dc 100644 --- a/include/Nebula.h +++ b/include/Nebula.h @@ -274,12 +274,12 @@ public: static string version() { - return "OpenNebula 3.7.0"; + return "OpenNebula 3.7.80"; }; static string db_version() { - return "3.7.0"; + return "3.7.80"; } void start(); diff --git a/include/Request.h b/include/Request.h index 07129634ee..ea73ae2f58 100644 --- a/include/Request.h +++ b/include/Request.h @@ -74,6 +74,7 @@ protected: string gname; /**< name of the user's group */ string session; /**< Session from ONE XML-RPC API */ + int req_id; /**< Request ID for log messages */ xmlrpc_c::value * retval; /**< Return value from libxmlrpc-c */ @@ -311,6 +312,47 @@ protected: RequestAttributes& att, PoolObjectAuth& perms, string& name); + + /** + * Logs the method invocation, including the arguments + * + * @param att the specific request attributes + * @param paramList list of XML parameters + */ + virtual void log_method_invoked( + const RequestAttributes& att, + const xmlrpc_c::paramList& paramList); + + /** + * Logs the method result, including the output data or error message + * + * @param att the specific request attributes + */ + virtual void log_result( + const RequestAttributes& att); + + /** + * Formats and adds a xmlrpc_c::value input parameter to oss. + * + * @param v value to format + * @param oss stream to write v + * @param index parameter index + */ + virtual void log_xmlrpc_param( + const xmlrpc_c::value& v, + ostringstream& oss, + const int& index); + + /** + * Formats and adds a xmlrpc_c::value to oss. + * + * @param v value to format + * @param oss stream to write v + */ + virtual void log_xmlrpc_value( + const xmlrpc_c::value& v, + ostringstream& oss); + private: /* ------------- Functions to manage user and group quotas -------------- */ diff --git a/include/RequestManagerAllocate.h b/include/RequestManagerAllocate.h index d6683448bc..4957ded508 100644 --- a/include/RequestManagerAllocate.h +++ b/include/RequestManagerAllocate.h @@ -304,6 +304,11 @@ public: int& id, string& error_str, RequestAttributes& att); + + void log_xmlrpc_param( + const xmlrpc_c::value& v, + ostringstream& oss, + const int& index); }; /* ------------------------------------------------------------------------- */ diff --git a/include/RequestManagerSystem.h b/include/RequestManagerSystem.h new file mode 100644 index 0000000000..f774a7759a --- /dev/null +++ b/include/RequestManagerSystem.h @@ -0,0 +1,67 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2012, 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. */ +/* -------------------------------------------------------------------------- */ + +#ifndef REQUEST_MANAGER_SYSTEM_H +#define REQUEST_MANAGER_SYSTEM_H + +#include "Request.h" + +using namespace std; + +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +class RequestManagerSystem: public Request +{ +protected: + RequestManagerSystem( const string& method_name, + const string& help, + const string& params) + :Request(method_name,params,help) + {}; + + ~RequestManagerSystem(){}; + + /* -------------------------------------------------------------------- */ + + virtual void request_execute(xmlrpc_c::paramList const& _paramList, + RequestAttributes& att) = 0; +}; + +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +class SystemVersion : public RequestManagerSystem +{ +public: + SystemVersion(): + RequestManagerSystem("SystemVersion", + "Returns the OpenNebula version", + "A:s") + {}; + + ~SystemVersion(){}; + + void request_execute(xmlrpc_c::paramList const& _paramList, + RequestAttributes& att); +}; + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +#endif diff --git a/include/RequestManagerUser.h b/include/RequestManagerUser.h index e65d914b67..4f95682fd3 100644 --- a/include/RequestManagerUser.h +++ b/include/RequestManagerUser.h @@ -74,6 +74,11 @@ public: int user_action(int user_id, xmlrpc_c::paramList const& _paramList, string& err); + + void log_xmlrpc_param( + const xmlrpc_c::value& v, + ostringstream& oss, + const int& index); }; /* ------------------------------------------------------------------------- */ @@ -95,6 +100,11 @@ public: int user_action(int user_id, xmlrpc_c::paramList const& _paramList, string& err); + + void log_xmlrpc_param( + const xmlrpc_c::value& v, + ostringstream& oss, + const int& index); }; /* ------------------------------------------------------------------------- */ diff --git a/share/man/econe-describe-images.1 b/share/man/econe-describe-images.1 index 583c331231..dd9c562327 100644 --- a/share/man/econe-describe-images.1 +++ b/share/man/econe-describe-images.1 @@ -1,36 +1,56 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "July 2012" "OpenNebula 3.7.0" "User Commands" +.TH OPENNEBULA "1" "October 2012" "OpenNebula 3.7.80" "User Commands" .SH NAME OpenNebula \- OpenNebula econe-describe-images -.SH SYNOPSIS -.B econe-describe-images -[\fIOPTIONS\fR] .SH DESCRIPTION -econe\-describe\-images +## SYNOPSIS +.PP +econe\-describe\-images [OPTIONS] .PP List and describe previously uploaded images of a user to be used with an OpenNebula Cloud. -.SH OPTIONS -.HP -\fB\-\-help\fR, \fB\-h\fR -.IP -Show help -.HP -\fB\-\-access\-key\fR , \fB\-K\fR -.IP +.PP +## OPTIONS +.TP +\fB\-v\fR, \fB\-\-verbose\fR +Verbose mode +.TP +\fB\-h\fR, \fB\-\-help\fR +Show this message +.TP +\fB\-V\fR, \fB\-\-version\fR +Show version and copyright information +.TP +\fB\-K\fR, \fB\-\-access\-key\fR id The username of the user -.HP -\fB\-\-secret\-key\fR , \fB\-S\fR -.IP -The password of the user -.HP -\fB\-\-url\fR , \fB\-U\fR -.IP +.TP +\fB\-S\fR, \fB\-\-sercret\-key\fR key +The sha1 hashed password of the user +.TP +\fB\-U\fR, \fB\-\-url\fR url Set url as the web service url to use -.HP -\fB\-\-headers\fR, \fB\-H\fR +.PP +## ARGUMENT FORMATS +.TP +\fBfile\fR .IP -Display column headers +Path to a file +.TP +\fBrange\fR +.IP +List of id's in the form 1,8..15 +.TP +\fBtext\fR +.IP +String +.PP +## LICENSE +OpenNebula 3.7.80 +Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula.org) +.PP +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 .SH COPYRIGHT Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula.org) .PP diff --git a/share/man/econe-describe-instances.1 b/share/man/econe-describe-instances.1 index 05695e411b..25d3cf3e5f 100644 --- a/share/man/econe-describe-instances.1 +++ b/share/man/econe-describe-instances.1 @@ -1,36 +1,55 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "July 2012" "OpenNebula 3.7.0" "User Commands" +.TH OPENNEBULA "1" "October 2012" "OpenNebula 3.7.80" "User Commands" .SH NAME OpenNebula \- OpenNebula econe-describe-instances -.SH SYNOPSIS -.B econe-describe-instances -[\fIOPTIONS\fR] .SH DESCRIPTION -econe\-describe\-instances +## SYNOPSIS +.PP +econe\-describe\-instances [OPTIONS] .PP List and describe running instances -.SH OPTIONS - -.HP -\fB\-\-help\fR, \fB\-h\fR -.IP -Show help -.HP -\fB\-\-access\-key\fR , \fB\-K\fR -.IP +.PP +## OPTIONS +.TP +\fB\-v\fR, \fB\-\-verbose\fR +Verbose mode +.TP +\fB\-h\fR, \fB\-\-help\fR +Show this message +.TP +\fB\-V\fR, \fB\-\-version\fR +Show version and copyright information +.TP +\fB\-K\fR, \fB\-\-access\-key\fR id The username of the user -.HP -\fB\-\-secret\-key\fR , \fB\-S\fR -.IP -The password of the user -.HP -\fB\-\-url\fR , \fB\-U\fR -.IP +.TP +\fB\-S\fR, \fB\-\-sercret\-key\fR key +The sha1 hashed password of the user +.TP +\fB\-U\fR, \fB\-\-url\fR url Set url as the web service url to use -.HP -\fB\-\-headers\fR, \fB\-H\fR +.PP +## ARGUMENT FORMATS +.TP +\fBfile\fR .IP -Display column headers +Path to a file +.TP +\fBrange\fR +.IP +List of id's in the form 1,8..15 +.TP +\fBtext\fR +.IP +String +.PP +## LICENSE +OpenNebula 3.7.80 +Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula.org) +.PP +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 .SH COPYRIGHT Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula.org) .PP diff --git a/share/man/econe-register.1 b/share/man/econe-register.1 index 02fe3ab4de..b11d6c3d03 100644 --- a/share/man/econe-register.1 +++ b/share/man/econe-register.1 @@ -1,40 +1,60 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "July 2012" "OpenNebula 3.7.0" "User Commands" +.TH OPENNEBULA "1" "October 2012" "OpenNebula 3.7.80" "User Commands" .SH NAME OpenNebula \- OpenNebula econe-register -.SH SYNOPSIS -.B econe-register -[\fIOPTIONS\fR] \fIIMAGE-ID\fR .SH DESCRIPTION -econe\-register +## SYNOPSIS .PP -Register a previously uploaded image for use with an -OpenNebula Cloud. -.SH OPTIONS - -.HP -\fB\-\-help\fR, \fB\-h\fR -.IP -Show help -.HP -\fB\-\-access\-key\fR , \fB\-K\fR -.IP +econe\-register [OPTIONS] IMAGE\-ID +.PP +<<\-EOT +Register a previously uploaded image for use with an OpenNebula Cloud. +IMAGE\-ID: The image identification as returned by the econe\-upload command +EOT +.PP +## OPTIONS +.TP +\fB\-v\fR, \fB\-\-verbose\fR +Verbose mode +.TP +\fB\-h\fR, \fB\-\-help\fR +Show this message +.TP +\fB\-V\fR, \fB\-\-version\fR +Show version and copyright information +.TP +\fB\-K\fR, \fB\-\-access\-key\fR id The username of the user -.HP -\fB\-\-secret\-key\fR , \fB\-S\fR -.IP -The password of the user -.HP -\fB\-\-url\fR , \fB\-U\fR -.IP +.TP +\fB\-S\fR, \fB\-\-sercret\-key\fR key +The sha1 hashed password of the user +.TP +\fB\-U\fR, \fB\-\-url\fR url Set url as the web service url to use -.HP -\fB\-\-headers\fR, \fB\-H\fR -.IP -Display column headers .PP -IMAGE\-ID: The image identification as returned by -the econe\-upload command + +.PP +## ARGUMENT FORMATS +.TP +\fBfile\fR +.IP +Path to a file +.TP +\fBrange\fR +.IP +List of id's in the form 1,8..15 +.TP +\fBtext\fR +.IP +String +.PP +## LICENSE +OpenNebula 3.7.80 +Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula.org) +.PP +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 .SH COPYRIGHT Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula.org) .PP diff --git a/share/man/econe-run-instances.1 b/share/man/econe-run-instances.1 index 5ab91b15d3..97cbc79228 100644 --- a/share/man/econe-run-instances.1 +++ b/share/man/econe-run-instances.1 @@ -1,48 +1,66 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "July 2012" "OpenNebula 3.7.0" "User Commands" +.TH OPENNEBULA "1" "October 2012" "OpenNebula 3.7.80" "User Commands" .SH NAME OpenNebula \- OpenNebula econe-run-instances -.SH SYNOPSIS -.B econe-run-instances -[\fIOPTIONS\fR] \fIIMAGE-ID\fR .SH DESCRIPTION -econe\-run\-instances +## SYNOPSIS +.PP +econe\-run\-instances [OPTIONS] IMAGE\-ID .PP Runs an instance of a particular image -.SH OPTIONS - -.HP -\fB\-\-help\fR, \fB\-h\fR -.IP -Show help -.HP -\fB\-\-access\-key\fR , \fB\-K\fR -.IP -The username of the user -.HP -\fB\-\-secret\-key\fR , \fB\-S\fR -.IP -The password of the user -.HP -\fB\-\-url\fR , \fB\-U\fR -.IP -Set url as the web service url to use -.HP -\fB\-\-type\fR , \fB\-t\fR -.IP -OpenNebula template in which is based this instance -.HP -\fB\-\-user\-data\fR, \fB\-d\fR -.IP -Specifies Base64\-encoded MIME user data to be made -available to the instance -.HP -\fB\-\-headers\fR, \fB\-H\fR -.IP -Display column headers +IMAGE\-ID: The image identification as returned by the econe\-upload command .PP -IMAGE\-ID: The image identification as returned by -the econe\-upload command +## OPTIONS +.TP +\fB\-v\fR, \fB\-\-verbose\fR +Verbose mode +.TP +\fB\-h\fR, \fB\-\-help\fR +Show this message +.TP +\fB\-V\fR, \fB\-\-version\fR +Show version and copyright information +.TP +\fB\-K\fR, \fB\-\-access\-key\fR id +The username of the user +.TP +\fB\-S\fR, \fB\-\-sercret\-key\fR key +The sha1 hashed password of the user +.TP +\fB\-U\fR, \fB\-\-url\fR url +Set url as the web service url to use +.TP +\fB\-d\fR, \fB\-\-user\-data\fR data +Specifies Base64\-encoded MIME user data to be made +.IP +available to the instance +.TP +\fB\-t\fR, \fB\-\-type\fR type +OpenNebula template in which is based this instance +.PP + +.PP +## ARGUMENT FORMATS +.TP +\fBfile\fR +.IP +Path to a file +.TP +\fBrange\fR +.IP +List of id's in the form 1,8..15 +.TP +\fBtext\fR +.IP +String +.PP +## LICENSE +OpenNebula 3.7.80 +Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula.org) +.PP +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 .SH COPYRIGHT Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula.org) .PP diff --git a/share/man/econe-terminate-instances.1 b/share/man/econe-terminate-instances.1 index c22ed735c9..31cdab8bb6 100644 --- a/share/man/econe-terminate-instances.1 +++ b/share/man/econe-terminate-instances.1 @@ -1,35 +1,58 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "July 2012" "OpenNebula 3.7.0" "User Commands" +.TH OPENNEBULA "1" "October 2012" "OpenNebula 3.7.80" "User Commands" .SH NAME OpenNebula \- OpenNebula econe-terminate-instances -.SH SYNOPSIS -.B econe-register -[\fIOPTIONS\fR] \fIINSTANCE-ID\fR .SH DESCRIPTION -econe\-terminate\-instances +## SYNOPSIS +.PP +econe\-terminate\-instances [OPTIONS] INSTANCE\-ID .PP Terminate the selected running instance -.SH OPTIONS - -.HP -\fB\-\-help\fR, \fB\-h\fR -.IP -Show help -.HP -\fB\-\-access\-key\fR , \fB\-K\fR -.IP +INSTANCE\-ID: The instance identification as returned by the econe\-run\-instances command +.PP +## OPTIONS +.TP +\fB\-v\fR, \fB\-\-verbose\fR +Verbose mode +.TP +\fB\-h\fR, \fB\-\-help\fR +Show this message +.TP +\fB\-V\fR, \fB\-\-version\fR +Show version and copyright information +.TP +\fB\-K\fR, \fB\-\-access\-key\fR id The username of the user -.HP -\fB\-\-secret\-key\fR , \fB\-S\fR -.IP -The password of the user -.HP -\fB\-\-url\fR , \fB\-U\fR -.IP +.TP +\fB\-S\fR, \fB\-\-sercret\-key\fR key +The sha1 hashed password of the user +.TP +\fB\-U\fR, \fB\-\-url\fR url Set url as the web service url to use .PP -INSTANCE\-ID: The instance identification as returned by -the econe\-run\-instances command + +.PP +## ARGUMENT FORMATS +.TP +\fBfile\fR +.IP +Path to a file +.TP +\fBrange\fR +.IP +List of id's in the form 1,8..15 +.TP +\fBtext\fR +.IP +String +.PP +## LICENSE +OpenNebula 3.7.80 +Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula.org) +.PP +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 .SH COPYRIGHT Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula.org) .PP diff --git a/share/man/econe-upload.1 b/share/man/econe-upload.1 index c1be1b714a..bb272db089 100644 --- a/share/man/econe-upload.1 +++ b/share/man/econe-upload.1 @@ -1,39 +1,62 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "July 2012" "OpenNebula 3.7.0" "User Commands" +.TH OPENNEBULA "1" "October 2012" "OpenNebula 3.7.80" "User Commands" .SH NAME OpenNebula \- OpenNebula econe-upload -.SH SYNOPSIS -.B econe-upload -[\fIOPTIONS\fR] \fIIMAGE-PATH\fR .SH DESCRIPTION -econe\-upload +## SYNOPSIS +.PP +econe\-upload [OPTIONS] IMAGE\-PATH .PP Uploads an image for use with an OpenNebula Cloud. This image should be later register with econe\-register using the returned ImageId -.SH OPTIONS - -.HP -\fB\-\-help\fR, \fB\-h\fR -.IP -Show help -.HP -\fB\-\-access\-key\fR , \fB\-K\fR -.IP +IMAGE\-PATH: Path to the image to upload +.PP +## OPTIONS +.TP +\fB\-v\fR, \fB\-\-verbose\fR +Verbose mode +.TP +\fB\-h\fR, \fB\-\-help\fR +Show this message +.TP +\fB\-V\fR, \fB\-\-version\fR +Show version and copyright information +.TP +\fB\-K\fR, \fB\-\-access\-key\fR id The username of the user -.HP -\fB\-\-secret\-key\fR , \fB\-S\fR -.IP -The password of the user -.HP -\fB\-\-url\fR , \fB\-U\fR -.IP +.TP +\fB\-S\fR, \fB\-\-sercret\-key\fR key +The sha1 hashed password of the user +.TP +\fB\-U\fR, \fB\-\-url\fR url Set url as the web service url to use -.HP -\fB\-\-multipart\fR, \fB\-M\fR -.IP +.TP +\fB\-M\fR, \fB\-\-multipart\fR Use 'multipart\-post' library instead of Curb/Curl .PP -IMAGE\-PATH: Path to the image to upload + +.PP +## ARGUMENT FORMATS +.TP +\fBfile\fR +.IP +Path to a file +.TP +\fBrange\fR +.IP +List of id's in the form 1,8..15 +.TP +\fBtext\fR +.IP +String +.PP +## LICENSE +OpenNebula 3.7.80 +Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula.org) +.PP +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 .SH COPYRIGHT Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula.org) .PP diff --git a/share/man/occi-compute.1 b/share/man/occi-compute.1 index 095f2031c5..c2d6b05f5d 100644 --- a/share/man/occi-compute.1 +++ b/share/man/occi-compute.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "July 2012" "OpenNebula 3.7.0" "User Commands" +.TH OPENNEBULA "1" "October 2012" "OpenNebula 3.7.80" "User Commands" .SH NAME OpenNebula \- OpenNebula occi-compute .SH SYNOPSIS @@ -60,6 +60,14 @@ provided \fBdelete\fR .IP deletes the compute resource idenfitied by +.TP +\fBattachdisk\fR +.IP +attaches an storage to a given compute +.TP +\fBdetachdisk\fR +.IP +detaches the target disk form the compute .SH COPYRIGHT Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula.org) .PP diff --git a/share/man/occi-network.1 b/share/man/occi-network.1 index bf4c5948fb..63119ad5f4 100644 --- a/share/man/occi-network.1 +++ b/share/man/occi-network.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "July 2012" "OpenNebula 3.7.0" "User Commands" +.TH OPENNEBULA "1" "October 2012" "OpenNebula 3.7.80" "User Commands" .SH NAME OpenNebula \- OpenNebula occi-network .SH SYNOPSIS diff --git a/share/man/occi-storage.1 b/share/man/occi-storage.1 index 4fda20bdd7..113d6c0d31 100644 --- a/share/man/occi-storage.1 +++ b/share/man/occi-storage.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "July 2012" "OpenNebula 3.7.0" "User Commands" +.TH OPENNEBULA "1" "October 2012" "OpenNebula 3.7.80" "User Commands" .SH NAME OpenNebula \- OpenNebula occi-storage .SH SYNOPSIS @@ -68,6 +68,11 @@ provided \fBdelete\fR .IP deletes the storage resource idenfitied by +.TP +\fBclone\fR +.IP +clones the storage resource idenfitied by in a new one +using the given .SH COPYRIGHT Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula.org) .PP diff --git a/share/man/oneacct.1 b/share/man/oneacct.1 index dc285514b1..129c908d20 100644 --- a/share/man/oneacct.1 +++ b/share/man/oneacct.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEACCT" "1" "September 2012" "" "oneacct(1) -- OpenNebula Accountin Tool" +.TH "ONEACCT" "1" "October 2012" "" "oneacct(1) -- OpenNebula Accountin Tool" . .SH "NAME" \fBoneacct\fR @@ -75,7 +75,7 @@ String .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.7\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.7\.80 Copyright 2002\-2012, 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/oneacl.1 b/share/man/oneacl.1 index be4948e52a..f0a1870dd8 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 2012" "" "oneacl(1) -- manages OpenNebula ACLs" +.TH "ONEACL" "1" "October 2012" "" "oneacl(1) -- manages OpenNebula ACLs" . .SH "NAME" \fBoneacl\fR @@ -14,6 +14,7 @@ .nf \-x, \-\-xml Show the resource in xml format + \-\-describe Describe list columns \-v, \-\-verbose Verbose mode \-h, \-\-help Show this message \-V, \-\-version Show version and copyright information @@ -58,7 +59,7 @@ list .nf Lists the ACL rule set -valid options: xml +valid options: xml, describe . .fi . @@ -128,7 +129,7 @@ Comma\-separated list of OpenNebula ACL names or ids .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.7\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.7\.80 Copyright 2002\-2012, 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/onecluster.1 b/share/man/onecluster.1 index 4b97815adf..76446b5f8b 100644 --- a/share/man/onecluster.1 +++ b/share/man/onecluster.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONECLUSTER" "1" "July 2012" "" "onecluster(1) -- manages OpenNebula clusters" +.TH "ONECLUSTER" "1" "October 2012" "" "onecluster(1) -- manages OpenNebula clusters" . .SH "NAME" \fBonecluster\fR @@ -17,6 +17,7 @@ \-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 + \-\-describe Describe list columns \-v, \-\-verbose Verbose mode \-h, \-\-help Show this message \-V, \-\-version Show version and copyright information @@ -61,7 +62,7 @@ list .nf Lists Clusters in the pool -valid options: list, delay, xml, numeric +valid options: list, delay, xml, numeric, describe . .fi . @@ -301,7 +302,7 @@ OpenNebula DATASTORE name or id .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.7\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.7\.80 Copyright 2002\-2012, 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/onedatastore.1 b/share/man/onedatastore.1 index b562710852..0b96f02d4f 100644 --- a/share/man/onedatastore.1 +++ b/share/man/onedatastore.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEDATASTORE" "1" "July 2012" "" "onedatastore(1) -- manages OpenNebula datastores" +.TH "ONEDATASTORE" "1" "October 2012" "" "onedatastore(1) -- manages OpenNebula datastores" . .SH "NAME" \fBonedatastore\fR @@ -18,6 +18,7 @@ \-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 + \-\-describe Describe list columns \-v, \-\-verbose Verbose mode \-h, \-\-help Show this message \-V, \-\-version Show version and copyright information @@ -105,7 +106,7 @@ list .nf Lists Datastores in the pool -valid options: list, delay, xml, numeric +valid options: list, delay, xml, numeric, describe . .fi . @@ -261,7 +262,7 @@ OpenNebula USER name or id .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.7\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.7\.80 Copyright 2002\-2012, 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 9ece109827..c6dfcbc7f8 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 2012" "" "onedb(1) -- OpenNebula database migration tool" +.TH "ONEDB" "1" "October 2012" "" "onedb(1) -- OpenNebula database migration tool" . .SH "NAME" \fBonedb\fR diff --git a/share/man/onegroup.1 b/share/man/onegroup.1 index 2847eeedbe..dc41cb6e39 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 2012" "" "onegroup(1) -- manages OpenNebula groups" +.TH "ONEGROUP" "1" "October 2012" "" "onegroup(1) -- manages OpenNebula groups" . .SH "NAME" \fBonegroup\fR @@ -17,6 +17,7 @@ \-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 + \-\-describe Describe list columns \-v, \-\-verbose Verbose mode \-h, \-\-help Show this message \-V, \-\-version Show version and copyright information @@ -61,7 +62,7 @@ list .nf Lists Groups in the pool -valid options: list, delay, xml, numeric +valid options: list, delay, xml, numeric, describe . .fi . @@ -97,6 +98,21 @@ will be launched to modify the current quotas\. . .IP "" 0 +. +.IP "\(bu" 4 +batchquota \fIrange|groupid_list\fR [\fIfile\fR] +. +.IP "" 4 +. +.nf + +Sets the quota limits in batch for various groups\. If a path is not +provided the editor will be launched to create new quotas\. +. +.fi +. +.IP "" 0 + . .IP "" 0 . @@ -175,7 +191,7 @@ Comma\-separated list of OpenNebula GROUP names or ids .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.7\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.7\.80 Copyright 2002\-2012, 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 5315022f26..d3b36a6089 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 2012" "" "onehost(1) -- manages OpenNebula hosts" +.TH "ONEHOST" "1" "October 2012" "" "onehost(1) -- manages OpenNebula hosts" . .SH "NAME" \fBonehost\fR @@ -22,6 +22,7 @@ \-x, \-\-xml Show the resource in xml format \-n, \-\-numeric Do not translate user and group IDs \-k, \-\-kilobytes Show units in kilobytes + \-\-describe Describe list columns \-v, \-\-verbose Verbose mode \-h, \-\-help Show this message \-V, \-\-version Show version and copyright information @@ -126,7 +127,7 @@ list .nf Lists Hosts in the pool -valid options: list, delay, xml, numeric, kilobytes +valid options: list, delay, xml, numeric, kilobytes, describe . .fi . @@ -254,7 +255,7 @@ Comma\-separated list of OpenNebula HOST names or ids .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.7\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.7\.80 Copyright 2002\-2012, 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 2c6c45d758..082f6b19ff 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 2012" "" "oneimage(1) -- manages OpenNebula images" +.TH "ONEIMAGE" "1" "October 2012" "" "oneimage(1) -- manages OpenNebula images" . .SH "NAME" \fBoneimage\fR @@ -14,10 +14,23 @@ .nf \-d, \-\-datastore id|name Selects the datastore + \-\-name name Name of the new image + \-\-description description Description for the new Image + \-\-type type Type of the new Image: OS, CDROM or DATABLOCK + \-\-persistent Tells if the image will be persistent + \-\-prefix prefix Device prefix for the disk (eg\. hd, sd, xvd or vd) + \-\-target target Device the disk will be attached to + \-\-path path Path of the image file + \-\-driver driver Driver to use image (raw, qcow2, tap:aio:\.\.\.) + \-\-disk_type disk_type Type of the image (BLOCK, CDROM or FILE) + \-\-source source Source to be used\. Useful for not file\-based images + \-\-size size Size in MB\. Used for DATABLOCK type + \-\-fstype fstype Type of file system to be built\. This can be any value understood by mkfs unix command\. \-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 + \-\-describe Describe list columns \-v, \-\-verbose Verbose mode \-h, \-\-help Show this message \-V, \-\-version Show version and copyright information @@ -27,14 +40,33 @@ .SH "COMMANDS" . .IP "\(bu" 4 -create \fIfile\fR +create [\fIfile\fR] . .IP "" 4 . .nf -Creates a new Image from the given template file -valid options: datastore +Creates a new Image +Examples: + \- using a template description file: + + oneimage create \-d default centOS\.tmpl + + \- new image "arch" using a path of type centOS: + + oneimage create \-d default \-\-name arch \-\-path /tmp/arch\.img + + \- new persistent image, OS type and qcow2 format: + + oneimage create \-d 1 \-\-name ubuntu \-\-path /tmp/ubuntu\.qcow2 \e + \-\-prefix sd \-\-type OS \-\-driver qcow2 \e + \-\-description "A OS plain installation" + + \- a datablock image of 400MB: + + oneimage create \-d 1 \-\-name data \-\-type DATABLOCK \-\-size 400 \e + \-\-fstype ext2 +valid options: datastore, name, description, type, persistent, prefix, target, path, driver, disk_type, source, size, fstype . .fi . @@ -237,7 +269,7 @@ list [\fIfilterflag\fR] .nf Lists Images in the pool -valid options: list, delay, xml, numeric +valid options: list, delay, xml, numeric, describe . .fi . @@ -267,7 +299,7 @@ top [\fIfilterflag\fR] .nf Lists Images continuously -valid options: list, delay, xml, numeric +valid options: list, delay, xml, numeric, describe . .fi . @@ -398,7 +430,7 @@ user IMAGE of the user identified by the username .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.7\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.7\.80 Copyright 2002\-2012, 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 2812dfd099..045a8b3867 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 2012" "" "onetemplate(1) -- manages OpenNebula templates" +.TH "ONETEMPLATE" "1" "October 2012" "" "onetemplate(1) -- manages OpenNebula templates" . .SH "NAME" \fBonetemplate\fR @@ -13,7 +13,14 @@ . .nf - \-n, \-\-name vm_name Name of the new Virtual Machine\. When instantiating + \-\-name name Name for the VM + \-\-cpu cpu CPU percentage reserved for the VM (1=100% one CPU) + \-\-arch arch Architecture of the VM, e\.g\.: i386 or x86_64 + \-\-memory memory Memory ammount given to the VM + \-\-disk disk0,disk1 Disks to attach\. To use a disk owned by other user use user[disk] + \-\-network network0,network1 Networks to attach\. To use a network owned by other user use user[network] + \-\-raw string Raw string to add to the template\. Not to be confused with the RAW attribute + \-\-name vm_name Name of the new Virtual Machine\. When instantiating multiple VMs you can use the"%i" wildcard to produce different names such as vm\-0, vm\-1\.\.\. @@ -22,6 +29,7 @@ \-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 + \-\-describe Describe list columns \-v, \-\-verbose Verbose mode \-h, \-\-help Show this message \-V, \-\-version Show version and copyright information @@ -31,13 +39,28 @@ .SH "COMMANDS" . .IP "\(bu" 4 -create \fIfile\fR +create [\fIfile\fR] . .IP "" 4 . .nf -Creates a new Template from the given template file +Creates a new VM Template from the given description + +Examples: + \- using a VM Template description file: + + onetemplate create vm_description\.tmpl + + \- new VM Template named "arch vm" with a disk and a nic: + + onetemplate create \-\-name "arch vm" \-\-memory 128 \-\-cpu 1 \-\-disk arch \e + \-\-network private_lan + + \- using two disks: + + onevm create \-\-name "test vm" \-\-memory 128 \-\-cpu 1 \-\-disk arch,data +valid options: name, cpu, arch, memory, disk, network, raw . .fi . @@ -184,7 +207,7 @@ list [\fIfilterflag\fR] .nf Lists Templates in the pool -valid options: list, delay, xml, numeric +valid options: list, delay, xml, numeric, describe . .fi . @@ -214,7 +237,7 @@ top [\fIfilterflag\fR] .nf Lists Templates continuously -valid options: list, delay, xml, numeric +valid options: list, delay, xml, numeric, describe . .fi . @@ -345,7 +368,7 @@ user VMTEMPLATE of the user identified by the username .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.7\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.7\.80 Copyright 2002\-2012, 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 58dada1657..dddef6e821 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 2012" "" "oneuser(1) -- manages OpenNebula users" +.TH "ONEUSER" "1" "October 2012" "" "oneuser(1) -- manages OpenNebula users" . .SH "NAME" \fBoneuser\fR @@ -27,6 +27,7 @@ \-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 + \-\-describe Describe list columns \-v, \-\-verbose Verbose mode \-h, \-\-help Show this message \-V, \-\-version Show version and copyright information @@ -85,6 +86,21 @@ will be launched to modify the current quotas\. . .IP "" 0 +. +.IP "\(bu" 4 +batchquota \fIrange|userid_list\fR [\fIfile\fR] +. +.IP "" 4 +. +.nf + +Sets the quota limits in batch for various users\. If a path is not +provided the editor will be launched to create new quotas\. +. +.fi +. +.IP "" 0 + . .IP "\(bu" 4 login \fIusername\fR @@ -96,8 +112,10 @@ login \fIusername\fR 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 + 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 @@ -112,6 +130,8 @@ key . .nf +DEPRECATED, use login to generate auth files\. + Shows a public key from a private SSH key\. Use it as password for the SSH authentication mechanism\. valid options: key @@ -194,7 +214,7 @@ list .nf Lists Users in the pool -valid options: list, delay, xml, numeric +valid options: list, delay, xml, numeric, describe . .fi . @@ -335,7 +355,7 @@ User password .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.7\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.7\.80 Copyright 2002\-2012, 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 cc12b87cc8..e38a080723 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 2012" "" "onevdc(1) -- manages OpenNebula Virtual DataCenters" +.TH "ONEVDC" "1" "October 2012" "" "onevdc(1) -- manages OpenNebula Virtual DataCenters" . .SH "NAME" \fBonevdc\fR @@ -178,7 +178,7 @@ VDC ID .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.7\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.7\.80 Copyright 2002\-2012, 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 0b8fc79fed..e202859e53 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 2012" "" "onevm(1) -- manages OpenNebula virtual machines" +.TH "ONEVM" "1" "October 2012" "" "onevm(1) -- manages OpenNebula virtual machines" . .SH "NAME" \fBonevm\fR @@ -14,15 +14,23 @@ .nf \-m, \-\-multiple x Instance multiple VMs - \-x, \-\-xml Show the resource in xml format - \-n, \-\-numeric Do not translate user and group IDs - \-k, \-\-kilobytes Show units in kilobytes + \-\-name name Name for the VM + \-\-cpu cpu CPU percentage reserved for the VM (1=100% one CPU) + \-\-arch arch Architecture of the VM, e\.g\.: i386 or x86_64 + \-\-memory memory Memory ammount given to the VM + \-\-disk disk0,disk1 Disks to attach\. To use a disk owned by other user use user[disk] + \-\-network network0,network1 Networks to attach\. To use a network owned by other user use user[network] + \-\-raw string Raw string to add to the template\. Not to be confused with the RAW attribute \-t, \-\-type type Type of the new Image \-f, \-\-file file Selects the template file \-i, \-\-image id|name Selects the image \-t, \-\-target type Device where the image will be attached \-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 + \-\-describe Describe list columns \-v, \-\-verbose Verbose mode \-h, \-\-help Show this message \-V, \-\-version Show version and copyright information @@ -32,16 +40,30 @@ .SH "COMMANDS" . .IP "\(bu" 4 -create \fIfile\fR +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 +Creates a new VM from the given description instead of using a previously +defined template (see \'onetemplate create\' and \'onetemplate instantiate\')\. + +Examples: + + \- using a template description file: + + onevm create vm_description\.tmpl + + \- new VM named "arch vm" with a disk and a nic + + onevm create \-\-name "arch vm" \-\-memory 128 \-\-cpu 1 \-\-disk arch \e + \-\-network private_lan + + \- a vm with two disks + + onevm create \-\-name "test vm" \-\-memory 128 \-\-cpu 1 \-\-disk arch,data +valid options: multiple, name, cpu, arch, memory, disk, network, raw . .fi . @@ -105,8 +127,8 @@ saveas \fIvmid\fR \fIdiskid\fR \fIimg_name\fR .nf Sets the specified VM disk to be saved in a new Image\. The Image is -created inmediately, but the contents are saved only if the VM is -shut down gracefuly (i\.e\., using \'onevm shutdown\' and not +created immediately, but the contents are saved only if the VM is +shut down gracefully (i\.e\., using \'onevm shutdown\' and not \'onevm delete\') States: ANY @@ -124,7 +146,24 @@ shutdown \fIrange|vmid_list\fR . .nf -Shuts down the given VM\. +Shuts down the given VM\. The VM life cycle will end\. + +States: RUNNING +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +poweroff \fIrange|vmid_list\fR +. +.IP "" 4 +. +.nf + +Powers off the given VM\. The VM will remain in the poweroff state, and +can be powered on with the \'onevm restart\' command\. States: RUNNING . @@ -223,9 +262,9 @@ restart \fIrange|vmid_list\fR . .nf -Forces a re\-deployment of the given VM, issuing a boot action\. +Boots the given VM\. -States: UNKNOWN, BOOT +States: UNKNOWN, BOOT, POWEROFF . .fi . @@ -239,9 +278,9 @@ resubmit \fIrange|vmid_list\fR . .nf -Resubmits the VM to PENDING state\. This is intented for VMs stuck in a +Resubmits the VM to PENDING state\. This is intended 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\' +Template and instantiate it, see \'onetemplate instantiate\' States: ANY, except SUSPENDED or DONE . @@ -435,7 +474,7 @@ list [\fIfilterflag\fR] .nf Lists VMs in the pool -valid options: list, delay, xml, numeric, kilobytes +valid options: list, delay, xml, numeric, kilobytes, describe . .fi . @@ -624,7 +663,7 @@ Integer .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.7\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.7\.80 Copyright 2002\-2012, 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 e505d13b84..51db8211b4 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 2012" "" "onevnet(1) -- manages OpenNebula networks" +.TH "ONEVNET" "1" "October 2012" "" "onevnet(1) -- manages OpenNebula networks" . .SH "NAME" \fBonevnet\fR @@ -19,6 +19,7 @@ \-x, \-\-xml Show the resource in xml format \-n, \-\-numeric Do not translate user and group IDs \-k, \-\-kilobytes Show units in kilobytes + \-\-describe Describe list columns \-v, \-\-verbose Verbose mode \-h, \-\-help Show this message \-V, \-\-version Show version and copyright information @@ -193,7 +194,7 @@ list [\fIfilterflag\fR] .nf Lists Virtual Networks in the pool -valid options: list, delay, xml, numeric, kilobytes +valid options: list, delay, xml, numeric, kilobytes, describe . .fi . @@ -354,7 +355,7 @@ user VNET of the user identified by the username .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.7\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.7\.80 Copyright 2002\-2012, 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 75e46f9f43..af90966d3f 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 2012" "" "onezone(1) -- manages OpenNebula zones" +.TH "ONEZONE" "1" "October 2012" "" "onezone(1) -- manages OpenNebula zones" . .SH "NAME" \fBonezone\fR @@ -148,7 +148,7 @@ Zone ID .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.7\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.7\.80 Copyright 2002\-2012, 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/src/acl/AclManager.cc b/src/acl/AclManager.cc index 5075767fa0..8e80e4dba7 100644 --- a/src/acl/AclManager.cc +++ b/src/acl/AclManager.cc @@ -87,6 +87,13 @@ AclManager::AclManager(SqlDB * _db) : db(_db), lastOID(-1) PoolObjectSQL::HOST, AuthRequest::MANAGE, error_str); + + add_rule(AclRule::ALL_ID, + AclRule::ALL_ID | + PoolObjectSQL::DOCUMENT, + AuthRequest::CREATE, + error_str); + } } diff --git a/src/cli/command_parser.rb b/src/cli/command_parser.rb index 3f34026087..ab6c05e33b 100644 --- a/src/cli/command_parser.rb +++ b/src/cli/command_parser.rb @@ -441,12 +441,14 @@ module CommandParser opts.on(*args) do |o| if e[:proc] rc = e[:proc].call(o, @options) - if rc.instance_of?(Array) && rc[0] == 0 - options[e[:name].to_sym] = rc[1] - else - puts rc[1] - puts "option #{e[:name]}: Parsing error" - exit -1 + if rc.instance_of?(Array) + if rc[0] == 0 + options[e[:name].to_sym] = rc[1] + else + puts rc[1] + puts "option #{e[:name]}: Parsing error" + exit -1 + end end elsif e[:name]=="help" print_help diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index ba149d6a31..efe115ee7c 100644 --- a/src/cli/one_helper.rb +++ b/src/cli/one_helper.rb @@ -83,6 +83,13 @@ EOT 'CPU percentage reserved for the VM (1=100% one CPU)', :format => Float }, + { + :name => 'arch', + :large => '--arch arch', + :description => + 'Architecture of the VM, e.g.: i386 or x86_64', + :format => String + }, { :name => 'memory', :large => '--memory memory', @@ -118,6 +125,12 @@ EOT :large => '--network network0,network1', :description => 'Networks to attach. To use a network owned by other user use user[network]', :format => Array + }, + { + :name => 'raw', + :large => '--raw string', + :description => 'Raw string to add to the template. Not to be confused with the RAW attribute', + :format => String } ] @@ -552,8 +565,10 @@ EOT template='' template<<"NAME=\"#{options[:name]}\"\n" if options[:name] + template<<"OS = [ ARCH = \"#{options[:arch]}\" ]\n" if options[:arch] template<<"CPU=#{options[:cpu]}\n" if options[:cpu] template<<"MEMORY=#{options[:memory]}\n" if options[:memory] + template<<"#{options[:raw]}\n" if options[:raw] if options[:disk] res=create_disk_net(options[:disk], 'DISK', 'IMAGE') diff --git a/src/cloud/common/CloudClient.rb b/src/cloud/common/CloudClient.rb index b7ee78569b..46dd9b8147 100644 --- a/src/cloud/common/CloudClient.rb +++ b/src/cloud/common/CloudClient.rb @@ -22,6 +22,8 @@ require 'net/https' require "rexml/document" +require 'ostruct' + begin require 'rexml/formatters/pretty' REXML_FORMATTERS=true @@ -50,7 +52,7 @@ end module CloudClient # OpenNebula version - VERSION = '3.7.0' + VERSION = '3.7.80' # ######################################################################### # Default location for the authentication file diff --git a/src/cloud/ec2/bin/econe-allocate-address b/src/cloud/ec2/bin/econe-allocate-address index 8c780ec682..19744ec86e 100755 --- a/src/cloud/ec2/bin/econe-allocate-address +++ b/src/cloud/ec2/bin/econe-allocate-address @@ -40,6 +40,7 @@ CommandParser::CmdParser.new(ARGV) do option [ CommandParser::VERBOSE, CommandParser::HELP, + CommandParser::VERSION, EC2QueryClient::ACCESS_KEY, EC2QueryClient::SECRET_KEY, EC2QueryClient::URL diff --git a/src/cloud/ec2/bin/econe-associate-address b/src/cloud/ec2/bin/econe-associate-address index 7abb873578..fc33d92be5 100755 --- a/src/cloud/ec2/bin/econe-associate-address +++ b/src/cloud/ec2/bin/econe-associate-address @@ -45,6 +45,7 @@ EOT option [ CommandParser::VERBOSE, CommandParser::HELP, + CommandParser::VERSION, EC2QueryClient::ACCESS_KEY, EC2QueryClient::SECRET_KEY, EC2QueryClient::URL @@ -68,4 +69,4 @@ EOT exit_with_code 0 end end -end \ No newline at end of file +end diff --git a/src/cloud/ec2/bin/econe-attach-volume b/src/cloud/ec2/bin/econe-attach-volume index 14d25ba5f5..d90d849be5 100755 --- a/src/cloud/ec2/bin/econe-attach-volume +++ b/src/cloud/ec2/bin/econe-attach-volume @@ -23,125 +23,72 @@ else RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" end - $: << RUBY_LIB_LOCATION $: << RUBY_LIB_LOCATION+"/cloud" -COMMANDS_HELP=<<-EOT -econe-attach-volume - -Attaches a DATABLOCK to a running instance and exposes it as the specified device. - -Usage: - econe-attach-volume [OPTIONS] VOLUME-ID - -Options: - - --help, -h - Show help - - --access-key , -K - The username of the user - - --secret-key , -S - The password of the user - - --url , -U - Set url as the web service url to use - - --instance , -i - The ID of the instance to attach the volume to - - --device , -d "instance_id", + :short => "-i instance_id", + :large => "--instance instance_id", + :description => "The ID of the instance to attach the volume to", + :format => String +} -headers = false -url = nil -access = nil -secret = nil -instance = nil -device = nil +DEVICE = { + :name => "device", + :short => "-d device", + :large => "--device device", + :description => "Specifies the device name to expose to the instance." << + " Example: -d /dev/sdf", + :format => String +} -begin - opts.each do |opt, arg| - case opt - when '--help' - puts COMMANDS_HELP - return - when '--version' - puts CloudCLI.version_text - exit 0 - when '--access-key' - access = arg - when '--secret-key' - secret = arg - when '--url' - url = arg - when '--instance' - instance = arg - when '--headers' - headers = true - when '--device' - device = arg +CommandParser::CmdParser.new(ARGV) do + usage "econe-attach-volume [OPTIONS] VOLUME-ID" + version CloudCLI.version_text + description <<-EOT +Attaches a DATABLOCK to a running instance and exposes it as the specified device. +VOLUME-ID: The ID of the DATABLOCK +EOT + + option [ + CommandParser::VERBOSE, + CommandParser::HELP, + CommandParser::VERSION, + EC2QueryClient::ACCESS_KEY, + EC2QueryClient::SECRET_KEY, + EC2QueryClient::URL, + INSTANCE, + DEVICE + ] + + main :volume_id do + begin + ec2_client = EC2QueryClient::Client.new( + options[:access_key], + options[:secret_key], + options[:url]) + rescue Exception => e + exit_with_code -1, "#{cmd_name}: #{e.message}" + end + + rc = ec2_client.attach_volume(args[0], options[:instance_id], options[:device]) + + if CloudClient::is_error?(rc) + exit_with_code -1, "#{cmd_name}: #{rc.message}" + else + puts "volumeId: #{rc['volumeId']}" + puts "instanceId: #{rc['instanceId']}" + puts "status: #{rc['status']}" + puts "device: #{rc['device']}" + exit_with_code 0 end end -rescue Exception => e - exit -1 end - -volume_id = ARGV.shift - -if !volume_id - puts "#{cmd_name}: missing VOLUME-ID parameter" - exit -1 -end - -begin - ec2_client = EC2QueryClient::Client.new(access, secret, url) -rescue Exception => e - puts "#{cmd_name}: #{e.message}" - exit -1 -end - -rc = ec2_client.attach_volume(volume_id, instance, device) - -if CloudClient::is_error?(rc) - puts "#{cmd_name}: #{rc.message}" - exit -1 -end - -fmt = "%-15s %-15s %-10s %s" - -if headers - puts fmt % ["volumeId", "instanceId", "status", "device"] - puts "------------------------------------------------------------------------------" -end - -puts fmt % [rc['volumeId'], rc['instanceId'], rc['status'], rc['device']] - -exit 0 diff --git a/src/cloud/ec2/bin/econe-create-keypair b/src/cloud/ec2/bin/econe-create-keypair index b49d8c0ac8..ff7016dd3b 100755 --- a/src/cloud/ec2/bin/econe-create-keypair +++ b/src/cloud/ec2/bin/econe-create-keypair @@ -44,6 +44,7 @@ EOT option [ CommandParser::VERBOSE, CommandParser::HELP, + CommandParser::VERSION, EC2QueryClient::ACCESS_KEY, EC2QueryClient::SECRET_KEY, EC2QueryClient::URL diff --git a/src/cloud/ec2/bin/econe-create-volume b/src/cloud/ec2/bin/econe-create-volume index ca542f77aa..8450ad559b 100755 --- a/src/cloud/ec2/bin/econe-create-volume +++ b/src/cloud/ec2/bin/econe-create-volume @@ -23,113 +23,58 @@ else RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" end - $: << RUBY_LIB_LOCATION $: << RUBY_LIB_LOCATION+"/cloud" -COMMANDS_HELP=<<-EOT -econe-create-volume - -Create a new DATABLOCK - -Usage: - econe-create-volume [OPTIONS] - -Options: - - --help, -h - Show help - - --access-key , -K - The username of the user - - --secret-key , -S - The password of the user - - --url , -U - Set url as the web service url to use - - --size , -s - The ID of the instance to attach the volume to - - --headers, -H - Display column headers - -EOT +require 'cli/command_parser' +require 'cli/cli_helper' require 'econe/EC2QueryClient' -require 'CloudClient' -require 'getoptlong' include CloudCLI -opts = GetoptLong.new( - ['--help', '-h',GetoptLong::NO_ARGUMENT], - ['--version', '-v',GetoptLong::NO_ARGUMENT], - ['--access-key', '-K',GetoptLong::REQUIRED_ARGUMENT], - ['--secret-key', '-S',GetoptLong::REQUIRED_ARGUMENT], - ['--url', '-U',GetoptLong::REQUIRED_ARGUMENT], - ['--size', '-s',GetoptLong::REQUIRED_ARGUMENT], - ['--headers', '-H',GetoptLong::NO_ARGUMENT] - ) +SIZE = { + :name => "size", + :short => "-s size", + :large => "--size size", + :description => "The size of the volume, in GiBs.", + :format => String +} -headers = false -url = nil -access = nil -secret = nil -size = nil +CommandParser::CmdParser.new(ARGV) do + usage "econe-create-volume [OPTIONS]" + version CloudCLI.version_text + description "Create a new VOLUME" -begin - opts.each do |opt, arg| - case opt - when '--help' - puts COMMANDS_HELP - return - when '--version' - puts CloudCLI.version_text - exit 0 - when '--access-key' - access = arg - when '--secret-key' - secret = arg - when '--url' - url = arg - when '--size' - size = arg - when '--headers' - headers = true + option [ + CommandParser::VERBOSE, + CommandParser::HELP, + CommandParser::VERSION, + EC2QueryClient::ACCESS_KEY, + EC2QueryClient::SECRET_KEY, + EC2QueryClient::URL, + SIZE + ] + + main :volume_id do + begin + ec2_client = EC2QueryClient::Client.new( + options[:access_key], + options[:secret_key], + options[:url]) + rescue Exception => e + exit_with_code -1, "#{cmd_name}: #{e.message}" + end + + rc = ec2_client.create_volume(options[:size]) + + if CloudClient::is_error?(rc) + exit_with_code -1, "#{cmd_name}: #{rc.message}" + else + puts "volumeId: #{rc['volumeId']}" + puts "size: #{rc['size']}" + puts "createTime: #{rc['createTime']}" + exit_with_code 0 end end -rescue Exception => e - exit -1 end - -if !size - puts "#{cmd_name}: missing --size option" - exit -1 -end - -begin - ec2_client = EC2QueryClient::Client.new(access, secret, url) -rescue Exception => e - puts "#{cmd_name}: #{e.message}" - exit -1 -end - -rc = ec2_client.create_volume(size) - -if CloudClient::is_error?(rc) - puts "#{cmd_name}: #{rc.message}" - exit -1 -end - -fmt = "%-15s %-10s %s" - -if headers - puts fmt % ["volumeId", "size", "createTime"] - puts "------------------------------------------------------------------------------" -end - -puts fmt % [rc['volumeId'], rc['size'], rc['createTime']] - -exit 0 diff --git a/src/cloud/ec2/bin/econe-delete-keypair b/src/cloud/ec2/bin/econe-delete-keypair index 3e8e2adbe5..8b2a50057f 100755 --- a/src/cloud/ec2/bin/econe-delete-keypair +++ b/src/cloud/ec2/bin/econe-delete-keypair @@ -44,6 +44,7 @@ EOT option [ CommandParser::VERBOSE, CommandParser::HELP, + CommandParser::VERSION, EC2QueryClient::ACCESS_KEY, EC2QueryClient::SECRET_KEY, EC2QueryClient::URL diff --git a/src/cloud/ec2/bin/econe-delete-volume b/src/cloud/ec2/bin/econe-delete-volume index 4a143a82d5..44c9402060 100755 --- a/src/cloud/ec2/bin/econe-delete-volume +++ b/src/cloud/ec2/bin/econe-delete-volume @@ -23,101 +23,49 @@ else RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" end - $: << RUBY_LIB_LOCATION $: << RUBY_LIB_LOCATION+"/cloud" -COMMANDS_HELP=<<-EOT -econe-delete-volume - -Deletes a DATABLOCK - -Usage: - econe-delete-volume [OPTIONS] VOLUME-ID - -Options: - - --help, -h - Show help - - --access-key , -K - The username of the user - - --secret-key , -S - The password of the user - - --url , -U - Set url as the web service url to use - - --headers, -H - Display column headers - -VOLUME-ID: The ID of the DATABLOCK - -EOT +require 'cli/command_parser' +require 'cli/cli_helper' require 'econe/EC2QueryClient' -require 'CloudClient' -require 'getoptlong' include CloudCLI -opts = GetoptLong.new( - ['--help', '-h',GetoptLong::NO_ARGUMENT], - ['--version', '-v',GetoptLong::NO_ARGUMENT], - ['--access-key', '-K',GetoptLong::REQUIRED_ARGUMENT], - ['--secret-key', '-S',GetoptLong::REQUIRED_ARGUMENT], - ['--url', '-U',GetoptLong::REQUIRED_ARGUMENT], - ['--headers', '-H',GetoptLong::NO_ARGUMENT] - ) +CommandParser::CmdParser.new(ARGV) do + usage "econe-delete-volume [OPTIONS] VOLUME-ID" + version CloudCLI.version_text + description <<-EOT +Deletes the targe VOLUME +VOLUME-ID: The ID of the DATABLOCK +EOT -headers = false -url = nil -access = nil -secret = nil + option [ + CommandParser::VERBOSE, + CommandParser::HELP, + CommandParser::VERSION, + EC2QueryClient::ACCESS_KEY, + EC2QueryClient::SECRET_KEY, + EC2QueryClient::URL + ] -begin - opts.each do |opt, arg| - case opt - when '--help' - puts COMMANDS_HELP - return - when '--version' - puts CloudCLI.version_text - exit 0 - when '--access-key' - access = arg - when '--secret-key' - secret = arg - when '--url' - url = arg - when '--headers' - headers = true + main :volume_id do + begin + ec2_client = EC2QueryClient::Client.new( + options[:access_key], + options[:secret_key], + options[:url]) + rescue Exception => e + exit_with_code -1, "#{cmd_name}: #{e.message}" + end + + rc = ec2_client.delete_volume(args[0]) + + if CloudClient::is_error?(rc) + exit_with_code -1, "#{cmd_name}: #{rc.message}" + else + exit_with_code 0 end end -rescue Exception => e - exit -1 end - -volume_id = ARGV.shift - -if !volume_id - puts "#{cmd_name}: missing VOLUME-ID parameter" - exit -1 -end - -begin - ec2_client = EC2QueryClient::Client.new(access, secret, url) -rescue Exception => e - puts "#{cmd_name}: #{e.message}" - exit -1 -end - -rc = ec2_client.delete_volume(volume_id) - -if CloudClient::is_error?(rc) - puts "#{cmd_name}: #{rc.message}" - exit -1 -end - -exit 0 diff --git a/src/cloud/ec2/bin/econe-describe-addresses b/src/cloud/ec2/bin/econe-describe-addresses index 0dce55e95b..7238917c33 100755 --- a/src/cloud/ec2/bin/econe-describe-addresses +++ b/src/cloud/ec2/bin/econe-describe-addresses @@ -34,15 +34,15 @@ require 'econe/EC2QueryClient' include CloudCLI TABLE = CLIHelper::ShowTable.new(nil, self) do - column :publicIP, "publicIP", :size=>10 do |d| - d["publicIP"] + column :publicIp, "publicIp", :size=>10 do |d| + d["publicIp"] end - column :instanceID, "instanceID", :size=>25 do |d| - d["instanceID"] + column :instanceId, "instanceId", :size=>25 do |d| + d["instanceId"] end - default :publicIP, :instanceID + default :publicIp, :instanceId end @@ -54,6 +54,7 @@ CommandParser::CmdParser.new(ARGV) do option [ CommandParser::VERBOSE, CommandParser::HELP, + CommandParser::VERSION, EC2QueryClient::ACCESS_KEY, EC2QueryClient::SECRET_KEY, EC2QueryClient::URL @@ -74,6 +75,7 @@ CommandParser::CmdParser.new(ARGV) do if CloudClient::is_error?(rc) exit_with_code -1, "#{cmd_name}: #{rc.message}" else + puts rc if rc.empty? || rc['addressesSet'].nil? || rc['addressesSet']['item'].nil? addrs = [] else diff --git a/src/cloud/ec2/bin/econe-describe-images b/src/cloud/ec2/bin/econe-describe-images index 7ada55841e..6eddc27ddc 100755 --- a/src/cloud/ec2/bin/econe-describe-images +++ b/src/cloud/ec2/bin/econe-describe-images @@ -66,6 +66,7 @@ used with an OpenNebula Cloud." option [ CommandParser::VERBOSE, CommandParser::HELP, + CommandParser::VERSION, EC2QueryClient::ACCESS_KEY, EC2QueryClient::SECRET_KEY, EC2QueryClient::URL diff --git a/src/cloud/ec2/bin/econe-describe-instances b/src/cloud/ec2/bin/econe-describe-instances index 89a68f0684..76fa7e132b 100755 --- a/src/cloud/ec2/bin/econe-describe-instances +++ b/src/cloud/ec2/bin/econe-describe-instances @@ -64,6 +64,7 @@ CommandParser::CmdParser.new(ARGV) do option [ CommandParser::VERBOSE, CommandParser::HELP, + CommandParser::VERSION, EC2QueryClient::ACCESS_KEY, EC2QueryClient::SECRET_KEY, EC2QueryClient::URL diff --git a/src/cloud/ec2/bin/econe-describe-keypairs b/src/cloud/ec2/bin/econe-describe-keypairs index f0e7b047be..17b99a0248 100755 --- a/src/cloud/ec2/bin/econe-describe-keypairs +++ b/src/cloud/ec2/bin/econe-describe-keypairs @@ -37,7 +37,7 @@ TABLE = CLIHelper::ShowTable.new(nil, self) do d["keyName"] end - column :keyFingerprint, "keyFingerprint", :left, :size=>65 do |d| + column :keyFingerprint, "keyFingerprint", :left, :size=>60 do |d| d["keyFingerprint"] end @@ -52,6 +52,7 @@ CommandParser::CmdParser.new(ARGV) do option [ CommandParser::VERBOSE, CommandParser::HELP, + CommandParser::VERSION, EC2QueryClient::ACCESS_KEY, EC2QueryClient::SECRET_KEY, EC2QueryClient::URL diff --git a/src/cloud/ec2/bin/econe-describe-volumes b/src/cloud/ec2/bin/econe-describe-volumes index 895f2283c4..ee7b099fb1 100755 --- a/src/cloud/ec2/bin/econe-describe-volumes +++ b/src/cloud/ec2/bin/econe-describe-volumes @@ -14,7 +14,6 @@ # See the License for the specific language governing permissions and # # limitations under the License. # #--------------------------------------------------------------------------- # - ONE_LOCATION=ENV["ONE_LOCATION"] if !ONE_LOCATION @@ -23,116 +22,86 @@ else RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" end - $: << RUBY_LIB_LOCATION $: << RUBY_LIB_LOCATION+"/cloud" -COMMANDS_HELP=<<-EOT -econe-describe-volumes - -Describes your Amazon EBS volumes - -Usage: - econe-describe-volumes [OPTIONS] - -Options: - --help, -h - Show help - - --access-key , -K - The username of the user - - --secret-key , -S - The password of the user - - --url , -U - Set url as the web service url to use - - --headers, -H - Display column headers - -EOT +require 'cli/command_parser' +require 'cli/cli_helper' require 'econe/EC2QueryClient' -require 'CloudClient' -require 'getoptlong' include CloudCLI +TABLE = CLIHelper::ShowTable.new(nil, self) do + column :volumeId, "volumeId", :size=>12 do |d| + d["volumeId"] + end -opts = GetoptLong.new( - ['--help', '-h',GetoptLong::NO_ARGUMENT], - ['--version', '-v',GetoptLong::NO_ARGUMENT], - ['--access-key', '-K',GetoptLong::REQUIRED_ARGUMENT], - ['--secret-key', '-S',GetoptLong::REQUIRED_ARGUMENT], - ['--url', '-U',GetoptLong::REQUIRED_ARGUMENT], - ['--headers', '-H',GetoptLong::NO_ARGUMENT] - ) + column :size, "size", :size=>6 do |d| + d["size"] + end -headers = false -url = nil -access = nil -secret = nil + column :status, "status", :size=>10 do |d| + d["status"] + end -begin - opts.each do |opt, arg| - case opt - when '--help' - puts COMMANDS_HELP - return - when '--version' - puts CloudCLI.version_text - exit 0 - when '--access-key' - access = arg - when '--secret-key' - secret = arg - when '--url' - url = arg - when '--headers' - headers = true + column :createTime, "createTime", :size=>28 do |d| + d['createTime'] + end + + column :instanceId, "instanceId", :size=>12 do |d| + if d['attachmentSet'] && d['attachmentSet']['item'] + d['attachmentSet']['item'][0]['instanceId'] end end -rescue Exception => e - exit -1 -end -begin - ec2_client = EC2QueryClient::Client.new(access, secret, url) -rescue Exception => e - puts "#{cmd_name}: #{e.message}" - exit -1 -end - -rc = ec2_client.describe_volumes - -if CloudClient::is_error?(rc) - puts "#{cmd_name}: #{rc.message}" - exit -1 -end - -volumes = [] -if rc['volumeSet'] - volumes = rc['volumeSet']['item'] -end - -fmt = "%-15s %-10s %s" - -if headers - puts fmt % ["volumeId", "size", "instanceId"] - puts "------------------------------------------------------------------------------" -end - -volumes.each { |vol| - instances = "" - if vol['attachmentSet'] && vol['attachmentSet']['item'] - instances = vol['attachmentSet']['item'].collect{ |item| - item['instanceId'] - }.join(',') + column :device, "device", :size=>8 do |d| + if d['attachmentSet'] && d['attachmentSet']['item'] + d['attachmentSet']['item'][0]['device'] + end end - puts fmt % [vol['volumeId'], vol['size'], instances] -} + default :volumeId, :size, :status, :createTime, :instanceId, :device +end -exit 0 +CommandParser::CmdParser.new(ARGV) do + usage "econe-describe-volumes [OPTIONS]" + version CloudCLI.version_text + description "List and describe volumes" + + option [ + CommandParser::VERBOSE, + CommandParser::HELP, + CommandParser::VERSION, + EC2QueryClient::ACCESS_KEY, + EC2QueryClient::SECRET_KEY, + EC2QueryClient::URL + ] + + main do + begin + ec2_client = EC2QueryClient::Client.new( + options[:access_key], + options[:secret_key], + options[:url]) + rescue Exception => e + exit_with_code -1, "#{cmd_name}: #{e.message}" + end + + rc = ec2_client.describe_volumes + + if CloudClient::is_error?(rc) + exit_with_code -1, "#{cmd_name}: #{rc.message}" + else + if rc.empty? || rc['volumeSet'].nil? || rc['volumeSet']['item'].nil? + vols = [] + else + vols = rc['volumeSet']['item'] + end + + TABLE.show(vols) + exit_with_code 0 + end + end +end diff --git a/src/cloud/ec2/bin/econe-detach-volume b/src/cloud/ec2/bin/econe-detach-volume index 85699eb909..2a29613e68 100755 --- a/src/cloud/ec2/bin/econe-detach-volume +++ b/src/cloud/ec2/bin/econe-detach-volume @@ -23,126 +23,73 @@ else RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" end - $: << RUBY_LIB_LOCATION $: << RUBY_LIB_LOCATION+"/cloud" -COMMANDS_HELP=<<-EOT -econe-detach-volume - -Detaches an Amazon EBS volume from an instance. Make sure to unmount any -file systems on the device within your operating system before detaching the volume - -Usage: - econe-detach-volume [OPTIONS] VOLUME-ID - -Options: - - --help, -h - Show help - - --access-key , -K - The username of the user - - --secret-key , -S - The password of the user - - --url , -U - Set url as the web service url to use - - --instance , -i - The ID of the instance to attach the volume to - - --device , -d "instance_id", + :short => "-i instance_id", + :large => "--instance instance_id", + :description => "The ID of the instance to attach the volume to", + :format => String +} -headers = false -url = nil -access = nil -secret = nil -instance = nil -device = nil +DEVICE = { + :name => "device", + :short => "-d device", + :large => "--device device", + :description => "Specifies the device name to expose to the instance." << + " Example: -d /dev/sdf", + :format => String +} -begin - opts.each do |opt, arg| - case opt - when '--help' - puts COMMANDS_HELP - return - when '--version' - puts CloudCLI.version_text - exit 0 - when '--access-key' - access = arg - when '--secret-key' - secret = arg - when '--url' - url = arg - when '--instance' - instance = arg - when '--headers' - headers = true - when '--device' - device = arg +CommandParser::CmdParser.new(ARGV) do + usage "econe-detach-volume [OPTIONS] VOLUME-ID" + version CloudCLI.version_text + description <<-EOT +Detaches a volume from an instance. Make sure to unmount any file systems +on the device within your operating system before detaching the volume +VOLUME-ID: The ID of the DATABLOCK +EOT + + option [ + CommandParser::VERBOSE, + CommandParser::HELP, + CommandParser::VERSION, + EC2QueryClient::ACCESS_KEY, + EC2QueryClient::SECRET_KEY, + EC2QueryClient::URL, + INSTANCE, + DEVICE + ] + + main :volume_id do + begin + ec2_client = EC2QueryClient::Client.new( + options[:access_key], + options[:secret_key], + options[:url]) + rescue Exception => e + exit_with_code -1, "#{cmd_name}: #{e.message}" + end + + rc = ec2_client.detach_volume(args[0], options[:instance_id], options[:device]) + + if CloudClient::is_error?(rc) + exit_with_code -1, "#{cmd_name}: #{rc.message}" + else + puts "volumeId: #{rc['volumeId']}" + puts "instanceId: #{rc['instanceId']}" + puts "status: #{rc['status']}" + puts "device: #{rc['device']}" + exit_with_code 0 end end -rescue Exception => e - exit -1 end - -volume_id = ARGV.shift - -if !volume_id - puts "#{cmd_name}: missing VOLUME-ID parameter" - exit -1 -end - -begin - ec2_client = EC2QueryClient::Client.new(access, secret, url) -rescue Exception => e - puts "#{cmd_name}: #{e.message}" - exit -1 -end - -rc = ec2_client.detach_volume(volume_id, instance, device) - -if CloudClient::is_error?(rc) - puts "#{cmd_name}: #{rc.message}" - exit -1 -end - -fmt = "%-15s %-15s %-10s %s" - -if headers - puts fmt % ["volumeId", "instanceId", "status", "device"] - puts "------------------------------------------------------------------------------" -end - -puts fmt % [rc['volumeId'], rc['instanceId'], rc['status'], rc['device']] - -exit 0 diff --git a/src/cloud/ec2/bin/econe-disassociate-address b/src/cloud/ec2/bin/econe-disassociate-address index 0e055b8c44..0dd0e49ee4 100755 --- a/src/cloud/ec2/bin/econe-disassociate-address +++ b/src/cloud/ec2/bin/econe-disassociate-address @@ -44,6 +44,7 @@ EOT" option [ CommandParser::VERBOSE, CommandParser::HELP, + CommandParser::VERSION, EC2QueryClient::ACCESS_KEY, EC2QueryClient::SECRET_KEY, EC2QueryClient::URL diff --git a/src/cloud/ec2/bin/econe-reboot-instances b/src/cloud/ec2/bin/econe-reboot-instances index d6ee877979..5e473069d6 100755 --- a/src/cloud/ec2/bin/econe-reboot-instances +++ b/src/cloud/ec2/bin/econe-reboot-instances @@ -23,100 +23,52 @@ else RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" end - $: << RUBY_LIB_LOCATION $: << RUBY_LIB_LOCATION+"/cloud" -COMMANDS_HELP=<<-EOT -econe-reboot-instances - -reboot the selected running instance - -Usage: - econe-register [OPTIONS] INSTANCE-ID - -Options: - - --help, -h - Show help - - --access-key , -K - The username of the user - - --secret-key , -S - The password of the user - - --url , -U - Set url as the web service url to use - -INSTANCE-ID: The instance identification as returned by -the econe-run-instances command - -EOT +require 'cli/command_parser' +require 'cli/cli_helper' require 'econe/EC2QueryClient' -require 'CloudClient' -require 'getoptlong' include CloudCLI -opts = GetoptLong.new( - ['--help', '-h',GetoptLong::NO_ARGUMENT], - ['--version', '-v',GetoptLong::NO_ARGUMENT], - ['--access-key', '-K',GetoptLong::REQUIRED_ARGUMENT], - ['--secret-key', '-S',GetoptLong::REQUIRED_ARGUMENT], - ['--url', '-U',GetoptLong::REQUIRED_ARGUMENT] - ) -url = nil -access = nil -secret = nil +CommandParser::CmdParser.new(ARGV) do + usage "econe-reboot-instances [OPTIONS] INSTANCE-ID" + version CloudCLI.version_text + description <<-EOT +Reboot the selected running instance +INSTANCE-ID: The instance identification as returned by the econe-run-instances command +EOT -begin - opts.each do |opt, arg| - case opt - when '--help' - puts COMMANDS_HELP - return - when '--version' - puts CloudCLI.version_text - exit 0 - when '--access-key' - access = arg - when '--secret-key' - secret = arg - when '--url' - url = arg - when '--headers' - headers = true + option [ + CommandParser::VERBOSE, + CommandParser::HELP, + CommandParser::VERSION, + EC2QueryClient::ACCESS_KEY, + EC2QueryClient::SECRET_KEY, + EC2QueryClient::URL + ] + + main :instance_id do + begin + ec2_client = EC2QueryClient::Client.new( + options[:access_key], + options[:secret_key], + options[:url]) + rescue Exception => e + puts "#{cmd_name}: #{e.message}" + exit -1 + end + + rc = ec2_client.reboot_instances(args[0]) + + if CloudClient::is_error?(rc) + exit_with_code -1, "#{cmd_name}: #{rc.message}" + else + puts "Success: Rebooting" + exit_with_code 0 end end -rescue Exception => e - exit -1 end - -instance = ARGV.shift - -if !instance - puts "#{cmd_name}: missing INSTANCE-ID parameter" - exit -1 -end - -begin - ec2_client = EC2QueryClient::Client.new(access, secret, url) -rescue Exception => e - puts "#{cmd_name}: #{e.message}" - exit -1 -end - -rc = ec2_client.reboot_instances(instance) - -if CloudClient::is_error?(rc) - puts "#{cmd_name}: #{rc.message}" - exit -1 -end - - -puts "Success: Reboting" - -exit 0 diff --git a/src/cloud/ec2/bin/econe-register b/src/cloud/ec2/bin/econe-register index 74cc5523ea..d5103cb62a 100755 --- a/src/cloud/ec2/bin/econe-register +++ b/src/cloud/ec2/bin/econe-register @@ -44,6 +44,7 @@ EOT" option [ CommandParser::VERBOSE, CommandParser::HELP, + CommandParser::VERSION, EC2QueryClient::ACCESS_KEY, EC2QueryClient::SECRET_KEY, EC2QueryClient::URL diff --git a/src/cloud/ec2/bin/econe-release-address b/src/cloud/ec2/bin/econe-release-address index f03fb8d689..6f1afd8883 100755 --- a/src/cloud/ec2/bin/econe-release-address +++ b/src/cloud/ec2/bin/econe-release-address @@ -44,6 +44,7 @@ EOT option [ CommandParser::VERBOSE, CommandParser::HELP, + CommandParser::VERSION, EC2QueryClient::ACCESS_KEY, EC2QueryClient::SECRET_KEY, EC2QueryClient::URL @@ -66,12 +67,7 @@ EOT [-1, "#{cmd_name}: #{rc.message}"] else exit_code 0 - - if options[:headers] - CLIHelper.print_header("publicIP") - end - - puts rc['publicIP'] + puts "publicIP: #{rc['publicIP']}" end end end diff --git a/src/cloud/ec2/bin/econe-run-instances b/src/cloud/ec2/bin/econe-run-instances index 416953cca5..c19d1a78d0 100755 --- a/src/cloud/ec2/bin/econe-run-instances +++ b/src/cloud/ec2/bin/econe-run-instances @@ -89,6 +89,7 @@ EOT option [ CommandParser::VERBOSE, CommandParser::HELP, + CommandParser::VERSION, EC2QueryClient::ACCESS_KEY, EC2QueryClient::SECRET_KEY, EC2QueryClient::URL, diff --git a/src/cloud/ec2/bin/econe-start-instances b/src/cloud/ec2/bin/econe-start-instances index b9fd0a6062..548ba59598 100755 --- a/src/cloud/ec2/bin/econe-start-instances +++ b/src/cloud/ec2/bin/econe-start-instances @@ -23,101 +23,54 @@ else RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" end - $: << RUBY_LIB_LOCATION $: << RUBY_LIB_LOCATION+"/cloud" -COMMANDS_HELP=<<-EOT -econe-start-instances - -Start the selected running instance - -Usage: - econe-register [OPTIONS] INSTANCE-ID - -Options: - - --help, -h - Show help - - --access-key , -K - The username of the user - - --secret-key , -S - The password of the user - - --url , -U - Set url as the web service url to use - -INSTANCE-ID: The instance identification as returned by -the econe-run-instances command - -EOT +require 'cli/command_parser' +require 'cli/cli_helper' require 'econe/EC2QueryClient' -require 'CloudClient' -require 'getoptlong' include CloudCLI -opts = GetoptLong.new( - ['--help', '-h',GetoptLong::NO_ARGUMENT], - ['--version', '-v',GetoptLong::NO_ARGUMENT], - ['--access-key', '-K',GetoptLong::REQUIRED_ARGUMENT], - ['--secret-key', '-S',GetoptLong::REQUIRED_ARGUMENT], - ['--url', '-U',GetoptLong::REQUIRED_ARGUMENT] - ) -url = nil -access = nil -secret = nil +CommandParser::CmdParser.new(ARGV) do + usage "econe-start-instances [OPTIONS] INSTANCE-ID" + version CloudCLI.version_text + description <<-EOT +Start the selected stopped instance +INSTANCE-ID: The instance identification as returned by the econe-run-instances command +EOT -begin - opts.each do |opt, arg| - case opt - when '--help' - puts COMMANDS_HELP - return - when '--version' - puts CloudCLI.version_text - exit 0 - when '--access-key' - access = arg - when '--secret-key' - secret = arg - when '--url' - url = arg - when '--headers' - headers = true + option [ + CommandParser::VERBOSE, + CommandParser::HELP, + CommandParser::VERSION, + EC2QueryClient::ACCESS_KEY, + EC2QueryClient::SECRET_KEY, + EC2QueryClient::URL + ] + + main :instance_id do + begin + ec2_client = EC2QueryClient::Client.new( + options[:access_key], + options[:secret_key], + options[:url]) + rescue Exception => e + puts "#{cmd_name}: #{e.message}" + exit -1 + end + + rc = ec2_client.start_instances(args[0]) + + if CloudClient::is_error?(rc) + exit_with_code -1, "#{cmd_name}: #{rc.message}" + else + result = rc['instancesSet']['item'][0] + puts "Success: Starting #{result['instanceId']} in " << + "#{result['previousState']['name']} state" + exit_with_code 0 end end -rescue Exception => e - exit -1 end - -instance = ARGV.shift - -if !instance - puts "#{cmd_name}: missing INSTANCE-ID parameter" - exit -1 -end - -begin - ec2_client = EC2QueryClient::Client.new(access, secret, url) -rescue Exception => e - puts "#{cmd_name}: #{e.message}" - exit -1 -end - -rc = ec2_client.start_instances(instance) - -if CloudClient::is_error?(rc) - puts "#{cmd_name}: #{rc.message}" - exit -1 -end - -result = rc['instancesSet']['item'][0] - -puts "Success: Starting #{result['instanceId']} in #{result['previousState']['name']} state" - -exit 0 diff --git a/src/cloud/ec2/bin/econe-stop-instances b/src/cloud/ec2/bin/econe-stop-instances index 3b8f4865a6..a9e1e83ae2 100755 --- a/src/cloud/ec2/bin/econe-stop-instances +++ b/src/cloud/ec2/bin/econe-stop-instances @@ -23,101 +23,54 @@ else RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" end - $: << RUBY_LIB_LOCATION $: << RUBY_LIB_LOCATION+"/cloud" -COMMANDS_HELP=<<-EOT -econe-stop-instances - -Stop the selected running instance - -Usage: - econe-register [OPTIONS] INSTANCE-ID - -Options: - - --help, -h - Show help - - --access-key , -K - The username of the user - - --secret-key , -S - The password of the user - - --url , -U - Set url as the web service url to use - -INSTANCE-ID: The instance identification as returned by -the econe-run-instances command - -EOT +require 'cli/command_parser' +require 'cli/cli_helper' require 'econe/EC2QueryClient' -require 'CloudClient' -require 'getoptlong' include CloudCLI -opts = GetoptLong.new( - ['--help', '-h',GetoptLong::NO_ARGUMENT], - ['--version', '-v',GetoptLong::NO_ARGUMENT], - ['--access-key', '-K',GetoptLong::REQUIRED_ARGUMENT], - ['--secret-key', '-S',GetoptLong::REQUIRED_ARGUMENT], - ['--url', '-U',GetoptLong::REQUIRED_ARGUMENT] - ) -url = nil -access = nil -secret = nil +CommandParser::CmdParser.new(ARGV) do + usage "econe-stop-instances [OPTIONS] INSTANCE-ID" + version CloudCLI.version_text + description <<-EOT +Stop the selected running instance +INSTANCE-ID: The instance identification as returned by the econe-run-instances command +EOT -begin - opts.each do |opt, arg| - case opt - when '--help' - puts COMMANDS_HELP - return - when '--version' - puts CloudCLI.version_text - exit 0 - when '--access-key' - access = arg - when '--secret-key' - secret = arg - when '--url' - url = arg - when '--headers' - headers = true + option [ + CommandParser::VERBOSE, + CommandParser::HELP, + CommandParser::VERSION, + EC2QueryClient::ACCESS_KEY, + EC2QueryClient::SECRET_KEY, + EC2QueryClient::URL + ] + + main :instance_id do + begin + ec2_client = EC2QueryClient::Client.new( + options[:access_key], + options[:secret_key], + options[:url]) + rescue Exception => e + puts "#{cmd_name}: #{e.message}" + exit -1 + end + + rc = ec2_client.stop_instances(args[0]) + + if CloudClient::is_error?(rc) + exit_with_code -1, "#{cmd_name}: #{rc.message}" + else + result = rc['instancesSet']['item'][0] + puts "Success: Stopping #{result['instanceId']} in " << + "#{result['previousState']['name']} state" + exit_with_code 0 end end -rescue Exception => e - exit -1 end - -instance = ARGV.shift - -if !instance - puts "#{cmd_name}: missing INSTANCE-ID parameter" - exit -1 -end - -begin - ec2_client = EC2QueryClient::Client.new(access, secret, url) -rescue Exception => e - puts "#{cmd_name}: #{e.message}" - exit -1 -end - -rc = ec2_client.stop_instances(instance) - -if CloudClient::is_error?(rc) - puts "#{cmd_name}: #{rc.message}" - exit -1 -end - -result = rc['instancesSet']['item'][0] - -puts "Success: Stopping #{result['instanceId']} in #{result['previousState']['name']} state" - -exit 0 diff --git a/src/cloud/ec2/bin/econe-terminate-instances b/src/cloud/ec2/bin/econe-terminate-instances index c2f923d84d..bc3847a729 100755 --- a/src/cloud/ec2/bin/econe-terminate-instances +++ b/src/cloud/ec2/bin/econe-terminate-instances @@ -45,14 +45,13 @@ EOT option [ CommandParser::VERBOSE, CommandParser::HELP, + CommandParser::VERSION, EC2QueryClient::ACCESS_KEY, EC2QueryClient::SECRET_KEY, - EC2QueryClient::URL, - USER_DATA, - TYPE + EC2QueryClient::URL ] - main :image_id do + main :instance_id do begin ec2_client = EC2QueryClient::Client.new( options[:access_key], @@ -69,9 +68,9 @@ EOT exit_with_code -1, "#{cmd_name}: #{rc.message}" else result = rc['instancesSet']['item'][0] - puts "Success: Terminating #{result['instanceId']} in \ - #{result['previousState']['name']} state" + puts "Success: Terminating #{result['instanceId']} in " << + "#{result['previousState']['name']} state" exit_with_code 0 end end -end \ No newline at end of file +end diff --git a/src/cloud/ec2/bin/econe-upload b/src/cloud/ec2/bin/econe-upload index 76606d4f78..dfebf1d25a 100755 --- a/src/cloud/ec2/bin/econe-upload +++ b/src/cloud/ec2/bin/econe-upload @@ -53,11 +53,11 @@ EOT option [ CommandParser::VERBOSE, CommandParser::HELP, + CommandParser::VERSION, EC2QueryClient::ACCESS_KEY, EC2QueryClient::SECRET_KEY, EC2QueryClient::URL, - USER_DATA, - TYPE + MULTIPART ] main :file do diff --git a/src/cloud/ec2/lib/EC2QueryClient.rb b/src/cloud/ec2/lib/EC2QueryClient.rb index 8fe2383e24..dcc53bda24 100644 --- a/src/cloud/ec2/lib/EC2QueryClient.rb +++ b/src/cloud/ec2/lib/EC2QueryClient.rb @@ -252,6 +252,7 @@ module EC2QueryClient connection = Curl::Easy.new(@uri.to_s) connection.multipart_form_post = true + connection.ssl_verify_peer = false connection.http_post(*post_fields) diff --git a/src/cloud/ec2/lib/EC2QueryServer.rb b/src/cloud/ec2/lib/EC2QueryServer.rb index ec18f1504f..4478961206 100644 --- a/src/cloud/ec2/lib/EC2QueryServer.rb +++ b/src/cloud/ec2/lib/EC2QueryServer.rb @@ -63,6 +63,11 @@ end ############################################################################### class EC2QueryServer < CloudServer + include ElasticIP + include Keypair + include EBS + include Instance + ############################################################################ # # @@ -78,18 +83,6 @@ class EC2QueryServer < CloudServer else @base_url="http://#{config[:server]}:#{config[:port]}" end - - # ----------- Load EC2 API modules ------------ - - if @config[:elasticips_vnet_id].nil? - logger.error { 'ElasticIP module not loaded' } - else - extend ElasticIP - end - - extend Keypair - extend EBS - extend Instance end ########################################################################### @@ -166,29 +159,6 @@ class EC2QueryServer < CloudServer return response.result(binding), 200 end - ########################################################################### - # Provide defaults for Elastic IP if not loaded - ########################################################################### - def allocate_address(params) - return OpenNebula::Error.new('Unsupported') - end - - def release_address(params) - return OpenNebula::Error.new('Unsupported') - end - - def describe_addresses(params) - return OpenNebula::Error.new('Unsupported') - end - - def associate_address(params) - return OpenNebula::Error.new('Unsupported') - end - - def disassociate_address(params) - return OpenNebula::Error.new('Unsupported') - end - ########################################################################### # Helper functions ########################################################################### diff --git a/src/cloud/ec2/lib/instance.rb b/src/cloud/ec2/lib/instance.rb index 2fa75872c1..14f6157774 100644 --- a/src/cloud/ec2/lib/instance.rb +++ b/src/cloud/ec2/lib/instance.rb @@ -165,6 +165,10 @@ module Instance rc = block.call(vm) + if OpenNebula::is_error?(rc) + return rc + end + vm.info erb_current_state = render_state(vm) diff --git a/src/cloud/ec2/lib/keypair.rb b/src/cloud/ec2/lib/keypair.rb index fb438c6288..77ba2a29bf 100644 --- a/src/cloud/ec2/lib/keypair.rb +++ b/src/cloud/ec2/lib/keypair.rb @@ -93,7 +93,7 @@ module Keypair erb_ssh_public_key = erb_public_key.ssh_type << " " << - [ erb_public_key.to_blob ].pack('m0') << + [ erb_public_key.to_blob ].pack('m0').gsub(/\n/, '') << " " << erb_keyname kp[erb_keyname] = { diff --git a/src/cloud/occi/lib/ui/templates/login.html b/src/cloud/occi/lib/ui/templates/login.html index 0f7af9f3dd..a9e412093e 100644 --- a/src/cloud/occi/lib/ui/templates/login.html +++ b/src/cloud/occi/lib/ui/templates/login.html @@ -53,7 +53,7 @@ diff --git a/src/cloud/occi/lib/ui/views/index.erb b/src/cloud/occi/lib/ui/views/index.erb index 7453100052..de88128782 100644 --- a/src/cloud/occi/lib/ui/views/index.erb +++ b/src/cloud/occi/lib/ui/views/index.erb @@ -81,7 +81,7 @@ diff --git a/src/oca/java/src/org/opennebula/client/Client.java b/src/oca/java/src/org/opennebula/client/Client.java index 36c0b36b5c..7d4c87ad83 100644 --- a/src/oca/java/src/org/opennebula/client/Client.java +++ b/src/oca/java/src/org/opennebula/client/Client.java @@ -119,6 +119,16 @@ public class Client{ return new OneResponse(success, msg); } + /** + * Calls OpenNebula and retrieves oned version + * + * @return The server's xml-rpc response encapsulated + */ + public OneResponse get_version() + { + return call("system.version"); + } + //-------------------------------------------------------------------------- // PRIVATE ATTRIBUTES AND METHODS //-------------------------------------------------------------------------- diff --git a/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java b/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java index 245de275ef..d9e8bd2add 100644 --- a/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java +++ b/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java @@ -491,6 +491,15 @@ public class VirtualMachine extends PoolElement{ return action("shutdown"); } + /** + * Powers off a running VM. + * @return If an error occurs the error message contains the reason. + */ + public OneResponse poweroff() + { + return action("poweroff"); + } + /** * Reboots a running VM. * @return If an error occurs the error message contains the reason. diff --git a/src/oca/ruby/OpenNebula.rb b/src/oca/ruby/OpenNebula.rb index 34980fd0c3..6374c04051 100644 --- a/src/oca/ruby/OpenNebula.rb +++ b/src/oca/ruby/OpenNebula.rb @@ -52,7 +52,7 @@ require 'OpenNebula/DocumentPool' module OpenNebula # OpenNebula version - VERSION = '3.7.0' + VERSION = '3.7.80' # The Error Class represents a generic error in the OpenNebula # library. It contains a readable representation of the error. @@ -167,5 +167,9 @@ module OpenNebula Error.new(e.message) end end + + def get_version() + call("system.version") + end end end diff --git a/src/onedb/3.6.0_to_3.7.80.rb b/src/onedb/3.6.0_to_3.7.80.rb index b06e50ac93..262cbe5872 100644 --- a/src/onedb/3.6.0_to_3.7.80.rb +++ b/src/onedb/3.6.0_to_3.7.80.rb @@ -28,7 +28,90 @@ module Migrator def up ######################################################################## - # Bug #1335 + # Feature #1522: Allow users to create Documents by default + ######################################################################## + + # Insert rule "* DOCUMENT/* CREATE" + + last_oid = 0 + @db.fetch("SELECT last_oid FROM pool_control WHERE tablename='acl'") do |row| + last_oid = row[:last_oid].to_i + end + + @db[:acl].insert( + :oid => (last_oid + 1).to_s, + :user => 0x400000000.to_s, + :resource => 0x400400000000.to_s, + :rights => 0x8.to_s) + + @db.run("UPDATE pool_control SET last_oid=#{last_oid + 1} WHERE tablename='acl';") + + ######################################################################## + # Bugs #1363: Make sure all VMs have CPU (float) & MEM (int) + ######################################################################## + + # NOTE: The VM memory and CPU are modified, but the sum in + # HOST/HOST_SHARE is not. A onedb fsck is required + + @db.run "ALTER TABLE vm_pool RENAME TO old_vm_pool;" + @db.run "CREATE TABLE vm_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, last_poll INTEGER, state INTEGER, lcm_state INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER);" + + @db.fetch("SELECT * FROM old_vm_pool") do |row| + if ( row[:state] == 6 ) + body = row[:body] + else + vm_doc = Document.new(row[:body]) + + memory = nil + vm_doc.root.each_element("TEMPLATE/MEMORY") { |e| + memory = e.text.to_i + memory = 0 if memory < 0 + + e.text = memory.to_s + } + + if memory.nil? + vm_doc.root.each_element("TEMPLATE") { |e| + e.add_element("MEMORY").text = "0" + } + end + + cpu = nil + vm_doc.root.each_element("TEMPLATE/CPU") { |e| + # truncate to 2 decimals + cpu = (e.text.to_f * 100).to_i / 100.0 + cpu = 0 if cpu < 0 + + e.text = cpu.to_s + } + + if cpu.nil? + vm_doc.root.each_element("TEMPLATE") { |e| + e.add_element("CPU").text = "0" + } + end + + body = vm_doc.root.to_s + end + + @db[:vm_pool].insert( + :oid => row[:oid], + :name => row[:name], + :body => body, + :uid => row[:uid], + :gid => row[:gid], + :last_poll => row[:last_poll], + :state => row[:state], + :lcm_state => row[:lcm_state], + :owner_u => row[:owner_u], + :group_u => row[:group_u], + :other_u => row[:other_u]) + end + + @db.run "DROP TABLE old_vm_pool;" + + ######################################################################## + # Bug #1335: Add suspended VMs resoureces to Host usage ######################################################################## @db.fetch("SELECT * FROM vm_pool WHERE state = 5") do |row| @@ -41,7 +124,7 @@ module Migrator cpu = 0 vm_doc.root.each_element("TEMPLATE/CPU") { |e| - cpu = e.text.to_i + cpu = e.text.to_f } hid = -1 @@ -188,7 +271,7 @@ module Migrator mem_used = 0 vms_used = 0 - @db.fetch("SELECT body FROM vm_pool WHERE #{where_filter} AND state!=6") do |vm_row| + @db.fetch("SELECT body FROM vm_pool WHERE #{where_filter} AND state<>6") do |vm_row| vmdoc = Document.new(vm_row[:body]) # VM quotas diff --git a/src/ozones/Server/templates/index.html b/src/ozones/Server/templates/index.html index 6c9364153d..c2ca6e1db9 100644 --- a/src/ozones/Server/templates/index.html +++ b/src/ozones/Server/templates/index.html @@ -65,7 +65,7 @@
diff --git a/src/ozones/Server/templates/login.html b/src/ozones/Server/templates/login.html index 47d4f9d36e..08a4e85d0e 100644 --- a/src/ozones/Server/templates/login.html +++ b/src/ozones/Server/templates/login.html @@ -49,7 +49,7 @@
diff --git a/src/rm/Request.cc b/src/rm/Request.cc index 0a9f4d3450..21bc34ed39 100644 --- a/src/rm/Request.cc +++ b/src/rm/Request.cc @@ -19,7 +19,6 @@ #include "PoolObjectAuth.h" - /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -31,17 +30,20 @@ void Request::execute( att.retval = _retval; att.session = xmlrpc_c::value_string (_paramList.getString(0)); + att.req_id = rand() % 1000; Nebula& nd = Nebula::instance(); UserPool* upool = nd.get_upool(); - NebulaLog::log("ReM",Log::DEBUG, method_name + " method invoked"); + bool authenticated = upool->authenticate( att.session, + att.uid, + att.gid, + att.uname, + att.gname); - if ( upool->authenticate(att.session, - att.uid, - att.gid, - att.uname, - att.gname) == false ) + log_method_invoked(att, _paramList); + + if ( authenticated == false ) { failure_response(AUTHENTICATION, authenticate_error(), att); } @@ -49,11 +51,155 @@ void Request::execute( { request_execute(_paramList, att); } + + log_result(att); }; /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +void Request::log_method_invoked( + const RequestAttributes& att, + const xmlrpc_c::paramList& paramList) +{ + ostringstream oss; + + oss << "[" << att.req_id << "] "; + + if ( att.uid != -1 ) + { + oss << "[" << att.uid << " " << att.uname << "] "; + } + else + { + oss << "[- -] "; + } + + oss << "[" << method_name << "] method invoked"; + + for (unsigned int i=1; i const vvalue(array1.vectorValueValue()); + + if ( static_cast(xmlrpc_c::value_boolean(vvalue[0])) ) + { + oss << "SUCCESS"; + + for (unsigned int i=1; i(xmlrpc_c::value_string(vvalue[1])); + + NebulaLog::log("ReM",Log::ERROR, oss); + } +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void Request::log_xmlrpc_param( + const xmlrpc_c::value& v, + ostringstream& oss, + const int& index) +{ + log_xmlrpc_value(v, oss); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void Request::log_xmlrpc_value( + const xmlrpc_c::value& v, + ostringstream& oss) +{ + size_t st_limit = 20; + size_t st_newline; + + switch (v.type()) + { + case xmlrpc_c::value::TYPE_INT: + oss << ", " << static_cast(xmlrpc_c::value_int(v)); + break; + case xmlrpc_c::value::TYPE_BOOLEAN: + oss << ", "; + + if ( static_cast(xmlrpc_c::value_boolean(v)) ) + { + oss << "true"; + } + else + { + oss << "false"; + } + + break; + case xmlrpc_c::value::TYPE_STRING: + st_newline = + static_cast(xmlrpc_c::value_string(v)).find("\n"); + + if ( st_newline < st_limit ) + { + st_limit = st_newline; + } + + oss << ", \"" << + static_cast(xmlrpc_c::value_string(v)).substr(0,st_limit); + + if ( static_cast(xmlrpc_c::value_string(v)).size() > st_limit ) + { + oss << "..."; + } + + oss << "\""; + break; + case xmlrpc_c::value::TYPE_DOUBLE: + oss << ", " + << static_cast(xmlrpc_c::value_double(v)); + break; + default: + oss << ", unknown param type"; + break; + } +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + bool Request::basic_authorization(int oid, AuthRequest::Operation op, RequestAttributes& att) @@ -338,8 +484,6 @@ void Request::failure_response(ErrorCode ec, const string& str_val, xmlrpc_c::value_array arrayresult(arrayData); *(att.retval) = arrayresult; - - NebulaLog::log("ReM",Log::ERROR,str_val); } /* -------------------------------------------------------------------------- */ diff --git a/src/rm/RequestManager.cc b/src/rm/RequestManager.cc index 4c2135785b..341d44d159 100644 --- a/src/rm/RequestManager.cc +++ b/src/rm/RequestManager.cc @@ -37,6 +37,8 @@ #include "RequestManagerCluster.h" #include "RequestManagerGroup.h" +#include "RequestManagerSystem.h" + #include #include #include @@ -362,6 +364,9 @@ void RequestManager::register_xml_methods() xmlrpc_c::methodPtr cluster_addvnet(new ClusterAddVNet()); xmlrpc_c::methodPtr cluster_delvnet(new ClusterDelVNet()); + // System Methods + xmlrpc_c::methodPtr system_version(new SystemVersion()); + /* VM related methods */ RequestManagerRegistry.addMethod("one.vm.deploy", vm_deploy); RequestManagerRegistry.addMethod("one.vm.action", vm_action); @@ -490,6 +495,11 @@ void RequestManager::register_xml_methods() RequestManagerRegistry.addMethod("one.document.clone", doc_clone); RequestManagerRegistry.addMethod("one.documentpool.info",docpool_info); + + /* System related methods */ + RequestManagerRegistry.addMethod("one.system.version", system_version); + + }; /* -------------------------------------------------------------------------- */ diff --git a/src/rm/RequestManagerAllocate.cc b/src/rm/RequestManagerAllocate.cc index 2da96e857b..e376487176 100644 --- a/src/rm/RequestManagerAllocate.cc +++ b/src/rm/RequestManagerAllocate.cc @@ -546,6 +546,23 @@ int UserAllocate::pool_allocate(xmlrpc_c::paramList const& paramList, return upool->allocate(&id,ugid,uname,ugname,passwd,driver,true,error_str); } +/* -------------------------------------------------------------------------- */ + +void UserAllocate::log_xmlrpc_param( + const xmlrpc_c::value& v, + ostringstream& oss, + const int& index) +{ + if ( index == 2 ) // password argument + { + oss << ", ****"; + } + else + { + Request::log_xmlrpc_param(v, oss, index); + } +} + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ diff --git a/src/rm/RequestManagerSystem.cc b/src/rm/RequestManagerSystem.cc new file mode 100644 index 0000000000..84d9486e5e --- /dev/null +++ b/src/rm/RequestManagerSystem.cc @@ -0,0 +1,39 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2012, 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. */ +/* -------------------------------------------------------------------------- */ + +#include "RequestManagerSystem.h" +#include "Nebula.h" + +using namespace std; + +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +void SystemVersion::request_execute(xmlrpc_c::paramList const& paramList, + RequestAttributes& att) +{ + // TODO: request_execute will not be executed if the session string + // is not authenticated in Request::execute. + // Should we make the version call accessible even + // if no user is provided? + + success_response(Nebula::instance().db_version(), att); + + return; +} + +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ diff --git a/src/rm/RequestManagerUser.cc b/src/rm/RequestManagerUser.cc index 2af6c7d61d..9e9da50eaa 100644 --- a/src/rm/RequestManagerUser.cc +++ b/src/rm/RequestManagerUser.cc @@ -86,6 +86,23 @@ int UserChangePassword::user_action(int user_id, return rc; } +/* -------------------------------------------------------------------------- */ + +void UserChangePassword::log_xmlrpc_param( + const xmlrpc_c::value& v, + ostringstream& oss, + const int& index) +{ + if ( index == 2 ) // password argument + { + oss << ", ****"; + } + else + { + Request::log_xmlrpc_param(v, oss, index); + } +} + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -133,6 +150,23 @@ int UserChangeAuth::user_action(int user_id, return rc; } +/* -------------------------------------------------------------------------- */ + +void UserChangeAuth::log_xmlrpc_param( + const xmlrpc_c::value& v, + ostringstream& oss, + const int& index) +{ + if ( index == 3 ) // password argument + { + oss << ", ****"; + } + else + { + Request::log_xmlrpc_param(v, oss, index); + } +} + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ diff --git a/src/rm/SConstruct b/src/rm/SConstruct index 6260123704..4420593001 100644 --- a/src/rm/SConstruct +++ b/src/rm/SConstruct @@ -40,7 +40,8 @@ source_files=[ 'RequestManagerAcl.cc', 'RequestManagerChmod.cc', 'RequestManagerCluster.cc', - 'RequestManagerClone.cc' + 'RequestManagerClone.cc', + 'RequestManagerSystem.cc' ] # Build library diff --git a/src/sunstone/views/index.erb b/src/sunstone/views/index.erb index 5b466ff8f8..90867c883b 100644 --- a/src/sunstone/views/index.erb +++ b/src/sunstone/views/index.erb @@ -94,7 +94,7 @@ diff --git a/src/sunstone/views/login.erb b/src/sunstone/views/login.erb index 30147df259..ab06fcc823 100644 --- a/src/sunstone/views/login.erb +++ b/src/sunstone/views/login.erb @@ -36,7 +36,7 @@ diff --git a/src/tm_mad/qcow2/clone b/src/tm_mad/qcow2/clone index d5271aaf8d..57e1b78b8a 100755 --- a/src/tm_mad/qcow2/clone +++ b/src/tm_mad/qcow2/clone @@ -41,13 +41,17 @@ fi #------------------------------------------------------------------------------- # Set dst path and dir #------------------------------------------------------------------------------- -SRC_PATH=`arg_path $SRC` -SRC_PATH="../../${SRC_PATH##"$DS_DIR/"}" - DST_PATH=`arg_path $DST` DST_HOST=`arg_host $DST` DST_DIR=`dirname $DST_PATH` +SRC_ARG_PATH=`arg_path $SRC` + +DST_DS_PATH="$(dirname $(dirname $(dirname $DST_PATH)))" +SRC_DS_PATH="$(dirname $(dirname $SRC_ARG_PATH))" + +SRC_PATH="${DST_DS_PATH}${SRC_ARG_PATH##$SRC_DS_PATH}" + ssh_make_path $DST_HOST $DST_DIR #------------------------------------------------------------------------------- diff --git a/src/tm_mad/qcow2/mvds b/src/tm_mad/qcow2/mvds index dabec292c9..9507555ea8 100755 --- a/src/tm_mad/qcow2/mvds +++ b/src/tm_mad/qcow2/mvds @@ -38,17 +38,19 @@ fi . $TMCOMMON -set_ds_location - #------------------------------------------------------------------------------- # Set dst path and dir #------------------------------------------------------------------------------- SRC_PATH=`arg_path $SRC` -DST_PATH=`arg_path $DST` - -DST_PATH="$RMT_DS_DIR/${DST_PATH##"$DS_DIR/"}" - SRC_HOST=`arg_host $SRC` +SRC_DIR=`dirname $SRC_PATH` + +DST_ARG_PATH=`arg_path $DST` + +SRC_DS_PATH="$(dirname $(dirname $(dirname $SRC_PATH)))" +DST_DS_PATH="$(dirname $(dirname $DST_ARG_PATH))" + +DST_PATH="${SRC_DS_PATH}${DST_ARG_PATH##$DST_DS_PATH}" #------------------------------------------------------------------------------- # Move the image back to the datastore diff --git a/src/tm_mad/shared/clone b/src/tm_mad/shared/clone index 9888811512..cbe500e0a4 100755 --- a/src/tm_mad/shared/clone +++ b/src/tm_mad/shared/clone @@ -41,13 +41,17 @@ fi #------------------------------------------------------------------------------- # Set dst path and dir #------------------------------------------------------------------------------- -SRC_PATH=`arg_path $SRC` -SRC_PATH="../../${SRC_PATH##"$DS_DIR/"}" - DST_PATH=`arg_path $DST` DST_HOST=`arg_host $DST` DST_DIR=`dirname $DST_PATH` +SRC_ARG_PATH=`arg_path $SRC` + +DST_DS_PATH="$(dirname $(dirname $(dirname $DST_PATH)))" +SRC_DS_PATH="$(dirname $(dirname $SRC_ARG_PATH))" + +SRC_PATH="${DST_DS_PATH}${SRC_ARG_PATH##$SRC_DS_PATH}" + ssh_make_path $DST_HOST $DST_DIR #------------------------------------------------------------------------------- diff --git a/src/tm_mad/shared/ln b/src/tm_mad/shared/ln index 19aa46786c..c323ffdd24 100755 --- a/src/tm_mad/shared/ln +++ b/src/tm_mad/shared/ln @@ -41,46 +41,43 @@ fi #------------------------------------------------------------------------------- # Set dst path and dir #------------------------------------------------------------------------------- -SRC_PATH=`arg_path $SRC` -SRC_PATH="../../${SRC_PATH##"$DS_DIR/"}" - DST_PATH=`arg_path $DST` DST_HOST=`arg_host $DST` DST_DIR=`dirname $DST_PATH` +SRC_ARG_PATH=`arg_path $SRC` + +DST_DS_PATH="$(dirname $(dirname $(dirname $DST_PATH)))" +SRC_DS_PATH="$(dirname $(dirname $SRC_ARG_PATH))" + +SRC_PATH="${DST_DS_PATH}${SRC_ARG_PATH##$SRC_DS_PATH}" + #------------------------------------------------------------------------------- # Link (ln) SRC into DST #------------------------------------------------------------------------------- # Is it a file or a folder (VMware)? if [ -d `arg_path $SRC` ]; then - ssh_make_path $DST_HOST $DST_PATH + ssh_make_path $DST_HOST $DST_PATH - # It's a folder, make links for all elements - SRC_FOLDER_NAME=`basename $SRC_PATH` - SRC_WITH_NO_FOLDER=`dirname $SRC_PATH` - SRC_DS_NAME=`basename $SRC_WITH_NO_FOLDER` - REL_SRC_PATH="../../../$SRC_DS_NAME/$SRC_FOLDER_NAME" - - log "Link all files in $SRC_PATH to $DST_PATH" + log "Link all files in $SRC_PATH to $DST_PATH" LINK_SCRIPT=$(cat < "sudo /sbin/vconfig", :virsh => "virsh -c qemu:///system", :xm => "sudo /usr/sbin/xm", - :ovs_vsctl=> "sudo /usr/local/bin/ovs-vsctl", + :ovs_vsctl=> "sudo /usr/bin/ovs-vsctl", + :ovs_ofctl=> "sudo /usr/bin/ovs-ofctl", :lsmod => "/sbin/lsmod" } diff --git a/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb b/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb index 45f957373d..8ea85732f1 100644 --- a/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb +++ b/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb @@ -17,7 +17,11 @@ require 'OpenNebulaNetwork' class OpenvSwitchVLAN < OpenNebulaNetwork - XPATH_FILTER = "TEMPLATE/NIC[VLAN='YES']" + FIREWALL_PARAMS = [:black_ports_tcp, + :black_ports_udp, + :icmp] + + XPATH_FILTER = "TEMPLATE/NIC" def initialize(vm, deploy_id = nil, hypervisor = nil) super(vm,XPATH_FILTER,deploy_id,hypervisor) @@ -25,18 +29,117 @@ class OpenvSwitchVLAN < OpenNebulaNetwork def activate process do |nic| - if nic[:vlan_id] - vlan = nic[:vlan_id] - else - vlan = CONF[:start_vlan] + nic[:network_id].to_i - end + @nic = nic - cmd = "#{COMMANDS[:ovs_vsctl]} set Port #{nic[:tap]} " - cmd << "tag=#{vlan}" + # Apply VLAN + tag_vlan if @nic[:vlan] == "YES" - OpenNebula.exec_and_log(cmd) + # Prevent Mac-spoofing + mac_spoofing + + # Apply Firewall + configure_fw if FIREWALL_PARAMS & @nic.keys != [] end - return 0 end + + def deactivate + process do |nic| + @nic = nic + + # Remove flows + del_flows + end + end + + def tag_vlan + if @nic[:vlan_id] + vlan = @nic[:vlan_id] + else + vlan = CONF[:start_vlan] + @nic[:network_id].to_i + end + + cmd = "#{COMMANDS[:ovs_vsctl]} set Port #{@nic[:tap]} " + cmd << "tag=#{vlan}" + + run cmd + end + + def mac_spoofing + add_flow("in_port=#{port},dl_src=#{@nic[:mac]}",:normal,40000) + add_flow("in_port=#{port}",:drop,39000) + end + + def configure_fw + # TCP + if range = @nic[:black_ports_tcp] + if range? range + range.split(",").each do |p| + add_flow("tcp,dl_dst=#{@nic[:mac]},tp_dst=#{p}",:drop) + end + end + end + + # UDP + if range = @nic[:black_ports_udp] + if range? range + range.split(",").each do |p| + add_flow("udp,dl_dst=#{@nic[:mac]},tp_dst=#{p}",:drop) + end + end + end + + # ICMP + if @nic[:icmp] + if %w(no drop).include? @nic[:icmp].downcase + add_flow("icmp,dl_dst=#{@nic[:mac]}",:drop) + end + end + end + + def del_flows + in_port = "" + + dump_flows = "#{COMMANDS[:ovs_ofctl]} dump-flows #{@nic[:bridge]}" + `#{dump_flows}`.lines do |flow| + next unless flow.match("#{@nic[:mac]}") + flow = flow.split.select{|e| e.match(@nic[:mac])}.first + if in_port.empty? and (m = flow.match(/in_port=(\d+)/)) + in_port = m[1] + end + del_flow flow + end + + del_flow "in_port=#{in_port}" if !in_port.empty? + end + + def add_flow(filter,action,priority=nil) + priority = (priority.to_s.empty? ? "" : "priority=#{priority},") + + run "#{COMMANDS[:ovs_ofctl]} add-flow " << + "#{@nic[:bridge]} #{filter},#{priority}actions=#{action}" + end + + def del_flow(filter) + filter.gsub!(/priority=(\d+)/,"") + run "#{COMMANDS[:ovs_ofctl]} del-flows " << + "#{@nic[:bridge]} #{filter}" + end + + def run(cmd) + OpenNebula.exec_and_log(cmd) + end + + def port + return @nic[:port] if @nic[:port] + + dump_ports = `#{COMMANDS[:ovs_ofctl]} \ + dump-ports #{@nic[:bridge]} #{@nic[:tap]}` + + @nic[:port] = dump_ports.scan(/^\s*port\s*(\d+):/).flatten.first + end + + def range?(range) + !range.match(/^\d+(,\d+)*$/).nil? + end end diff --git a/src/vnm_mad/remotes/ovswitch/clean b/src/vnm_mad/remotes/ovswitch/clean index c63c4821f7..d1cd859edd 100755 --- a/src/vnm_mad/remotes/ovswitch/clean +++ b/src/vnm_mad/remotes/ovswitch/clean @@ -19,9 +19,9 @@ $: << File.dirname(__FILE__) $: << File.join(File.dirname(__FILE__), "..") -require 'OpenNebulaNetwork' -require 'Firewall' +require 'OpenvSwitch' -fw = OpenNebulaFirewall.from_base64(ARGV[0]) +template64 = ARGV[0] -fw.deactivate +ovs = OpenvSwitchVLAN.from_base64(template64) +ovs.deactivate diff --git a/src/vnm_mad/remotes/ovswitch/post b/src/vnm_mad/remotes/ovswitch/post index 1f4720badb..80cda45c63 100755 --- a/src/vnm_mad/remotes/ovswitch/post +++ b/src/vnm_mad/remotes/ovswitch/post @@ -20,15 +20,9 @@ $: << File.dirname(__FILE__) $: << File.join(File.dirname(__FILE__), "..") require 'OpenvSwitch' -require 'Firewall' template64 = ARGV[0] deploy_id = ARGV[1] -onevlan = OpenvSwitchVLAN.from_base64(template64, deploy_id) - -onevlan.activate - -fw = OpenNebulaFirewall.from_base64(template64, deploy_id) - -fw.activate +ovs = OpenvSwitchVLAN.from_base64(template64, deploy_id) +ovs.activate