diff --git a/NOTICE b/NOTICE index a60de3f651..d5e4daa42a 100644 --- a/NOTICE +++ b/NOTICE @@ -1,7 +1,6 @@ OpenNebula Open Source Project -------------------------------------------------------------------------------- -Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) -Copyright 2010-2012, C12G Labs S.L. (C12G.com) +Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs -------------------------------------------------------------------------------- You can find more information about the project, release notes and diff --git a/README.md b/README.md index 1261b2301c..687277f083 100644 --- a/README.md +++ b/README.md @@ -167,7 +167,7 @@ Support mailing list: http://opennebula.org/support:support ## LICENSE -Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) +Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs 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 diff --git a/SConstruct b/SConstruct index 78485245f4..caecc84867 100644 --- a/SConstruct +++ b/SConstruct @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -118,6 +118,15 @@ if mysql=='yes': else: main_env.Append(mysql='no') +# SysLog +syslog=ARGUMENTS.get('syslog', 'no') +if syslog=='yes': + main_env.Append(syslog='yes') + main_env.Append(CPPFLAGS=["-DSYSLOG_LOG"]) + main_env.Append(LIBS=['pthread','log4cpp']) +else: + main_env.Append(syslog='no') + # xmlrpc xmlrpc_dir=ARGUMENTS.get('xmlrpc', 'none') if xmlrpc_dir!='none': @@ -229,7 +238,7 @@ build_scripts=[ 'share/man/SConstruct', 'src/sunstone/locale/languages/SConstruct', 'src/cloud/occi/lib/ui/locale/languages/SConstruct', - 'share/scripts/context-packages/Sconstruct', + 'share/scripts/context-packages/SConstruct', 'share/rubygems/SConstruct' ] diff --git a/include/AclManager.h b/include/AclManager.h index d4401cbff1..e4e0fe7b1c 100644 --- a/include/AclManager.h +++ b/include/AclManager.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -108,6 +108,13 @@ public: */ void del_gid_rules(int gid); + /** + * Deletes rules that apply to this cluster id + * + * @param cid The cluster id + */ + void del_cid_rules(int cid); + /** * Deletes all rules that apply to this resource * @@ -127,6 +134,7 @@ public: * @param all True if the user can perform the operation over any object * @param oids Set of object IDs over which the user can operate * @param gids Set of object group IDs over which the user can operate + * @param cids Set of object cluster IDs over which the user can operate */ void reverse_search(int uid, int gid, @@ -134,7 +142,8 @@ public: AuthRequest::Operation op, bool& all, vector& oids, - vector& gids); + vector& gids, + vector& cids); /* ---------------------------------------------------------------------- */ /* DB management */ @@ -179,10 +188,12 @@ private: * @param user_req user/group id and flags * @param resource_oid_req 64 bit request, ob. type and individual oid * @param resource_gid_req 64 bit request, ob. type and group id + * @param resource_cid_req 64 bit request, ob. type and cluster id * @param resource_all_req 64 bit request, ob. type and all flag * @param rights_req Requested rights * @param individual_obj_type Mask with ob. type and individual flags * @param group_obj_type Mask with ob. type and group flags + * @param cluster_obj_type Mask with ob. type and cluster flags * @param rules ACL rules to match * * @return true if any rule grants permission @@ -191,10 +202,12 @@ private: long long user_req, long long resource_oid_req, long long resource_gid_req, + long long resource_cid_req, long long resource_all_req, long long rights_req, long long individual_obj_type, long long group_obj_type, + long long cluster_obj_type, multimap &rules); /** @@ -204,10 +217,12 @@ private: * @param user_req user/group id and flags * @param resource_oid_req 64 bit request, ob. type and individual oid * @param resource_gid_req 64 bit request, ob. type and group id + * @param resource_cid_req 64 bit request, ob. type and cluster id * @param resource_all_req 64 bit request, ob. type and all flag * @param rights_req Requested rights * @param individual_obj_type Mask with ob. type and individual flags * @param group_obj_type Mask with ob. type and group flags + * @param cluster_obj_type Mask with ob. type and cluster flags * @param tmp_rules Temporary map group of ACL rules * * @return true if any rule grants permission @@ -216,10 +231,12 @@ private: long long user_req, long long resource_oid_req, long long resource_gid_req, + long long resource_cid_req, long long resource_all_req, long long rights_req, long long individual_obj_type, long long group_obj_type, + long long cluster_obj_type, multimap &tmp_rules); /** diff --git a/include/AclRule.h b/include/AclRule.h index 57bf4c6fb2..46de7aea82 100644 --- a/include/AclRule.h +++ b/include/AclRule.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -36,10 +36,12 @@ public: // ------------------------------------------------------------------------ static const long long INDIVIDUAL_ID; - + static const long long GROUP_ID; static const long long ALL_ID; + + static const long long CLUSTER_ID; // ------------------------------------------------------------------------ /** @@ -50,9 +52,9 @@ public: /** * Main ACL rule constructor */ - AclRule(int _oid, - long long _user, - long long _resource, + AclRule(int _oid, + long long _user, + long long _resource, long long _rights): oid(_oid), user(_user), resource(_resource), rights(_rights) { @@ -64,8 +66,8 @@ public: */ void set(int _oid, - long long _user, - long long _resource, + long long _user, + long long _resource, long long _rights) { oid = _oid; @@ -189,8 +191,8 @@ private: int oid; /** - * 64 bit integer holding a user compound: - * + * 64 bit integer holding a user compound: + * * 32 bits 32 bits * +-----------------------+-----------------------+ * | Type (user,group,all) | user/group ID | @@ -200,7 +202,7 @@ private: /** * 64 bit integer holding a resource compound - * + * * 32 bits 32 bits * +-----------------------+-----------------------+ * | Type (VM, Host...) | resource ID | @@ -241,6 +243,11 @@ private: static const int num_auth_operations; static const AuthRequest::Operation auth_operations[]; + + /** + * Objects that cannot be used with the CLUSTER(%) selector + */ + static const long long INVALID_CLUSTER_OBJECTS; }; #endif /*ACL_RULE_H*/ diff --git a/include/ActionManager.h b/include/ActionManager.h index a23aada27d..741843fe3d 100644 --- a/include/ActionManager.h +++ b/include/ActionManager.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/Attribute.h b/include/Attribute.h index 408f79678b..cd3b8f2881 100644 --- a/include/Attribute.h +++ b/include/Attribute.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -48,7 +48,7 @@ public: if ((size >0 && !isalpha(aname[0]))|| (size >=3 && (aname[0]=='X' && aname[1]=='M' && aname[2]=='L'))) { - attribute_name.insert(0,"ONE_"); + attribute_name.insert(0,"ONE_"); } }; @@ -198,7 +198,7 @@ public: */ Attribute* clone() const { - return new SingleAttribute(*this); + return new SingleAttribute(*this); }; private: @@ -246,6 +246,15 @@ public: */ string vector_value(const char *name) const; + /** + * Returns the boolean value + * @param name of the attribute + * @param value Bool value ("YES" is true) + * + * @return 0 on success, -1 otherwise + */ + int vector_value(const char *name, bool& value) const; + /** * Returns the integer value * @@ -336,7 +345,36 @@ public: oss << value; replace(name, oss.str()); - } + } + + /** + * Replace the value of the given vector attribute + */ + void replace(const string& name, const char* value) + { + string svalue(value); + + replace(name, svalue); + } + + /** + * Replace the value of the given vector attribute + */ + void replace(const string& name, bool value) + { + string b_value; + + if (value == true) + { + b_value = "YES"; + } + else + { + b_value = "NO"; + } + + replace(name, b_value); + } /** * Removes given the vector attribute @@ -357,7 +395,7 @@ public: */ Attribute* clone() const { - return new VectorAttribute(*this); + return new VectorAttribute(*this); }; private: diff --git a/include/AuthManager.h b/include/AuthManager.h index ea4da3ccb4..d620b38867 100644 --- a/include/AuthManager.h +++ b/include/AuthManager.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/AuthManagerDriver.h b/include/AuthManagerDriver.h index 3f560e5f0d..723f24d9f3 100644 --- a/include/AuthManagerDriver.h +++ b/include/AuthManagerDriver.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/AuthRequest.h b/include/AuthRequest.h index 2ae3e04471..13e48f24c7 100644 --- a/include/AuthRequest.h +++ b/include/AuthRequest.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -21,8 +21,8 @@ #include "ActionManager.h" #include "PoolObjectAuth.h" -#include "SSLTools.h" #include "AuthManager.h" +#include "NebulaUtil.h" #include "SyncRequest.h" @@ -75,26 +75,26 @@ public: username = _username; password = _password; session = _session; - + driver = _driver; } /** * Adds a CREATE authorization request. - * + * * OBJECT:<-1|OBJECT_TMPL_XML64>:CREATE:UID:AUTH - * + * * @param type of the object to be created - * @param template (base64 encoded) of the new object + * @param txml template of the new object */ - void add_create_auth(PoolObjectSQL::ObjectType type, const string& txml_64) + void add_create_auth(PoolObjectSQL::ObjectType type, const string& txml) { PoolObjectAuth perms; //oid & gid set to -1 - + perms.uid = uid; perms.obj_type = type; - add_auth(AuthRequest::CREATE, perms, txml_64); + add_auth(AuthRequest::CREATE, perms, txml); } /** @@ -143,20 +143,20 @@ public: bool core_authenticate() { - string sha1_session = SSLTools::sha1_digest(session); + string sha1_session = one_util::sha1_digest(session); return (password == sha1_session); } - -private: - + +private: + friend class AuthManager; - + /** * The user id for this request */ int uid; - + /** * The user group ID */ diff --git a/include/Callbackable.h b/include/Callbackable.h index 78146bb9bd..474aa833b7 100644 --- a/include/Callbackable.h +++ b/include/Callbackable.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/Cluster.h b/include/Cluster.h index 2aa93e5e8d..822c2a28d0 100644 --- a/include/Cluster.h +++ b/include/Cluster.h @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------ */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -32,20 +32,13 @@ class Cluster : public PoolObjectSQL public: /** - * Returns the SYSTEM_DS attribute, or the system DS id if it is not defined + * Returns the SYSTEM_DS attribute * - * @return the SYSTEM_DS attribute, or the system DS id if it is not defined + * @return the SYSTEM_DS attribute */ int get_ds_id() { - int ds_id; - - if ( obj_template->get("SYSTEM_DS", ds_id) == false ) - { - ds_id = DatastorePool::SYSTEM_DS_ID; - } - - return ds_id; + return system_ds; } /** @@ -100,32 +93,11 @@ public: /** * Adds this datastore ID to the set. * @param id to be added to the cluster + * @param ds_type Datastore type * @param error_msg Error message, if any * @return 0 on success */ - int add_datastore(int id, string& error_msg) - { - // TODO: should fail for any system DS? - if ( id == DatastorePool::SYSTEM_DS_ID ) - { - ostringstream oss; - oss << "Datastore '"<< DatastorePool::SYSTEM_DS_NAME - << "' cannot be added to any cluster."; - - error_msg = oss.str(); - - return -1; - } - - int rc = datastores.add_collection_id(id); - - if ( rc < 0 ) - { - error_msg = "Datastore ID is already in the cluster set."; - } - - return rc; - } + int add_datastore(int id, Datastore::DatastoreType ds_type, string& error_msg); /** * Deletes this datastore ID from the set. @@ -133,17 +105,7 @@ public: * @param error_msg Error message, if any * @return 0 on success */ - int del_datastore(int id, string& error_msg) - { - int rc = datastores.del_collection_id(id); - - if ( rc < 0 ) - { - error_msg = "Datastore ID is not part of the cluster set."; - } - - return rc; - } + int del_datastore(int id, string& error_msg); /** * Adds this vnet ID to the set. @@ -219,13 +181,18 @@ private: virtual ~Cluster(){}; // ************************************************************************* - // Object Collections (Private) + // Attributes (Private) // ************************************************************************* ObjectCollection hosts; ObjectCollection datastores; ObjectCollection vnets; + /** + * System datastore id + */ + int system_ds; + // ************************************************************************* // DataBase implementation (Private) // ************************************************************************* diff --git a/include/ClusterPool.h b/include/ClusterPool.h index 35712708ed..008d97f7ac 100644 --- a/include/ClusterPool.h +++ b/include/ClusterPool.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/ClusterTemplate.h b/include/ClusterTemplate.h index b317b2e592..e05d253d30 100644 --- a/include/ClusterTemplate.h +++ b/include/ClusterTemplate.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/Clusterable.h b/include/Clusterable.h index 94bd133fed..93723c28a9 100644 --- a/include/Clusterable.h +++ b/include/Clusterable.h @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------ */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/Datastore.h b/include/Datastore.h index a4b8d4243d..d89193b109 100644 --- a/include/Datastore.h +++ b/include/Datastore.h @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------ */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -195,6 +195,7 @@ private: int gid, const string& uname, const string& gname, + int umask, DatastoreTemplate* ds_template, int cluster_id, const string& cluster_name); diff --git a/include/DatastorePool.h b/include/DatastorePool.h index 07d607a749..e533228062 100644 --- a/include/DatastorePool.h +++ b/include/DatastorePool.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -75,6 +75,7 @@ public: * @param gid the id of the group this object is assigned to * @param uname name of the user * @param gname name of the group + * @param umask permissions umask * @param ds_template Datastore definition template * @param oid the id assigned to the Datastore * @param cluster_id the id of the cluster this Datastore will belong to @@ -88,6 +89,7 @@ public: int gid, const string& uname, const string& gname, + int umask, DatastoreTemplate * ds_template, int * oid, int cluster_id, @@ -182,7 +184,7 @@ private: */ PoolObjectSQL * create() { - return new Datastore(-1,-1,"","", 0, -1, ""); + return new Datastore(-1,-1,"","", 0, 0, -1, ""); }; }; diff --git a/include/DatastoreTemplate.h b/include/DatastoreTemplate.h index d8856dbe2f..3f283f0a23 100644 --- a/include/DatastoreTemplate.h +++ b/include/DatastoreTemplate.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/DefaultQuotas.h b/include/DefaultQuotas.h index 9a90f4e239..eaad86273b 100644 --- a/include/DefaultQuotas.h +++ b/include/DefaultQuotas.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/DispatchManager.h b/include/DispatchManager.h index 71781d34f8..91e2f2ffb7 100644 --- a/include/DispatchManager.h +++ b/include/DispatchManager.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -259,8 +259,8 @@ public: * @return 0 on success, -1 otherwise */ int attach( - int vid, - VirtualMachineTemplate * tmpl, + int vid, + VirtualMachineTemplate * tmpl, string& error_str); /** @@ -301,6 +301,49 @@ public: int id, int nic_id, string& error_str); + /** + * Starts the snapshot create action + * + * @param vid VirtualMachine identification + * @param name Name for the new snapshot + * @param snap_id Will contain the new snapshot ID + * @param error_str Error reason, if any + * + * @return 0 on success, -1 otherwise + */ + int snapshot_create( + int vid, + string& name, + int& snap_id, + string& error_str); + + /** + * Starts the snapshot revert action + * + * @param vid VirtualMachine identification + * @param snap_id Snapshot to be restored + * @param error_str Error reason, if any + * + * @return 0 on success, -1 otherwise + */ + int snapshot_revert( + int vid, + int snap_id, + string& error_str); + + /** + * Starts the snapshot delete action + * + * @param vid VirtualMachine identification + * @param snap_id Snapshot to be deleted + * @param error_str Error reason, if any + * + * @return 0 on success, -1 otherwise + */ + int snapshot_delete( + int vid, + int snap_id, + string& error_str); private: /** diff --git a/include/Document.h b/include/Document.h index fa3ec1fbc1..d6d61a6808 100644 --- a/include/Document.h +++ b/include/Document.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -127,6 +127,7 @@ protected: int gid, const string& uname, const string& gname, + int umask, int type, Template * _template_contents); diff --git a/include/DocumentPool.h b/include/DocumentPool.h index 47b5b96f7f..4665ca3f87 100644 --- a/include/DocumentPool.h +++ b/include/DocumentPool.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -38,6 +38,7 @@ public: * @param gid the id of the group this object is assigned to * @param uname name of the owner user * @param gname name of the group + * @param umask permissions umask * @param type for the new Document * @param template_contents a Template object * @param oid the id assigned to the Document @@ -49,13 +50,14 @@ public: int gid, const string& uname, const string& gname, + int umask, int type, Template * template_contents, int * oid, string& error_str) { *oid = PoolSQL::allocate( - new Document(-1, uid, gid, uname, gname, type, template_contents), + new Document(-1, uid, gid, uname, gname, umask, type, template_contents), error_str); return *oid; @@ -115,7 +117,7 @@ private: */ PoolObjectSQL * create() { - return new Document(-1,-1,-1,"","",0,0); + return new Document(-1,-1,-1,"","",0,0,0); }; }; diff --git a/include/FixedLeases.h b/include/FixedLeases.h index 89ae6b6c62..52169dcbb4 100644 --- a/include/FixedLeases.h +++ b/include/FixedLeases.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -36,6 +36,8 @@ public: FixedLeases(SqlDB * db, int _oid, unsigned int _mac_prefix, + unsigned int _global[], + unsigned int _site[], vector& vector_leases); /** * Create a plain FixedLeases, you can populate the lease pool using @@ -43,8 +45,10 @@ public: */ FixedLeases(SqlDB * db, int _oid, - unsigned int _mac_prefix): - Leases(db,_oid,0,_mac_prefix), + unsigned int _mac_prefix, + unsigned int _global[], + unsigned int _site[]): + Leases(db,_oid,0,_mac_prefix,_global,_site), current(leases.begin()){}; ~FixedLeases(){}; @@ -56,7 +60,7 @@ public: * @param mac mac of the returned lease * @return 0 if success */ - int get(int vid, string& ip, string& mac); + int get(int vid, string& ip, string& mac, unsigned int eui64[]); /** * Ask for a specific lease in the network @@ -65,7 +69,7 @@ public: * @param mac mac of the lease * @return 0 if success */ - int set(int vid, const string& ip, string& mac); + int set(int vid, const string& ip, string& mac, unsigned int eui64[]); /** * Release an used lease, which becomes unused @@ -110,7 +114,6 @@ public: } private: - /** * Current lease pointer */ diff --git a/include/Group.h b/include/Group.h index 3a080e0566..37c8f9d590 100644 --- a/include/Group.h +++ b/include/Group.h @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------ */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/GroupPool.h b/include/GroupPool.h index 43302daf2c..0ce5813b36 100644 --- a/include/GroupPool.h +++ b/include/GroupPool.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/History.h b/include/History.h index a3bcd71758..942f8068b6 100644 --- a/include/History.h +++ b/include/History.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/Hook.h b/include/Hook.h index 6995756730..5dd29a8f90 100644 --- a/include/Hook.h +++ b/include/Hook.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/HookManager.h b/include/HookManager.h index 5f1ad6c347..13faa936b9 100644 --- a/include/HookManager.h +++ b/include/HookManager.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/HookManagerDriver.h b/include/HookManagerDriver.h index 3209fea2a2..164eff6670 100644 --- a/include/HookManagerDriver.h +++ b/include/HookManagerDriver.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/Host.h b/include/Host.h index 532e8c18aa..31cc4477d2 100644 --- a/include/Host.h +++ b/include/Host.h @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------ */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -80,27 +80,6 @@ public: return ((state == MONITORING_ERROR) || (state==MONITORING_MONITORED)); } - /** - * Updates the Host's last_monitored time stamp. - * @param success if the monitored action was successfully performed - */ - void touch(bool success) - { - last_monitored = time(0); - - if ( state != DISABLED) //Don't change the state is host is disabled - { - if (success == true) - { - state = MONITORED; - } - else - { - state = ERROR; - } - } - }; - /** * Disables the current host, it will not be monitored nor used by the * scheduler @@ -119,11 +98,27 @@ public: state = INIT; }; - /** Update host counters and update the whole host on the DB + /** + * Update host after a successful monitor. It modifies counters, state + * and template attributes * @param parse_str string with values to be parsed + * @param with_vm_info if monitoring contains VM information + * @param lost set of VMs that should be in the host and were not found + * @param found VMs running in the host (as expected) and info. * @return 0 on success **/ - int update_info(string &parse_str); + int update_info(string &parse_str, + bool &with_vm_info, + set &lost, + map &found); + + /** + * Update host after a failed monitor. It state + * and template attributes + * @param message from the driver + * @param vm_ids running on the host + */ + void error_info(const string& message, set &vm_ids); /** * Inserts the last monitoring, and deletes old monitoring entries. @@ -134,7 +129,7 @@ public: int update_monitoring(SqlDB * db); /** - * Retrives host state + * Retrieves host state * @return HostState code number */ HostState get_state() const @@ -143,7 +138,7 @@ public: }; /** - * Retrives VMM mad name + * Retrieves VMM mad name * @return string vmm mad name */ const string& get_vmm_mad() const @@ -152,7 +147,7 @@ public: }; /** - * Retrives VNM mad name + * Retrieves VNM mad name * @return string vnm mad name */ const string& get_vnm_mad() const @@ -161,7 +156,7 @@ public: }; /** - * Retrives IM mad name + * Retrieves IM mad name * @return string im mad name */ const string& get_im_mad() const @@ -194,7 +189,7 @@ public: }; /** - * Retrives last time the host was monitored + * Retrieves last time the host was monitored * @return time_t last monitored time */ time_t get_last_monitored() const @@ -273,7 +268,7 @@ public: } /** - * Adds a new VM to the given share by icrementing the cpu, mem and disk + * Adds a new VM to the given share by incrementing the cpu, mem and disk * counters * @param vm_id id of the vm to add to the host * @param cpu needed by the VM (percentage) @@ -302,7 +297,7 @@ public: * disk counters * @param vm_id id of the vm to delete from the host * @param cpu used by the VM (percentage) - * @param mem used by the VM (in Kb) + * @param mem used by the VM (in KB) * @param disk used by the VM * @return 0 on success */ @@ -322,6 +317,19 @@ public: } }; + /** + * Updates the capacity used in a host when a VM is resized + * counters + * @param cpu increment of cpu requested by the VM + * @param mem increment of memory requested by the VM + * @param disk not used + * @return 0 on success + */ + void update_capacity(int cpu, int mem, int disk) + { + host_share.update(cpu,mem,disk); + }; + /** * Tests whether a new VM can be hosted by the host or not * @param cpu needed by the VM (percentage) @@ -331,7 +339,7 @@ public: */ bool test_capacity(int cpu, int mem, int disk) { - return host_share.test(cpu,mem,disk); + return host_share.test(cpu, mem, disk); } /** @@ -409,6 +417,31 @@ private: virtual ~Host(); + // ************************************************************************* + // Host Management + // ************************************************************************* + + /** + * Updates the Host's last_monitored time stamp. + * @param success if the monitored action was successfully performed + */ + void touch(bool success) + { + last_monitored = time(0); + + if ( state != DISABLED) //Don't change the state is host is disabled + { + if (success == true) + { + state = MONITORED; + } + else + { + state = ERROR; + } + } + }; + // ************************************************************************* // DataBase implementation (Private) // ************************************************************************* diff --git a/include/HostHook.h b/include/HostHook.h index cac20cdcfe..eca6c21ef2 100644 --- a/include/HostHook.h +++ b/include/HostHook.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/HostPool.h b/include/HostPool.h index 7d72895294..8ccb539097 100644 --- a/include/HostPool.h +++ b/include/HostPool.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -109,12 +109,12 @@ public: /** * Get the least monitored hosts - * @param discovered hosts, map to store the retrieved hosts hids and - * hostnames + * @param discovered hosts * @param host_limit max. number of hosts to monitor at a time + * @param target_time Filters hosts with last_mon_time <= target_time * @return int 0 if success */ - int discover(map * discovered_hosts, int host_limit); + int discover(set * discovered_hosts, int host_limit, time_t target_time); /** * Allocates a given capacity to the host @@ -267,12 +267,15 @@ private: /** * Callback function to get the IDs of the hosts to be monitored * (Host::discover) + * + * @param _set the set* of host ids * @param num the number of columns read from the DB + * @param values the column values * @param names the column names - * @param vaues the column values + * * @return 0 on success */ - int discover_cb(void * _map, int num, char **values, char **names); + int discover_cb(void * _set, int num, char **values, char **names); /** * Deletes all monitoring entries for all hosts diff --git a/include/HostShare.h b/include/HostShare.h index 8dfcbf6e33..66c5acf536 100644 --- a/include/HostShare.h +++ b/include/HostShare.h @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------ */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -54,6 +54,19 @@ public: running_vms++; } + /** + * Updates the capacity of VM in this share + * @param cpu increment + * @param mem increment + * @param disk increment + */ + void update(int cpu, int mem, int disk) + { + cpu_usage += cpu; + mem_usage += mem; + disk_usage += disk; + } + /** * Delete a VM from this share * @param cpu requested by the VM diff --git a/include/HostTemplate.h b/include/HostTemplate.h index c2f9195c21..b040691aa3 100644 --- a/include/HostTemplate.h +++ b/include/HostTemplate.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/Image.h b/include/Image.h index d23530fadc..08949f6c72 100644 --- a/include/Image.h +++ b/include/Image.h @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------ */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -77,7 +77,8 @@ public: { FILE = 0, /** < File-based disk */ CD_ROM = 1, /** < An ISO9660 disk */ - BLOCK = 2 /** < Block-device disk */ + BLOCK = 2, /** < Block-device disk */ + RBD = 3 /** < CEPH RBD disk */ }; /** @@ -92,6 +93,7 @@ public: case FILE: return "FILE" ; break; case CD_ROM: return "CDROM" ; break; case BLOCK: return "BLOCK" ; break; + case RBD: return "RBD" ; break; default: return ""; } }; @@ -615,6 +617,7 @@ protected: int gid, const string& uname, const string& gname, + int umask, ImageTemplate* img_template); virtual ~Image(); diff --git a/include/ImageManager.h b/include/ImageManager.h index 91e02129e8..6fcc6012ba 100644 --- a/include/ImageManager.h +++ b/include/ImageManager.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/ImageManagerDriver.h b/include/ImageManagerDriver.h index 1fcbe56641..785f08029a 100644 --- a/include/ImageManagerDriver.h +++ b/include/ImageManagerDriver.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/ImagePool.h b/include/ImagePool.h index a2ef77a4e1..ed55a17d0f 100644 --- a/include/ImagePool.h +++ b/include/ImagePool.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -54,6 +54,7 @@ public: * @param gid the id of the group this object is assigned to * @param uname name of the user * @param gname name of the group + * @param umask permissions umask * @param img_template template associated with the image * @param ds_id the id of the datastore * @param ds_name the name of the datastore @@ -73,6 +74,7 @@ public: int gid, const string& uname, const string& gname, + int umask, ImageTemplate * img_template, int ds_id, const string& ds_name, @@ -219,7 +221,7 @@ private: */ PoolObjectSQL * create() { - return new Image(-1,-1,"","",0); + return new Image(-1,-1,"","",0,0); }; }; diff --git a/include/ImageTemplate.h b/include/ImageTemplate.h index b30f7d2738..7f7b0b2a43 100644 --- a/include/ImageTemplate.h +++ b/include/ImageTemplate.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/InformationManager.h b/include/InformationManager.h index b48af6f86e..cae100c7b1 100644 --- a/include/InformationManager.h +++ b/include/InformationManager.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -122,7 +122,7 @@ private: friend void * im_action_loop(void *arg); /** - * Time in seconds to expire a monitoring action (10 minutes) + * Time in seconds to expire a monitoring action (5 minutes) */ static const time_t monitor_expire; diff --git a/include/InformationManagerDriver.h b/include/InformationManagerDriver.h index da85f5ccda..91b0c3e8dd 100644 --- a/include/InformationManagerDriver.h +++ b/include/InformationManagerDriver.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/Leases.h b/include/Leases.h index d6adc8040e..575c6b15b6 100644 --- a/include/Leases.h +++ b/include/Leases.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -40,9 +40,17 @@ public: * @param _oid the virtual network unique identifier * @param _size the max number of leases */ - Leases(SqlDB * _db, int _oid, unsigned long _size, unsigned int _mac_prefix): - ObjectSQL(), - oid(_oid), size(_size), n_used(0), mac_prefix(_mac_prefix), db(_db){}; + Leases(SqlDB * _db, int _oid, unsigned long _size, unsigned int _mac_prefix, + unsigned int _global[], unsigned int _site[]): + ObjectSQL(), oid(_oid), size(_size), n_used(0), mac_prefix(_mac_prefix) + , db(_db) + { + global[1] = _global[1]; + global[0] = _global[0]; + + site[1] = _site[1]; + site[0] = _site[0]; + }; virtual ~Leases() { @@ -61,18 +69,20 @@ public: * @param vid identifier of the VM getting this lease * @param ip ip of the returned lease * @param mac mac of the returned lease + * @param eui64 extended unique identifier * @return 0 if success */ - virtual int get(int vid, string& ip,string& mac) = 0; + virtual int get(int vid, string& ip, string& mac, unsigned int *eui64) = 0; /** * Ask for a specific lease in the network * @param vid identifier of the VM getting this lease * @param ip ip of lease requested * @param mac mac of the lease + * @param eui64 extended unique identifier * @return 0 if success */ - virtual int set(int vid, const string& ip, string& mac) = 0; + virtual int set(int vid, const string& ip, string& mac, unsigned int *eui64) = 0; /** * Release an used lease, which becomes unused @@ -122,9 +132,6 @@ public: */ int free_leases(vector& vector_leases, string& error_msg); - // ------------------------------------------------------------------------- - // ------------------------------------------------------------------------- - protected: /** * The Lease class, it represents a pair of IP and MAC assigned to @@ -133,16 +140,6 @@ protected: class Lease : public ObjectXML { public: - /** - * Creates a new lease, string form. This constructor throws a runtime - * exception if the IP or MAC format is wrong. - * @param _ip, the Lease IP in string format - * @param _mac, the Lease MAC in string format - * @param _vid, the ID of the VM owning the lease - * @param _used, the lease is in use - */ - //Lease(const string& _ip, const string& _mac,int _vid, bool _used=true); - /** * Creates a new lease, numeric form. * @param _ip, the Lease IP in numeric format @@ -150,12 +147,16 @@ protected: * @param _vid, the ID of the VM owning the lease * @param _used, the lease is in use */ - Lease(unsigned int _ip, unsigned int _mac[], int _vid, bool _used=true) - :ObjectXML(),ip(_ip), vid(_vid), used(_used) + Lease(unsigned int _ip, + unsigned int _mac[], + int _vid, + bool _used) + :ObjectXML(),ip(_ip), vid(_vid), used(_used) { - // TODO check size - mac[PREFIX]=_mac[PREFIX]; - mac[SUFFIX]=_mac[SUFFIX]; + mac[1]=_mac[1]; + mac[0]=_mac[0]; + + mac_to_eui64(mac, eui64); }; /** @@ -166,13 +167,6 @@ protected: ~Lease(){}; - /** - * Converts this lease's IP and MAC to string - * @param ip ip of the lease in string - * @param mac mac of the lease in string - */ - void to_string(string& _ip, string& _mac) const; - /** * Conversion from string IP to unsigned int IP * @return 0 if success @@ -184,21 +178,35 @@ protected: */ static void ip_to_string(const unsigned int i_ip, string& ip); + /** + * Generates IPv6 strings based on the modified EUI64 and global and + * site network prefixes. + */ + static void ip6_to_string(const unsigned int eui64[], + const unsigned int prefix[], + string& ip6s); /** * Conversion from string MAC to unsigned int[] MAC * @return 0 if success */ static int mac_to_number(const string& mac, unsigned int i_mac[]); + /** + * Generates the modified extended unique identifier based on MAC + * @param i_mac the MAC address + * @param i_meui64 the modified EUI64 + */ + static void mac_to_eui64(const unsigned int mac[], unsigned int eui64[]); + /** * Conversion from string IP to unsigned int IP */ static void mac_to_string(const unsigned int i_mac[], string& mac); /** - * Prints a Lease in a single line + * Conversion from string IP to unsigned int IP */ - friend ostream& operator<<(ostream& os, Lease& _lease); + static int prefix6_to_number(const string& prefix, unsigned int ip[]); /** * Function to print the Lease object into a string in @@ -206,8 +214,9 @@ protected: * @param xml the resulting XML string * @return a reference to the generated string */ - string& to_xml(string& xml) const; - + string& to_xml(string& xml, + const unsigned int global[], + const unsigned int site[]) const; /** * Function to print the Lease object into a string in * XML format. The output contains all the internal attributes, @@ -225,22 +234,15 @@ protected: */ int from_xml(const string &xml_str); - /** - * Constants to access the array storing the MAC address - */ - enum MACIndex - { - SUFFIX = 0,/**< Lower significant 4 bytes */ - PREFIX = 1 /**< Higher significant 2 bytes */ - }; + unsigned int ip; - unsigned int ip; + unsigned int mac[2]; - unsigned int mac [2]; + unsigned int eui64[2]; - int vid; + int vid; - bool used; + bool used; }; friend class VirtualNetwork; @@ -252,12 +254,12 @@ protected: /** * Leases identifier. Connects it to a Virtual Network */ - int oid; + int oid; /** * Number of possible leases (free + assigned) */ - unsigned int size; + unsigned int size; /** * Hash of leases, indexed by lease.ip @@ -274,6 +276,16 @@ protected: */ unsigned int mac_prefix; + /** + * Global prefix for IPv6 addresses (64 upper bits) + */ + unsigned int global[2]; + + /** + * Global prefix for IPv6 addresses (64 upper bits) + */ + unsigned int site[2]; + // ------------------------------------------------------------------------- // DataBase implementation variables // ------------------------------------------------------------------------- @@ -307,7 +319,7 @@ protected: bool check(unsigned int ip); /** - * Check if a VM is the owner of the ip + * Check if a VM is the owner of the ip * @param ip of the lease to be checked * @param vid the ID of the VM * @return true if the ip was already assigned diff --git a/include/LibVirtDriver.h b/include/LibVirtDriver.h index 081124bc38..97945b6361 100644 --- a/include/LibVirtDriver.h +++ b/include/LibVirtDriver.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/LifeCycleManager.h b/include/LifeCycleManager.h index 9045b65502..7c755ef1a4 100644 --- a/include/LifeCycleManager.h +++ b/include/LifeCycleManager.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -66,6 +66,14 @@ public: ATTACH_NIC_FAILURE,/**< Sent by the VMM when an attach nic action fails */ DETACH_NIC_SUCCESS,/**< Sent by the VMM when a detach nic action succeeds */ DETACH_NIC_FAILURE,/**< Sent by the VMM when a detach nic action fails */ + CLEANUP_SUCCESS, /**< Sent by the VMM when a cleanup action succeeds */ + CLEANUP_FAILURE, /**< Sent by the VMM when a cleanup action fails */ + SNAPSHOT_CREATE_SUCCESS, /**< Sent by the VMM on snap. create success */ + SNAPSHOT_CREATE_FAILURE, /**< Sent by the VMM on snap. create failure */ + SNAPSHOT_REVERT_SUCCESS, /**< Sent by the VMM on snap. revert success */ + SNAPSHOT_REVERT_FAILURE, /**< Sent by the VMM on snap. revert failure */ + SNAPSHOT_DELETE_SUCCESS, /**< Sent by the VMM on snap. revert success */ + SNAPSHOT_DELETE_FAILURE, /**< Sent by the VMM on snap. revert failure */ DEPLOY, /**< Sent by the DM to deploy a VM on a host */ SUSPEND, /**< Sent by the DM to suspend an running VM */ RESTORE, /**< Sent by the DM to restore a suspended VM */ @@ -149,7 +157,7 @@ private: * the history registers * @param vm with the lock aquired */ - void clean_up_vm (VirtualMachine *vm); + void clean_up_vm (VirtualMachine *vm, bool dispose); void save_success_action(int vid); @@ -197,6 +205,20 @@ private: void detach_nic_failure_action(int vid); + void cleanup_callback_action(int vid); + + void snapshot_create_success(int vid); + + void snapshot_create_failure(int vid); + + void snapshot_revert_success(int vid); + + void snapshot_revert_failure(int vid); + + void snapshot_delete_success(int vid); + + void snapshot_delete_failure(int vid); + void deploy_action(int vid); void suspend_action(int vid); diff --git a/include/Log.h b/include/Log.h index e4539a2665..bed96a4c09 100644 --- a/include/Log.h +++ b/include/Log.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -19,6 +19,13 @@ #include #include +#include + +#include "PoolObjectSQL.h" + +#ifdef SYSLOG_LOG +# include "log4cpp/Priority.hh" +#endif /* SYSLOG_LOG */ using namespace std; @@ -79,7 +86,7 @@ public: const char * module, const MessageType type, const char * message); - + private: char * log_file; }; @@ -137,4 +144,128 @@ public: const char * message); }; +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +#ifdef SYSLOG_LOG + +/** + * Send log messages to syslog + */ +class SysLog : public Log +{ +public: + SysLog(const MessageType level, + const string& label); + + virtual ~SysLog() {}; + + virtual void log( + const char * module, + const MessageType type, + const char * message); + + static log4cpp::Priority::PriorityLevel get_priority_level( + const MessageType level); +protected: + /** + * Specialized constructor only for derived classes that uses an initialzed + * SysLog system. + */ + SysLog(const MessageType level):Log(level){}; + + /** + * This is the root category name used by any syslog resource + * in the process + */ + static const char * CATEGORY; + + /** + * This is the daemon name+pid, used to label every message in the process + */ + static string LABEL; + +}; + +#else + +/** + * Dummy syslog class + */ +class SysLog : public Log +{ +public: + SysLog(const MessageType level, + const string& label) { + throw runtime_error("Aborting oned, SysLog support not compiled!"); + }; + + virtual ~SysLog() {}; + + virtual void log( + const char * module, + const MessageType type, + const char * message) {}; +}; + +#endif /* SYSLOG_LOG */ + +#ifdef SYSLOG_LOG + +/** + * Send log messages to syslog per resource. It requires a Root Syslog + * to be initialized before using a SysLogResource + */ +class SysLogResource : public SysLog +{ +public: + SysLogResource( + int oid, + const PoolObjectSQL::ObjectType obj_type, + const MessageType clevel); + + virtual ~SysLogResource(){}; + + void log( + const char * module, + const MessageType type, + const char * message); + +protected: + /** + * This is the resource category name used by any syslog resource + * in the process + */ + static const char * CATEGORY; + + /** + * The resource log label + */ + string obj_label; +}; + +#else + +/** + * Dummy SysLogResource class + */ +class SysLogResource : public SysLog +{ +public: + SysLogResource(int oid, + const PoolObjectSQL::ObjectType obj_type, + const MessageType clevel):SysLog(clevel, "") { + throw runtime_error("Aborting oned, SysLog support not compiled!"); + }; + + virtual ~SysLogResource(){}; + + void log( + const char * module, + const MessageType type, + const char * message) {}; +}; + +#endif /* SYSLOG_LOG */ + #endif /* _LOG_H_ */ diff --git a/include/Mad.h b/include/Mad.h index 9b46424f38..79188ab2fb 100644 --- a/include/Mad.h +++ b/include/Mad.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/MadManager.h b/include/MadManager.h index 43cfd434f5..d49d895ee9 100644 --- a/include/MadManager.h +++ b/include/MadManager.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/MySqlDB.h b/include/MySqlDB.h index f2475bae70..5e4643abaf 100644 --- a/include/MySqlDB.h +++ b/include/MySqlDB.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/Nebula.h b/include/Nebula.h index 6cd0963af5..9b68cb3188 100644 --- a/include/Nebula.h +++ b/include/Nebula.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -172,24 +172,61 @@ public: // -------------------------------------------------------------- /** - * Returns the value of DEBUG_LEVEL in oned.conf file + * Returns the value of LOG->DEBUG_LEVEL in oned.conf file * @return the debug level, to instantiate Log'ers */ Log::MessageType get_debug_level() const { - Log::MessageType clevel = Log::ERROR; - int log_level_int; + Log::MessageType clevel = Log::ERROR; + vector logs; + int rc; + int log_level_int; - nebula_configuration->get("DEBUG_LEVEL", log_level_int); + rc = nebula_configuration->get("LOG", logs); - if (0 <= log_level_int && log_level_int <= 3 ) + if ( rc != 0 ) { - clevel = static_cast(log_level_int); + string value; + const VectorAttribute * log = static_cast + (logs[0]); + value = log->vector_value("DEBUG_LEVEL"); + + log_level_int = atoi(value.c_str()); + + if (0 <= log_level_int && log_level_int <= 3 ) + { + clevel = static_cast(log_level_int); + } } return clevel; } + /** + * Returns the value of LOG->SYSTEM in oned.conf file + * @return the logging system CERR, FILE_TS or SYSLOG + */ + NebulaLog::LogType get_log_system() const + { + vector logs; + int rc; + NebulaLog::LogType log_system = NebulaLog::UNDEFINED; + + rc = nebula_configuration->get("LOG", logs); + + if ( rc != 0 ) + { + string value; + const VectorAttribute * log = static_cast + (logs[0]); + + value = log->vector_value("SYSTEM"); + log_system = NebulaLog::str_to_type(value); + } + + return log_system; + }; + /** * Returns the value of ONE_LOCATION env variable. When this variable is * not defined the nebula location is "/". @@ -288,11 +325,19 @@ public: return oss.str(); }; + /** + * Returns the name of the host running oned + * @return the name + */ const string& get_nebula_hostname() { return hostname; }; + /** + * Returns the version of oned + * @return the version + */ static string version() { return "OpenNebula 3.9.0"; @@ -303,32 +348,74 @@ public: return "3.9.0"; } + /** + * Starts all the modules and services for OpenNebula + */ void start(); + // ----------------------------------------------------------------------- + // Configuration attributes (read from oned.conf) + // ----------------------------------------------------------------------- + + /** + * Gets a configuration attribute for oned + * @param name of the attribute + * @param value of the attribute + */ void get_configuration_attribute( const char * name, string& value) const { string _name(name); - nebula_configuration->Template::get(_name,value); + nebula_configuration->Template::get(_name, value); }; + /** + * Gets a configuration attribute for oned, bool version + */ + void get_configuration_attribute( + const char * name, + bool& value) const + { + string _name(name); + + nebula_configuration->Template::get(_name, value); + }; + + /** + * Gets an XML document with all of the configuration attributes + * @return the XML + */ string get_configuration_xml() const { string xml; return nebula_configuration->to_xml(xml); }; + // ----------------------------------------------------------------------- + // Default Quotas + // ----------------------------------------------------------------------- + + /** + * Get the default quotas for OpenNebula users + * @return the default quotas + */ const DefaultQuotas& get_default_user_quota() { return default_user_quota; }; + /** + * Set the default quotas for OpenNebula users + * @param tmpl template with the default quotas + * @param error describes the error if any + * + * @return 0 if success + */ int set_default_user_quota(Template *tmpl, string& error) { - int rc; - rc = default_user_quota.set(tmpl, error); + int rc = default_user_quota.set(tmpl, error); if ( rc == 0 ) { @@ -338,15 +425,25 @@ public: return rc; }; + /** + * Get the default quotas for OpenNebula for groups + * @return the default quotas + */ const DefaultQuotas& get_default_group_quota() { return default_group_quota; }; + /** + * Set the default quotas for OpenNebula groups + * @param tmpl template with the default quotas + * @param error describes the error if any + * + * @return 0 if success + */ int set_default_group_quota(Template *tmpl, string& error) { - int rc; - rc = default_group_quota.set(tmpl, error); + int rc = default_group_quota.set(tmpl, error); if ( rc == 0 ) { diff --git a/include/NebulaLog.h b/include/NebulaLog.h index 47bea21c19..95e3141715 100644 --- a/include/NebulaLog.h +++ b/include/NebulaLog.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -18,8 +18,13 @@ #define _NEBULA_LOG_H_ #include "Log.h" + #include +#ifdef SYSLOG_LOG +# include +#endif /* SYSLOG_LOG */ + using namespace std; /** @@ -31,7 +36,9 @@ public: enum LogType { FILE = 0, FILE_TS = 1, - CERR = 2 + CERR = 2, + SYSLOG = 3, + UNDEFINED = 4 }; // --------------------------------------------------------------- @@ -41,23 +48,47 @@ public: static void init_log_system( LogType ltype, Log::MessageType clevel, - const char * filename = 0, - ios_base::openmode mode = ios_base::trunc) + const char * filename, + ios_base::openmode mode, + const string& daemon) { switch(ltype) { case FILE: - NebulaLog::logger = new FileLog(filename,clevel,mode); - break; + NebulaLog::logger = new FileLog(filename,clevel,mode); + break; case FILE_TS: - NebulaLog::logger = new FileLogTS(filename,clevel,mode); - break; + NebulaLog::logger = new FileLogTS(filename,clevel,mode); + break; + case SYSLOG: + NebulaLog::logger = new SysLog(clevel, daemon); + break; default: - NebulaLog::logger = new CerrLog(clevel); - break; + NebulaLog::logger = new CerrLog(clevel); + break; } }; + static LogType str_to_type(string& type) + { + transform(type.begin(), type.end(), type.begin(), (int(*)(int))toupper); + + if (type == "FILE") + { + return FILE_TS; + } + else if (type == "SYSLOG") + { + return SYSLOG; + } + else if (type == "STDERR") + { + return CERR; + } + + return UNDEFINED; + } + static void finalize_log_system() { delete logger; diff --git a/include/NebulaTemplate.h b/include/NebulaTemplate.h index c9bbc5e9f1..c264942ef9 100644 --- a/include/NebulaTemplate.h +++ b/include/NebulaTemplate.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -102,6 +102,13 @@ public: Template::get(_name,value); }; + void get(const char *name, bool& value) const + { + string _name(name); + + Template::get(_name,value); + }; + // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- diff --git a/include/SSLTools.h b/include/NebulaUtil.h similarity index 56% rename from include/SSLTools.h rename to include/NebulaUtil.h index bb3ecd0962..3ffb3958c9 100644 --- a/include/SSLTools.h +++ b/include/NebulaUtil.h @@ -1,39 +1,40 @@ -/* ------------------------------------------------------------------------ */ -/* 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. */ -/* -------------------------------------------------------------------------*/ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ +/* */ +/* 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 SSL_TOOLS_H_ -#define SSL_TOOLS_H_ +#ifndef _NEBULA_UTIL_H_ +#define _NEBULA_UTIL_H_ #include -using namespace std; - -/** - * The SSLTools class provides a simple interface to common SSL utils used - * in OpenNebula - */ -class SSLTools +namespace one_util { -public: + std::string& toupper(std::string& st); + + std::string& tolower(std::string& st); + + std::string log_time(time_t the_time); + + std::string log_time(); + /** - * sha1 digest + * sha1 digest * @param in the string to be hashed * @return sha1 hash of str */ - static string sha1_digest(const string& in); + std::string sha1_digest(const std::string& in); /** * Base 64 encoding @@ -41,11 +42,16 @@ public: * @return a pointer to the encoded string (must be freed) or 0 in case of * error */ - static string * base64_encode(const string& in); + std::string * base64_encode(const std::string& in); + + /** + * Base 64 deencoding + * @param in the string to decode + * @return a pointer to the decoded string (must be freed) or 0 in case of + * error + */ + std::string * base64_decode(const std::string& in); -private: - SSLTools(){}; - ~SSLTools(){}; }; -#endif /*SSL_TOOLS_H_*/ +#endif /* _NEBULA_UTIL_H_ */ diff --git a/include/ObjectCollection.h b/include/ObjectCollection.h index 4d11b25f32..c621c9de39 100644 --- a/include/ObjectCollection.h +++ b/include/ObjectCollection.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/ObjectSQL.h b/include/ObjectSQL.h index 837dbf3115..0683d2f663 100644 --- a/include/ObjectSQL.h +++ b/include/ObjectSQL.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/ObjectXML.h b/include/ObjectXML.h index a018cc3325..47281e65ed 100644 --- a/include/ObjectXML.h +++ b/include/ObjectXML.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -148,6 +148,18 @@ public: */ int get_nodes(const char * xpath_expr, vector& content); + /** + * Adds a copy of the node as a child of the node in the xpath expression. + * The source node must be cleaned by the caller. + * + * @param xpath_expr Path of the parent node + * @param node Node copy and add + * @param new_name New name for the node copy + * + * @return 0 on success, -1 otherwise + */ + int add_node(const char * xpath_expr, xmlNodePtr node, const char * new_name); + /** * Frees a vector of XMLNodes, as returned by the get_nodes function * @param content the vector of xmlNodePtr @@ -184,6 +196,15 @@ public: */ static int validate_xml(const string &xml_doc); + /** + * Renames the nodes given in the xpath expression + * @param xpath_expr xpath expression to find the nodes to rename + * @param new_name new name for the xml elements + * + * @return the number of nodes renamed + */ + int rename_nodes(const char * xpath_expr, const char * new_name); + // --------------------------------------------------------- // Lex & bison parser for requirements and rank expressions // --------------------------------------------------------- diff --git a/include/OneClient.h b/include/OneClient.h index 27125481f8..dada53c852 100644 --- a/include/OneClient.h +++ b/include/OneClient.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/PoolObjectAuth.h b/include/PoolObjectAuth.h index 12bcf40dea..3c1f3bcc8f 100644 --- a/include/PoolObjectAuth.h +++ b/include/PoolObjectAuth.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -34,6 +34,7 @@ public: oid(-1), uid(-1), gid(-1), + cid(-1), owner_u(1), owner_m(1), owner_a(0), @@ -60,6 +61,7 @@ public: int oid; int uid; int gid; + int cid; int owner_u; int owner_m; diff --git a/include/PoolObjectSQL.h b/include/PoolObjectSQL.h index 220e66b51a..beec7d8651 100644 --- a/include/PoolObjectSQL.h +++ b/include/PoolObjectSQL.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -110,7 +110,7 @@ public: other_u(0), other_m(0), other_a(0), - obj_template(0), + obj_template(0), table(_table) { pthread_mutex_init(&mutex,0); @@ -140,6 +140,11 @@ public: return name; }; + void set_name(const string& _name) + { + name = _name; + }; + int get_uid() const { return uid; @@ -159,7 +164,7 @@ public: { return gname; }; - + /** * Changes the object's owner * @param _uid New User ID @@ -344,6 +349,21 @@ public: return obj_template->get(name,value); } + /** + * Gets a boolean attribute (single) (YES = true) + * @param name of the attribute + * @param value of the attribute (True if "YES", false otherwise) + * + * @return True if the Single attribute was found and is a valid boolean + * value + */ + bool get_template_attribute( + const char * name, + bool& value) const + { + return obj_template->get(name,value); + } + /** * Adds a new attribute to the template (replacing it if * already defined), the object's mutex SHOULD be locked @@ -377,12 +397,46 @@ public: } /** - * Sets an error message for the VM in the template - * @param message - * @return 0 on success + * Sets an error message with timestamp in the template + * @param message Message string */ void set_template_error_message(const string& message); + /** + * Deletes the error message from the template + */ + void clear_template_error_message(); + + /** + * Adds a string attribute + * @param att_name Name for the attribute + * @param att_val Message string + */ + void add_template_attribute(const string& name, const string& value) + { + obj_template->add(name, value); + } + + /** + * Adds an int attribute + * @param att_name Name for the attribute + * @param att_val integer + */ + void add_template_attribute(const string& name, int value) + { + obj_template->add(name, value); + } + + /** + * Adds a float attribute + * @param att_name Name for the attribute + * @param att_val integer + */ + void add_template_attribute(const string& name, float value) + { + obj_template->add(name, value); + } + /** * Factory method for templates, it should be implemented * by classes that uses templates @@ -498,6 +552,14 @@ protected: } }; + /** + * Initializes the object's permissions, according to the provided umask. + * + * @param umask Permission mask, similar to unix umask. + * For example a umask of 137 will set the permissions "um- u-- ---" + */ + void set_umask(int umask); + /** * The object's unique ID */ diff --git a/include/PoolSQL.h b/include/PoolSQL.h index 71380880fd..8febb8dd77 100644 --- a/include/PoolSQL.h +++ b/include/PoolSQL.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/Quota.h b/include/Quota.h index 0a7122196f..ad99b047b8 100644 --- a/include/Quota.h +++ b/include/Quota.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -51,13 +51,26 @@ public: */ virtual bool check(Template* tmpl, Quotas& default_quotas, string& error) = 0; + /** + * Check if a resource update in usage counters will exceed the + * quota limits. If not the usage counters are updated for that resource + * @param tmpl with increments in MEMORY and CPU + * @param default_quotas Quotas that contain the default limits + * @param error string + * @return true if the operation can be performed + */ + virtual bool update(Template * tmpl, Quotas& default_quotas, string& error) + { + error = "Update operation for quotas not supported."; + return false; + }; + /** * Decrement usage counters when deallocating image * @param tmpl template for the resource */ virtual void del(Template* tmpl) = 0; - /** * Returns the name that identifies the quota in a template */ diff --git a/include/QuotaDatastore.h b/include/QuotaDatastore.h index b37fe53c68..2d7eb305b5 100644 --- a/include/QuotaDatastore.h +++ b/include/QuotaDatastore.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/QuotaImage.h b/include/QuotaImage.h index 57a8c8e759..7a3e8e2f2f 100644 --- a/include/QuotaImage.h +++ b/include/QuotaImage.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/QuotaNetwork.h b/include/QuotaNetwork.h index 2bb4d6d6d1..57faad4806 100644 --- a/include/QuotaNetwork.h +++ b/include/QuotaNetwork.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/QuotaVirtualMachine.h b/include/QuotaVirtualMachine.h index 3d33eb9f10..e46c47c0c3 100644 --- a/include/QuotaVirtualMachine.h +++ b/include/QuotaVirtualMachine.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -57,6 +57,16 @@ public: */ bool check(Template* tmpl, Quotas& default_quotas, string& error); + /** + * Check if the resource update (change in MEMORY or CPU) will exceed the + * quota limits. If not the usage counters are updated + * @param tmpl with increments in MEMORY and CPU + * @param default_quotas Quotas that contain the default limits + * @param error string + * @return true if the operation can be performed + */ + bool update(Template * tmpl, Quotas& default_quotas, string& error); + /** * Decrement usage counters when deallocating image * @param tmpl template for the resource diff --git a/include/Quotas.h b/include/Quotas.h index fb6392540f..02a30e36d7 100644 --- a/include/Quotas.h +++ b/include/Quotas.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -141,13 +141,27 @@ public: * @param tmpl template for the VirtualMachine * @param default_quotas Quotas that contain the default limits * @param error_str string describing the error - * @return true if VM can be allocated, false otherwise + * @return true if resource can be allocated, false otherwise */ bool quota_check(QuotaType type, Template *tmpl, Quotas& default_quotas, string& error_str); + /** + * Update usage of an existing quota (e.g. size of an image), it updates + * the usage counters if quotas are not exceeded. + * @param type the quota to work with + * @param tmpl template for the VirtualMachine + * @param default_quotas Quotas that contain the default limits + * @param error_str string describing the error + * @return true if resource can be updated, false otherwise + */ + bool quota_update(QuotaType type, + Template *tmpl, + Quotas& default_quotas, + string& error_str); + /** * Delete usage from the given quota counters. * @param type the quota to work with diff --git a/include/RangedLeases.h b/include/RangedLeases.h index 27547bf7fb..df18f4b969 100644 --- a/include/RangedLeases.h +++ b/include/RangedLeases.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -32,6 +32,8 @@ public: RangedLeases(SqlDB * db, int _oid, unsigned int _mac_prefix, + unsigned int _global[], + unsigned int _site[], unsigned int _ip_start, unsigned int _ip_end); @@ -55,7 +57,7 @@ public: * @param mac mac of the returned lease * @return 0 if success */ - int get(int vid, string& ip, string& mac); + int get(int vid, string& ip, string& mac, unsigned int eui64[]); /** * Ask for a specific lease in the network @@ -64,7 +66,7 @@ public: * @param mac mac of the lease * @return 0 if success */ - int set(int vid, const string& ip, string& mac); + int set(int vid, const string& ip, string& mac, unsigned int eui64[]); /** * Release an used lease, which becomes unused diff --git a/include/Request.h b/include/Request.h index ea73ae2f58..214f1fc9ec 100644 --- a/include/Request.h +++ b/include/Request.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/RequestManager.h b/include/RequestManager.h index e942c716d8..e568557ac0 100644 --- a/include/RequestManager.h +++ b/include/RequestManager.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/RequestManagerAcl.h b/include/RequestManagerAcl.h index 8b920eeedf..02e1b96d0c 100644 --- a/include/RequestManagerAcl.h +++ b/include/RequestManagerAcl.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/RequestManagerAllocate.h b/include/RequestManagerAllocate.h index 4957ded508..48e494a434 100644 --- a/include/RequestManagerAllocate.h +++ b/include/RequestManagerAllocate.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -65,7 +65,8 @@ protected: Template * tmpl, int& id, string& error_str, - RequestAttributes& att) + RequestAttributes& att, + int umask) { return -1; }; @@ -76,9 +77,10 @@ protected: string& error_str, RequestAttributes& att, int cluster_id, - const string& cluster_name) + const string& cluster_name, + int umask) { - return pool_allocate(_paramList, tmpl, id, error_str, att); + return pool_allocate(_paramList, tmpl, id, error_str, att, umask); }; virtual int get_cluster_id(xmlrpc_c::paramList const& paramList) @@ -86,11 +88,20 @@ protected: return ClusterPool::NONE_CLUSTER_ID; }; - virtual int add_to_cluster(Cluster* cluster, int id, string& error_msg) + virtual int add_to_cluster( + Cluster* cluster, + int id, + Datastore::DatastoreType ds_type, + string& error_msg) { return -1; }; + virtual Datastore::DatastoreType get_ds_type(int oid) + { + return Datastore::FILE_DS; + }; + protected: ClusterPool * clpool; @@ -109,7 +120,7 @@ public: VirtualMachineAllocate(): RequestManagerAllocate("VirtualMachineAllocate", "Allocates a new virtual machine", - "A:ss", + "A:ssb", true) { Nebula& nd = Nebula::instance(); @@ -130,7 +141,8 @@ public: Template * tmpl, int& id, string& error_str, - RequestAttributes& att); + RequestAttributes& att, + int umask); bool allocate_authorization(Template * obj_template, RequestAttributes& att, @@ -169,14 +181,19 @@ public: string& error_str, RequestAttributes& att, int cluster_id, - const string& cluster_name); + const string& cluster_name, + int umask); int get_cluster_id(xmlrpc_c::paramList const& paramList) { return xmlrpc_c::value_int(paramList.getInt(2)); }; - int add_to_cluster(Cluster* cluster, int id, string& error_msg) + int add_to_cluster( + Cluster* cluster, + int id, + Datastore::DatastoreType ds_type, + string& error_msg) { return cluster->add_vnet(id, error_msg); }; @@ -237,7 +254,8 @@ public: Template * tmpl, int& id, string& error_str, - RequestAttributes& att); + RequestAttributes& att, + int umask); }; /* ------------------------------------------------------------------------- */ @@ -267,14 +285,19 @@ public: string& error_str, RequestAttributes& att, int cluster_id, - const string& cluster_name); + const string& cluster_name, + int umask); int get_cluster_id(xmlrpc_c::paramList const& paramList) { return xmlrpc_c::value_int(paramList.getInt(5)); }; - int add_to_cluster(Cluster* cluster, int id, string& error_msg) + int add_to_cluster( + Cluster* cluster, + int id, + Datastore::DatastoreType ds_type, + string& error_msg) { return cluster->add_host(id, error_msg); }; @@ -303,7 +326,8 @@ public: Template * tmpl, int& id, string& error_str, - RequestAttributes& att); + RequestAttributes& att, + int umask); void log_xmlrpc_param( const xmlrpc_c::value& v, @@ -334,7 +358,8 @@ public: Template * tmpl, int& id, string& error_str, - RequestAttributes& att); + RequestAttributes& att, + int umask); }; /* ------------------------------------------------------------------------- */ @@ -369,16 +394,35 @@ public: string& error_str, RequestAttributes& att, int cluster_id, - const string& cluster_name); + const string& cluster_name, + int umask); int get_cluster_id(xmlrpc_c::paramList const& paramList) { return xmlrpc_c::value_int(paramList.getInt(2)); }; - int add_to_cluster(Cluster* cluster, int id, string& error_msg) + virtual Datastore::DatastoreType get_ds_type(int oid) { - return cluster->add_datastore(id, error_msg); + Datastore::DatastoreType ds_type = Datastore::FILE_DS; + Datastore *ds = static_cast(pool)->get(oid, true); + + if ( ds != 0 ) + { + ds_type = ds->get_type(); + ds->unlock(); + } + + return ds_type; + }; + + int add_to_cluster( + Cluster* cluster, + int id, + Datastore::DatastoreType ds_type, + string& error_msg) + { + return cluster->add_datastore(id, ds_type, error_msg); }; }; @@ -405,7 +449,8 @@ public: Template * tmpl, int& id, string& error_str, - RequestAttributes& att); + RequestAttributes& att, + int umask); }; /* ------------------------------------------------------------------------- */ @@ -438,7 +483,8 @@ public: Template * tmpl, int& id, string& error_str, - RequestAttributes& att); + RequestAttributes& att, + int umask); }; /* -------------------------------------------------------------------------- */ diff --git a/include/RequestManagerChmod.h b/include/RequestManagerChmod.h index cbee7a81dd..754196a17a 100644 --- a/include/RequestManagerChmod.h +++ b/include/RequestManagerChmod.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/RequestManagerChown.h b/include/RequestManagerChown.h index 2fa0494cf5..64382a3eac 100644 --- a/include/RequestManagerChown.h +++ b/include/RequestManagerChown.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/RequestManagerClone.h b/include/RequestManagerClone.h index 37d1428e30..9ef0c54a8f 100644 --- a/include/RequestManagerClone.h +++ b/include/RequestManagerClone.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -49,7 +49,8 @@ protected: Template * tmpl, int& id, string& error_str, - RequestAttributes& att) = 0; + RequestAttributes& att, + int umask) = 0; }; /* ------------------------------------------------------------------------- */ @@ -83,15 +84,16 @@ public: Template * tmpl, int& id, string& error_str, - RequestAttributes& att) + RequestAttributes& att, + int umask) { VMTemplatePool * tpool = static_cast(pool); VirtualMachineTemplate * ttmpl = static_cast(tmpl); - return tpool->allocate(att.uid, att.gid, att.uname, att.gname, ttmpl, - &id, error_str); + return tpool->allocate(att.uid, att.gid, att.uname, att.gname, umask, + ttmpl, &id, error_str); }; }; @@ -127,12 +129,13 @@ public: Template * tmpl, int& id, string& error_str, - RequestAttributes& att) + RequestAttributes& att, + int umask) { DocumentPool * docpool = static_cast(pool); Document * doc = docpool->get(source_id, true); - return docpool->allocate(att.uid, att.gid, att.uname, att.gname, + return docpool->allocate(att.uid, att.gid, att.uname, att.gname, umask, doc->get_document_type(), tmpl, &id, error_str); }; }; diff --git a/include/RequestManagerCluster.h b/include/RequestManagerCluster.h index 22ab693207..44175d64b6 100644 --- a/include/RequestManagerCluster.h +++ b/include/RequestManagerCluster.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -65,7 +65,24 @@ protected: PoolSQL * pool, PoolObjectSQL::ObjectType type); - virtual int add_object(Cluster* cluster, int id, string& error_msg) = 0; + virtual Datastore::DatastoreType get_ds_type(PoolObjectSQL *obj) + { + return Datastore::FILE_DS; + }; + + /** + * Add object to cluster id collection + * @param cluster where to add the object + * @param id of the object + * @param ds_type Datastore type, will be ignored for different objects + * @param error_msg Error reason, if any + * @return 0 on success + */ + virtual int add_object( + Cluster* cluster, + int id, + Datastore::DatastoreType ds_type, + string& error_msg) = 0; virtual int del_object(Cluster* cluster, int id, string& error_msg) = 0; @@ -86,7 +103,11 @@ public: ~RequestManagerClusterHost(){}; - virtual int add_object(Cluster* cluster, int id, string& error_msg) + virtual int add_object( + Cluster* cluster, + int id, + Datastore::DatastoreType ds_type, + string& error_msg) { return cluster->add_host(id, error_msg); }; @@ -169,9 +190,18 @@ public: ~RequestManagerClusterDatastore(){}; - virtual int add_object(Cluster* cluster, int id, string& error_msg) + virtual Datastore::DatastoreType get_ds_type(PoolObjectSQL *obj) { - return cluster->add_datastore(id, error_msg); + return static_cast(obj)->get_type(); + }; + + virtual int add_object( + Cluster* cluster, + int id, + Datastore::DatastoreType ds_type, + string& error_msg) + { + return cluster->add_datastore(id, ds_type, error_msg); }; virtual int del_object(Cluster* cluster, int id, string& error_msg) @@ -253,7 +283,11 @@ public: ~RequestManagerClusterVNet(){}; - virtual int add_object(Cluster* cluster, int id, string& error_msg) + virtual int add_object( + Cluster* cluster, + int id, + Datastore::DatastoreType ds_type, + string& error_msg) { return cluster->add_vnet(id, error_msg); }; diff --git a/include/RequestManagerDelete.h b/include/RequestManagerDelete.h index 6137bfc377..f6bf6fa8d4 100644 --- a/include/RequestManagerDelete.h +++ b/include/RequestManagerDelete.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -268,6 +268,8 @@ public: }; ~ClusterDelete(){}; + + int drop(int oid, PoolObjectSQL * object, string& error_msg); }; /* ------------------------------------------------------------------------- */ diff --git a/include/RequestManagerGroup.h b/include/RequestManagerGroup.h index 968654af05..3d8b19db34 100644 --- a/include/RequestManagerGroup.h +++ b/include/RequestManagerGroup.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/RequestManagerHost.h b/include/RequestManagerHost.h index 65f538cf0c..f21bfc943d 100644 --- a/include/RequestManagerHost.h +++ b/include/RequestManagerHost.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/RequestManagerImage.h b/include/RequestManagerImage.h index 092c66df8c..4582694a18 100644 --- a/include/RequestManagerImage.h +++ b/include/RequestManagerImage.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/RequestManagerInfo.h b/include/RequestManagerInfo.h index 2fa77ce08f..4499cac4f8 100644 --- a/include/RequestManagerInfo.h +++ b/include/RequestManagerInfo.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/RequestManagerPoolInfoFilter.h b/include/RequestManagerPoolInfoFilter.h index 7975948d52..5927cdc30a 100644 --- a/include/RequestManagerPoolInfoFilter.h +++ b/include/RequestManagerPoolInfoFilter.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/RequestManagerRename.h b/include/RequestManagerRename.h new file mode 100644 index 0000000000..0034e5b62a --- /dev/null +++ b/include/RequestManagerRename.h @@ -0,0 +1,166 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ +/* */ +/* 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_RENAME_H_ +#define REQUEST_MANAGER_RENAME_H_ + +#include "Request.h" +#include "Nebula.h" + +using namespace std; + +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +class RequestManagerRename : public Request +{ +protected: + RequestManagerRename(const string& method_name, + const string& help, + const string& params = "A:sis") + :Request(method_name,params,help) + { + auth_op = AuthRequest::MANAGE; + }; + + virtual ~RequestManagerRename(){}; + + /* -------------------------------------------------------------------- */ + + void request_execute(xmlrpc_c::paramList const& _paramList, + RequestAttributes& att); + + virtual PoolObjectSQL * get(const string& name, int uid, bool lock) = 0; +}; + +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +class VirtualMachineRename : public RequestManagerRename +{ +public: + VirtualMachineRename(): + RequestManagerRename("VirtualMachineRename","Renames a virtual machine") + { + Nebula& nd = Nebula::instance(); + pool = nd.get_vmpool(); + auth_object = PoolObjectSQL::VM; + }; + + ~VirtualMachineRename(){}; + + PoolObjectSQL * get(const string& name, int uid, bool lock) + { + return 0; + }; +}; + +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +class TemplateRename : public RequestManagerRename +{ +public: + TemplateRename(): + RequestManagerRename("TemplateRename", + "Renames a virtual machine template") + { + Nebula& nd = Nebula::instance(); + pool = nd.get_tpool(); + auth_object = PoolObjectSQL::TEMPLATE; + }; + + ~TemplateRename(){}; + + PoolObjectSQL * get(const string& name, int uid, bool lock) + { + return static_cast(pool)->get(name, uid, lock); + }; +}; + +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + + +class VirtualNetworkRename: public RequestManagerRename +{ +public: + VirtualNetworkRename(): + RequestManagerRename("VirtualNetworkRename","Renames a virtual network") + { + Nebula& nd = Nebula::instance(); + pool = nd.get_vnpool(); + auth_object = PoolObjectSQL::NET; + }; + + ~VirtualNetworkRename(){}; + + PoolObjectSQL * get(const string& name, int uid, bool lock) + { + return static_cast(pool)->get(name, uid, lock); + }; +}; + +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +class ImageRename: public RequestManagerRename +{ +public: + ImageRename(): + RequestManagerRename("ImageRename", "Renames an image") + { + Nebula& nd = Nebula::instance(); + pool = nd.get_ipool(); + auth_object = PoolObjectSQL::IMAGE; + }; + + ~ImageRename(){}; + + PoolObjectSQL * get(const string& name, int uid, bool lock) + { + return static_cast(pool)->get(name, uid, lock); + }; +}; + +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +class DocumentRename : public RequestManagerRename +{ +public: + DocumentRename(): + RequestManagerRename("DocumentRename", "Renames a generic document") + { + Nebula& nd = Nebula::instance(); + pool = nd.get_docpool(); + auth_object = PoolObjectSQL::DOCUMENT; + }; + + ~DocumentRename(){}; + + PoolObjectSQL * get(const string& name, int uid, bool lock) + { + return 0; + }; +}; + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +#endif diff --git a/include/RequestManagerSystem.h b/include/RequestManagerSystem.h index 4e436b7d4e..75e32d3788 100644 --- a/include/RequestManagerSystem.h +++ b/include/RequestManagerSystem.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/RequestManagerUpdateTemplate.h b/include/RequestManagerUpdateTemplate.h index 511f149ce7..fbea334fd0 100644 --- a/include/RequestManagerUpdateTemplate.h +++ b/include/RequestManagerUpdateTemplate.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -53,7 +53,7 @@ public: TemplateUpdateTemplate(): RequestManagerUpdateTemplate("TemplateUpdateTemplate", "Updates a virtual machine template") - { + { Nebula& nd = Nebula::instance(); pool = nd.get_tpool(); auth_object = PoolObjectSQL::TEMPLATE; @@ -65,13 +65,31 @@ public: /* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */ +class VirtualMachineUpdateTemplate: public RequestManagerUpdateTemplate +{ +public: + VirtualMachineUpdateTemplate(): + RequestManagerUpdateTemplate("VirtualMachineUpdateTemplate", + "Updates a virtual machine user template") + { + Nebula& nd = Nebula::instance(); + pool = nd.get_vmpool(); + auth_object = PoolObjectSQL::VM; + }; + + ~VirtualMachineUpdateTemplate(){}; +}; + +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + class ImageUpdateTemplate: public RequestManagerUpdateTemplate { public: ImageUpdateTemplate(): RequestManagerUpdateTemplate("ImageUpdateTemplate", "Updates an image template") - { + { Nebula& nd = Nebula::instance(); pool = nd.get_ipool(); auth_object = PoolObjectSQL::IMAGE; @@ -89,10 +107,11 @@ public: HostUpdateTemplate(): RequestManagerUpdateTemplate("HostUpdateTemplate", "Updates a host template") - { + { Nebula& nd = Nebula::instance(); pool = nd.get_hpool(); auth_object = PoolObjectSQL::HOST; + auth_op = AuthRequest::ADMIN; }; ~HostUpdateTemplate(){}; @@ -107,7 +126,7 @@ public: VirtualNetworkUpdateTemplate(): RequestManagerUpdateTemplate("VirtualNetworkUpdateTemplate", "Updates a vnet template") - { + { Nebula& nd = Nebula::instance(); pool = nd.get_vnpool(); auth_object = PoolObjectSQL::NET; @@ -125,7 +144,7 @@ public: UserUpdateTemplate(): RequestManagerUpdateTemplate("UserUpdateTemplate", "Updates a user template") - { + { Nebula& nd = Nebula::instance(); pool = nd.get_upool(); auth_object = PoolObjectSQL::USER; diff --git a/include/RequestManagerUser.h b/include/RequestManagerUser.h index 4f95682fd3..be6571ea47 100644 --- a/include/RequestManagerUser.h +++ b/include/RequestManagerUser.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/RequestManagerVMTemplate.h b/include/RequestManagerVMTemplate.h index 95c0a2f200..1c9baefe87 100644 --- a/include/RequestManagerVMTemplate.h +++ b/include/RequestManagerVMTemplate.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -57,7 +57,7 @@ public: VMTemplateInstantiate(): RequestManagerVMTemplate("TemplateInstantiate", "Instantiates a new virtual machine using a template", - "A:sis") + "A:sisbs") { auth_op = AuthRequest::USE; }; diff --git a/include/RequestManagerVirtualMachine.h b/include/RequestManagerVirtualMachine.h index 29602deb21..20fb202dc4 100644 --- a/include/RequestManagerVirtualMachine.h +++ b/include/RequestManagerVirtualMachine.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -62,10 +62,16 @@ protected: string& vnm, string& tm, string& ds_location, - int& ds_id, + int& ds_id, RequestAttributes& att, PoolObjectAuth& host_perms); + bool check_host(int hid, + int cpu, + int mem, + int disk, + string& error); + int add_history(VirtualMachine * vm, int hid, const string& hostname, @@ -106,7 +112,7 @@ public: VirtualMachineDeploy(): RequestManagerVirtualMachine("VirtualMachineDeploy", "Deploys a virtual machine", - "A:sii") + "A:siib") { auth_op = AuthRequest::ADMIN; }; @@ -126,7 +132,7 @@ public: VirtualMachineMigrate(): RequestManagerVirtualMachine("VirtualMachineMigrate", "Migrates a virtual machine", - "A:siib") + "A:siibb") { auth_op = AuthRequest::ADMIN; }; @@ -171,8 +177,6 @@ public: ~VirtualMachineMonitoring(){}; - /* -------------------------------------------------------------------- */ - void request_execute( xmlrpc_c::paramList const& paramList, RequestAttributes& att); }; @@ -246,6 +250,72 @@ public: }; /* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +class VirtualMachineResize : public RequestManagerVirtualMachine +{ +public: + VirtualMachineResize(): + RequestManagerVirtualMachine("VirtualMachineResize", + "Changes the capacity of the virtual machine", + "A:sidiib"){}; + ~VirtualMachineResize(){}; + + void request_execute(xmlrpc_c::paramList const& _paramList, + RequestAttributes& att); +}; + +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +class VirtualMachineSnapshotCreate: public RequestManagerVirtualMachine +{ +public: + VirtualMachineSnapshotCreate(): + RequestManagerVirtualMachine("VirtualMachineSnapshotCreate", + "Creates a new virtual machine snapshot", + "A:sis"){}; + + ~VirtualMachineSnapshotCreate(){}; + + void request_execute(xmlrpc_c::paramList const& _paramList, + RequestAttributes& att); +}; + +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +class VirtualMachineSnapshotRevert: public RequestManagerVirtualMachine +{ +public: + VirtualMachineSnapshotRevert(): + RequestManagerVirtualMachine("VirtualMachineSnapshotRevert", + "Reverts a virtual machine to a snapshot", + "A:sii"){}; + + ~VirtualMachineSnapshotRevert(){}; + + void request_execute(xmlrpc_c::paramList const& _paramList, + RequestAttributes& att); +}; + +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +class VirtualMachineSnapshotDelete: public RequestManagerVirtualMachine +{ +public: + VirtualMachineSnapshotDelete(): + RequestManagerVirtualMachine("VirtualMachineSnapshotDelete", + "Deletes a virtual machine snapshot", + "A:sii"){}; + + ~VirtualMachineSnapshotDelete(){}; + + void request_execute(xmlrpc_c::paramList const& _paramList, + RequestAttributes& att); +}; + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ diff --git a/include/RequestManagerVirtualNetwork.h b/include/RequestManagerVirtualNetwork.h index de11553656..dec48c9ff0 100644 --- a/include/RequestManagerVirtualNetwork.h +++ b/include/RequestManagerVirtualNetwork.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/SqlDB.h b/include/SqlDB.h index c086eb3221..4daafeb8c0 100644 --- a/include/SqlDB.h +++ b/include/SqlDB.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/SqliteDB.h b/include/SqliteDB.h index f9892797ef..197712782a 100644 --- a/include/SqliteDB.h +++ b/include/SqliteDB.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/SyncRequest.h b/include/SyncRequest.h index 21f941d809..64fb490439 100644 --- a/include/SyncRequest.h +++ b/include/SyncRequest.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/SystemDB.h b/include/SystemDB.h index 597868c9b1..a5e442b5af 100644 --- a/include/SystemDB.h +++ b/include/SystemDB.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/Template.h b/include/Template.h index e71432a917..21e3aed633 100644 --- a/include/Template.h +++ b/include/Template.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -156,10 +156,10 @@ public: oss << value; - return replace(name, oss.str()); + return replace(name, oss.str()); } - /* + /* * Adds a new single attribute to the template. It will replace an existing * one if replace_mode was set to true * @param name of the attribute @@ -184,6 +184,20 @@ public: set(new SingleAttribute(name, oss.str())); } + /** + * Adds a new single attribute to the template. + * @param name of the attribute + * @param value of the attribute + */ + void add(const string& name, float value) + { + ostringstream oss; + + oss << value; + + set(new SingleAttribute(name, oss.str())); + } + /** * Removes an attribute from the template. The attributes are returned. The * attributes MUST be freed by the calling funtion @@ -196,10 +210,10 @@ public: vector& values); /** - * Removes an attribute from the template, but it DOES NOT free the + * Removes an attribute from the template, but it DOES NOT free the * attribute. * @param att Attribute to remove. It will be deleted - * @return pointer to the removed attribute or 0 if non attribute was + * @return pointer to the removed attribute or 0 if non attribute was * removed */ virtual Attribute * remove(Attribute * att); @@ -265,6 +279,35 @@ public: const string& name, float& value) const; + /** + * Gets the value of a Single attributes (bool) with the given name. + * @param name the attribute name. + * @param value the attribute value, a bool, false if the attribute is not + * defined or not Single + * + * @return True if the Single attribute was found and is a valid bool + * value + */ + virtual bool get( + const string& name, + bool& value) const; + + /** + * Trims the trailing spaces in the NAME attribute + * @return True if the attribute was found and trimmed + */ + virtual bool trim_name() + { + return trim("NAME"); + }; + + /** + * Trims the trailing spaces in the attribute + * @param name of the attribute + * @return True if the attribute was found and trimmed + */ + virtual bool trim(const string& name); + friend ostream& operator<<(ostream& os, const Template& t); /** @@ -283,6 +326,17 @@ public: */ int from_xml_node(const xmlNodePtr node); + /** + * Merges another Template, adding the new attributes and + * replacing the existing ones + * + * @param from_tmpl the template to be merged + * @param error_str string describing the error + * + * @return 0 on success. + */ + int merge(const Template * from_tmpl, string& error_str); + protected: /** * The template attributes @@ -322,6 +376,16 @@ protected: */ bool check(string& rs_attr, const vector &restricted_attributes); + /** + * Updates the xml root element name + * + * @param _xml_root New name + */ + void set_xml_root(const char * _xml_root) + { + xml_root = _xml_root; + }; + private: bool replace_mode; diff --git a/include/TransferManager.h b/include/TransferManager.h index 1b2b1265a6..a31a8484bb 100644 --- a/include/TransferManager.h +++ b/include/TransferManager.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -54,6 +54,7 @@ public: EPILOG_DELETE, EPILOG_DELETE_PREVIOUS, EPILOG_DELETE_STOP, + EPILOG_DELETE_BOTH, CHECKPOINT, DRIVER_CANCEL, FINALIZE @@ -138,6 +139,20 @@ public: VirtualMachine * vm, ostream& xfr); + /** + * This function generates the the epilog_delete sequence for current, + * front-end and previous hosts. + * @param vm pointer to VM, locked + * @param xfr stream to write the commands + * @param local true to delete the front-end + * @param previous true to delete the previous host + * + * @return 0 on success + */ + int epilog_delete_commands(VirtualMachine *vm, + ostream& xfr, + bool local, + bool previous); private: /** * Thread id for the Transfer Manager @@ -247,7 +262,8 @@ private: void epilog_stop_action(int vid); /** - * This function starts the epilog_delete sequence + * This function starts the epilog_delete sequence in the current host + * @param vid the Virtual Machine ID */ void epilog_delete_action(int vid) { @@ -256,22 +272,32 @@ private: /** * This function starts the epilog_delete_stop sequence on the local host + * i.e. the front-end (the VM is not running) + * @param vid the Virtual Machine ID */ void epilog_delete_stop_action(int vid) { epilog_delete_action(true, vid); } + /** + * This function starts the epilog_delete sequence on the previous host + * @param vid the Virtual Machine ID + */ + void epilog_delete_previous_action(int vid); + + /** + * This function starts the epilog_delete sequence on the current and + * previous hosts + * @param vid the Virtual Machine ID + */ + void epilog_delete_both_action(int vid); + /** * This function starts the epilog_delete sequence */ void epilog_delete_action(bool local, int vid); - /** - * This function starts the epilog_delete sequence on the previous host - */ - void epilog_delete_previous_action(int vid); - /** * This function starts the epilog sequence */ diff --git a/include/TransferManagerDriver.h b/include/TransferManagerDriver.h index 125193dcf6..beb0be2836 100644 --- a/include/TransferManagerDriver.h +++ b/include/TransferManagerDriver.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/User.h b/include/User.h index f8aa724fcc..10655eedf1 100644 --- a/include/User.h +++ b/include/User.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -173,6 +173,14 @@ public: */ Quotas quota; + /** + * Returns the UMASK template attribute (read as an octal number), or the + * default UMASK from oned.conf if it does not exist + * + * @return the UMASK to create new objects + */ + int get_umask() const; + private: // ------------------------------------------------------------------------- // Friends diff --git a/include/UserPool.h b/include/UserPool.h index fe8fd2c190..d81684c3ab 100644 --- a/include/UserPool.h +++ b/include/UserPool.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/UserTemplate.h b/include/UserTemplate.h index c23ad3f0fb..6149d90458 100644 --- a/include/UserTemplate.h +++ b/include/UserTemplate.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/VMTemplate.h b/include/VMTemplate.h index b48f7ddb75..16b86330e8 100644 --- a/include/VMTemplate.h +++ b/include/VMTemplate.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -117,6 +117,7 @@ protected: int gid, const string& uname, const string& gname, + int umask, VirtualMachineTemplate * _template_contents); ~VMTemplate(); diff --git a/include/VMTemplatePool.h b/include/VMTemplatePool.h index 71c7d7bf73..1ac5e52751 100644 --- a/include/VMTemplatePool.h +++ b/include/VMTemplatePool.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -36,6 +36,9 @@ public: * allocated for the object. * @param uid user id (the owner of the Template) * @param gid the id of the group this object is assigned to + * @param uname user name + * @param gname group name + * @param umask permissions umask * @param template_contents a VM Template object * @param oid the id assigned to the Template * @param error_str Returns the error reason, if any @@ -46,6 +49,7 @@ public: int gid, const string& uname, const string& gname, + int umask, VirtualMachineTemplate * template_contents, int * oid, string& error_str); @@ -118,7 +122,7 @@ private: */ PoolObjectSQL * create() { - return new VMTemplate(-1,-1,-1,"","",0); + return new VMTemplate(-1,-1,-1,"","",0,0); }; }; diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index f77ba0819f..c7022c9c89 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -81,14 +81,16 @@ public: SHUTDOWN = 12, CANCEL = 13, FAILURE = 14, - CLEANUP = 15, + CLEANUP_RESUBMIT = 15, UNKNOWN = 16, HOTPLUG = 17, SHUTDOWN_POWEROFF = 18, BOOT_UNKNOWN = 19, BOOT_POWEROFF = 20, BOOT_SUSPENDED = 21, - BOOT_STOPPED = 22 + BOOT_STOPPED = 22, + CLEANUP_DELETE = 23, + HOTPLUG_SNAPSHOT = 24 }; // ------------------------------------------------------------------------- @@ -170,7 +172,7 @@ public: }; /** - * Updates VM dynamic information (usage counters). + * Updates VM dynamic information (usage counters), and updates last_poll * @param _memory Kilobytes used by the VM (total) * @param _cpu used by the VM (rate) * @param _net_tx transmitted bytes (total) @@ -180,28 +182,8 @@ public: const int _memory, const int _cpu, const long long _net_tx, - const long long _net_rx) - { - if (_memory != -1) - { - memory = _memory; - } - - if (_cpu != -1) - { - cpu = _cpu; - } - - if (_net_tx != -1) - { - net_tx = _net_tx; - } - - if (_net_rx != -1) - { - net_rx = _net_rx; - } - }; + const long long _net_rx, + const map &custom); /** * Returns the deployment ID @@ -702,6 +684,20 @@ public: *(static_cast(obj_template))); }; + /** + * This function replaces the *user template*. + * @param tmpl_str new contents + * @param error string describing the error if any + * @return 0 on success + */ + int replace_template(const string& tmpl_str, string& error); + + void get_user_template_attribute( + const char * name, + string& value) const + { + user_obj_template->get(name,value); + } // ------------------------------------------------------------------------ // States @@ -759,7 +755,7 @@ public: }; // ------------------------------------------------------------------------ - // Timers + // Timers & // ------------------------------------------------------------------------ /** * Gets time from last information polling. @@ -770,15 +766,6 @@ public: return last_poll; }; - /** - * Sets time of last information polling. - * @param poll time in epoch, normally time(0) - */ - void set_last_poll(time_t poll) - { - last_poll = poll; - }; - /** * Get the VM physical requirements for the host. * @param cpu @@ -787,6 +774,28 @@ public: */ void get_requirements (int& cpu, int& memory, int& disk); + /** + * Checks if the resize parameters are valid + * @param cpu New CPU. 0 means unchanged. + * @param memory New MEMORY. 0 means unchanged. + * @param vcpu New VCPU. 0 means unchanged. + * @param error_str Error reason, if any + * + * @return 0 on success + */ + int check_resize (float cpu, int memory, int vcpu, string& error_str); + + /** + * Resize the VM capacity + * @param cpu + * @param memory + * @param vcpu + * @param error_str Error reason, if any + * + * @return 0 on success + */ + int resize (float cpu, int memory, int vcpu, string& error_str); + // ------------------------------------------------------------------------ // Network Leases & Disk Images // ------------------------------------------------------------------------ @@ -1001,6 +1010,54 @@ public: */ int set_attach_nic(int nic_id); + + // ------------------------------------------------------------------------ + // Snapshot related functions + // ------------------------------------------------------------------------ + + /** + * Creates a new Snapshot attribute, and sets it to ACTIVE=YES + * + * @param name for the new Snapshot. If it is empty, the generated name + * will be placed in this param + * @param snap_id Id of the new snapshot + * + * @return 0 on success + */ + int new_snapshot(string& name, int& snap_id); + + /** + * Sets the given Snapshot as ACTIVE=YES + * + * @param snap_id the snapshow ID + * + * @return 0 on success + */ + int set_active_snapshot(int snap_id); + + /** + * Replaces HYPERVISOR_ID for the active SNAPSHOT + * + * @param hypervisor_id Id returned by the hypervisor for the newly + * created snapshot + */ + void update_snapshot_id(string& hypervisor_id); + + /** + * Cleans the ACTIVE = YES attribute from the snapshots + */ + void clear_active_snapshot(); + + /** + * Deletes the SNAPSHOT that was in the process of being created + */ + void delete_active_snapshot(); + + /** + * Deletes all SNAPSHOT attributes + */ + void delete_snapshots(); + private: // ------------------------------------------------------------------------- @@ -1097,8 +1154,15 @@ private: * $ONE_LOCATION/var/$VID/vm.log * or, in case that OpenNebula is installed in root * /var/log/one/$VM_ID.log + * For the syslog... TODO */ - FileLog * _log; + Log * _log; + + /** + * User template to store custom metadata. This template can be updated + * + */ + Template * user_obj_template; // ************************************************************************* // DataBase implementation (Private) @@ -1219,7 +1283,7 @@ private: int parse_context(string& error_str); /** - * Parse the "REQUIREMENTS" attribute of the template by substituting + * Parse the "SCHED_REQUIREMENTS" attribute of the template by substituting * $VARIABLE, $VARIABLE[ATTR] and $VARIABLE[ATTR, ATTR = VALUE] * @param error_str Returns the error reason, if any * @return 0 on success @@ -1240,6 +1304,12 @@ private: */ void parse_graphics(); + /** + * Searches the meaningful attributes and moves them from the user template + * to the internal template + */ + void parse_well_known_attributes(); + /** * Function that renders the VM in XML format optinally including * extended information (all history records) @@ -1263,6 +1333,7 @@ protected: int gid, const string& uname, const string& gname, + int umask, VirtualMachineTemplate * _vm_template); virtual ~VirtualMachine(); diff --git a/include/VirtualMachineHook.h b/include/VirtualMachineHook.h index 92c3773cea..743f196244 100644 --- a/include/VirtualMachineHook.h +++ b/include/VirtualMachineHook.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/VirtualMachineManager.h b/include/VirtualMachineManager.h index 03168112c3..90a4d042e9 100644 --- a/include/VirtualMachineManager.h +++ b/include/VirtualMachineManager.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -49,6 +49,9 @@ public: SHUTDOWN, CANCEL, CANCEL_PREVIOUS, + CLEANUP, + CLEANUP_BOTH, + CLEANUP_PREVIOUS, MIGRATE, RESTORE, REBOOT, @@ -60,7 +63,10 @@ public: ATTACH, DETACH, ATTACH_NIC, - DETACH_NIC + DETACH_NIC, + SNAPSHOT_CREATE, + SNAPSHOT_REVERT, + SNAPSHOT_DELETE }; /** @@ -259,6 +265,22 @@ private: void cancel_previous_action( int vid); + /** + * Cleanups a host (cancel VM + delete disk images). + * @param vid the id of the VM. + * @param cancel_previous if true the VM will be canceled in the previous + * host (only relevant to delete VM's in MIGRATE state) + */ + void cleanup_action( + int vid, bool cancel_previous); + + /** + * Cleanups the previous host (cancel VM + delete disk images). + * @param vid the id of the VM. + */ + void cleanup_previous_action( + int vid); + /** * Function to migrate (live) a VM (MIGRATE action). * @param vid the id of the VM. @@ -331,6 +353,30 @@ private: void detach_nic_action( int vid); + /** + * Creates a new system snapshot. The VM must have a snapshot with the + * attribute ACTIVE = YES + * + * @param vid the id of the VM. + */ + void snapshot_create_action(int vid); + + /** + * Reverts to a snapshot. The VM must have a snapshot with the + * attribute ACTIVE = YES + * + * @param vid the id of the VM. + */ + void snapshot_revert_action(int vid); + + /** + * Deletes a snapshot. The VM must have a snapshot with the + * attribute ACTIVE = YES + * + * @param vid the id of the VM. + */ + void snapshot_delete_action(int vid); + /** * This function cancels the current driver operation */ diff --git a/include/VirtualMachineManagerDriver.h b/include/VirtualMachineManagerDriver.h index b7a221227b..5be093aa76 100644 --- a/include/VirtualMachineManagerDriver.h +++ b/include/VirtualMachineManagerDriver.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -30,7 +30,7 @@ using namespace std; * VirtualMachineManagerDriver provides a base class to implement VM Manager * Drivers. This class implements the protocol and recover functions * from the Mad interface. Classes derived from the VirtualMachineManagerDriver - * must implement the deployment function to generate specific VM + * must implement the deployment function to generate specific VM * deployment information for the unerlying MAD. */ class VirtualMachineManagerDriver : public Mad @@ -53,7 +53,7 @@ public: string& message); /** - * TODO: What do we need here? just poll the active VMs to recover + * TODO: What do we need here? just poll the active VMs to recover * connections? Or an specific recover action from the MAD? */ void recover(); @@ -67,25 +67,41 @@ public: virtual int deployment_description( const VirtualMachine * vm, const string& file_name) const = 0; - -protected: + /** - * Gets a configuration attr from driver configuration file (single + * Updates the VM with the information gathered by the drivers + * + * @param id VM id + * @param monitor_str String returned by the poll driver call + */ + static void process_poll(int id, const string &monitor_str); + + /** + * Updates the VM with the information gathered by the drivers + * + * @param vm VM to update, must be locked + * @param monitor_str String returned by the poll driver call + */ + static void process_poll(VirtualMachine* vm, const string &monitor_str); + +protected: + /** + * Gets a configuration attr from driver configuration file (single * version) * @param name of config attribute * @param value of the attribute */ void get_default( - const char * name, + const char * name, string& value) const { string sn = name; - + driver_conf.get(sn,value); - } + } /** - * Gets a configuration attr from driver configuration file (vector + * Gets a configuration attr from driver configuration file (vector * version) * @param name of config vector attribute for the domain * @param vname of the attribute @@ -95,20 +111,34 @@ protected: const char * name, const char * vname, string& value) const; - -private: - /** + + /** + * Gets a configuration attr from driver configuration file (vector + * version) + * @param name of config vector attribute for the domain + * @param vname of the attribute + * @param value of the attribute + * + * @return true if the attribute was found + */ + bool get_default( + const char * name, + const char * vname, + bool& value) const; + +private: + /** * Configuration file for the driver */ Template driver_conf; - + /** * Pointer to the Virtual Machine Pool, to access VMs */ VirtualMachinePool * vmpool; friend class VirtualMachineManager; - + /** * Sends a deploy request to the MAD: "DEPLOY ID XML_DRV_MSG" * @param oid the virtual machine id. @@ -169,6 +199,18 @@ private: write_drv("CANCEL", oid, drv_msg); } + /** + * Sends a cleanup request to the MAD: "CLEANUP ID XML_DRV_MSG" + * @param oid the virtual machine id. + * @param drv_msg xml data for the mad operation + */ + void cleanup ( + const int oid, + const string& drv_msg) const + { + write_drv("CLEANUP", oid, drv_msg); + } + /** * Sends a checkpoint request to the MAD: "CHECKPOINT ID XML_DRV_MSG" * @param oid the virtual machine id. @@ -280,14 +322,73 @@ private: write_drv("DETACHNIC", oid, drv_msg); } -private: + /** + * Sends a snapshot create request to the MAD: + * "SNAPSHOTCREATE ID XML_DRV_MSG" + * @param oid the virtual machine id. + * @param drv_msg xml data for the mad operation + */ + void snapshot_create ( + const int oid, + const string& drv_msg) const + { + write_drv("SNAPSHOTCREATE", oid, drv_msg); + } + /** + * Sends a snapshot revert request to the MAD: + * "SNAPSHOTREVERT ID XML_DRV_MSG" + * @param oid the virtual machine id. + * @param drv_msg xml data for the mad operation + */ + void snapshot_revert ( + const int oid, + const string& drv_msg) const + { + write_drv("SNAPSHOTREVERT", oid, drv_msg); + } + + /** + * Sends a snapshot delete request to the MAD: + * "SNAPSHOTDELETE ID XML_DRV_MSG" + * @param oid the virtual machine id. + * @param drv_msg xml data for the mad operation + */ + void snapshot_delete ( + const int oid, + const string& drv_msg) const + { + write_drv("SNAPSHOTDELETE", oid, drv_msg); + } + + /** + * Gets VM information from the driver answer + * @param monitor_str from the driver + * @param memory Kilobytes used by the VM (total) + * @param cpu used by the VM (rate) + * @param net_tx transmitted bytes (total) + * @param net_rx received bytes (total) + * @param state of the vm + * @param custom monitor information + */ + static int parse_vm_info( + const string& monitor_str, + int &cpu, + int &memory, + long long &net_tx, + long long &net_rx, + char &state, + map &custom); + + /** + * + */ void write_drv(const char * aname, const int oid, const string& msg) const { ostringstream os; os << aname << " " << oid << " " << msg << endl; - + write(os); } }; @@ -296,4 +397,3 @@ private: /* -------------------------------------------------------------------------- */ #endif /*VIRTUAL_MACHINE_MANAGER_DRIVER_H_*/ - diff --git a/include/VirtualMachinePool.h b/include/VirtualMachinePool.h index e3b75236b8..e43f802cc9 100644 --- a/include/VirtualMachinePool.h +++ b/include/VirtualMachinePool.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -37,7 +37,8 @@ public: const string& hook_location, const string& remotes_location, vector& restricted_attrs, - time_t expire_time); + time_t expire_time, + bool on_hold); ~VirtualMachinePool(){}; @@ -45,10 +46,14 @@ public: * Function to allocate a new VM object * @param uid user id (the owner of the VM) * @param gid the id of the group this object is assigned to + * @param uname user name + * @param gname group name + * @param umask permissions umask * @param vm_template a VM Template object describing the VM * @param oid the id assigned to the VM (output) * @param error_str Returns the error reason, if any * @param on_hold flag to submit on hold + * * @return oid on success, -1 error inserting in DB or -2 error parsing * the template */ @@ -57,6 +62,7 @@ public: int gid, const string& uname, const string& gname, + int umask, VirtualMachineTemplate * vm_template, int * oid, string& error_str, @@ -248,13 +254,18 @@ private: */ PoolObjectSQL * create() { - return new VirtualMachine(-1,-1,-1,"","",0); + return new VirtualMachine(-1,-1,-1,"","",0,0); }; /** * Size, in seconds, of the historical monitoring information */ static time_t _monitor_expiration; + + /** + * True or false whether to submit new VM on HOLD or not + */ + static bool _submit_on_hold; }; #endif /*VIRTUAL_MACHINE_POOL_H_*/ diff --git a/include/VirtualMachineTemplate.h b/include/VirtualMachineTemplate.h index 5e36fbbb8c..532c6fae0d 100644 --- a/include/VirtualMachineTemplate.h +++ b/include/VirtualMachineTemplate.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -45,7 +45,12 @@ public: { return Template::check(rs_attr, restricted_attributes); }; - + + void set_xml_root(const char * _xml_root) + { + Template::set_xml_root(_xml_root); + }; + private: friend class VirtualMachinePool; diff --git a/include/VirtualNetwork.h b/include/VirtualNetwork.h index a70063059c..286f2ae787 100644 --- a/include/VirtualNetwork.h +++ b/include/VirtualNetwork.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -36,7 +36,7 @@ using namespace std; /* -------------------------------------------------------------------------- */ /** - * The Virtual Network class. It represents a Virtual Network at manages its + * The Virtual Network class. It represents a Virtual Network at manages its * leases. One lease is formed by one IP and one MAC address. * MAC address are derived from IP addresses. */ @@ -70,7 +70,7 @@ public: /** * Adds Leases to the virtual network (Only implemented for FIXED networks) * @param leases template in the form LEASES = [IP=XX, MAC=XX]. - * MAC is optional. The template can only contain one LEASE + * MAC is optional. The template can only contain one LEASE * definition. * @param error_msg If the action fails, this message contains the reason. * @return 0 on success @@ -78,7 +78,7 @@ public: int add_leases(VirtualNetworkTemplate * leases, string& error_msg); /** - * Removes Leases from the virtual network; if they are not used.(Only + * Removes Leases from the virtual network; if they are not used.(Only * implemented for FIXED networks) * @param leases template in the form LEASES = [IP=XX]. * The template can only contain one LEASE definition. @@ -117,8 +117,10 @@ public: */ int get_lease(int vid, string& _ip, string& _mac, string& _bridge) { + unsigned int eui64[2]; + _bridge = bridge; - return leases->get(vid,_ip,_mac); + return leases->get(vid, _ip, _mac, eui64); }; /** @@ -131,8 +133,10 @@ public: */ int set_lease(int vid, const string& _ip, string& _mac, string& _bridge) { + unsigned int eui64[2]; + _bridge = bridge; - return leases->set(vid,_ip,_mac); + return leases->set(vid, _ip, _mac, eui64); }; /** @@ -146,7 +150,7 @@ public: }; /** - * Check if a VM is the owner of the ip + * Check if a VM is the owner of the ip * @param ip of the lease to be checked * @param vid the ID of the VM * @return true if the ip was already assigned @@ -216,7 +220,7 @@ private: * Name of the physical device the bridge should be attached to */ string phydev; - + /** * VLAN ID of the NIC */ @@ -227,6 +231,26 @@ private: */ int vlan; + /** + * IPv6 address global unicast prefix + */ + string global; + + /** + * Binary representation of the IPv6 address global unicast prefix + */ + unsigned int global_bin[2]; + + /** + * IPv6 address site unicast prefix + */ + string site; + + /** + * Binary representation of the IPv6 address site unicast prefix + */ + unsigned int site_bin[2]; + // ------------------------------------------------------------------------- // Virtual Network Description // ------------------------------------------------------------------------- @@ -299,6 +323,7 @@ private: int gid, const string& _uname, const string& _gname, + int _umask, int _cluster_id, const string& _cluster_name, VirtualNetworkTemplate * _vn_template = 0); @@ -326,8 +351,8 @@ private: * Reads the Virtual Network (identified with its OID) from the database. * @param db pointer to the db * @param name of the network - * @param uid of the owner - * + * @param uid of the owner + * * @return 0 on success */ int select(SqlDB * db, const string& name, int uid); diff --git a/include/VirtualNetworkPool.h b/include/VirtualNetworkPool.h index 0639414def..369612f0e0 100644 --- a/include/VirtualNetworkPool.h +++ b/include/VirtualNetworkPool.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -45,6 +45,9 @@ public: * Function to allocate a new VNET object * @param uid user identifier * @param gid the id of the group this object is assigned to + * @param uname user name + * @param gname group name + * @param umask permissions umask * @param vn_template a VirtualNetworkTemplate describing the VNET * @param oid the id assigned to the VM (output) * @param cluster_id the id of the cluster this VNET will belong to @@ -57,6 +60,7 @@ public: int gid, const string& uname, const string& gname, + int umask, VirtualNetworkTemplate * vn_template, int * oid, int cluster_id, @@ -176,7 +180,7 @@ private: */ PoolObjectSQL * create() { - return new VirtualNetwork(-1,-1,"","",-1,"",0); + return new VirtualNetwork(-1,-1,"","",0,-1,"",0); }; /** diff --git a/include/VirtualNetworkTemplate.h b/include/VirtualNetworkTemplate.h index 4cd0d42a56..0f4d453638 100644 --- a/include/VirtualNetworkTemplate.h +++ b/include/VirtualNetworkTemplate.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/XMLDriver.h b/include/XMLDriver.h index f032893df5..dfb6d66ba2 100644 --- a/include/XMLDriver.h +++ b/include/XMLDriver.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/XenDriver.h b/include/XenDriver.h index c80be8405d..9d01e74f7a 100644 --- a/include/XenDriver.h +++ b/include/XenDriver.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/mem_collector.h b/include/mem_collector.h index 84246de38f..144f386012 100644 --- a/include/mem_collector.h +++ b/include/mem_collector.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/test/NebulaTest.h b/include/test/NebulaTest.h index 31697a5271..4a201de7ce 100644 --- a/include/test/NebulaTest.h +++ b/include/test/NebulaTest.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/test/OneUnitTest.h b/include/test/OneUnitTest.h index 6f83193053..f710d9c097 100644 --- a/include/test/OneUnitTest.h +++ b/include/test/OneUnitTest.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/include/test/PoolTest.h b/include/test/PoolTest.h index 5f9dc8f485..7cd1f868ff 100644 --- a/include/test/PoolTest.h +++ b/include/test/PoolTest.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/install.sh b/install.sh index e316e55b94..c89bc87bc6 100755 --- a/install.sh +++ b/install.sh @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -49,7 +49,13 @@ usage() { } #------------------------------------------------------------------------------- -TEMP_OPT=`getopt -o hkrlcsou:g:d: -n 'install.sh' -- "$@"` +PARAMETERS="hkrlcsou:g:d:" + +if [ $(getopt --version | tr -d " ") = "--" ]; then + TEMP_OPT=`getopt $PARAMETERS "$@"` +else + TEMP_OPT=`getopt -o $PARAMETERS -n 'install.sh' -- "$@"` +fi if [ $? != 0 ] ; then usage @@ -183,7 +189,8 @@ else CHOWN_DIRS="$ROOT" fi -SHARE_DIRS="$SHARE_LOCATION/examples" +SHARE_DIRS="$SHARE_LOCATION/examples \ + $SHARE_LOCATION/tgt" ETC_DIRS="$ETC_LOCATION/im_ec2 \ $ETC_LOCATION/vmm_ec2 \ @@ -196,7 +203,7 @@ ETC_DIRS="$ETC_LOCATION/im_ec2 \ $ETC_LOCATION/cli" LIB_DIRS="$LIB_LOCATION/ruby \ - $LIB_LOCATION/ruby/OpenNebula \ + $LIB_LOCATION/ruby/opennebula \ $LIB_LOCATION/ruby/zona \ $LIB_LOCATION/ruby/cloud/ \ $LIB_LOCATION/ruby/cloud/econe \ @@ -218,7 +225,8 @@ VAR_DIRS="$VAR_LOCATION/remotes \ $VAR_LOCATION/remotes/im/ganglia.d \ $VAR_LOCATION/remotes/vmm \ $VAR_LOCATION/remotes/vmm/kvm \ - $VAR_LOCATION/remotes/vmm/xen \ + $VAR_LOCATION/remotes/vmm/xen3 \ + $VAR_LOCATION/remotes/vmm/xen4 \ $VAR_LOCATION/remotes/vmm/vmware \ $VAR_LOCATION/remotes/vnm \ $VAR_LOCATION/remotes/vnm/802.1Q \ @@ -226,6 +234,7 @@ VAR_DIRS="$VAR_LOCATION/remotes \ $VAR_LOCATION/remotes/vnm/ebtables \ $VAR_LOCATION/remotes/vnm/fw \ $VAR_LOCATION/remotes/vnm/ovswitch \ + $VAR_LOCATION/remotes/vnm/ovswitch_brcompat \ $VAR_LOCATION/remotes/vnm/vmware \ $VAR_LOCATION/remotes/tm/ \ $VAR_LOCATION/remotes/tm/dummy \ @@ -235,6 +244,7 @@ VAR_DIRS="$VAR_LOCATION/remotes \ $VAR_LOCATION/remotes/tm/vmfs \ $VAR_LOCATION/remotes/tm/iscsi \ $VAR_LOCATION/remotes/tm/lvm \ + $VAR_LOCATION/remotes/tm/ceph \ $VAR_LOCATION/remotes/hooks \ $VAR_LOCATION/remotes/hooks/ft \ $VAR_LOCATION/remotes/datastore \ @@ -244,6 +254,7 @@ VAR_DIRS="$VAR_LOCATION/remotes \ $VAR_LOCATION/remotes/datastore/vmfs \ $VAR_LOCATION/remotes/datastore/iscsi \ $VAR_LOCATION/remotes/datastore/lvm \ + $VAR_LOCATION/remotes/datastore/ceph \ $VAR_LOCATION/remotes/auth \ $VAR_LOCATION/remotes/auth/plain \ $VAR_LOCATION/remotes/auth/ssh \ @@ -357,26 +368,26 @@ SELF_SERVICE_DIRS="\ $LIB_LOCATION/ruby/cloud/occi/ui/public/vendor/FontAwesome/font" OZONES_CLIENT_DIRS="$LIB_LOCATION/ruby \ - $LIB_LOCATION/ruby/OpenNebula \ + $LIB_LOCATION/ruby/opennebula \ $LIB_LOCATION/ruby/cli \ $LIB_LOCATION/ruby/cli/ozones_helper \ $LIB_LOCATION/ruby/zona" LIB_ECO_CLIENT_DIRS="$LIB_LOCATION/ruby \ - $LIB_LOCATION/ruby/OpenNebula \ + $LIB_LOCATION/ruby/opennebula \ $LIB_LOCATION/ruby/cloud/ \ $LIB_LOCATION/ruby/cloud/econe" LIB_OCCI_CLIENT_DIRS="$LIB_LOCATION/ruby \ - $LIB_LOCATION/ruby/OpenNebula \ + $LIB_LOCATION/ruby/opennebula \ $LIB_LOCATION/ruby/cloud/occi" LIB_MARKET_CLIENT_DIRS="$LIB_LOCATION/ruby \ - $LIB_LOCATION/ruby/OpenNebula \ + $LIB_LOCATION/ruby/opennebula \ $LIB_LOCATION/ruby/cloud/marketplace" LIB_OCA_CLIENT_DIRS="$LIB_LOCATION/ruby \ - $LIB_LOCATION/ruby/OpenNebula" + $LIB_LOCATION/ruby/opennebula" LIB_CLI_CLIENT_DIRS="$LIB_LOCATION/ruby/cli \ $LIB_LOCATION/ruby/cli/one_helper" @@ -406,7 +417,8 @@ INSTALL_FILES=( INCLUDE_FILES:$INCLUDE_LOCATION LIB_FILES:$LIB_LOCATION RUBY_LIB_FILES:$LIB_LOCATION/ruby - RUBY_OPENNEBULA_LIB_FILES:$LIB_LOCATION/ruby/OpenNebula + RUBY_AUTH_LIB_FILES:$LIB_LOCATION/ruby/opennebula + RUBY_OPENNEBULA_LIB_FILES:$LIB_LOCATION/ruby/opennebula MAD_RUBY_LIB_FILES:$LIB_LOCATION/ruby MAD_RUBY_LIB_FILES:$VAR_LOCATION/remotes MAD_SH_LIB_FILES:$LIB_LOCATION/sh @@ -426,7 +438,8 @@ INSTALL_FILES=( AUTH_DUMMY_FILES:$VAR_LOCATION/remotes/auth/dummy AUTH_PLAIN_FILES:$VAR_LOCATION/remotes/auth/plain VMM_EXEC_KVM_SCRIPTS:$VAR_LOCATION/remotes/vmm/kvm - VMM_EXEC_XEN_SCRIPTS:$VAR_LOCATION/remotes/vmm/xen + VMM_EXEC_XEN3_SCRIPTS:$VAR_LOCATION/remotes/vmm/xen3 + VMM_EXEC_XEN4_SCRIPTS:$VAR_LOCATION/remotes/vmm/xen4 VMM_EXEC_VMWARE_SCRIPTS:$VAR_LOCATION/remotes/vmm/vmware TM_FILES:$VAR_LOCATION/remotes/tm TM_SHARED_FILES:$VAR_LOCATION/remotes/tm/shared @@ -435,6 +448,7 @@ INSTALL_FILES=( TM_VMFS_FILES:$VAR_LOCATION/remotes/tm/vmfs TM_ISCSI_FILES:$VAR_LOCATION/remotes/tm/iscsi TM_LVM_FILES:$VAR_LOCATION/remotes/tm/lvm + TM_CEPH_FILES:$VAR_LOCATION/remotes/tm/ceph TM_DUMMY_FILES:$VAR_LOCATION/remotes/tm/dummy DATASTORE_DRIVER_COMMON_SCRIPTS:$VAR_LOCATION/remotes/datastore/ DATASTORE_DRIVER_DUMMY_SCRIPTS:$VAR_LOCATION/remotes/datastore/dummy @@ -443,14 +457,17 @@ INSTALL_FILES=( DATASTORE_DRIVER_VMFS_SCRIPTS:$VAR_LOCATION/remotes/datastore/vmfs DATASTORE_DRIVER_ISCSI_SCRIPTS:$VAR_LOCATION/remotes/datastore/iscsi DATASTORE_DRIVER_LVM_SCRIPTS:$VAR_LOCATION/remotes/datastore/lvm + DATASTORE_DRIVER_CEPH_SCRIPTS:$VAR_LOCATION/remotes/datastore/ceph NETWORK_FILES:$VAR_LOCATION/remotes/vnm NETWORK_8021Q_FILES:$VAR_LOCATION/remotes/vnm/802.1Q NETWORK_DUMMY_FILES:$VAR_LOCATION/remotes/vnm/dummy NETWORK_EBTABLES_FILES:$VAR_LOCATION/remotes/vnm/ebtables NETWORK_FW_FILES:$VAR_LOCATION/remotes/vnm/fw NETWORK_OVSWITCH_FILES:$VAR_LOCATION/remotes/vnm/ovswitch + NETWORK_OVSWITCH_BRCOMPAT_FILES:$VAR_LOCATION/remotes/vnm/ovswitch_brcompat NETWORK_VMWARE_FILES:$VAR_LOCATION/remotes/vnm/vmware EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples + TGT_SHARE_FILES:$SHARE_LOCATION/tgt INSTALL_NOVNC_SHARE_FILE:$SHARE_LOCATION INSTALL_GEMS_SHARE_FILE:$SHARE_LOCATION HOOK_FT_FILES:$VAR_LOCATION/remotes/hooks/ft @@ -488,11 +505,11 @@ INSTALL_CLIENT_FILES=( OZONES_LIB_API_ZONA_FILES:$LIB_LOCATION/ruby/zona CLI_CONF_FILES:$ETC_LOCATION/cli OCA_LIB_FILES:$LIB_LOCATION/ruby - RUBY_OPENNEBULA_LIB_FILES:$LIB_LOCATION/ruby/OpenNebula + RUBY_OPENNEBULA_LIB_FILES:$LIB_LOCATION/ruby/opennebula ) INSTALL_SUNSTONE_RUBY_FILES=( - RUBY_OPENNEBULA_LIB_FILES:$LIB_LOCATION/ruby/OpenNebula + RUBY_OPENNEBULA_LIB_FILES:$LIB_LOCATION/ruby/opennebula OCA_LIB_FILES:$LIB_LOCATION/ruby ) @@ -541,7 +558,7 @@ INSTALL_SUNSTONE_ETC_FILES=( INSTALL_OZONES_RUBY_FILES=( OZONES_RUBY_LIB_FILES:$LIB_LOCATION/ruby - RUBY_OPENNEBULA_LIB_FILES:$LIB_LOCATION/ruby/OpenNebula + RUBY_OPENNEBULA_LIB_FILES:$LIB_LOCATION/ruby/opennebula ) INSTALL_OZONES_FILES=( @@ -673,8 +690,15 @@ RUBY_LIB_FILES="src/mad/ruby/ActionManager.rb \ src/mad/ruby/ssh_stream.rb \ src/vnm_mad/one_vnm.rb \ src/mad/ruby/Ganglia.rb \ - src/oca/ruby/OpenNebula.rb \ - src/authm_mad/remotes/ssh/ssh_auth.rb \ + src/oca/ruby/deprecated/OpenNebula.rb \ + src/oca/ruby/opennebula.rb \ + src/sunstone/OpenNebulaVNC.rb" + +#------------------------------------------------------------------------------- +# Ruby auth library files, to be installed under $LIB_LOCATION/ruby/opennebula +#------------------------------------------------------------------------------- + +RUBY_AUTH_LIB_FILES="src/authm_mad/remotes/ssh/ssh_auth.rb \ src/authm_mad/remotes/server_x509/server_x509_auth.rb \ src/authm_mad/remotes/server_cipher/server_cipher_auth.rb \ src/authm_mad/remotes/ldap/ldap_auth.rb \ @@ -735,15 +759,18 @@ VMM_EXEC_KVM_SCRIPTS="src/vmm_mad/remotes/kvm/cancel \ src/vmm_mad/remotes/kvm/poll_ganglia \ src/vmm_mad/remotes/kvm/attach_disk \ src/vmm_mad/remotes/kvm/detach_disk \ + src/vmm_mad/remotes/kvm/snapshot_create \ + src/vmm_mad/remotes/kvm/snapshot_revert \ + src/vmm_mad/remotes/kvm/snapshot_delete \ src/vmm_mad/remotes/kvm/shutdown" #------------------------------------------------------------------------------- # VMM SH Driver Xen scripts, to be installed under $REMOTES_LOCATION/vmm/xen #------------------------------------------------------------------------------- -VMM_EXEC_XEN_SCRIPTS="src/vmm_mad/remotes/xen/cancel \ +VMM_EXEC_XEN3_SCRIPTS="src/vmm_mad/remotes/xen/cancel \ src/vmm_mad/remotes/xen/deploy \ - src/vmm_mad/remotes/xen/xenrc \ + src/vmm_mad/remotes/xen/xen3/xenrc \ src/vmm_mad/remotes/xen/migrate \ src/vmm_mad/remotes/xen/restore \ src/vmm_mad/remotes/xen/reboot \ @@ -753,8 +780,27 @@ VMM_EXEC_XEN_SCRIPTS="src/vmm_mad/remotes/xen/cancel \ src/vmm_mad/remotes/xen/poll_ganglia \ src/vmm_mad/remotes/xen/attach_disk \ src/vmm_mad/remotes/xen/detach_disk \ + src/vmm_mad/remotes/xen/snapshot_create \ + src/vmm_mad/remotes/xen/snapshot_revert \ + src/vmm_mad/remotes/xen/snapshot_delete \ src/vmm_mad/remotes/xen/shutdown" +VMM_EXEC_XEN4_SCRIPTS="src/vmm_mad/remotes/xen/cancel \ + src/vmm_mad/remotes/xen/deploy \ + src/vmm_mad/remotes/xen/xen4/xenrc \ + src/vmm_mad/remotes/xen/migrate \ + src/vmm_mad/remotes/xen/restore \ + src/vmm_mad/remotes/xen/reboot \ + src/vmm_mad/remotes/xen/reset \ + src/vmm_mad/remotes/xen/save \ + src/vmm_mad/remotes/xen/poll \ + src/vmm_mad/remotes/xen/poll_ganglia \ + src/vmm_mad/remotes/xen/attach_disk \ + src/vmm_mad/remotes/xen/detach_disk \ + src/vmm_mad/remotes/xen/snapshot_create \ + src/vmm_mad/remotes/xen/snapshot_revert \ + src/vmm_mad/remotes/xen/snapshot_delete \ + src/vmm_mad/remotes/xen/shutdown" #------------------------------------------------------------------------------- # VMM Driver VMWARE scripts, to be installed under $REMOTES_LOCATION/vmm/vmware #------------------------------------------------------------------------------- @@ -762,6 +808,9 @@ VMM_EXEC_XEN_SCRIPTS="src/vmm_mad/remotes/xen/cancel \ VMM_EXEC_VMWARE_SCRIPTS="src/vmm_mad/remotes/vmware/cancel \ src/vmm_mad/remotes/vmware/attach_disk \ src/vmm_mad/remotes/vmware/detach_disk \ + src/vmm_mad/remotes/vmware/snapshot_create \ + src/vmm_mad/remotes/vmware/snapshot_revert \ + src/vmm_mad/remotes/vmware/snapshot_delete \ src/vmm_mad/remotes/vmware/scripts_common_sh.sh \ src/vmm_mad/remotes/vmware/deploy \ src/vmm_mad/remotes/vmware/migrate \ @@ -783,11 +832,13 @@ IM_PROBES_FILES="src/im_mad/remotes/run_probes" IM_PROBES_KVM_FILES="src/im_mad/remotes/kvm.d/kvm.rb \ src/im_mad/remotes/kvm.d/architecture.sh \ src/im_mad/remotes/kvm.d/cpu.sh \ + src/im_mad/remotes/kvm.d/poll.sh \ src/im_mad/remotes/kvm.d/name.sh" IM_PROBES_XEN_FILES="src/im_mad/remotes/xen.d/xen.rb \ src/im_mad/remotes/xen.d/architecture.sh \ src/im_mad/remotes/xen.d/cpu.sh \ + src/im_mad/remotes/xen.d/poll.sh \ src/im_mad/remotes/xen.d/name.sh" IM_PROBES_VMWARE_FILES="src/im_mad/remotes/vmware.d/vmware.rb" @@ -843,6 +894,11 @@ NETWORK_OVSWITCH_FILES="src/vnm_mad/remotes/ovswitch/clean \ src/vnm_mad/remotes/ovswitch/pre \ src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb" +NETWORK_OVSWITCH_BRCOMPAT_FILES="src/vnm_mad/remotes/ovswitch_brcompat/clean \ + src/vnm_mad/remotes/ovswitch_brcompat/post \ + src/vnm_mad/remotes/ovswitch_brcompat/pre \ + src/vnm_mad/remotes/ovswitch_brcompat/OpenvSwitch.rb" + NETWORK_VMWARE_FILES="src/vnm_mad/remotes/vmware/clean \ src/vnm_mad/remotes/vmware/post \ src/vnm_mad/remotes/vmware/pre \ @@ -857,6 +913,7 @@ NETWORK_VMWARE_FILES="src/vnm_mad/remotes/vmware/clean \ # - VMWARE TM, $VAR_LOCATION/tm/vmware # - ISCSI TM, $VAR_LOCATION/tm/iscsi # - LVM TM, $VAR_LOCATION/tm/lvm +# - CEPH TM, $VAR_LOCATION/tm/ceph #------------------------------------------------------------------------------- TM_FILES="src/tm_mad/tm_common.sh" @@ -932,6 +989,14 @@ TM_LVM_FILES="src/tm_mad/lvm/clone \ src/tm_mad/lvm/postmigrate \ src/tm_mad/lvm/delete" +TM_CEPH_FILES="src/tm_mad/ceph/clone \ + src/tm_mad/ceph/ln \ + src/tm_mad/ceph/mv \ + src/tm_mad/ceph/mvds \ + src/tm_mad/ceph/premigrate \ + src/tm_mad/ceph/postmigrate \ + src/tm_mad/ceph/delete" + #------------------------------------------------------------------------------- # Datastore drivers, to be installed under $REMOTES_LOCATION/datastore # - Dummy Image Repository, $REMOTES_LOCATION/datastore/dummy @@ -985,6 +1050,13 @@ DATASTORE_DRIVER_LVM_SCRIPTS="src/datastore_mad/remotes/lvm/cp \ src/datastore_mad/remotes/lvm/clone \ src/datastore_mad/remotes/lvm/lvm.conf" +DATASTORE_DRIVER_CEPH_SCRIPTS="src/datastore_mad/remotes/ceph/cp \ + src/datastore_mad/remotes/ceph/mkfs \ + src/datastore_mad/remotes/ceph/stat \ + src/datastore_mad/remotes/ceph/rm \ + src/datastore_mad/remotes/ceph/clone \ + src/datastore_mad/remotes/ceph/ceph.conf" + #------------------------------------------------------------------------------- # Migration scripts for onedb command, to be installed under $LIB_LOCATION #------------------------------------------------------------------------------- @@ -1032,7 +1104,8 @@ VMM_EC2_ETC_FILES="src/vmm_mad/ec2/vmm_ec2rc \ VMM_EXEC_ETC_FILES="src/vmm_mad/exec/vmm_execrc \ src/vmm_mad/exec/vmm_exec_kvm.conf \ - src/vmm_mad/exec/vmm_exec_xen.conf \ + src/vmm_mad/exec/vmm_exec_xen3.conf \ + src/vmm_mad/exec/vmm_exec_xen4.conf \ src/vmm_mad/exec/vmm_exec_vmware.conf" #------------------------------------------------------------------------------- @@ -1065,6 +1138,12 @@ EXAMPLE_SHARE_FILES="share/examples/vm.template \ share/examples/private.net \ share/examples/public.net" +#------------------------------------------------------------------------------- +# File required to interact with a tgtd server +#------------------------------------------------------------------------------- + +TGT_SHARE_FILES="share/scripts/tgt/tgt-setup-lun-one" + #------------------------------------------------------------------------------- # HOOK scripts, to be installed under $VAR_LOCATION/remotes/hooks #------------------------------------------------------------------------------- @@ -1081,35 +1160,40 @@ INSTALL_GEMS_SHARE_FILE="share/install_gems/install_gems" #------------------------------------------------------------------------------- # OCA Files #------------------------------------------------------------------------------- -OCA_LIB_FILES="src/oca/ruby/OpenNebula.rb" +OCA_LIB_FILES="src/oca/ruby/opennebula.rb" -RUBY_OPENNEBULA_LIB_FILES="src/oca/ruby/OpenNebula/Host.rb \ - src/oca/ruby/OpenNebula/HostPool.rb \ - src/oca/ruby/OpenNebula/Pool.rb \ - src/oca/ruby/OpenNebula/User.rb \ - src/oca/ruby/OpenNebula/UserPool.rb \ - src/oca/ruby/OpenNebula/VirtualMachine.rb \ - src/oca/ruby/OpenNebula/VirtualMachinePool.rb \ - src/oca/ruby/OpenNebula/VirtualNetwork.rb \ - src/oca/ruby/OpenNebula/VirtualNetworkPool.rb \ - src/oca/ruby/OpenNebula/Image.rb \ - src/oca/ruby/OpenNebula/ImagePool.rb \ - src/oca/ruby/OpenNebula/Template.rb \ - src/oca/ruby/OpenNebula/TemplatePool.rb \ - src/oca/ruby/OpenNebula/Document.rb \ - src/oca/ruby/OpenNebula/DocumentPool.rb \ - src/oca/ruby/OpenNebula/DocumentJSON.rb \ - src/oca/ruby/OpenNebula/DocumentPoolJSON.rb \ - src/oca/ruby/OpenNebula/Group.rb \ - src/oca/ruby/OpenNebula/GroupPool.rb \ - src/oca/ruby/OpenNebula/Acl.rb \ - src/oca/ruby/OpenNebula/AclPool.rb \ - src/oca/ruby/OpenNebula/Datastore.rb \ - src/oca/ruby/OpenNebula/DatastorePool.rb \ - src/oca/ruby/OpenNebula/Cluster.rb \ - src/oca/ruby/OpenNebula/ClusterPool.rb \ - src/oca/ruby/OpenNebula/XMLUtils.rb \ - src/oca/ruby/OpenNebula/System.rb" +RUBY_OPENNEBULA_LIB_FILES="src/oca/ruby/opennebula/host.rb \ + src/oca/ruby/opennebula/host_pool.rb \ + src/oca/ruby/opennebula/pool.rb \ + src/oca/ruby/opennebula/user.rb \ + src/oca/ruby/opennebula/user_pool.rb \ + src/oca/ruby/opennebula/virtual_machine.rb \ + src/oca/ruby/opennebula/virtual_machine_pool.rb \ + src/oca/ruby/opennebula/virtual_network.rb \ + src/oca/ruby/opennebula/virtual_network_pool.rb \ + src/oca/ruby/opennebula/image.rb \ + src/oca/ruby/opennebula/image_pool.rb \ + src/oca/ruby/opennebula/template.rb \ + src/oca/ruby/opennebula/template_pool.rb \ + src/oca/ruby/opennebula/document.rb \ + src/oca/ruby/opennebula/document_pool.rb \ + src/oca/ruby/opennebula/document_json.rb \ + src/oca/ruby/opennebula/document_pool_json.rb \ + src/oca/ruby/opennebula/group.rb \ + src/oca/ruby/opennebula/group_pool.rb \ + src/oca/ruby/opennebula/acl.rb \ + src/oca/ruby/opennebula/acl_pool.rb \ + src/oca/ruby/opennebula/datastore.rb \ + src/oca/ruby/opennebula/datastore_pool.rb \ + src/oca/ruby/opennebula/cluster.rb \ + src/oca/ruby/opennebula/cluster_pool.rb \ + src/oca/ruby/opennebula/xml_utils.rb \ + src/oca/ruby/opennebula/client.rb \ + src/oca/ruby/opennebula/error.rb \ + src/oca/ruby/opennebula/pool_element.rb \ + src/oca/ruby/opennebula/xml_element.rb \ + src/oca/ruby/opennebula/xml_pool.rb \ + src/oca/ruby/opennebula/system.rb" #------------------------------------------------------------------------------- # Common Cloud Files @@ -1319,9 +1403,10 @@ ETC_CLIENT_FILES="src/cli/etc/group.default" #----------------------------------------------------------------------------- SUNSTONE_FILES="src/sunstone/sunstone-server.rb \ - src/sunstone/OpenNebulaVNC.rb" + src/sunstone/config.ru" -SUNSTONE_BIN_FILES="src/sunstone/bin/sunstone-server" +SUNSTONE_BIN_FILES="src/sunstone/bin/sunstone-server \ + src/sunstone/bin/novnc-server" SUNSTONE_ETC_FILES="src/sunstone/etc/sunstone-server.conf \ src/sunstone/etc/sunstone-plugins.yaml" diff --git a/share/doc/one/one.doxyfile b/share/doc/one/one.doxyfile index 7bcb99a929..bfeb52fcd8 100644 --- a/share/doc/one/one.doxyfile +++ b/share/doc/one/one.doxyfile @@ -1,1294 +1,1792 @@ -# Doxyfile 1.5.3 +# Doxyfile 1.8.1.2 # This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project +# doxygen (www.doxygen.org) for a project. # -# All text after a hash (#) is considered a comment and will be ignored +# All text after a hash (#) is considered a comment and will be ignored. # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") +# Values that contain spaces should be placed between quotes (" "). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- -# This tag specifies the encoding used for all characters in the config file that -# follow. The default is UTF-8 which is also the encoding used for all text before -# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into -# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of -# possible encodings. +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. -DOXYFILE_ENCODING = UTF-8 +DOXYFILE_ENCODING = UTF-8 -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. +# The PROJECT_NAME tag is a single word (or sequence of words) that should +# identify the project. Note that if you do not use Doxywizard you need +# to put quotes around the project name if it contains spaces. -PROJECT_NAME = "OpenNebula Internal documentation" +PROJECT_NAME = "OpenNebula Internal documentation" -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 1.0 +PROJECT_NUMBER = 1.0 -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer +# a quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# Doxygen will copy the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = ./ +OUTPUT_DIRECTORY = ./ -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. -CREATE_SUBDIRS = YES +CREATE_SUBDIRS = YES -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, -# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, -# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, -# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. -OUTPUT_LANGUAGE = English +OUTPUT_LANGUAGE = English -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). # Set to NO to disable this. -BRIEF_MEMBER_DESC = NO +BRIEF_MEMBER_DESC = YES -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. -REPEAT_BRIEF = YES +REPEAT_BRIEF = YES -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" -ABBREVIATE_BRIEF = +ABBREVIATE_BRIEF = -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief # description. -ALWAYS_DETAILED_SEC = NO +ALWAYS_DETAILED_SEC = YES -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. -INLINE_INHERITED_MEMB = NO +INLINE_INHERITED_MEMB = NO -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. -FULL_PATH_NAMES = YES +FULL_PATH_NAMES = YES -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the # path to strip. -STRIP_FROM_PATH = /home/ruben/Programs/Eclipse_Workspace/ +STRIP_FROM_PATH = ../../../ -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. -STRIP_FROM_INC_PATH = +STRIP_FROM_INC_PATH = -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system # doesn't support long names like on DOS, Mac, or CD-ROM. -SHORT_NAMES = NO +SHORT_NAMES = NO -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) -JAVADOC_AUTOBRIEF = NO +JAVADOC_AUTOBRIEF = YES -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) -QT_AUTOBRIEF = NO +QT_AUTOBRIEF = NO -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it # re-implements. -INHERIT_DOCS = YES +INHERIT_DOCS = YES -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. -SEPARATE_MEMBER_PAGES = NO +SEPARATE_MEMBER_PAGES = NO -# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. -TAB_SIZE = 4 +TAB_SIZE = 4 -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. -ALIASES = +ALIASES = -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding +# "class=itcl::class" will allow you to use the command class in the +# itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. -OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_FOR_C = NO -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. -OPTIMIZE_OUTPUT_JAVA = NO +OPTIMIZE_OUTPUT_JAVA = NO -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to -# include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all +# comments according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you +# can mix doxygen, HTML, and XML commands with Markdown formatting. +# Disable only in case of backward compatibilities issues. + +MARKDOWN_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. -BUILTIN_STL_SUPPORT = YES +BUILTIN_STL_SUPPORT = YES # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. -CPP_CLI_SUPPORT = NO +CPP_CLI_SUPPORT = NO -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. -DISTRIBUTE_GROUP_DOC = NO +DISTRIBUTE_GROUP_DOC = NO -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. -SUBGROUPING = YES +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or +# section (for LaTeX and RTF). + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and +# unions with only public data fields will be shown inline in the documentation +# of the scope in which they are defined (i.e. file, namespace, or group +# documentation), provided this scope is documented. If set to NO (the default), +# structs, classes, and unions are shown on a separate page (for HTML and Man +# pages) or section (for LaTeX and RTF). + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penalty. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +SYMBOL_CACHE_SIZE = 0 + +# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be +# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given +# their name and scope. Since this can be an expensive process and often the +# same symbol appear multiple times in the code, doxygen keeps a cache of +# pre-resolved symbols. If the cache is too small doxygen will become slower. +# If the cache is too large, memory is wasted. The cache size is given by this +# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES -EXTRACT_ALL = NO +EXTRACT_ALL = NO -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. -EXTRACT_PRIVATE = NO +EXTRACT_PRIVATE = NO -# If the EXTRACT_STATIC tag is set to YES all static members of a file +# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal scope will be included in the documentation. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. -EXTRACT_STATIC = NO +EXTRACT_STATIC = NO -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. -EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_CLASSES = YES -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. -EXTRACT_LOCAL_METHODS = NO +EXTRACT_LOCAL_METHODS = NO -# If this flag is set to YES, the members of anonymous namespaces will be extracted -# and appear in the documentation as a namespace called 'anonymous_namespace{file}', -# where file will be replaced with the base name of the file that contains the anonymous -# namespace. By default anonymous namespace are hidden. +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. -EXTRACT_ANON_NSPACES = NO +EXTRACT_ANON_NSPACES = NO -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. -HIDE_UNDOC_MEMBERS = YES +HIDE_UNDOC_MEMBERS = YES -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. -HIDE_UNDOC_CLASSES = YES +HIDE_UNDOC_CLASSES = YES -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the # documentation. -HIDE_FRIEND_COMPOUNDS = NO +HIDE_FRIEND_COMPOUNDS = NO -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. -HIDE_IN_BODY_DOCS = NO +HIDE_IN_BODY_DOCS = NO -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. -INTERNAL_DOCS = NO +INTERNAL_DOCS = NO -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. -CASE_SENSE_NAMES = YES +CASE_SENSE_NAMES = YES -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. -HIDE_SCOPE_NAMES = NO +HIDE_SCOPE_NAMES = NO -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation # of that file. -SHOW_INCLUDE_FILES = YES +SHOW_INCLUDE_FILES = YES -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. -INLINE_INFO = YES +INLINE_INFO = YES -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in # declaration order. -SORT_MEMBER_DOCS = YES +SORT_MEMBER_DOCS = YES -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in # declaration order. -SORT_BRIEF_DOCS = NO +SORT_BRIEF_DOCS = NO -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the +# Note: This option applies only to the class list, not to the # alphabetical list. -SORT_BY_SCOPE_NAME = NO +SORT_BY_SCOPE_NAME = NO -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# will still accept a match between prototype and implementation in such cases. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. -GENERATE_TODOLIST = YES +GENERATE_TODOLIST = YES -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test # commands in the documentation. -GENERATE_TESTLIST = YES +GENERATE_TESTLIST = YES -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. -GENERATE_BUGLIST = YES +GENERATE_BUGLIST = YES -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. -GENERATE_DEPRECATEDLIST = YES +GENERATE_DEPRECATEDLIST= YES -# The ENABLED_SECTIONS tag can be used to enable conditional +# The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. -ENABLED_SECTIONS = +ENABLED_SECTIONS = -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. -MAX_INITIALIZER_LINES = 30 +MAX_INITIALIZER_LINES = 30 -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. -SHOW_USED_FILES = YES +SHOW_USED_FILES = YES -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. -SHOW_DIRECTORIES = NO +SHOW_FILES = YES -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from the -# version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. -FILE_VERSION_FILTER = +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files +# containing the references data. This must be a list of .bib files. The +# .bib extension is automatically appended if omitted. Using this command +# requires the bibtex tool to be installed. See also +# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style +# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this +# feature you need bibtex and perl available in the search path. + +CITE_BIB_FILES = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- -# The QUIET tag can be used to turn on/off the messages that are generated +# The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. -QUIET = NO +QUIET = NO -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank # NO is used. -WARNINGS = YES +WARNINGS = YES -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. -WARN_IF_UNDOCUMENTED = NO +WARN_IF_UNDOCUMENTED = NO -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. -WARN_IF_DOC_ERROR = YES +WARN_IF_DOC_ERROR = YES -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of # documentation. -WARN_NO_PARAMDOC = NO +WARN_NO_PARAMDOC = NO -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) -WARN_FORMAT = "$file:$line: $text" +WARN_FORMAT = "$file:$line: $text" -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written # to stderr. -WARN_LOGFILE = +WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = ../../../include +INPUT = ../../../include ../../../src/scheduler/include/ -# This tag can be used to specify the character encoding of the source files that -# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default -# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. -# See http://www.gnu.org/software/libiconv for the list of possible encodings. +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. -INPUT_ENCODING = UTF-8 +INPUT_ENCODING = UTF-8 -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# *.f90 *.f *.for *.vhd *.vhdl -FILE_PATTERNS = *.h +FILE_PATTERNS = *.h -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. -RECURSIVE = NO +RECURSIVE = NO -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. +# Note that relative paths are relative to the directory from which doxygen is +# run. -EXCLUDE = +EXCLUDE = -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded # from the input. -EXCLUDE_SYMLINKS = NO +EXCLUDE_SYMLINKS = NO -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* -EXCLUDE_PATTERNS = +EXCLUDE_PATTERNS = -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the output. -# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, -# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test -EXCLUDE_SYMBOLS = +EXCLUDE_SYMBOLS = -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see # the \include command). -EXAMPLE_PATH = +EXAMPLE_PATH = -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left # blank all files are included. -EXAMPLE_PATTERNS = +EXAMPLE_PATTERNS = -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. -EXAMPLE_RECURSIVE = NO +EXAMPLE_RECURSIVE = NO -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see # the \image command). -IMAGE_PATH = +IMAGE_PATH = -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be # ignored. -INPUT_FILTER = +INPUT_FILTER = -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if +# non of the patterns match the file name, INPUT_FILTER is applied. -FILTER_PATTERNS = +FILTER_PATTERNS = -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). -FILTER_SOURCE_FILES = NO +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when +# FILTER_SOURCE_FILES is enabled. + +FILTER_SOURCE_PATTERNS = #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. If you have enabled CALL_GRAPH or CALLER_GRAPH -# then you must also enable this option. If you don't then doxygen will produce -# a warning and turn it on anyway +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. -SOURCE_BROWSER = NO +SOURCE_BROWSER = NO -# Setting the INLINE_SOURCES tag to YES will include the body +# Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. -INLINE_SOURCES = NO +INLINE_SOURCES = NO -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C, C++ and Fortran comments will always remain visible. -STRIP_CODE_COMMENTS = YES +STRIP_CODE_COMMENTS = YES -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities # called/used by that function will be listed. -REFERENCES_RELATION = YES +REFERENCES_RELATION = YES # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentstion. +# link to the source code. +# Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. -USE_HTAGS = NO +USE_HTAGS = NO -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. -VERBATIM_HEADERS = YES +VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. -ALPHABETICAL_INDEX = NO +ALPHABETICAL_INDEX = NO -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) -COLS_IN_ALPHA_INDEX = 5 +COLS_IN_ALPHA_INDEX = 5 -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. -IGNORE_PREFIX = +IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. -GENERATE_HTML = YES +GENERATE_HTML = YES -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. -HTML_OUTPUT = html +HTML_OUTPUT = html -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. -HTML_FILE_EXTENSION = .html +HTML_FILE_EXTENSION = .html -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is advised to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when +# changing the value of configuration settings such as GENERATE_TREEVIEW! -HTML_HEADER = +HTML_HEADER = -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a # standard footer. -HTML_FOOTER = +HTML_FOOTER = -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# style sheet in the HTML output directory as well, or it will be erased! -HTML_STYLESHEET = +HTML_STYLESHEET = -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# the files will be copied as-is; there are no commands or markers available. -HTML_ALIGN_MEMBERS = YES +HTML_EXTRA_FILES = -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the style sheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of +# entries shown in the various tree structured indices initially; the user +# can expand and collapse entries dynamically later on. Doxygen will expand +# the tree to such a level that at most the specified number of entries are +# visible (unless a fully collapsed tree already exceeds this amount). +# So setting the number of entries 1 will produce a full collapsed tree by +# default. 0 is a special value representing an infinite number of entries +# and will result in a full expanded tree by default. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. -GENERATE_HTMLHELP = NO +GENERATE_HTMLHELP = NO -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox -# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). - -HTML_DYNAMIC_SECTIONS = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be # written to the html output directory. -CHM_FILE = +CHM_FILE = -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. -HHC_LOCATION = +HHC_LOCATION = -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). -GENERATE_CHI = NO +GENERATE_CHI = NO -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. -BINARY_TOC = NO +BINARY_TOC = NO -# The TOC_EXPAND flag can be set to YES to add extra items for group members +# The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. -TOC_EXPAND = NO +TOC_EXPAND = NO -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. -DISABLE_INDEX = NO +GENERATE_QHP = NO -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. -ENUM_VALUES_PER_LINE = 4 +QCH_FILE = -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace -GENERATE_TREEVIEW = NO +QHP_NAMESPACE = org.doxygen.Project -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) +# at top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. Since the tabs have the same information as the +# navigation tree you can set this option to NO if you already set +# GENERATE_TREEVIEW to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. +# Since the tree basically has the same information as the tab index you +# could consider to set DISABLE_INDEX to NO when enabling this option. + +GENERATE_TREEVIEW = YES + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree # is shown. -TREEVIEW_WIDTH = 250 +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you may also need to install MathJax separately and +# configure the path to it using the MATHJAX_RELPATH option. + +USE_MATHJAX = NO + +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to +# the MathJax Content Delivery Network so you can quickly see the result without +# installing MathJax. +# However, it is strongly recommended to install a local +# copy of MathJax from http://www.mathjax.org before deployment. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension +# names that should be enabled during MathJax rendering. + +MATHJAX_EXTENSIONS = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = YES + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvantages are that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. -GENERATE_LATEX = YES +GENERATE_LATEX = NO -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. -LATEX_OUTPUT = latex +LATEX_OUTPUT = latex -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. -LATEX_CMD_NAME = latex +LATEX_CMD_NAME = latex -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. -MAKEINDEX_CMD_NAME = makeindex +MAKEINDEX_CMD_NAME = makeindex -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to # save some trees in general. -COMPACT_LATEX = NO +COMPACT_LATEX = NO -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and # executive. If left blank a4wide will be used. -PAPER_TYPE = a4wide +PAPER_TYPE = a4wide -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. -EXTRA_PACKAGES = +EXTRA_PACKAGES = -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! -LATEX_HEADER = +LATEX_HEADER = -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a +# standard footer. Notice: only use this tag if you know what you are doing! + +LATEX_FOOTER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. -PDF_HYPERLINKS = NO +PDF_HYPERLINKS = NO -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. -USE_PDFLATEX = NO +USE_PDFLATEX = NO -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. -LATEX_BATCHMODE = NO +LATEX_BATCHMODE = NO -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) # in the output. -LATEX_HIDE_INDICES = NO +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +# The LATEX_BIB_STYLE tag can be used to specify the style to use for the +# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See +# http://en.wikipedia.org/wiki/BibTeX for more info. + +LATEX_BIB_STYLE = plain #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. -GENERATE_RTF = NO +GENERATE_RTF = NO -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. -RTF_OUTPUT = rtf +RTF_OUTPUT = rtf -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to # save some trees in general. -COMPACT_RTF = NO +COMPACT_RTF = NO -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. # Note: wordpad (write) and others do not support links. -RTF_HYPERLINKS = NO +RTF_HYPERLINKS = NO -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide +# Load style sheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. -RTF_STYLESHEET_FILE = +RTF_STYLESHEET_FILE = -# Set optional variables used in the generation of an rtf document. +# Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. -RTF_EXTENSIONS_FILE = +RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages -GENERATE_MAN = NO +GENERATE_MAN = NO -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. -MAN_OUTPUT = man +MAN_OUTPUT = man -# The MAN_EXTENSION tag determines the extension that is added to +# The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) -MAN_EXTENSION = .3 +MAN_EXTENSION = .3 -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. -MAN_LINKS = NO +MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of # the code including all documentation. -GENERATE_XML = NO +GENERATE_XML = NO -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. -XML_OUTPUT = xml +XML_OUTPUT = xml -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the # syntax of the XML files. -XML_SCHEMA = +XML_SCHEMA = -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the # syntax of the XML files. -XML_DTD = +XML_DTD = -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. -XML_PROGRAMLISTING = YES +XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental # and incomplete at the moment. -GENERATE_AUTOGEN_DEF = NO +GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the # moment. -GENERATE_PERLMOD = NO +GENERATE_PERLMOD = NO -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. -PERLMOD_LATEX = NO +PERLMOD_LATEX = NO -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. -PERLMOD_PRETTY = YES +PERLMOD_PRETTY = YES -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. -PERLMOD_MAKEVAR_PREFIX = +PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- -# Configuration options related to the preprocessor +# Configuration options related to the preprocessor #--------------------------------------------------------------------------- -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include # files. -ENABLE_PREPROCESSING = YES +ENABLE_PREPROCESSING = YES -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. -MACRO_EXPANSION = NO +MACRO_EXPANSION = NO -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. -EXPAND_ONLY_PREDEF = NO +EXPAND_ONLY_PREDEF = NO -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# pointed to by INCLUDE_PATH will be searched when a #include is found. -SEARCH_INCLUDES = YES +SEARCH_INCLUDES = YES -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by # the preprocessor. -INCLUDE_PATH = +INCLUDE_PATH = -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. -INCLUDE_FILE_PATTERNS = +INCLUDE_FILE_PATTERNS = -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator # instead of the = operator. -PREDEFINED = +PREDEFINED = -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that +# overrules the definition found in the source code. -EXPAND_AS_DEFINED = +EXPAND_AS_DEFINED = -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a +# semicolon, because these will confuse the parser if not removed. -SKIP_FUNCTION_MACROS = YES +SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- -# Configuration::additions related to external references +# Configuration::additions related to external references #--------------------------------------------------------------------------- -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. +# The TAGFILES option can be used to specify one or more tagfiles. For each +# tag file the location of the external documentation should be added. The +# format of a tag file without this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths +# or URLs. Note that each tag file must have a unique name (where the name does +# NOT include the path). If a tag file is not located in the directory in which +# doxygen is run, you must also specify the path to the tagfile here. -TAGFILES = +TAGFILES = -# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. -GENERATE_TAGFILE = +GENERATE_TAGFILE = -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes # will be listed. -ALLEXTERNALS = NO +ALLEXTERNALS = NO -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will # be listed. -EXTERNAL_GROUPS = YES +EXTERNAL_GROUPS = YES -# The PERL_PATH should be the absolute path and name of the perl script +# The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). -PERL_PATH = /usr/bin/perl +PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- -# Configuration options related to the dot tool +# Configuration options related to the dot tool #--------------------------------------------------------------------------- -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to +# install and use dot, since it yields more powerful graphs. -CLASS_DIAGRAMS = NO +CLASS_DIAGRAMS = NO -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to -# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to -# specify the directory where the mscgen tool resides. If left empty the tool is assumed to -# be found in the default search path. +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. -MSCGEN_PATH = +MSCGEN_PATH = -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented # or is not a class. -HIDE_UNDOC_RELATIONS = YES +HIDE_UNDOC_RELATIONS = YES -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) -HAVE_DOT = YES +HAVE_DOT = YES -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. -CLASS_GRAPH = YES +DOT_NUM_THREADS = 0 -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and +# By default doxygen will use the Helvetica font for all dot files that +# doxygen generates. When you want a differently looking font you can specify +# the font name using DOT_FONTNAME. You need to make sure dot is able to find +# the font, which can be done by putting it in a standard location or by setting +# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the +# directory containing the font. + +DOT_FONTNAME = Helvetica + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the Helvetica font. +# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to +# set the path where dot can find it. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. -COLLABORATION_GRAPH = YES +COLLABORATION_GRAPH = YES -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies -GROUP_GRAPHS = YES +GROUP_GRAPHS = YES -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. -UML_LOOK = NO +UML_LOOK = NO -# If set to YES, the inheritance and collaboration graphs will show the +# If the UML_LOOK tag is enabled, the fields and methods are shown inside +# the class node. If there are many fields or methods and many nodes the +# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS +# threshold limits the number of items for each type to make the size more +# managable. Set this to 0 for no limit. Note that the threshold may be +# exceeded by 50% before the limit is enforced. + +UML_LIMIT_NUM_FIELDS = 10 + +# If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. -TEMPLATE_RELATIONS = NO +TEMPLATE_RELATIONS = NO -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with # other documented files. -INCLUDE_GRAPH = YES +INCLUDE_GRAPH = YES -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or # indirectly include this file. -INCLUDED_BY_GRAPH = YES +INCLUDED_BY_GRAPH = YES -# If the CALL_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. -CALL_GRAPH = NO +CALL_GRAPH = NO -# If the CALLER_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will -# generate a caller dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable caller graphs for selected -# functions only using the \callergraph command. +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. -CALLER_GRAPH = NO +CALLER_GRAPH = NO -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. -GRAPHICAL_HIERARCHY = YES +GRAPHICAL_HIERARCHY = YES -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories +# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. -DIRECTORY_GRAPH = YES +DIRECTORY_GRAPH = YES -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. If you choose svg you need to set +# HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible in IE 9+ (other browsers do not have this requirement). -DOT_IMAGE_FORMAT = png +DOT_IMAGE_FORMAT = png -# The tag DOT_PATH can be used to specify the path where the dot tool can be +# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to +# enable generation of interactive SVG images that allow zooming and panning. +# Note that this requires a modern browser other than Internet Explorer. +# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you +# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible. Older versions of IE do not have SVG support. + +INTERACTIVE_SVG = NO + +# The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. -DOT_PATH = +DOT_PATH = -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the # \dotfile command). -DOTFILE_DIRS = +DOTFILE_DIRS = -# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the number -# of direct children of the root node in a graph is already larger than -# MAX_DOT_GRAPH_NOTES then the graph will not be shown at all. Also note +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the +# \mscfile command). + +MSCFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. -DOT_GRAPH_MAX_NODES = 50 +DOT_GRAPH_MAX_NODES = 50 -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. -MAX_DOT_GRAPH_DEPTH = 0 +MAX_DOT_GRAPH_DEPTH = 0 -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, which results in a white background. -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). -DOT_TRANSPARENT = NO +DOT_TRANSPARENT = NO -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. -DOT_MULTI_TARGETS = NO +DOT_MULTI_TARGETS = NO -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. -GENERATE_LEGEND = YES +GENERATE_LEGEND = YES -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate # the various graphs. -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO +DOT_CLEANUP = YES diff --git a/share/doc/xsd/acct.xsd b/share/doc/xsd/acct.xsd index 824bbc25a0..dafb8c78d7 100644 --- a/share/doc/xsd/acct.xsd +++ b/share/doc/xsd/acct.xsd @@ -83,29 +83,31 @@ diff --git a/share/doc/xsd/test.sh b/share/doc/xsd/test.sh index 50d77e06a5..265f69025b 100755 --- a/share/doc/xsd/test.sh +++ b/share/doc/xsd/test.sh @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/doc/xsd/vm.xsd b/share/doc/xsd/vm.xsd index ae3b333c6f..bb72bc4dd5 100644 --- a/share/doc/xsd/vm.xsd +++ b/share/doc/xsd/vm.xsd @@ -45,29 +45,31 @@ @@ -87,6 +89,7 @@ + diff --git a/share/doc/xsd/vnet.xsd b/share/doc/xsd/vnet.xsd index 936f876c51..825da54bd6 100644 --- a/share/doc/xsd/vnet.xsd +++ b/share/doc/xsd/vnet.xsd @@ -32,6 +32,8 @@ + + diff --git a/share/etc/defaultrc b/share/etc/defaultrc index 08ef64c303..bbdaca8c98 100644 --- a/share/etc/defaultrc +++ b/share/etc/defaultrc @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/etc/oned.conf b/share/etc/oned.conf index 8660300863..06132ab3ea 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -6,16 +6,14 @@ # Daemon configuration attributes #------------------------------------------------------------------------------- # MANAGER_TIMER: Time in seconds the core uses to evaluate periodical functions. -# HOST_MONITORING_INTERVAL and VM_POLLING_INTERVAL can not have smaller values -# than MANAGER_TIMER. +# MONITORING_INTERVAL cannot have a smaller value than MANAGER_TIMER. +# +# MONITORING_INTERVAL: Time in seconds between host and VM monitorization. # -# HOST_MONITORING_INTERVAL: Time in seconds between host monitorization. # HOST_PER_INTERVAL: Number of hosts monitored in each interval. # HOST_MONITORING_EXPIRATION_TIME: Time, in seconds, to expire monitoring # information. Use 0 to disable HOST monitoring recording. # -# VM_POLLING_INTERVAL: Time in seconds between virtual machine monitorization. -# Use 0 to disable VM monitoring. # VM_PER_INTERVAL: Number of VMs monitored in each interval. # VM_MONITORING_EXPIRATION_TIME: Time, in seconds, to expire monitoring # information. Use 0 to disable VM monitoring recording. @@ -37,16 +35,28 @@ # VNC_BASE_PORT: VNC ports for VMs can be automatically set to VNC_BASE_PORT + # VMID # -# DEBUG_LEVEL: 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG +# LOG: Configuration for the logging system +# system: defines the logging system: +# file to log in the oned.log file +# syslog to use the syslog facilities +# debug_level: 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG +# +# VM_SUBMIT_ON_HOLD: Forces VMs to be created on hold state instead of pending. +# Values: YES or NO. #******************************************************************************* +LOG = [ + system = "file", + debug_level = 3 +] + #MANAGER_TIMER = 30 -HOST_MONITORING_INTERVAL = 600 +MONITORING_INTERVAL = 300 + #HOST_PER_INTERVAL = 15 #HOST_MONITORING_EXPIRATION_TIME = 86400 -VM_POLLING_INTERVAL = 600 #VM_PER_INTERVAL = 5 #VM_MONITORING_EXPIRATION_TIME = 86400 @@ -66,7 +76,7 @@ DB = [ backend = "sqlite" ] VNC_BASE_PORT = 5900 -DEBUG_LEVEL = 3 +#VM_SUBMIT_ON_HOLD = "NO" #******************************************************************************* # Physical Networks configuration @@ -133,7 +143,7 @@ DEFAULT_DEVICE_PREFIX = "hd" # -t number of threads, i.e. number of hosts monitored at the same time #------------------------------------------------------------------------------- IM_MAD = [ - name = "im_kvm", + name = "kvm", executable = "one_im_ssh", arguments = "-r 0 -t 15 kvm" ] #------------------------------------------------------------------------------- @@ -144,7 +154,7 @@ IM_MAD = [ # -t number of threads, i.e. number of hosts monitored at the same time #------------------------------------------------------------------------------- #IM_MAD = [ -# name = "im_xen", +# name = "xen", # executable = "one_im_ssh", # arguments = "xen" ] #------------------------------------------------------------------------------- @@ -155,7 +165,7 @@ IM_MAD = [ # -t number of threads, i.e. number of hosts monitored at the same time #------------------------------------------------------------------------------- #IM_MAD = [ -# name = "im_vmware", +# name = "vmware", # executable = "one_im_sh", # arguments = "-c -t 15 -r 0 vmware" ] #------------------------------------------------------------------------------- @@ -164,7 +174,7 @@ IM_MAD = [ # EC2 Information Driver Manager Configuration #------------------------------------------------------------------------------- #IM_MAD = [ -# name = "im_ec2", +# name = "ec2", # executable = "one_im_ec2", # arguments = "im_ec2/im_ec2.conf" ] #------------------------------------------------------------------------------- @@ -173,7 +183,7 @@ IM_MAD = [ # Ganglia Information Driver Manager Configuration #----------------------------------------------------------------------------- #IM_MAD = [ -# name = "im_ganglia", +# name = "ganglia", # executable = "one_im_sh", # arguments = "ganglia" ] #----------------------------------------------------------------------------- @@ -181,7 +191,7 @@ IM_MAD = [ #------------------------------------------------------------------------------- # Dummy Information Driver Manager Configuration #------------------------------------------------------------------------------- -#IM_MAD = [ name="im_dummy", executable="one_im_dummy"] +#IM_MAD = [ name="dummy", executable="one_im_dummy"] #------------------------------------------------------------------------------- #******************************************************************************* @@ -215,7 +225,7 @@ IM_MAD = [ # An example: "-l migrate,poll=poll_ganglia,save" #------------------------------------------------------------------------------- VM_MAD = [ - name = "vmm_kvm", + name = "kvm", executable = "one_vmm_exec", arguments = "-t 15 -r 0 kvm", default = "vmm_exec/vmm_exec_kvm.conf", @@ -231,12 +241,23 @@ VM_MAD = [ # Valid actions: deploy, shutdown, cancel, save, restore, migrate, poll # An example: "-l migrate,poll=poll_ganglia,save" #------------------------------------------------------------------------------- + +# Driver for Xen 3.x #VM_MAD = [ -# name = "vmm_xen", +# name = "xen", # executable = "one_vmm_exec", -# arguments = "-t 15 -r 0 xen", -# default = "vmm_exec/vmm_exec_xen.conf", +# arguments = "-t 15 -r 0 xen3", +# default = "vmm_exec/vmm_exec_xen3.conf", # type = "xen" ] + +# Driver for Xen 4.x +#VM_MAD = [ +# name = "xen", +# executable = "one_vmm_exec", +# arguments = "-t 15 -r 0 xen4", +# default = "vmm_exec/vmm_exec_xen4.conf", +# type = "xen" ] + #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- @@ -245,7 +266,7 @@ VM_MAD = [ # -t number of threads, i.e. number of hosts monitored at the same time #------------------------------------------------------------------------------- #VM_MAD = [ -# name = "vmm_vmware", +# name = "vmware", # executable = "one_vmm_sh", # arguments = "-t 15 -r 0 vmware -s sh", # default = "vmm_exec/vmm_exec_vmware.conf", @@ -259,7 +280,7 @@ VM_MAD = [ # installed in /). #------------------------------------------------------------------------------- #VM_MAD = [ -# name = "vmm_ec2", +# name = "ec2", # executable = "one_vmm_ec2", # arguments = "vmm_ec2/vmm_ec2.conf", # type = "xml" ] @@ -268,7 +289,7 @@ VM_MAD = [ #------------------------------------------------------------------------------- # Dummy Virtualization Driver Configuration #------------------------------------------------------------------------------- -#VM_MAD = [ name="vmm_dummy", executable="one_vmm_dummy", type="xml" ] +#VM_MAD = [ name="dummy", executable="one_vmm_dummy", type="xml" ] #------------------------------------------------------------------------------- #******************************************************************************* @@ -289,7 +310,7 @@ VM_MAD = [ TM_MAD = [ executable = "one_tm", - arguments = "-t 15 -d dummy,lvm,shared,qcow2,ssh,vmfs,iscsi" ] + arguments = "-t 15 -d dummy,lvm,shared,qcow2,ssh,vmfs,iscsi,ceph" ] #******************************************************************************* # Datastore Driver Configuration @@ -306,7 +327,7 @@ TM_MAD = [ DATASTORE_MAD = [ executable = "one_datastore", - arguments = "-t 15 -d fs,vmware,vmfs,iscsi,lvm" + arguments = "-t 15 -d fs,vmware,vmfs,iscsi,lvm,ceph" ] #******************************************************************************* @@ -460,6 +481,10 @@ HM_MAD = [ # ENABLE_OTHER_PERMISSIONS: Whether or not users can set the permissions for # 'other', so publishing or sharing resources with others. Users in the oneadmin # group will still be able to change these permissions. Values: YES or NO. +# +# DEFAULT_UMASK: Similar to Unix umask, sets the default resources permissions. +# Its format must be 3 octal digits. For example a umask of 137 will set +# the new object's permissions to 640 "um- u-- ---" #******************************************************************************* AUTH_MAD = [ @@ -471,6 +496,8 @@ SESSION_EXPIRATION_TIME = 900 #ENABLE_OTHER_PERMISSIONS = "YES" +DEFAULT_UMASK = 177 + #******************************************************************************* # Restricted Attributes Configuration #******************************************************************************* @@ -480,6 +507,10 @@ SESSION_EXPIRATION_TIME = 900 VM_RESTRICTED_ATTR = "CONTEXT/FILES" VM_RESTRICTED_ATTR = "NIC/MAC" VM_RESTRICTED_ATTR = "NIC/VLAN_ID" -VM_RESTRICTED_ATTR = "RANK" + +#VM_RESTRICTED_ATTR = "RANK" +#VM_RESTRICTED_ATTR = "SCHED_RANK" +#VM_RESTRICTED_ATTR = "REQUIREMENTS" +#VM_RESTRICTED_ATTR = "SCHED_REQUIREMENTS" IMAGE_RESTRICTED_ATTR = "SOURCE" diff --git a/share/hooks/host_error.rb b/share/hooks/host_error.rb index a7eab104de..6d6dfa3fd9 100755 --- a/share/hooks/host_error.rb +++ b/share/hooks/host_error.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/man/SConstruct b/share/man/SConstruct index c051ff813f..4ac2b5d27b 100644 --- a/share/man/SConstruct +++ b/share/man/SConstruct @@ -1,7 +1,7 @@ # SConstruct for share/man # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/man/econe-allocate-address.1 b/share/man/econe-allocate-address.1 index 9db791f295..37d9208975 100644 --- a/share/man/econe-allocate-address.1 +++ b/share/man/econe-allocate-address.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-ALLOCATE\-ADDRESS" "1" "October 2012" "" "econe-allocate-address(1) -- Allocates a new elastic IP address for the user" +.TH "ECONE\-ALLOCATE\-ADDRESS" "1" "January 2013" "" "econe-allocate-address(1) -- Allocates a new elastic IP address for the user" . .SH "NAME" \fBecone\-allocate\-address\fR @@ -72,7 +72,7 @@ String .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/econe-associate-address.1 b/share/man/econe-associate-address.1 index 740cce5500..f5bb81edc0 100644 --- a/share/man/econe-associate-address.1 +++ b/share/man/econe-associate-address.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-ASSOCIATE\-ADDRESS" "1" "October 2012" "" "econe-associate-address(1) -- Associates a publicIP of the user with a given instance" +.TH "ECONE\-ASSOCIATE\-ADDRESS" "1" "January 2013" "" "econe-associate-address(1) -- Associates a publicIP of the user with a given instance" . .SH "NAME" \fBecone\-associate\-address\fR @@ -75,7 +75,7 @@ String .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/econe-attach-volume.1 b/share/man/econe-attach-volume.1 index 53a49ed2c0..590b092911 100644 --- a/share/man/econe-attach-volume.1 +++ b/share/man/econe-attach-volume.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-ATTACH\-VOLUME" "1" "October 2012" "" "econe-attach-volume(1) -- Attaches a DATABLOCK to an instance" +.TH "ECONE\-ATTACH\-VOLUME" "1" "January 2013" "" "econe-attach-volume(1) -- Attaches a DATABLOCK to an instance" . .SH "NAME" \fBecone\-attach\-volume\fR @@ -77,7 +77,7 @@ String .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/econe-create-keypair.1 b/share/man/econe-create-keypair.1 index 62296d18b2..058ecc78ae 100644 --- a/share/man/econe-create-keypair.1 +++ b/share/man/econe-create-keypair.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-CREATE\-KEYPAIR" "1" "October 2012" "" "econe-create-keypair(1) -- Creates the named keypair" +.TH "ECONE\-CREATE\-KEYPAIR" "1" "January 2013" "" "econe-create-keypair(1) -- Creates the named keypair" . .SH "NAME" \fBecone\-create\-keypair\fR @@ -75,7 +75,7 @@ String .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/econe-create-volume.1 b/share/man/econe-create-volume.1 index 9d72538c12..45be19bc2d 100644 --- a/share/man/econe-create-volume.1 +++ b/share/man/econe-create-volume.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-CREATE\-VOLUME" "1" "October 2012" "" "econe-create-volume(1) -- Creates a new DATABLOCK in OpenNebula" +.TH "ECONE\-CREATE\-VOLUME" "1" "January 2013" "" "econe-create-volume(1) -- Creates a new DATABLOCK in OpenNebula" . .SH "NAME" \fBecone\-create\-volume\fR @@ -73,7 +73,7 @@ String .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/econe-delete-keypair.1 b/share/man/econe-delete-keypair.1 index f9b3bee5a2..59884d0269 100644 --- a/share/man/econe-delete-keypair.1 +++ b/share/man/econe-delete-keypair.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-DELETE\-KEYPAIR" "1" "October 2012" "" "econe-delete-keypair(1) -- Deletes the named keypair, removes the associated keys" +.TH "ECONE\-DELETE\-KEYPAIR" "1" "January 2013" "" "econe-delete-keypair(1) -- Deletes the named keypair, removes the associated keys" . .SH "NAME" \fBecone\-delete\-keypair\fR @@ -75,7 +75,7 @@ String .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/econe-delete-volume.1 b/share/man/econe-delete-volume.1 index be7fdc858b..34c8e3b4eb 100644 --- a/share/man/econe-delete-volume.1 +++ b/share/man/econe-delete-volume.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-DELETE\-VOLUME" "1" "October 2012" "" "econe-delete-volume(1) -- Deletes an existing DATABLOCK" +.TH "ECONE\-DELETE\-VOLUME" "1" "January 2013" "" "econe-delete-volume(1) -- Deletes an existing DATABLOCK" . .SH "NAME" \fBecone\-delete\-volume\fR @@ -75,7 +75,7 @@ String .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/econe-describe-addresses.1 b/share/man/econe-describe-addresses.1 index e60ef40e6f..8bd4944b20 100644 --- a/share/man/econe-describe-addresses.1 +++ b/share/man/econe-describe-addresses.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-DESCRIBE\-ADDRESSES" "1" "October 2012" "" "econe-describe-addresses(1) -- Lists elastic IP addresses" +.TH "ECONE\-DESCRIBE\-ADDRESSES" "1" "January 2013" "" "econe-describe-addresses(1) -- Lists elastic IP addresses" . .SH "NAME" \fBecone\-describe\-addresses\fR @@ -72,7 +72,7 @@ String .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/econe-describe-images.1 b/share/man/econe-describe-images.1 index 06688ebefe..a5ebe6c179 100644 --- a/share/man/econe-describe-images.1 +++ b/share/man/econe-describe-images.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-DESCRIBE\-IMAGES" "1" "October 2012" "" "econe-describe-images(1) -- Lists all registered images belonging to one particular user" +.TH "ECONE\-DESCRIBE\-IMAGES" "1" "January 2013" "" "econe-describe-images(1) -- Lists all registered images belonging to one particular user" . .SH "SYNOPSIS" econe\-describe\-images \fIOPTIONS\fR @@ -69,7 +69,7 @@ String .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/econe-describe-instances.1 b/share/man/econe-describe-instances.1 index 606d2c8a9b..5ee0f2f889 100644 --- a/share/man/econe-describe-instances.1 +++ b/share/man/econe-describe-instances.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-DESCRIBE\-INSTANCES" "1" "October 2012" "" "econe-describe-instances(1) -- Outputs a list of launched images belonging to one particular user" +.TH "ECONE\-DESCRIBE\-INSTANCES" "1" "January 2013" "" "econe-describe-instances(1) -- Outputs a list of launched images belonging to one particular user" . .SH "NAME" \fBecone\-describe\-instances\fR @@ -72,7 +72,7 @@ String .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/econe-describe-keypairs.1 b/share/man/econe-describe-keypairs.1 index dfcf25d1e4..6ed7572c14 100644 --- a/share/man/econe-describe-keypairs.1 +++ b/share/man/econe-describe-keypairs.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-DESCRIBE\-KEYPAIRS" "1" "October 2012" "" "econe-describe-keypairs(1) -- List and describe the key pairs available to the user" +.TH "ECONE\-DESCRIBE\-KEYPAIRS" "1" "January 2013" "" "econe-describe-keypairs(1) -- List and describe the key pairs available to the user" . .SH "NAME" \fBecone\-describe\-keypairs\fR @@ -72,7 +72,7 @@ String .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/econe-describe-volumes.1 b/share/man/econe-describe-volumes.1 index 6c8b1c79d3..d5e29909c5 100644 --- a/share/man/econe-describe-volumes.1 +++ b/share/man/econe-describe-volumes.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-DESCRIBE\-VOLUMES" "1" "October 2012" "" "econe-describe-volumes(1) -- Describe all available DATABLOCKs for this user" +.TH "ECONE\-DESCRIBE\-VOLUMES" "1" "January 2013" "" "econe-describe-volumes(1) -- Describe all available DATABLOCKs for this user" . .SH "NAME" \fBecone\-describe\-volumes\fR @@ -72,7 +72,7 @@ String .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/econe-detach-volume.1 b/share/man/econe-detach-volume.1 index 63cd8af370..de0b00ba22 100644 --- a/share/man/econe-detach-volume.1 +++ b/share/man/econe-detach-volume.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-DETACH\-VOLUME" "1" "October 2012" "" "econe-detach-volume(1) -- Detaches a DATABLOCK from an instance" +.TH "ECONE\-DETACH\-VOLUME" "1" "January 2013" "" "econe-detach-volume(1) -- Detaches a DATABLOCK from an instance" . .SH "NAME" \fBecone\-detach\-volume\fR @@ -77,7 +77,7 @@ String .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/econe-disassociate-address.1 b/share/man/econe-disassociate-address.1 index 434a493593..6e055410fa 100644 --- a/share/man/econe-disassociate-address.1 +++ b/share/man/econe-disassociate-address.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-DISASSOCIATE\-ADDRESS" "1" "October 2012" "" "econe-disassociate-address(1) -- Disasociate a publicIP of the user currently associated with an instance" +.TH "ECONE\-DISASSOCIATE\-ADDRESS" "1" "January 2013" "" "econe-disassociate-address(1) -- Disasociate a publicIP of the user currently associated with an instance" . .SH "NAME" \fBecone\-disassociate\-address\fR @@ -75,7 +75,7 @@ String .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/econe-reboot-instances.1 b/share/man/econe-reboot-instances.1 index 97a9642e48..3db1b43d12 100644 --- a/share/man/econe-reboot-instances.1 +++ b/share/man/econe-reboot-instances.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-REBOOT\-INSTANCES" "1" "October 2012" "" "econe-reboot-instances(1) -- Reboots a set of virtual machines" +.TH "ECONE\-REBOOT\-INSTANCES" "1" "January 2013" "" "econe-reboot-instances(1) -- Reboots a set of virtual machines" . .SH "NAME" \fBecone\-reboot\-instances\fR @@ -89,7 +89,7 @@ The IDs of instances, comma\-separated .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/econe-register.1 b/share/man/econe-register.1 index f7be522fe2..65a3d110b8 100644 --- a/share/man/econe-register.1 +++ b/share/man/econe-register.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-REGISTER" "1" "October 2012" "" "econe-register(1) -- Registers an image" +.TH "ECONE\-REGISTER" "1" "January 2013" "" "econe-register(1) -- Registers an image" . .SH "NAME" \fBecone\-register\fR @@ -75,7 +75,7 @@ String .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/econe-release-address.1 b/share/man/econe-release-address.1 index 28b8146951..bf32e67fd9 100644 --- a/share/man/econe-release-address.1 +++ b/share/man/econe-release-address.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-RELEASE\-ADDRESS" "1" "October 2012" "" "econe-release-address(1) -- Releases a publicIP of the user" +.TH "ECONE\-RELEASE\-ADDRESS" "1" "January 2013" "" "econe-release-address(1) -- Releases a publicIP of the user" . .SH "NAME" \fBecone\-release\-address\fR @@ -75,7 +75,7 @@ String .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/econe-run-instances.1 b/share/man/econe-run-instances.1 index 1e531b3c45..1072f60c7f 100644 --- a/share/man/econe-run-instances.1 +++ b/share/man/econe-run-instances.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-RUN\-INSTANCES" "1" "October 2012" "" "econe-run-instances(1) -- Runs an instance of a particular image (that needs to be referenced)" +.TH "ECONE\-RUN\-INSTANCES" "1" "January 2013" "" "econe-run-instances(1) -- Runs an instance of a particular image (that needs to be referenced)" . .SH "NAME" \fBecone\-run\-instances\fR @@ -80,7 +80,7 @@ String .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/econe-start-instances.1 b/share/man/econe-start-instances.1 index 6afd4ef38b..9692cce707 100644 --- a/share/man/econe-start-instances.1 +++ b/share/man/econe-start-instances.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-START\-INSTANCES" "1" "October 2012" "" "econe-start-instances(1) -- Starts a set of virtual machines" +.TH "ECONE\-START\-INSTANCES" "1" "January 2013" "" "econe-start-instances(1) -- Starts a set of virtual machines" . .SH "NAME" \fBecone\-start\-instances\fR @@ -89,7 +89,7 @@ The IDs of instances, comma\-separated .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/econe-stop-instances.1 b/share/man/econe-stop-instances.1 index 5a9979cd6e..dd93dbbb85 100644 --- a/share/man/econe-stop-instances.1 +++ b/share/man/econe-stop-instances.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-STOP\-INSTANCES" "1" "October 2012" "" "econe-stop-instances(1) -- Stops a set of virtual machines" +.TH "ECONE\-STOP\-INSTANCES" "1" "January 2013" "" "econe-stop-instances(1) -- Stops a set of virtual machines" . .SH "NAME" \fBecone\-stop\-instances\fR @@ -89,7 +89,7 @@ The IDs of instances, comma\-separated .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/econe-terminate-instances.1 b/share/man/econe-terminate-instances.1 index 1d3e3c8cce..52c06dc600 100644 --- a/share/man/econe-terminate-instances.1 +++ b/share/man/econe-terminate-instances.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-TERMINATE\-INSTANCES" "1" "October 2012" "" "econe-terminate-instances(1) -- Shutdowns a set of virtual machines (or cancel, depending on its state)" +.TH "ECONE\-TERMINATE\-INSTANCES" "1" "January 2013" "" "econe-terminate-instances(1) -- Shutdowns a set of virtual machines (or cancel, depending on its state)" . .SH "NAME" \fBecone\-terminate\-instances\fR @@ -89,7 +89,7 @@ The IDs of instances, comma\-separated .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/econe-upload.1 b/share/man/econe-upload.1 index a8f28ff851..5c200b4c11 100644 --- a/share/man/econe-upload.1 +++ b/share/man/econe-upload.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-UPLOAD" "1" "October 2012" "" "econe-upload(1) -- Uploads an image to OpenNebula" +.TH "ECONE\-UPLOAD" "1" "January 2013" "" "econe-upload(1) -- Uploads an image to OpenNebula" . .SH "NAME" \fBecone\-upload\fR @@ -76,7 +76,7 @@ String .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/occi-compute.1 b/share/man/occi-compute.1 index b119434547..ff0bdf73ee 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" "October 2012" "OpenNebula 3.9.0" "User Commands" +.TH OPENNEBULA "1" "January 2013" "OpenNebula 3.9.0" "User Commands" .SH NAME OpenNebula \- OCCI Manage Compute .SH SYNOPSIS @@ -69,7 +69,7 @@ attaches an storage to a given compute .IP detaches the target disk form the compute .SH COPYRIGHT -Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula.org) +Copyright 2002\-2013, OpenNebula Project (OpenNebula.org), C12G Labs .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 diff --git a/share/man/occi-instance-type.1 b/share/man/occi-instance-type.1 index aeaa10f847..b1c4ea97c6 100644 --- a/share/man/occi-instance-type.1 +++ b/share/man/occi-instance-type.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "October 2012" "OpenNebula 3.9.0" "User Commands" +.TH OPENNEBULA "1" "January 2013" "OpenNebula 3.9.0" "User Commands" .SH NAME OpenNebula \- OCCI Manage Instance .SH SYNOPSIS @@ -46,7 +46,7 @@ The password provided will not be hashed .IP lists available instance types .SH COPYRIGHT -Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula.org) +Copyright 2002\-2013, OpenNebula Project (OpenNebula.org), C12G Labs .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 diff --git a/share/man/occi-network.1 b/share/man/occi-network.1 index 0250f64252..d8badb50a2 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" "October 2012" "OpenNebula 3.9.0" "User Commands" +.TH OPENNEBULA "1" "January 2013" "OpenNebula 3.9.0" "User Commands" .SH NAME OpenNebula \- OCCI Manage Network .SH SYNOPSIS @@ -65,7 +65,7 @@ provided .IP deletes the virtual network idenfitied by .SH COPYRIGHT -Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula.org) +Copyright 2002\-2013, OpenNebula Project (OpenNebula.org), C12G Labs .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 diff --git a/share/man/occi-storage.1 b/share/man/occi-storage.1 index 9d2b7dd60f..84a03e2dd3 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" "October 2012" "OpenNebula 3.9.0" "User Commands" +.TH OPENNEBULA "1" "January 2013" "OpenNebula 3.9.0" "User Commands" .SH NAME OpenNebula \- OCCI Manage Storage .SH SYNOPSIS @@ -74,7 +74,7 @@ deletes the storage resource idenfitied by clones the storage resource idenfitied by in a new one using the given .SH COPYRIGHT -Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula.org) +Copyright 2002\-2013, OpenNebula Project (OpenNebula.org), C12G Labs .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 diff --git a/share/man/oneacct.1 b/share/man/oneacct.1 index 45884aacfa..6b761f86e6 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" "October 2012" "" "oneacct(1) -- OpenNebula Accounting Tool" +.TH "ONEACCT" "1" "January 2013" "" "oneacct(1) -- OpenNebula Accounting Tool" . .SH "NAME" \fBoneacct\fR @@ -15,7 +15,7 @@ \-s, \-\-start TIME Start date and time to take into account \-e, \-\-end TIME End date and time - \-u, \-\-user user User name or id to filter the results + \-u, \-\-userfilter user User name or id to filter the results \-g, \-\-group group Group name or id to filter the results \-H, \-\-host HOST Host name or id to filter the results \-\-xpath XPATH_EXPRESSION Xpath expression to filter the results\. For example: oneacct \-\-xpath \'HISTORY[ETIME>0]\' @@ -25,6 +25,9 @@ \-v, \-\-verbose Verbose mode \-h, \-\-help Show this message \-V, \-\-version Show version and copyright information + \-\-user name User name used to connect to OpenNebula + \-\-password password Password to authenticate with OpenNebula + \-\-endpoint endpoint URL of OpenNebula xmlrpc frontend . .fi . @@ -75,7 +78,7 @@ String .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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 a169f1b1d9..6fa4ee17c9 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" "October 2012" "" "oneacl(1) -- manages OpenNebula ACLs" +.TH "ONEACL" "1" "January 2013" "" "oneacl(1) -- manages OpenNebula ACLs" . .SH "NAME" \fBoneacl\fR @@ -18,6 +18,9 @@ \-v, \-\-verbose Verbose mode \-h, \-\-help Show this message \-V, \-\-version Show version and copyright information + \-\-user name User name used to connect to OpenNebula + \-\-password password Password to authenticate with OpenNebula + \-\-endpoint endpoint URL of OpenNebula xmlrpc frontend . .fi . @@ -129,7 +132,7 @@ Comma\-separated list of OpenNebula ACL names or ids .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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 42677c8874..abaa9724fc 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" "October 2012" "" "onecluster(1) -- manages OpenNebula clusters" +.TH "ONECLUSTER" "1" "January 2013" "" "onecluster(1) -- manages OpenNebula clusters" . .SH "NAME" \fBonecluster\fR @@ -15,12 +15,17 @@ \-l, \-\-list x,y,z Selects columns to display with list command \-d, \-\-delay x Sets the delay in seconds for top command + \-f, \-\-filter x,y,z Filter data\. An array is specified with + column=value pairs\. \-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 + \-\-user name User name used to connect to OpenNebula + \-\-password password Password to authenticate with OpenNebula + \-\-endpoint endpoint URL of OpenNebula xmlrpc frontend . .fi . @@ -62,7 +67,7 @@ list .nf Lists Clusters in the pool -valid options: list, delay, xml, numeric, describe +valid options: list, delay, filter, xml, numeric, describe . .fi . @@ -302,7 +307,7 @@ OpenNebula DATASTORE name or id .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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 b17dbe7b16..4957a20dd6 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" "October 2012" "" "onedatastore(1) -- manages OpenNebula datastores" +.TH "ONEDATASTORE" "1" "January 2013" "" "onedatastore(1) -- manages OpenNebula datastores" . .SH "NAME" \fBonedatastore\fR @@ -16,12 +16,17 @@ \-c, \-\-cluster id|name Selects the cluster \-l, \-\-list x,y,z Selects columns to display with list command \-d, \-\-delay x Sets the delay in seconds for top command + \-f, \-\-filter x,y,z Filter data\. An array is specified with + column=value pairs\. \-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 + \-\-user name User name used to connect to OpenNebula + \-\-password password Password to authenticate with OpenNebula + \-\-endpoint endpoint URL of OpenNebula xmlrpc frontend . .fi . @@ -106,7 +111,7 @@ list .nf Lists Datastores in the pool -valid options: list, delay, xml, numeric, describe +valid options: list, delay, filter, xml, numeric, describe . .fi . @@ -262,7 +267,7 @@ OpenNebula USER name or id .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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 c54f1a6014..70b74c69a1 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" "October 2012" "" "onedb(1) -- OpenNebula database migration tool" +.TH "ONEDB" "1" "January 2013" "" "onedb(1) -- OpenNebula database migration tool" . .SH "NAME" \fBonedb\fR diff --git a/share/man/onegroup.1 b/share/man/onegroup.1 index 2a0c614d4a..a466f70710 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" "October 2012" "" "onegroup(1) -- manages OpenNebula groups" +.TH "ONEGROUP" "1" "January 2013" "" "onegroup(1) -- manages OpenNebula groups" . .SH "NAME" \fBonegroup\fR @@ -15,12 +15,17 @@ \-l, \-\-list x,y,z Selects columns to display with list command \-d, \-\-delay x Sets the delay in seconds for top command + \-f, \-\-filter x,y,z Filter data\. An array is specified with + column=value pairs\. \-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 + \-\-user name User name used to connect to OpenNebula + \-\-password password Password to authenticate with OpenNebula + \-\-endpoint endpoint URL of OpenNebula xmlrpc frontend . .fi . @@ -62,7 +67,7 @@ list .nf Lists Groups in the pool -valid options: list, delay, xml, numeric, describe +valid options: list, delay, filter, xml, numeric, describe . .fi . @@ -113,6 +118,21 @@ provided the editor will be launched to create new quotas\. . .IP "" 0 +. +.IP "\(bu" 4 +defaultquota [\fIfile\fR] +. +.IP "" 4 +. +.nf + +Sets the default quota limits for the groups\. If a path is not provided +the editor will be launched to modify the current default quotas\. +. +.fi +. +.IP "" 0 + . .IP "" 0 . @@ -191,7 +211,7 @@ Comma\-separated list of OpenNebula GROUP names or ids .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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 63c06698f8..087c6598fa 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" "October 2012" "" "onehost(1) -- manages OpenNebula hosts" +.TH "ONEHOST" "1" "January 2013" "" "onehost(1) -- manages OpenNebula hosts" . .SH "NAME" \fBonehost\fR @@ -19,6 +19,8 @@ \-c, \-\-cluster id|name Selects the cluster \-l, \-\-list x,y,z Selects columns to display with list command \-d, \-\-delay x Sets the delay in seconds for top command + \-f, \-\-filter x,y,z Filter data\. An array is specified with + column=value pairs\. \-x, \-\-xml Show the resource in xml format \-n, \-\-numeric Do not translate user and group IDs \-k, \-\-kilobytes Show units in kilobytes @@ -26,6 +28,9 @@ \-v, \-\-verbose Verbose mode \-h, \-\-help Show this message \-V, \-\-version Show version and copyright information + \-\-user name User name used to connect to OpenNebula + \-\-password password Password to authenticate with OpenNebula + \-\-endpoint endpoint URL of OpenNebula xmlrpc frontend . .fi . @@ -127,7 +132,7 @@ list .nf Lists Hosts in the pool -valid options: list, delay, xml, numeric, kilobytes, describe +valid options: list, delay, filter, xml, numeric, kilobytes, describe . .fi . @@ -157,7 +162,7 @@ top .nf Lists Hosts continuously -valid options: list, delay, xml, numeric, kilobytes +valid options: list, delay, filter, xml, numeric, kilobytes . .fi . @@ -255,7 +260,7 @@ Comma\-separated list of OpenNebula HOST names or ids .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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 3a84709a57..c79961a2dd 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" "October 2012" "" "oneimage(1) -- manages OpenNebula images" +.TH "ONEIMAGE" "1" "January 2013" "" "oneimage(1) -- manages OpenNebula images" . .SH "NAME" \fBoneimage\fR @@ -16,24 +16,33 @@ \-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 + \-\-type type Type of the new Image: OS, CDROM, DATABLOCK, KERNEL, RAMDISK, CONTEXT \-\-persistent Tells if the image will be persistent - \-\-prefix prefix Device prefix for the disk (eg\. hd, sd, xvd or vd) + \-\-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 + \-\-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\. + \-\-fstype fstype Type of file system to be built\. This can be + any value understood by mkfs unix command\. + \-\-dry Just print the template \-l, \-\-list x,y,z Selects columns to display with list command \-d, \-\-delay x Sets the delay in seconds for top command + \-f, \-\-filter x,y,z Filter data\. An array is specified with + column=value pairs\. \-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 + \-\-user name User name used to connect to OpenNebula + \-\-password password Password to authenticate with OpenNebula + \-\-endpoint endpoint URL of OpenNebula xmlrpc frontend . .fi . @@ -66,7 +75,7 @@ Examples: 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 +valid options: datastore, name, description, type, persistent, prefix, target, path, driver, disk_type, source, size, fstype, dry . .fi . @@ -260,6 +269,20 @@ Changes the Image permissions . .IP "" 0 +. +.IP "\(bu" 4 +rename \fIimageid\fR \fIname\fR +. +.IP "" 4 +. +.nf + +Renames the Image +. +.fi +. +.IP "" 0 + . .IP "\(bu" 4 list [\fIfilterflag\fR] @@ -269,7 +292,7 @@ list [\fIfilterflag\fR] .nf Lists Images in the pool -valid options: list, delay, xml, numeric, describe +valid options: list, delay, filter, xml, numeric, describe . .fi . @@ -299,7 +322,7 @@ top [\fIfilterflag\fR] .nf Lists Images continuously -valid options: list, delay, xml, numeric, describe +valid options: list, delay, filter, xml, numeric, describe . .fi . @@ -426,11 +449,25 @@ user IMAGE of the user identified by the username . .IP "" 0 +. +.IP "\(bu" 4 +type +. +.IP "" 4 +. +.nf + +Image type: OS, CDROM, DATABLOCK, KERNEL, RAMDISK, CONTEXT +. +.fi +. +.IP "" 0 + . .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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 db10eb0255..4da66629f9 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" "October 2012" "" "onetemplate(1) -- manages OpenNebula templates" +.TH "ONETEMPLATE" "1" "January 2013" "" "onetemplate(1) -- manages OpenNebula templates" . .SH "NAME" \fBonetemplate\fR @@ -16,21 +16,40 @@ \-\-name name Name of the new VM or TEMPLATE\. When instantiating multiple VMs you can use the"%i" wildcard to produce different names such as vm\-0, vm\-1\.\.\. - \-\-cpu cpu CPU percentage reserved for the VM (1=100% one CPU) + \-\-cpu cpu CPU percentage reserved for the VM (1=100% one + CPU) + \-\-vcpu vcpu Number of virtualized CPUs \-\-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 + \-\-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 + \-\-vnc Add VNC server to the VM + \-\-ssh [file] Add an ssh public key to the context\. If the + file is omited then the user variable + SSH_PUBLIC_KEY will be used\. + \-\-net_context Add network contextualization parameters + \-\-context line1,line2,line3 Lines to add to the context section + \-\-boot device Select boot device (hd|fd|cdrom|network) + \-\-dry Just print the template \-m, \-\-multiple x Instance multiple VMs + \-\-hold Creates the new VM on hold state instead of pending \-l, \-\-list x,y,z Selects columns to display with list command \-d, \-\-delay x Sets the delay in seconds for top command + \-f, \-\-filter x,y,z Filter data\. An array is specified with + column=value pairs\. \-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 + \-\-user name User name used to connect to OpenNebula + \-\-password password Password to authenticate with OpenNebula + \-\-endpoint endpoint URL of OpenNebula xmlrpc frontend . .fi . @@ -57,8 +76,8 @@ Examples: \- using two disks: - onevm create \-\-name "test vm" \-\-memory 128 \-\-cpu 1 \-\-disk arch,data -valid options: name, cpu, arch, memory, disk, network, raw + onetempate create \-\-name "test vm" \-\-memory 128 \-\-cpu 1 \-\-disk arch,data +valid options: name, cpu, vcpu, arch, memory, disk, network, raw, vnc, ssh, net_context, context, boot, dry . .fi . @@ -102,7 +121,7 @@ instantiate \fItemplateid\fR Creates a new VM instance from the given Template\. This VM can be managed with the \'onevm\' command -valid options: name, multiple +valid options: name, multiple, hold . .fi . @@ -196,6 +215,20 @@ be launched to modify the current content\. . .IP "" 0 +. +.IP "\(bu" 4 +rename \fItemplateid\fR \fIname\fR +. +.IP "" 4 +. +.nf + +Renames the Template +. +.fi +. +.IP "" 0 + . .IP "\(bu" 4 list [\fIfilterflag\fR] @@ -205,7 +238,7 @@ list [\fIfilterflag\fR] .nf Lists Templates in the pool -valid options: list, delay, xml, numeric, describe +valid options: list, delay, filter, xml, numeric, describe . .fi . @@ -235,7 +268,7 @@ top [\fIfilterflag\fR] .nf Lists Templates continuously -valid options: list, delay, xml, numeric, describe +valid options: list, delay, filter, xml, numeric, describe . .fi . @@ -366,7 +399,7 @@ user VMTEMPLATE of the user identified by the username .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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 d13021eb3f..ae09e42817 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" "October 2012" "" "oneuser(1) -- manages OpenNebula users" +.TH "ONEUSER" "1" "January 2013" "" "oneuser(1) -- manages OpenNebula users" . .SH "NAME" \fBoneuser\fR @@ -14,7 +14,8 @@ .nf \-r, \-\-read\-file Read password from file - \-\-sha1 The password will be hashed using the sha1 algorithm + \-\-sha1 The password will be hashed using the sha1 + algorithm \-\-ssh SSH Auth system \-\-x509 x509 Auth system for x509 certificates \-k, \-\-key path_to_private_key_pem Path to the Private Key of the User @@ -25,12 +26,17 @@ \-\-time x Token duration in seconds, defaults to 3600 (1 h) \-l, \-\-list x,y,z Selects columns to display with list command \-d, \-\-delay x Sets the delay in seconds for top command + \-f, \-\-filter x,y,z Filter data\. An array is specified with + column=value pairs\. \-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 + \-\-user name User name used to connect to OpenNebula + \-\-password password Password to authenticate with OpenNebula + \-\-endpoint endpoint URL of OpenNebula xmlrpc frontend . .fi . @@ -101,6 +107,41 @@ provided the editor will be launched to create new quotas\. . .IP "" 0 +. +.IP "\(bu" 4 +defaultquota [\fIfile\fR] +. +.IP "" 4 +. +.nf + +Sets the default quota limits for the users\. If a path is not provided +the editor will be launched to modify the current default quotas\. +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +umask \fIrange|userid_list\fR [\fImask\fR] +. +.IP "" 4 +. +.nf + +Changes the umask used to create the default permissions\. In a similar +way to the Unix umask command, the expected value is a three\-digit +base\-8 number\. Each digit is a mask that disables permissions for the +owner, group and other, respectively\. + +If mask is not given, or if it is an empty string, the umask will +be unset +. +.fi +. +.IP "" 0 + . .IP "\(bu" 4 login \fIusername\fR @@ -214,7 +255,7 @@ list .nf Lists Users in the pool -valid options: list, delay, xml, numeric, describe +valid options: list, delay, filter, xml, numeric, describe . .fi . @@ -355,7 +396,7 @@ User password .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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 06d80561ea..14eb0a0b6a 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" "October 2012" "" "onevdc(1) -- manages OpenNebula Virtual DataCenters" +.TH "ONEVDC" "1" "January 2013" "" "onevdc(1) -- manages OpenNebula Virtual DataCenters" . .SH "NAME" \fBonevdc\fR @@ -178,7 +178,7 @@ VDC ID .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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 bb0c2de4c1..f2a42b03ec 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" "October 2012" "" "onevm(1) -- manages OpenNebula virtual machines" +.TH "ONEVM" "1" "January 2013" "" "onevm(1) -- manages OpenNebula virtual machines" . .SH "NAME" \fBonevm\fR @@ -14,19 +14,36 @@ .nf \-m, \-\-multiple x Instance multiple VMs + \-\-hold Creates the new VM on hold state instead of pending \-\-name name Name for the new VM - \-\-cpu cpu CPU percentage reserved for the VM (1=100% one CPU) + \-\-cpu cpu CPU percentage reserved for the VM (1=100% one + CPU) + \-\-vcpu vcpu Number of virtualized CPUs \-\-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 + \-\-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 + \-\-vnc Add VNC server to the VM + \-\-ssh [file] Add an ssh public key to the context\. If the + file is omited then the user variable + SSH_PUBLIC_KEY will be used\. + \-\-net_context Add network contextualization parameters + \-\-context line1,line2,line3 Lines to add to the context section + \-\-boot device Select boot device (hd|fd|cdrom|network) + \-\-dry Just print the template \-t, \-\-type type Type of the new Image + \-e, \-\-enforce Enforce that the host capacity is not exceeded \-f, \-\-file file Selects the template file \-i, \-\-image id|name Selects the image - \-t, \-\-target type Device where the image will be attached + \-t, \-\-target target 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 + \-f, \-\-filter x,y,z Filter data\. An array is specified with + column=value pairs\. \-x, \-\-xml Show the resource in xml format \-n, \-\-numeric Do not translate user and group IDs \-k, \-\-kilobytes Show units in kilobytes @@ -34,6 +51,9 @@ \-v, \-\-verbose Verbose mode \-h, \-\-help Show this message \-V, \-\-version Show version and copyright information + \-\-user name User name used to connect to OpenNebula + \-\-password password Password to authenticate with OpenNebula + \-\-endpoint endpoint URL of OpenNebula xmlrpc frontend . .fi . @@ -63,7 +83,22 @@ Examples: \- 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 +valid options: multiple, hold, name, cpu, vcpu, arch, memory, disk, network, raw, vnc, ssh, net_context, context, boot, dry +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +update \fIvmid\fR [\fIfile\fR] +. +.IP "" 4 +. +.nf + +Update the user template contents\. If a path is not provided the +editor will be launched to modify the current content\. . .fi . @@ -217,6 +252,7 @@ deployment, in a standard installation the Scheduler is in charge of this decision States: PENDING +valid options: enforce . .fi . @@ -233,6 +269,7 @@ livemigrate \fIrange|vmid_list\fR \fIhostid\fR Migrates the given running VM to another Host without downtime States: RUNNING +valid options: enforce . .fi . @@ -249,6 +286,7 @@ migrate \fIrange|vmid_list\fR \fIhostid\fR Saves the given running VM and starts it again in the specified Host States: RUNNING +valid options: enforce . .fi . @@ -465,6 +503,20 @@ States: RUNNING . .IP "" 0 +. +.IP "\(bu" 4 +rename \fIvmid\fR \fIname\fR +. +.IP "" 4 +. +.nf + +Renames the VM +. +.fi +. +.IP "" 0 + . .IP "\(bu" 4 list [\fIfilterflag\fR] @@ -474,7 +526,7 @@ list [\fIfilterflag\fR] .nf Lists VMs in the pool -valid options: list, delay, xml, numeric, kilobytes, describe +valid options: list, delay, filter, xml, numeric, kilobytes, describe . .fi . @@ -504,7 +556,7 @@ top [\fIfilterflag\fR] .nf Lists Images continuously -valid options: list, delay, xml, numeric, kilobytes +valid options: list, delay, filter, xml, numeric, kilobytes . .fi . @@ -663,7 +715,7 @@ Integer .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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 b88e71361b..3b0b8bc7f7 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" "October 2012" "" "onevnet(1) -- manages OpenNebula networks" +.TH "ONEVNET" "1" "January 2013" "" "onevnet(1) -- manages OpenNebula networks" . .SH "NAME" \fBonevnet\fR @@ -16,6 +16,8 @@ \-c, \-\-cluster id|name Selects the cluster \-l, \-\-list x,y,z Selects columns to display with list command \-d, \-\-delay x Sets the delay in seconds for top command + \-f, \-\-filter x,y,z Filter data\. An array is specified with + column=value pairs\. \-x, \-\-xml Show the resource in xml format \-n, \-\-numeric Do not translate user and group IDs \-k, \-\-kilobytes Show units in kilobytes @@ -23,6 +25,9 @@ \-v, \-\-verbose Verbose mode \-h, \-\-help Show this message \-V, \-\-version Show version and copyright information + \-\-user name User name used to connect to OpenNebula + \-\-password password Password to authenticate with OpenNebula + \-\-endpoint endpoint URL of OpenNebula xmlrpc frontend . .fi . @@ -194,7 +199,7 @@ list [\fIfilterflag\fR] .nf Lists Virtual Networks in the pool -valid options: list, delay, xml, numeric, kilobytes, describe +valid options: list, delay, filter, xml, numeric, kilobytes, describe . .fi . @@ -230,6 +235,20 @@ be launched to modify the current content\. . .IP "" 0 +. +.IP "\(bu" 4 +rename \fIvnetid\fR \fIname\fR +. +.IP "" 4 +. +.nf + +Renames the Virtual Network +. +.fi +. +.IP "" 0 + . .IP "" 0 . @@ -355,7 +374,7 @@ user VNET of the user identified by the username .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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 aee046ad94..3bb5dbc4fe 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" "October 2012" "" "onezone(1) -- manages OpenNebula zones" +.TH "ONEZONE" "1" "January 2013" "" "onezone(1) -- manages OpenNebula zones" . .SH "NAME" \fBonezone\fR @@ -148,7 +148,7 @@ Zone ID .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.9\.0 Copyright 2002\-2012, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.9\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .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/router/init.rb b/share/router/init.rb index 9d49eaa5fe..fbae8b5b1b 100644 --- a/share/router/init.rb +++ b/share/router/init.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/rubygems/SConstruct b/share/rubygems/SConstruct index dfd637daab..0a2dcd197f 100644 --- a/share/rubygems/SConstruct +++ b/share/rubygems/SConstruct @@ -1,7 +1,7 @@ # SConstruct for share/scripts/rubygems # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/rubygems/generate b/share/rubygems/generate index a6c17e7f7b..a7313b843d 100755 --- a/share/rubygems/generate +++ b/share/rubygems/generate @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -21,7 +21,7 @@ require 'tmpdir' DEFAULTS={ - :version => "3.8.0", + :version => "3.9.0.beta", :date => Time.now.strftime("%Y-%m-%d"), :dependencies => [] } @@ -51,8 +51,9 @@ GEM_DESCRIPTION={ :oca => { :name => 'oca', :files => [ - ['src/oca/ruby/OpenNebula.rb', '/lib'], - ['src/oca/ruby/OpenNebula/*.rb', '/lib/OpenNebula'], + ['src/oca/ruby/opennebula.rb', '/lib'], + ['src/oca/ruby/opennebula/*.rb', '/lib/opennebula'], + ['src/authm_mad/remotes/**/*.rb', '/lib/opennebula'], ['NOTICE', ''], ['LICENSE', ''] ], diff --git a/share/scons/get_xmlrpc_config b/share/scons/get_xmlrpc_config index d54325a66e..bf2e2a66eb 100755 --- a/share/scons/get_xmlrpc_config +++ b/share/scons/get_xmlrpc_config @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/scons/lex_bison.py b/share/scons/lex_bison.py index 3f427b6303..48b59cff1d 100644 --- a/share/scons/lex_bison.py +++ b/share/scons/lex_bison.py @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/scons/po2json.rb b/share/scons/po2json.rb index 9153736f34..46dbd89579 100755 --- a/share/scons/po2json.rb +++ b/share/scons/po2json.rb @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/scripts/centos-5/context/init.sh b/share/scripts/centos-5/context/init.sh index 3f90d7a59a..2e9f7be97e 100644 --- a/share/scripts/centos-5/context/init.sh +++ b/share/scripts/centos-5/context/init.sh @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/scripts/centos-5/net-vmcontext/vmcontext b/share/scripts/centos-5/net-vmcontext/vmcontext index a195a6749a..5e7966d70b 100755 --- a/share/scripts/centos-5/net-vmcontext/vmcontext +++ b/share/scripts/centos-5/net-vmcontext/vmcontext @@ -4,7 +4,7 @@ # description: network reconfigure # # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/scripts/context-packages/SConstruct b/share/scripts/context-packages/SConstruct index ea3b26fa60..2c6324e31f 100644 --- a/share/scripts/context-packages/SConstruct +++ b/share/scripts/context-packages/SConstruct @@ -1,7 +1,7 @@ # SConstruct for share/scripts/context-packages # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/scripts/context-packages/base/etc/init.d/vmcontext b/share/scripts/context-packages/base/etc/init.d/vmcontext index 7fb86899f0..b05cf93d5d 100755 --- a/share/scripts/context-packages/base/etc/init.d/vmcontext +++ b/share/scripts/context-packages/base/etc/init.d/vmcontext @@ -4,7 +4,7 @@ # description: network reconfigure # # -------------------------------------------------------------------------- # -# Copyright 2010-2012, C12G Labs S.L. # +# Copyright 2010-2013, C12G Labs S.L. # # # # 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 # diff --git a/share/scripts/context-packages/base/etc/one-context.d/01-dns b/share/scripts/context-packages/base/etc/one-context.d/01-dns index bd78ac4bf3..b72277f68e 100755 --- a/share/scripts/context-packages/base/etc/one-context.d/01-dns +++ b/share/scripts/context-packages/base/etc/one-context.d/01-dns @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2010-2012, C12G Labs S.L. # +# Copyright 2010-2013, C12G Labs S.L. # # # # 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 # diff --git a/share/scripts/context-packages/base/etc/one-context.d/02-ssh_public_key b/share/scripts/context-packages/base/etc/one-context.d/02-ssh_public_key index 1771a8e6e9..c87c96a430 100755 --- a/share/scripts/context-packages/base/etc/one-context.d/02-ssh_public_key +++ b/share/scripts/context-packages/base/etc/one-context.d/02-ssh_public_key @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2010-2012, C12G Labs S.L. # +# Copyright 2010-2013, C12G Labs S.L. # # # # 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 # diff --git a/share/scripts/context-packages/base_deb/etc/one-context.d/00-network b/share/scripts/context-packages/base_deb/etc/one-context.d/00-network index 0b91783943..0a5fbd2f5e 100755 --- a/share/scripts/context-packages/base_deb/etc/one-context.d/00-network +++ b/share/scripts/context-packages/base_deb/etc/one-context.d/00-network @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2010-2012, C12G Labs S.L. # +# Copyright 2010-2013, C12G Labs S.L. # # # # 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 # @@ -146,6 +146,8 @@ configure_network() { gen_network_configuration > /etc/network/interfaces + service networking stop + sleep 1 service networking start sleep 2 diff --git a/share/scripts/context-packages/base_rpm/etc/one-context.d/00-network b/share/scripts/context-packages/base_rpm/etc/one-context.d/00-network index 47ac455148..92e630b645 100755 --- a/share/scripts/context-packages/base_rpm/etc/one-context.d/00-network +++ b/share/scripts/context-packages/base_rpm/etc/one-context.d/00-network @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2010-2012, C12G Labs S.L. # +# Copyright 2010-2013, C12G Labs S.L. # # # # 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 # diff --git a/share/scripts/context-packages/generate.sh b/share/scripts/context-packages/generate.sh index 246feedb88..3033859003 100755 --- a/share/scripts/context-packages/generate.sh +++ b/share/scripts/context-packages/generate.sh @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2010-2012, C12G Labs S.L. # +# Copyright 2010-2013, C12G Labs S.L. # # # # 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 # diff --git a/share/scripts/context-packages/postinstall b/share/scripts/context-packages/postinstall index 1b47c1c6fb..0a277b1293 100755 --- a/share/scripts/context-packages/postinstall +++ b/share/scripts/context-packages/postinstall @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2010-2012, C12G Labs S.L. # +# Copyright 2010-2013, C12G Labs S.L. # # # # 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 # diff --git a/share/scripts/debian/context/init.sh b/share/scripts/debian/context/init.sh index 0b55ea93b2..e7eccbb4eb 100644 --- a/share/scripts/debian/context/init.sh +++ b/share/scripts/debian/context/init.sh @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/scripts/debian/net-vmcontext/vmcontext b/share/scripts/debian/net-vmcontext/vmcontext index a0144c7296..72d9076cb2 100755 --- a/share/scripts/debian/net-vmcontext/vmcontext +++ b/share/scripts/debian/net-vmcontext/vmcontext @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/scripts/ganglia/push_ganglia b/share/scripts/ganglia/push_ganglia index ce5316e06a..ed7a90f989 100755 --- a/share/scripts/ganglia/push_ganglia +++ b/share/scripts/ganglia/push_ganglia @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/scripts/one b/share/scripts/one index 4f3514cd06..503cec61c6 100755 --- a/share/scripts/one +++ b/share/scripts/one @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/scripts/openSUSE/context/init.sh b/share/scripts/openSUSE/context/init.sh index db1cd90308..11d90e95cf 100644 --- a/share/scripts/openSUSE/context/init.sh +++ b/share/scripts/openSUSE/context/init.sh @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/scripts/openSUSE/net-vmcontext/vmcontext b/share/scripts/openSUSE/net-vmcontext/vmcontext index 7e51b8879f..3d17da24f6 100755 --- a/share/scripts/openSUSE/net-vmcontext/vmcontext +++ b/share/scripts/openSUSE/net-vmcontext/vmcontext @@ -4,7 +4,7 @@ # description: network reconfigure # # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/scripts/tgt/tgt-setup-lun-one b/share/scripts/tgt/tgt-setup-lun-one new file mode 100755 index 0000000000..faf08949b5 --- /dev/null +++ b/share/scripts/tgt/tgt-setup-lun-one @@ -0,0 +1,279 @@ +#!/bin/bash + +# LUN assignment script +# +# Copyright (C) 2007 Erez Zilber +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, version 2 of the +# License. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +# 02110-1301 USA + +usage() +{ + name=$(basename $0); + echo "usage:"; + echo -e "\t$name -n tgt_name -d dev -b bs_name -t transport [initiator_IP1 initiator_IP2 ...]"; + echo "defaults:"; + echo -e "\tbacking store: rdwr"; + echo -e "\ttransport: iscsi"; + echo -e "\tinitiator: ALL"; + echo "examples:"; + echo -e "\t$name -n tgt-1 -d /dev/sdb1 192.168.1.2"; + echo -e "\t$name -n tgt-2 -d /tmp/null -b null -t iser"; + echo -e "\t$name -n tgt-3 -d ~/disk3.bin -b rdwr 192.168.1.2 192.168.1.3"; +} + +verify_params() +{ + if ! [ "$dev" -o "$bs_type" == "null" ]; then + echo "Error: a device is mandatory"; + exit 1; + else + return; + fi + + # Make sure that the device exists + if ! [ -b $dev -o -f $dev -o -c $dev ]; then + echo "Error: $dev is not a device"; + exit 1; + fi + + if ! [ "$tgt_name" ]; then + echo "Error: target name is mandatory"; + exit 1; + fi + + if ! [ "$lld_name" ]; then + echo "Error: lld name empty"; + exit 1; + fi +} + +find_vacant_tgt_id() +{ + tmp_file=`mktemp` + tgtadm --lld $lld_name --op show --mode target | strings > $tmp_file + id_list=$(cat $tmp_file | grep Target | cut -d" " -f2 | sed s/://) + next_vacant_id=1 + for id in $id_list; do + if (($id > $next_vacant_id)); then + break; + else + next_vacant_id=$((next_vacant_id+1)) + fi + done + rm -f $tmp_file + echo $next_vacant_id +} + +find_vacant_lun() +{ + tid=$1 + tgt_found=0 + next_vacant_lun=0 + tmp_file=`mktemp` + + tgtadm --lld $lld_name --op show --mode target | strings | tgt-admin -s | grep 'LUN\|Target' > $tmp_file + retcode=$? + while read line; do + # Check if we finished going over this target + if ((tgt_found == 1 && $(echo $line | grep -c "^Target") == 1)); then + break + fi + + # Check if we found the requested target + if (($(echo $line | grep -c "Target $tid:") == 1)); then + tgt_found=1 + continue + fi + + if ((tgt_found == 1 && $(echo $line | grep -c "LUN:") == 1)); then + curr_lun=$(echo $line | cut -d" " -f2) + if (($curr_lun > $next_vacant_lun)); then + break + else + next_vacant_lun=$((next_vacant_lun+1)) + fi + fi + done < $tmp_file + + rm -f $tmp_file + + if ((tgt_found == 0)); then + echo "Error: could not find a LUN for target $tid, guessing 1 as next vacant LUN" + return 1 + fi + if ((next_vacant_lun == 0)); then + echo "Error: could not find a LUN for target $tid, guessing 1 as next vacant LUN" + return 1 + fi + + return $next_vacant_lun +} + +err_exit() +{ + if ((new_tgt == 0)); then + exit 1 + fi + + echo "Deleting new target, tid=$tid" + tgtadm --lld $lld_name --op delete --mode target --tid $tid + res=$? + + if [ $res -ne 0 ]; then + echo "Error: failed to delete target, tid=$tid" + fi + + exit 1 +} + +check_if_tgt_exists() +{ + tgt_list=$(tgtadm --lld $lld_name --op show --mode target | strings | grep Target | cut -d" " -f3) + + for curr_tgt in $tgt_list; do + if [ $tgt_name = $curr_tgt ]; then + return 1 + fi + done + + return 0 +} + +if [ $# -eq 0 ]; then + usage + exit 1 +fi + +lld_name="iscsi" + +while getopts "d:n:b:t:h:" opt +do + case ${opt} in + d) + dev=$OPTARG;; + n) + tgt_name=$OPTARG;; + b) + bs_type=$OPTARG;; + t) + lld_name=$OPTARG;; + h*) + usage + exit 1 + esac +done + +shift $(($OPTIND - 1)) + +initiators=$* + +verify_params + +# Check if tgtd is running (we should have 2 daemons) +tgtd_count=`pidof tgtd | wc -w` +if [ $tgtd_count -lt 1 ]; then + echo "tgtd is not running" + echo "Exiting..." + exit 1 +fi + +echo "Using transport: $lld_name" + +if ! [[ $tgt_name =~ ^iqn ]]; then + tgt_name="iqn.2001-04.com.$(hostname -s)-$tgt_name" +fi + +# Make sure that a target with the same name doesn't exist +check_if_tgt_exists +if [ $? -eq 1 ]; then + echo "Error: target named $tgt_name already exists" + read -p "Add a new lun to the existing target? (yes/NO): " add_lun + if [ $add_lun != "yes" ]; then + exit 1 + fi + tid=$(tgtadm --lld $lld_name --op show --mode target | strings | grep $tgt_name | cut -d" " -f2) + tid=${tid%:} + new_tgt=0 +else + + i=0 + while [ true ] + do + let i=i+1 + tid=`find_vacant_tgt_id` + #tid=$? + # Create the new target + echo -n "Creating new target (name=$tgt_name, tid=$tid)..." + tgtoutput=`tgtadm --lld $lld_name --op new --mode target --tid $tid -T $tgt_name 2>&1` + res=$? + if [ "$tgtoutput" == "tgtadm: this target already exists" ]; then + echo "Target already exists (this should not happen)... Attempt $i" + elif [ $res -eq 0 ]; then # output is not about duplication and return value is zero, this is the normal condition + break + fi + if [ $i -eq 100 ]; then + echo "Too many attempts, giving up" + break + fi + done + if [ $res -ne 0 ]; then + echo "Error: failed to create target (name=$tgt_name, tid=$tid)" + exit 1 + fi + new_tgt=1 +fi +echo "OK" +find_vacant_lun $tid +lun=$? +echo "LUN ok, $lun" + +# Add a logical unit to the target +echo "Adding a logical unit ($dev) to target, tid=$tid" +if [ $bs_type ]; then + echo "Setting backing store type: $bs_type" + bs_opt="-E $bs_type" +fi +tgtadm --lld $lld_name --op new --mode logicalunit --tid $tid --lun $lun -b $dev $bs_opt +res=$? + +if [ $res -ne 0 ]; then + echo "Error: failed to add a logical unit ($dev) to target, tid=$tid" + err_exit +fi + +# Define which initiators can use this target +if test "$initiators" ; then + # Allow access only for specific initiators + echo "Accepting connections only from $initiators" + for initiator in $initiators; do + tgtadm --lld $lld_name --op bind --mode target --tid $tid -I $initiator + res=$? + + if [ $res -ne 0 ]; then + echo "Error: could not assign initiator $initiator to the target" + fi + done +else + # Allow access for everyone + echo "Accepting connections from all initiators" + tgtadm --lld $lld_name --op bind --mode target --tid $tid -I ALL + res=$? + + if [ $res -ne 0 ]; then + echo "Error: failed to set access for all initiators" + err_exit + fi +fi diff --git a/share/scripts/ttylinux/context/init.sh b/share/scripts/ttylinux/context/init.sh index 3008708b9f..335316cf0d 100644 --- a/share/scripts/ttylinux/context/init.sh +++ b/share/scripts/ttylinux/context/init.sh @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/scripts/ttylinux/net-vmcontext/vmcontexttty b/share/scripts/ttylinux/net-vmcontext/vmcontexttty index f0418533b6..f5f7075b93 100755 --- a/share/scripts/ttylinux/net-vmcontext/vmcontexttty +++ b/share/scripts/ttylinux/net-vmcontext/vmcontexttty @@ -4,7 +4,7 @@ # description: network reconfigure # # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/scripts/ubuntu/context/init.sh b/share/scripts/ubuntu/context/init.sh index e647eea0a7..33385d508c 100644 --- a/share/scripts/ubuntu/context/init.sh +++ b/share/scripts/ubuntu/context/init.sh @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/scripts/ubuntu/net-vmcontext/README b/share/scripts/ubuntu/net-vmcontext/README index dd850ec6ec..6cff01b10a 100755 --- a/share/scripts/ubuntu/net-vmcontext/README +++ b/share/scripts/ubuntu/net-vmcontext/README @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/scripts/ubuntu/net-vmcontext/vmcontext b/share/scripts/ubuntu/net-vmcontext/vmcontext index a0144c7296..72d9076cb2 100755 --- a/share/scripts/ubuntu/net-vmcontext/vmcontext +++ b/share/scripts/ubuntu/net-vmcontext/vmcontext @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/share/scripts/vmcontext.sh b/share/scripts/vmcontext.sh index 28148290f8..fa9b311744 100755 --- a/share/scripts/vmcontext.sh +++ b/share/scripts/vmcontext.sh @@ -14,7 +14,7 @@ ### END INIT INFO # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/acl/AclManager.cc b/src/acl/AclManager.cc index 69f180be68..b455da5ee5 100644 --- a/src/acl/AclManager.cc +++ b/src/acl/AclManager.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -168,6 +168,19 @@ const bool AclManager::authorize( resource_gid_req = AclRule::NONE_ID; } + long long resource_cid_req; + + if ( obj_perms.cid >= 0 ) + { + resource_cid_req = obj_perms.obj_type | + AclRule::CLUSTER_ID | + obj_perms.cid; + } + else + { + resource_cid_req = AclRule::NONE_ID; + } + long long resource_all_req = obj_perms.obj_type | AclRule::ALL_ID; long long rights_req = op; @@ -179,6 +192,10 @@ const bool AclManager::authorize( AclRule::GROUP_ID | 0x00000000FFFFFFFFLL; + long long resource_cid_mask = obj_perms.obj_type | + AclRule::CLUSTER_ID | + 0x00000000FFFFFFFFLL; + // Create a temporal rule, to log the request long long log_resource; @@ -190,6 +207,10 @@ const bool AclManager::authorize( { log_resource = resource_gid_req; } + else if ( obj_perms.cid >= 0 ) + { + log_resource = resource_cid_req; + } else { log_resource = resource_all_req; @@ -226,10 +247,12 @@ const bool AclManager::authorize( auth = match_rules_wrapper(user_req, resource_oid_req, resource_gid_req, + resource_cid_req, resource_all_req, rights_req, resource_oid_mask, resource_gid_mask, + resource_cid_mask, tmp_rules); if ( auth == true ) { @@ -244,10 +267,12 @@ const bool AclManager::authorize( auth = match_rules_wrapper(user_req, resource_oid_req, resource_gid_req, + resource_cid_req, resource_all_req, rights_req, resource_oid_mask, resource_gid_mask, + resource_cid_mask, tmp_rules); if ( auth == true ) { @@ -262,10 +287,12 @@ const bool AclManager::authorize( auth = match_rules_wrapper(user_req, resource_oid_req, resource_gid_req, + resource_cid_req, resource_all_req, rights_req, resource_oid_mask, resource_gid_mask, + resource_cid_mask, tmp_rules); if ( auth == true ) { @@ -285,10 +312,12 @@ bool AclManager::match_rules_wrapper( long long user_req, long long resource_oid_req, long long resource_gid_req, + long long resource_cid_req, long long resource_all_req, long long rights_req, long long individual_obj_type, long long group_obj_type, + long long cluster_obj_type, multimap &tmp_rules) { bool auth = false; @@ -298,10 +327,12 @@ bool AclManager::match_rules_wrapper( user_req, resource_oid_req, resource_gid_req, + resource_cid_req, resource_all_req, rights_req, individual_obj_type, group_obj_type, + cluster_obj_type, tmp_rules); if ( auth == true ) @@ -316,10 +347,12 @@ bool AclManager::match_rules_wrapper( user_req, resource_oid_req, resource_gid_req, + resource_cid_req, resource_all_req, rights_req, individual_obj_type, group_obj_type, + cluster_obj_type, acl_rules); unlock(); @@ -334,10 +367,12 @@ bool AclManager::match_rules( long long user_req, long long resource_oid_req, long long resource_gid_req, + long long resource_cid_req, long long resource_all_req, long long rights_req, long long resource_oid_mask, long long resource_gid_mask, + long long resource_cid_mask, multimap &rules) { @@ -370,6 +405,9 @@ bool AclManager::match_rules( || // Or rule's object type and individual object ID match ( ( it->second->resource & resource_oid_mask ) == resource_oid_req ) + || + // Or rule's object type and cluster object ID match + ( ( it->second->resource & resource_cid_mask ) == resource_cid_req ) ); if ( auth == true ) @@ -586,6 +624,20 @@ void AclManager::del_gid_rules(int gid) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +void AclManager::del_cid_rules(int cid) +{ + long long request = AclRule::CLUSTER_ID | cid; + long long resource_gid_mask = AclRule::CLUSTER_ID | + 0x00000000FFFFFFFFLL; + + // Delete rules that match + // __ __/%cid __ + del_resource_matching_rules(request, resource_gid_mask); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + void AclManager::del_resource_rules(int oid, PoolObjectSQL::ObjectType obj_type) { long long request = obj_type | @@ -669,7 +721,8 @@ void AclManager::reverse_search(int uid, AuthRequest::Operation op, bool& all, vector& oids, - vector& gids) + vector& gids, + vector& cids) { ostringstream oss; @@ -681,6 +734,7 @@ void AclManager::reverse_search(int uid, long long resource_oid_req = obj_type | AclRule::INDIVIDUAL_ID; long long resource_gid_req = obj_type | AclRule::GROUP_ID; long long resource_all_req = obj_type | AclRule::ALL_ID; + long long resource_cid_req = obj_type | AclRule::CLUSTER_ID; long long rights_req = op; long long resource_oid_mask = @@ -689,6 +743,9 @@ void AclManager::reverse_search(int uid, long long resource_gid_mask = ( obj_type | AclRule::GROUP_ID ); + long long resource_cid_mask = + ( obj_type | AclRule::CLUSTER_ID ); + // Create a temporal rule, to log the request long long log_resource; @@ -751,6 +808,13 @@ void AclManager::reverse_search(int uid, { oids.push_back(it->second->resource_id()); } + + // Rule grants permission for all objects of a cluster + if ( ( it->second->resource & resource_cid_mask ) == resource_cid_req ) + { + cids.push_back(it->second->resource_id()); + } + } } @@ -760,6 +824,7 @@ void AclManager::reverse_search(int uid, { oids.clear(); gids.clear(); + cids.clear(); } } } diff --git a/src/acl/AclRule.cc b/src/acl/AclRule.cc index 561b8634e3..6233168c7a 100644 --- a/src/acl/AclRule.cc +++ b/src/acl/AclRule.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -17,13 +17,14 @@ #include "AclRule.h" #include "AuthRequest.h" #include "PoolObjectSQL.h" - + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ const long long AclRule::INDIVIDUAL_ID = 0x0000000100000000LL; const long long AclRule::GROUP_ID = 0x0000000200000000LL; const long long AclRule::ALL_ID = 0x0000000400000000LL; +const long long AclRule::CLUSTER_ID = 0x0000000800000000LL; const long long AclRule::NONE_ID = 0x1000000000000000LL; @@ -49,6 +50,11 @@ const AuthRequest::Operation AclRule::auth_operations[] = { AuthRequest::CREATE }; +const long long AclRule::INVALID_CLUSTER_OBJECTS = + PoolObjectSQL::VM | PoolObjectSQL::IMAGE | PoolObjectSQL::USER | + PoolObjectSQL::TEMPLATE | PoolObjectSQL::GROUP | PoolObjectSQL::ACL | + PoolObjectSQL::CLUSTER | PoolObjectSQL::DOCUMENT; + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -56,6 +62,7 @@ bool AclRule::malformed(string& error_str) const { ostringstream oss; bool error = false; + long long resource_type; // Check user @@ -122,7 +129,11 @@ bool AclRule::malformed(string& error_str) const // Check resource - if ( (resource & INDIVIDUAL_ID) != 0 && (resource & GROUP_ID) != 0 ) + if ( ( (resource & INDIVIDUAL_ID) != 0 && (resource & 0xF00000000LL) != INDIVIDUAL_ID ) || + ( (resource & GROUP_ID) != 0 && (resource & 0xF00000000LL) != GROUP_ID ) || + ( (resource & CLUSTER_ID) != 0 && (resource & 0xF00000000LL) != CLUSTER_ID ) || + ( (resource & ALL_ID) != 0 && (resource & 0xF00000000LL) != ALL_ID ) + ) { if ( error ) { @@ -130,10 +141,13 @@ bool AclRule::malformed(string& error_str) const } error = true; - oss << "[resource] INDIVIDUAL (#) and GROUP (@) bits are exclusive"; + oss << "[resource] INDIVIDUAL (#), GROUP (@), CLUSTER (%) " + << "and ALL (*) bits are exclusive"; } - if ( (resource & INDIVIDUAL_ID) != 0 && (resource & ALL_ID) != 0 ) + resource_type = resource_code() & 0xFFFFFFF000000000LL; + + if ((resource & CLUSTER_ID) && (resource_type & INVALID_CLUSTER_OBJECTS)) { if ( error ) { @@ -141,10 +155,13 @@ bool AclRule::malformed(string& error_str) const } error = true; - oss << "[resource] INDIVIDUAL (#) and ALL (*) bits are exclusive"; + oss << "[resource] CLUSTER(%) selector can be applied only to " + << PoolObjectSQL::type_to_str(PoolObjectSQL::DATASTORE) << ", " + << PoolObjectSQL::type_to_str(PoolObjectSQL::HOST) << " and " + << PoolObjectSQL::type_to_str(PoolObjectSQL::NET) << " types"; } - if ( (resource & GROUP_ID) != 0 && (resource & ALL_ID) != 0 ) + if ( (resource & 0xF00000000LL) == 0 ) { if ( error ) { @@ -152,18 +169,7 @@ bool AclRule::malformed(string& error_str) const } error = true; - oss << "[resource] GROUP (@) and ALL (*) bits are exclusive"; - } - - if ( (resource & 0x700000000LL) == 0 ) - { - if ( error ) - { - oss << "; "; - } - - error = true; - oss << "[resource] is missing one of the INDIVIDUAL, GROUP or ALL bits"; + oss << "[resource] is missing one of the INDIVIDUAL, GROUP, CLUSTER or ALL bits"; } if ( resource_id() < 0 ) @@ -294,6 +300,10 @@ void AclRule::build_str() { oss << "#" << resource_id(); } + else if ( (resource & CLUSTER_ID) != 0 ) + { + oss << "%" << resource_id(); + } else if ( (resource & ALL_ID) != 0 ) { oss << "*"; @@ -302,7 +312,7 @@ void AclRule::build_str() { oss << "??"; } - + oss << " "; prefix = false; @@ -360,7 +370,7 @@ int AclRule::from_xml(xmlNodePtr node) break; } - xmlNodePtr elem = acl->children; + xmlNodePtr elem = acl->children; if ( elem->type != XML_TEXT_NODE ) { diff --git a/src/acl/SConstruct b/src/acl/SConstruct index 1a115fba08..568bd3499f 100644 --- a/src/acl/SConstruct +++ b/src/acl/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/authm # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/authm/AuthManager.cc b/src/authm/AuthManager.cc index c7ba3b694b..4c31b8500a 100644 --- a/src/authm/AuthManager.cc +++ b/src/authm/AuthManager.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -17,7 +17,7 @@ #include "AuthManager.h" #include "AuthRequest.h" #include "NebulaLog.h" -#include "SSLTools.h" +#include "NebulaUtil.h" #include "PoolObjectAuth.h" #include "Nebula.h" @@ -40,7 +40,7 @@ void AuthRequest::add_auth(Operation op, if ( !ob_template.empty() ) { - string * encoded_id = SSLTools::base64_encode(ob_template); + string * encoded_id = one_util::base64_encode(ob_template); if (encoded_id != 0) { diff --git a/src/authm/AuthManagerDriver.cc b/src/authm/AuthManagerDriver.cc index b83858497d..d4b4b93b5f 100644 --- a/src/authm/AuthManagerDriver.cc +++ b/src/authm/AuthManagerDriver.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/authm/SConstruct b/src/authm/SConstruct index a327a94f39..1d11fafa0d 100644 --- a/src/authm/SConstruct +++ b/src/authm/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/authm # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/authm/test/AuthManagerTest.cc b/src/authm/test/AuthManagerTest.cc index d5c709aa2f..f2834c7b36 100644 --- a/src/authm/test/AuthManagerTest.cc +++ b/src/authm/test/AuthManagerTest.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/authm/test/SConstruct b/src/authm/test/SConstruct index 3d7c89cba9..0ca18a3858 100644 --- a/src/authm/test/SConstruct +++ b/src/authm/test/SConstruct @@ -1,4 +1,4 @@ -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/authm/test/dummy b/src/authm/test/dummy index c3fa9f79ee..56a2d8474b 100755 --- a/src/authm/test/dummy +++ b/src/authm/test/dummy @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/authm_mad/one_auth_mad b/src/authm_mad/one_auth_mad index 837f5b9390..492970da97 100755 --- a/src/authm_mad/one_auth_mad +++ b/src/authm_mad/one_auth_mad @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/authm_mad/one_auth_mad.rb b/src/authm_mad/one_auth_mad.rb index b440c0791d..172275d1db 100755 --- a/src/authm_mad/one_auth_mad.rb +++ b/src/authm_mad/one_auth_mad.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/authm_mad/remotes/dummy/authenticate b/src/authm_mad/remotes/dummy/authenticate index 0917ac6d84..d0c9c24dc2 100755 --- a/src/authm_mad/remotes/dummy/authenticate +++ b/src/authm_mad/remotes/dummy/authenticate @@ -1,7 +1,7 @@ #!/usr/bin/env bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/authm_mad/remotes/ldap/authenticate b/src/authm_mad/remotes/ldap/authenticate index 516c3e37b1..0beea92d5a 100755 --- a/src/authm_mad/remotes/ldap/authenticate +++ b/src/authm_mad/remotes/ldap/authenticate @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # ---------------------------------------------------------------------------- # -# Copyright 2010-2012, C12G Labs S.L # +# Copyright 2010-2013, C12G Labs S.L # # # # 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 # @@ -29,7 +29,7 @@ end $: << RUBY_LIB_LOCATION require 'yaml' -require 'ldap_auth' +require 'opennebula/ldap_auth' require 'uri' if defined?(URI::Parser) @@ -66,7 +66,7 @@ order.each do |server_name| end begin - ldap=LdapAuth.new(server_conf) + ldap=OpenNebula::LdapAuth.new(server_conf) user_name=ldap.find_user(user) diff --git a/src/authm_mad/remotes/ldap/ldap_auth.conf b/src/authm_mad/remotes/ldap/ldap_auth.conf index af016f554e..400ccd50aa 100644 --- a/src/authm_mad/remotes/ldap/ldap_auth.conf +++ b/src/authm_mad/remotes/ldap/ldap_auth.conf @@ -1,5 +1,5 @@ # ---------------------------------------------------------------------------- # -# Copyright 2010-2012, C12G Labs S.L # +# Copyright 2010-2013, C12G Labs S.L # # # # 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 # @@ -28,6 +28,9 @@ server 1: :host: localhost :port: 389 + # Uncomment this line for tsl conections + #:encryption: :simple_tls + # base hierarchy where to search for users and groups :base: 'dc=domain' diff --git a/src/authm_mad/remotes/ldap/ldap_auth.rb b/src/authm_mad/remotes/ldap/ldap_auth.rb index 4090628fed..498c2bc9bc 100644 --- a/src/authm_mad/remotes/ldap/ldap_auth.rb +++ b/src/authm_mad/remotes/ldap/ldap_auth.rb @@ -1,5 +1,5 @@ # ---------------------------------------------------------------------------- # -# Copyright 2010-2012, C12G Labs S.L # +# Copyright 2010-2013, C12G Labs S.L # # # # 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 # @@ -17,7 +17,9 @@ require 'rubygems' require 'net/ldap' -class LdapAuth +module OpenNebula; end + +class OpenNebula::LdapAuth def initialize(options) @options={ :host => 'localhost', @@ -41,6 +43,7 @@ class LdapAuth ops[:host]=@options[:host] if @options[:host] ops[:port]=@options[:port].to_i if @options[:port] + ops[:encryption]=@options[:encryption] if @options[:encryption] @ldap=Net::LDAP.new(ops) end diff --git a/src/authm_mad/remotes/ldap/test/ldap_auth_spec.rb b/src/authm_mad/remotes/ldap/test/ldap_auth_spec.rb index 62b72dc9ac..bf5edfee73 100644 --- a/src/authm_mad/remotes/ldap/test/ldap_auth_spec.rb +++ b/src/authm_mad/remotes/ldap/test/ldap_auth_spec.rb @@ -1,5 +1,5 @@ # ---------------------------------------------------------------------------- # -# Copyright 2010-2012, C12G Labs S.L # +# Copyright 2010-2013, C12G Labs S.L # # # # 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 # diff --git a/src/authm_mad/remotes/plain/authenticate b/src/authm_mad/remotes/plain/authenticate index 36489712fd..8981d7b265 100755 --- a/src/authm_mad/remotes/plain/authenticate +++ b/src/authm_mad/remotes/plain/authenticate @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/authm_mad/remotes/server_cipher/authenticate b/src/authm_mad/remotes/server_cipher/authenticate index 9973e6e5ba..812932bf2a 100755 --- a/src/authm_mad/remotes/server_cipher/authenticate +++ b/src/authm_mad/remotes/server_cipher/authenticate @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -28,7 +28,7 @@ end $: << RUBY_LIB_LOCATION -require 'server_cipher_auth' +require 'opennebula/server_cipher_auth' require 'scripts_common' user = ARGV[0] # username as registered in OpenNebula @@ -38,7 +38,7 @@ secret = ARGV[2] # Base64 encoded secret as obtained from login_token #OpenNebula.log_debug("Authenticating #{user}, with password #{pass} (#{secret})") begin - server_auth = ServerCipherAuth.new_driver + server_auth = OpenNebula::ServerCipherAuth.new_driver rc = server_auth.authenticate(user, pass, secret) rescue => e OpenNebula.error_message e.message @@ -50,4 +50,4 @@ if rc == true else OpenNebula.error_message rc exit -1 -end \ No newline at end of file +end diff --git a/src/authm_mad/remotes/server_cipher/server_cipher_auth.rb b/src/authm_mad/remotes/server_cipher/server_cipher_auth.rb index 22ed7239fd..78476efa7d 100644 --- a/src/authm_mad/remotes/server_cipher/server_cipher_auth.rb +++ b/src/authm_mad/remotes/server_cipher/server_cipher_auth.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -20,10 +20,12 @@ require 'digest/sha1' require 'base64' require 'fileutils' +module OpenNebula; end + # Server authentication class. This method can be used by OpenNebula services # to let access authenticated users by other means. It is based on OpenSSL # symmetric ciphers -class ServerCipherAuth +class OpenNebula::ServerCipherAuth ########################################################################### #Constants with paths to relevant files and defaults ########################################################################### @@ -142,4 +144,5 @@ class ServerCipherAuth return rc end -end \ No newline at end of file +end + diff --git a/src/authm_mad/remotes/server_x509/authenticate b/src/authm_mad/remotes/server_x509/authenticate index 77be2ea3f5..bcb789ab7f 100755 --- a/src/authm_mad/remotes/server_x509/authenticate +++ b/src/authm_mad/remotes/server_x509/authenticate @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -28,7 +28,7 @@ end $: << RUBY_LIB_LOCATION -require 'server_x509_auth' +require 'opennebula/server_x509_auth' require 'scripts_common' user = ARGV[0] # username as registered in OpenNebula @@ -38,7 +38,7 @@ secret = ARGV[2] # Base64 encoded secret as obtained from login_token #OpenNebula.log_debug("Authenticating #{user}, with password #{pass} (#{secret})") begin - server_auth = ServerX509Auth.new + server_auth = OpenNebula::ServerX509Auth.new dsecret = Base64::decode64(secret) rc = server_auth.authenticate(user, pass, dsecret) diff --git a/src/authm_mad/remotes/server_x509/server_x509_auth.rb b/src/authm_mad/remotes/server_x509/server_x509_auth.rb index 27c1df42ee..6799e43fd6 100644 --- a/src/authm_mad/remotes/server_x509/server_x509_auth.rb +++ b/src/authm_mad/remotes/server_x509/server_x509_auth.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -18,12 +18,14 @@ require 'openssl' require 'base64' require 'fileutils' -require 'x509_auth' +require 'opennebula/x509_auth' + +module OpenNebula; end # Server authentication class. This authmethod can be used by opennebula services # to let access authenticated users by other means. It is based on x509 server # certificates -class ServerX509Auth < X509Auth +class OpenNebula::ServerX509Auth < OpenNebula::X509Auth ########################################################################### #Constants with paths to relevant files and defaults ########################################################################### @@ -61,7 +63,7 @@ class ServerX509Auth < X509Auth ########################################################################### # Creates a ServerCipher for client and driver sage - class << ServerX509Auth + class << OpenNebula::ServerX509Auth alias :new_client :new alias :new_driver :new end @@ -99,4 +101,4 @@ class ServerX509Auth < X509Auth return e.message end end -end \ No newline at end of file +end diff --git a/src/authm_mad/remotes/ssh/authenticate b/src/authm_mad/remotes/ssh/authenticate index d272ec0b57..e93e1abf02 100755 --- a/src/authm_mad/remotes/ssh/authenticate +++ b/src/authm_mad/remotes/ssh/authenticate @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -28,7 +28,7 @@ end $: << RUBY_LIB_LOCATION -require 'ssh_auth' +require 'opennebula/ssh_auth' require 'scripts_common' user = ARGV[0] @@ -37,7 +37,7 @@ secret = ARGV[2] #OpenNebula.log_debug("Authenticating #{user}, with password #{pass} (#{secret})") begin - ssh_auth = SshAuth.new(:public_key=>pass) + ssh_auth = OpenNebula::SshAuth.new(:public_key=>pass) rescue Exception => e OpenNebula.error_message e.message exit -1 diff --git a/src/authm_mad/remotes/ssh/ssh_auth.rb b/src/authm_mad/remotes/ssh/ssh_auth.rb index 7a322337cf..0b8275b115 100644 --- a/src/authm_mad/remotes/ssh/ssh_auth.rb +++ b/src/authm_mad/remotes/ssh/ssh_auth.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -20,10 +20,12 @@ require 'openssl' require 'base64' require 'fileutils' +module OpenNebula; end + # SSH key authentication class. It can be used as a driver for auth_mad # as auth method is defined. It also holds some helper methods to be used # by oneauth command -class SshAuth +class OpenNebula::SshAuth LOGIN_PATH = ENV['HOME']+'/.one/one_ssh' # Initialize SshAuth object diff --git a/src/authm_mad/remotes/x509/authenticate b/src/authm_mad/remotes/x509/authenticate index 5722049887..ffa2d95c7e 100755 --- a/src/authm_mad/remotes/x509/authenticate +++ b/src/authm_mad/remotes/x509/authenticate @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -28,7 +28,7 @@ end $: << RUBY_LIB_LOCATION -require 'x509_auth' +require 'opennebula/x509_auth' require 'scripts_common' user = ARGV[0] # username as registered in OpenNebula @@ -44,7 +44,7 @@ begin token = asecret[0] certs = asecret[1..-1] - x509_auth = X509Auth.new(:certs_pem=>certs) + x509_auth = OpenNebula::X509Auth.new(:certs_pem=>certs) rc = x509_auth.authenticate(user, pass, token) rescue => e diff --git a/src/authm_mad/remotes/x509/x509_auth.rb b/src/authm_mad/remotes/x509/x509_auth.rb index cad0ca7f29..4cdb0c7890 100644 --- a/src/authm_mad/remotes/x509/x509_auth.rb +++ b/src/authm_mad/remotes/x509/x509_auth.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -19,10 +19,12 @@ require 'base64' require 'fileutils' require 'yaml' +module OpenNebula; end + # X509 authentication class. It can be used as a driver for auth_mad # as auth method is defined. It also holds some helper methods to be used # by oneauth command -class X509Auth +class OpenNebula::X509Auth ########################################################################### #Constants with paths to relevant files and defaults ########################################################################### @@ -40,6 +42,14 @@ class X509Auth :ca_dir => ETC_LOCATION + "/auth/certificates" } + def self.escape_dn(dn) + dn.gsub(/\s/) { |s| "\\"+s[0].ord.to_s(16) } + end + + def self.unescape_dn(dn) + dn.gsub(/\\[0-9a-f]{2}/) { |s| s[1,2].to_i(16).chr } + end + ########################################################################### # Initialize x509Auth object # @@ -79,7 +89,7 @@ class X509Auth # Returns a valid password string to create a user using this auth driver. # In this case the dn of the user certificate. def password - @cert_chain[0].subject.to_s.delete("\s") + self.class.escape_dn(@cert_chain[0].subject.to_s) end # Generates a login token in the form: @@ -121,7 +131,8 @@ class X509Auth # Some DN in the chain must match a DN in the password dn_ok = @cert_chain.each do |cert| - if pass.split('|').include?(cert.subject.to_s.delete("\s")) + if pass.split('|').include?( + self.class.escape_dn(cert.subject.to_s)) break true end end diff --git a/src/cli/cli_helper.rb b/src/cli/cli_helper.rb index 4518d633b3..1fbd83b1f1 100644 --- a/src/cli/cli_helper.rb +++ b/src/cli/cli_helper.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -252,6 +252,9 @@ module CLIHelper if @columns[field] minus=( @columns[field][:left] ? "-" : "" ) size=@columns[field][:size] + if @columns[field][:donottruncate] + return "%#{minus}#{size}s" % [ data.to_s ] + end return "%#{minus}#{size}.#{size}s" % [ data.to_s ] else exit -1, "Column #{field} not defined." diff --git a/src/cli/command_parser.rb b/src/cli/command_parser.rb index 41bcce9b78..a75362b9d3 100644 --- a/src/cli/command_parser.rb +++ b/src/cli/command_parser.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -498,15 +498,9 @@ module CommandParser else puts "one parameter to run" end - puts - puts "Usage:" - if @main - print " #{@usage}\n" - else - print " #{name} " - print_command(@commands[name]) - end + print_command_help(name) + exit -1 else id=0 @@ -641,14 +635,20 @@ module CommandParser end def print_option(o) - opt_format = "#{' '*5}%-25s %s" + opt_format = "#{' '*5}%-25s" str = "" str << o[:short].split(' ').first << ', ' if o[:short] str << o[:large] - printf opt_format, str, o[:description] - puts + params=sprintf(opt_format, str) + + first_line=80-params.length + + description=word_wrap(80-32, o[:description], first_line). + join(("\n"+" "*31)) + + puts "#{params} #{description}" end def print_commands @@ -713,6 +713,30 @@ module CommandParser } end + def word_wrap(size, text, first_size=nil) + output=[] + line="" + if first_size + line_size=first_size + else + line_size=size + end + + text.scan(/[^\s]+/) do |word| + if line.length+word.length+1<=line_size + line+=" #{word}" + else + output< 'cpu', @@ -212,6 +213,8 @@ EOT TEMPLATE_OPTIONS_VM=[TEMPLATE_NAME_VM]+TEMPLATE_OPTIONS+[DRY] + CAPACITY_OPTIONS_VM=[TEMPLATE_OPTIONS[0],TEMPLATE_OPTIONS[1],TEMPLATE_OPTIONS[3]] + OPTIONS = XML, NUMERIC, KILOBYTES class OneHelper @@ -315,7 +318,15 @@ EOT pool_to_array(pool) } else - table.show(pool_to_array(pool), options) + array=pool_to_array(pool) + + if options[:ids] + array=array.select do |element| + options[:ids].include? element['ID'].to_i + end + end + + table.show(array, options) end return 0 @@ -331,7 +342,7 @@ EOT if options[:xml] return 0, resource.to_xml(true) else - format_resource(resource) + format_resource(resource, options) return 0 end end @@ -569,13 +580,19 @@ EOT end end - def OpenNebulaHelper.time_to_str(time) + def OpenNebulaHelper.time_to_str(time, print_seconds=true) value=time.to_i if value==0 value='-' else - value=Time.at(value).strftime("%m/%d %H:%M:%S") + if print_seconds + value=Time.at(value).strftime("%m/%d %H:%M:%S") + else + value=Time.at(value).strftime("%m/%d %H:%M") + end end + + return value end def OpenNebulaHelper.period_to_str(time, print_seconds=true) @@ -623,7 +640,7 @@ EOT end end - def OpenNebulaHelper.update_template(id, resource, path=nil) + def OpenNebulaHelper.update_template(id, resource, path=nil, xpath='TEMPLATE') unless path require 'tempfile' @@ -637,7 +654,7 @@ EOT exit -1 end - tmp << resource.template_str + tmp << resource.template_like_str(xpath) tmp.flush editor_path = ENV["EDITOR"] ? ENV["EDITOR"] : EDITOR_PATH diff --git a/src/cli/one_helper/oneacct_helper.rb b/src/cli/one_helper/oneacct_helper.rb index ffd08c048f..385c1f7921 100644 --- a/src/cli/one_helper/oneacct_helper.rb +++ b/src/cli/one_helper/oneacct_helper.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,6 +15,7 @@ #--------------------------------------------------------------------------- # require 'one_helper' +require 'optparse/time' class AcctHelper < OpenNebulaHelper::OneHelper START_TIME = { @@ -22,7 +23,7 @@ class AcctHelper < OpenNebulaHelper::OneHelper :short => "-s TIME", :large => "--start TIME" , :description => "Start date and time to take into account", - :format => String # TODO Time + :format => Time } END_TIME = { @@ -30,7 +31,7 @@ class AcctHelper < OpenNebulaHelper::OneHelper :short => "-e TIME", :large => "--end TIME" , :description => "End date and time", - :format => String # TODO Time + :format => Time } USERFILTER = { @@ -144,7 +145,7 @@ class AcctHelper < OpenNebulaHelper::OneHelper default :VID, :HOSTNAME, :REASON, :START_TIME, :END_TIME, :MEMORY, :CPU, :NET_RX, :NET_TX end - def self.print_start_enc_time_header(start_time, end_time) + def self.print_start_end_time_header(start_time, end_time) print "Showing active history records from " CLIHelper.scr_bold diff --git a/src/cli/one_helper/oneacl_helper.rb b/src/cli/one_helper/oneacl_helper.rb index 989be55de1..aaf009190b 100644 --- a/src/cli/one_helper/oneacl_helper.rb +++ b/src/cli/one_helper/oneacl_helper.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/cli/one_helper/onecluster_helper.rb b/src/cli/one_helper/onecluster_helper.rb index 2cd5716f2d..33028ce83b 100644 --- a/src/cli/one_helper/onecluster_helper.rb +++ b/src/cli/one_helper/onecluster_helper.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -95,13 +95,14 @@ class OneClusterHelper < OpenNebulaHelper::OneHelper OpenNebula::ClusterPool.new(@client) end - def format_resource(cluster) - str="%-15s: %-20s" + def format_resource(cluster, options = {}) + str="%-18s: %-20s" str_h1="%-80s" CLIHelper.print_header(str_h1 % "CLUSTER #{cluster['ID']} INFORMATION") puts str % ["ID", cluster.id.to_s] puts str % ["NAME", cluster.name] + puts str % ["SYSTEM DS", cluster['SYSTEM_DS']] puts CLIHelper.print_header(str_h1 % "CLUSTER TEMPLATE", false) diff --git a/src/cli/one_helper/onedatastore_helper.rb b/src/cli/one_helper/onedatastore_helper.rb index 3123cf18f0..b5ae134e07 100644 --- a/src/cli/one_helper/onedatastore_helper.rb +++ b/src/cli/one_helper/onedatastore_helper.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -95,7 +95,7 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper OpenNebula::DatastorePool.new(@client) end - def format_resource(datastore) + def format_resource(datastore, options = {}) str="%-15s: %-20s" str_h1="%-80s" @@ -110,6 +110,7 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper puts str % ["DS_MAD", datastore['DS_MAD']] puts str % ["TM_MAD", datastore['TM_MAD']] puts str % ["BASE PATH",datastore['BASE_PATH']] + puts str % ["DISK_TYPE",Image::DISK_TYPES[datastore['DISK_TYPE'].to_i]] puts CLIHelper.print_header(str_h1 % "PERMISSIONS",false) diff --git a/src/cli/one_helper/onegroup_helper.rb b/src/cli/one_helper/onegroup_helper.rb index 7bbcaa44dc..6e57657409 100644 --- a/src/cli/one_helper/onegroup_helper.rb +++ b/src/cli/one_helper/onegroup_helper.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -141,7 +141,7 @@ class OneGroupHelper < OpenNebulaHelper::OneHelper OpenNebula::GroupPool.new(@client) end - def format_resource(group) + def format_resource(group, options = {}) system = System.new(@client) default_quotas = system.get_group_quotas() diff --git a/src/cli/one_helper/onehost_helper.rb b/src/cli/one_helper/onehost_helper.rb index e52c4a1704..a5c35ffb88 100644 --- a/src/cli/one_helper/onehost_helper.rb +++ b/src/cli/one_helper/onehost_helper.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -162,7 +162,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper OpenNebula::HostPool.new(@client) end - def format_resource(host) + def format_resource(host, options = {}) str = "%-22s: %-20s" str_h1 = "%-80s" diff --git a/src/cli/one_helper/oneimage_helper.rb b/src/cli/one_helper/oneimage_helper.rb index 0155273a64..9628e4ed8b 100644 --- a/src/cli/one_helper/oneimage_helper.rb +++ b/src/cli/one_helper/oneimage_helper.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,6 +15,7 @@ #--------------------------------------------------------------------------- # require 'one_helper' +require 'one_helper/onevm_helper' class OneImageHelper < OpenNebulaHelper::OneHelper TEMPLATE_OPTIONS=[ @@ -101,14 +102,14 @@ class OneImageHelper < OpenNebulaHelper::OneHelper { :name => "disk_type", :large => "--disk_type disk_type", - :description => "Type of the image (BLOCK, CDROM or FILE)", + :description => "Type of the image (BLOCK, CDROM, RBD or FILE)", :format => String, :proc => lambda do |o, options| type=o.strip.upcase - if %w{BLOCK CDROM FILE}.include? type + if %w{BLOCK CDROM FILE RBD}.include? type [0, type] else - [-1, "Disk type must be BLOCK, CDROM or FILE"] + [-1, "Disk type must be BLOCK, CDROM, RBD or FILE"] end end }, @@ -261,7 +262,7 @@ class OneImageHelper < OpenNebulaHelper::OneHelper OpenNebula::ImagePool.new(@client, user_flag) end - def format_resource(image) + def format_resource(image, options = {}) str="%-15s: %-20s" str_h1="%-80s" @@ -298,6 +299,19 @@ class OneImageHelper < OpenNebulaHelper::OneHelper CLIHelper.print_header(str_h1 % "IMAGE TEMPLATE",false) puts image.template_str + + puts + CLIHelper.print_header("VIRTUAL MACHINES", false) + puts + + vms=image.retrieve_elements("VMS/ID") + + if vms + vms.map!{|e| e.to_i } + onevm_helper=OneVMHelper.new + onevm_helper.client=@client + onevm_helper.list_pool({:ids=>vms}, false) + end end def self.create_image_variables(options, name) @@ -323,9 +337,12 @@ class OneImageHelper < OpenNebulaHelper::OneHelper end template=create_image_variables( - options, template_options-[:persistent, :dry]) + options, template_options-[:persistent, :dry, :prefix]) template<<"PERSISTENT=YES\n" if options[:persistent] + if options[:prefix] + template<<"DEV_PREFIX=\"#{options[:prefix]}\"\n" + end [0, template] end diff --git a/src/cli/one_helper/onequota_helper.rb b/src/cli/one_helper/onequota_helper.rb index 5925c0d6da..3290d76306 100644 --- a/src/cli/one_helper/onequota_helper.rb +++ b/src/cli/one_helper/onequota_helper.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/cli/one_helper/onetemplate_helper.rb b/src/cli/one_helper/onetemplate_helper.rb index 4480283b5e..7d6a5626e3 100644 --- a/src/cli/one_helper/onetemplate_helper.rb +++ b/src/cli/one_helper/onetemplate_helper.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -23,7 +23,7 @@ class OneTemplateHelper < OpenNebulaHelper::OneHelper :format => String, :description => <<-EOT.strip Name of the new VM or TEMPLATE. When instantiating - multiple VMs you can use the\"%i\" wildcard to produce + multiple VMs you can use the \"%i\" wildcard to produce different names such as vm-0, vm-1... EOT } @@ -91,7 +91,7 @@ EOT OpenNebula::TemplatePool.new(@client, user_flag) end - def format_resource(template) + def format_resource(template, options = {}) str="%-15s: %-20s" str_h1="%-80s" diff --git a/src/cli/one_helper/oneuser_helper.rb b/src/cli/one_helper/oneuser_helper.rb index 8a04444ada..b9f6360116 100644 --- a/src/cli/one_helper/oneuser_helper.rb +++ b/src/cli/one_helper/oneuser_helper.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -42,7 +42,8 @@ class OneUserHelper < OpenNebulaHelper::OneHelper end if options[:driver] == OpenNebula::User::X509_AUTH - password.delete!("\s") + require 'opennebula/x509_auth' + password = OpenNebula::X509Auth.escape_dn(password) end if options[:sha1] || options[:driver] == OpenNebula::User::CIPHER_AUTH @@ -60,10 +61,10 @@ class OneUserHelper < OpenNebulaHelper::OneHelper return -1, "You have to specify the --key option" end - require 'ssh_auth' + require 'opennebula/ssh_auth' begin - auth = SshAuth.new(:private_key=>options[:key]) + auth = OpenNebula::SshAuth.new(:private_key=>options[:key]) rescue Exception => e return -1, e.message end @@ -74,11 +75,11 @@ class OneUserHelper < OpenNebulaHelper::OneHelper return -1, "You have to specify the --cert option" end - require 'x509_auth' + require 'opennebula/x509_auth' begin cert = [File.read(options[:cert])] - auth = X509Auth.new(:certs_pem=>cert) + auth = OpenNebula::X509Auth.new(:certs_pem=>cert) rescue Exception => e return -1, e.message end @@ -92,17 +93,17 @@ class OneUserHelper < OpenNebulaHelper::OneHelper def self.login(username, options) case options[:driver] when OpenNebula::User::SSH_AUTH - require 'ssh_auth' + require 'opennebula/ssh_auth' options[:key] ||= ENV['HOME']+'/.ssh/id_rsa' begin - auth = SshAuth.new(:private_key=>options[:key]) + auth = OpenNebula::SshAuth.new(:private_key=>options[:key]) rescue Exception => e return -1, e.message end when OpenNebula::User::X509_AUTH - require 'x509_auth' + require 'opennebula/x509_auth' options[:cert] ||= ENV['X509_USER_CERT'] options[:key] ||= ENV['X509_USER_KEY'] @@ -111,12 +112,12 @@ class OneUserHelper < OpenNebulaHelper::OneHelper certs = [File.read(options[:cert])] key = File.read(options[:key]) - auth = X509Auth.new(:certs_pem=>certs, :key_pem=>key) + auth = OpenNebula::X509Auth.new(:certs_pem=>certs, :key_pem=>key) rescue Exception => e return -1, e.message end when OpenNebula::User::X509_PROXY_AUTH - require 'x509_auth' + require 'opennebula/x509_auth' options[:proxy] ||= ENV['X509_PROXY_CERT'] @@ -129,7 +130,7 @@ class OneUserHelper < OpenNebulaHelper::OneHelper rc = proxy.match(/(-+BEGIN RSA PRIVATE KEY-+\n[^-]*\n-+END RSA PRIVATE KEY-+)/) key= rc[1] - auth = X509Auth.new(:certs_pem=>certs, :key_pem=>key) + auth = OpenNebula::X509Auth.new(:certs_pem=>certs, :key_pem=>key) rescue => e return -1, e.message end @@ -244,7 +245,7 @@ class OneUserHelper < OpenNebulaHelper::OneHelper OpenNebula::UserPool.new(@client) end - def format_resource(user) + def format_resource(user, options = {}) system = System.new(@client) default_quotas = system.get_user_quotas() diff --git a/src/cli/one_helper/onevm_helper.rb b/src/cli/one_helper/onevm_helper.rb index 594ed7f11f..246add5afb 100644 --- a/src/cli/one_helper/onevm_helper.rb +++ b/src/cli/one_helper/onevm_helper.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,6 +15,7 @@ #--------------------------------------------------------------------------- # require 'one_helper' +require 'optparse/time' class OneVMHelper < OpenNebulaHelper::OneHelper MULTIPLE={ @@ -62,6 +63,25 @@ class OneVMHelper < OpenNebulaHelper::OneHelper } } + HOLD = { + :name => "hold", + :large => "--hold", + :description => "Creates the new VM on hold state instead of pending" + } + + SCHEDULE = { + :name => "schedule", + :large => "--schedule TIME", + :description => "Schedules this action to be executed after the given time", + :format => Time + } + + ALL_TEMPLATE = { + :name => "all", + :large => "--all", + :description => "Show all template data" + } + def self.rname "VM" end @@ -146,6 +166,38 @@ class OneVMHelper < OpenNebulaHelper::OneHelper table end + + def schedule_actions(ids,options,action) + # Verbose by default + options[:verbose] = true + + perform_actions( + ids, options, + "#{action} scheduled at #{options[:schedule]}") do |vm| + + rc = vm.info + + if OpenNebula.is_error?(rc) + puts rc.message + exit -1 + end + + ids = vm.retrieve_elements('USER_TEMPLATE/SCHED_ACTION/ID') + + id = 0 + if (!ids.nil? && !ids.empty?) + ids.map! {|e| e.to_i } + id = ids.max + 1 + end + + tmp_str = vm.user_template_str + + tmp_str << "\nSCHED_ACTION = [ID = #{id}, ACTION = #{action}, TIME = #{options[:schedule].to_i}]" + + vm.update(tmp_str) + end + end + private def factory(id=nil) @@ -161,7 +213,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper OpenNebula::VirtualMachinePool.new(@client, user_flag) end - def format_resource(vm) + def format_resource(vm, options = {}) str_h1="%-80s" str="%-20s: %-20s" @@ -217,16 +269,253 @@ class OneVMHelper < OpenNebulaHelper::OneHelper } puts - CLIHelper.print_header(str_h1 % "VIRTUAL MACHINE TEMPLATE",false) - puts vm.template_str + if vm.has_elements?("/VM/TEMPLATE/DISK") + CLIHelper.print_header(str_h1 % "VM DISKS",false) + CLIHelper::ShowTable.new(nil, self) do + column :ID, "", :size=>3 do |d| + d["DISK_ID"] + end + + column :DATASTORE, "", :left, :size=>10 do |d| + d["DATASTORE"] + end + + column :TARGET, "", :size=>6 do |d| + d["TARGET"] + end + + column :IMAGE, "", :left, :size=>35 do |d| + if d["IMAGE"] + d["IMAGE"] + else + case d["TYPE"].upcase + when "FS" + "#{d["FORMAT"]} - "<< + OpenNebulaHelper.unit_to_str(d["SIZE"].to_i, + {}, "M") + when "SWAP" + OpenNebulaHelper.unit_to_str(d["SIZE"].to_i, + {}, "M") + + end + end + end + + column :TYPE, "", :left, :size=>4 do |d| + d["TYPE"].downcase + end + + column :"R/O", "", :size=>3 do |d| + d["READONLY"] + end + + column :"SAVE", "", :size=>4 do |d| + d["SAVE"] || "NO" + end + + column :"CLONE", "", :size=>5 do |d| + d["CLONE"] + end + + column :"SAVE_AS", "", :size=>7 do |d| + d["SAVE_AS"] || "-" + end + + + default :ID, :TARGET, :IMAGE, :TYPE, + :SAVE, :SAVE_AS + end.show([vm.to_hash['VM']['TEMPLATE']['DISK']].flatten, {}) + + while vm.has_elements?("/VM/TEMPLATE/DISK") + vm.delete_element("/VM/TEMPLATE/DISK") + end if !options[:all] + + puts + end + + if vm.has_elements?("/VM/TEMPLATE/NIC") + CLIHelper.print_header(str_h1 % "VM NICS",false) + + vm_nics = vm.to_hash['VM']['TEMPLATE']['NIC'] + + nic_default = {"NETWORK" => "-", + "IP" => "-", + "MAC"=> "-", + "VLAN"=>"no", + "BRIDGE"=>"-"} + nic_id = 0 + array_id = 0 + + vm_nics.each {|nic| + + next if nic.has_key?("NIC_ID") + + nic["NIC_ID"] = nic_id + + if nic.has_key?("IP6_LINK") + ip6_link = {"IP" => nic.delete("IP6_LINK"), + "NIC_ID" => nic_id, + "DOUBLE_ENTRY"=> true} + vm_nics.insert(array_id+1,ip6_link) + + array_id += 1 + end + + if nic.has_key?("IP6_SITE") + ip6_link = {"IP" => nic.delete("IP6_SITE"), + "NIC_ID" => nic_id, + "DOUBLE_ENTRY"=> true} + vm_nics.insert(array_id+1,ip6_link) + + array_id += 1 + end + + if nic.has_key?("IP6_GLOBAL") + ip6_link = {"IP" => nic.delete("IP6_GLOBAL"), + "NIC_ID" => nic_id, + "DOUBLE_ENTRY"=> true} + vm_nics.insert(array_id+1,ip6_link) + + array_id += 1 + end + + nic.merge!(nic_default) {|k,v1,v2| v1} + + nic_id += 1 + array_id += 1 + } + + CLIHelper::ShowTable.new(nil, self) do + column :ID, "", :size=>2 do |d| + if d["DOUBLE_ENTRY"] + "" + else + d["NIC_ID"] + end + end + + column :NETWORK, "", :left, :size=>12 do |d| + if d["DOUBLE_ENTRY"] + "" + else + d["NETWORK"] + end + end + + column :VLAN, "", :size=>4 do |d| + if d["DOUBLE_ENTRY"] + "" + else + d["VLAN"].downcase + end + end + + column :BRIDGE, "", :left, :size=>8 do |d| + if d["DOUBLE_ENTRY"] + "" + else + d["BRIDGE"] + end + end + + column :IP, "",:left, :donottruncate, :size=>15 do |d| + d["IP"] + end + + column :MAC, "", :left, :size=>17 do |d| + if d["DOUBLE_ENTRY"] + "" + else + d["MAC"] + end + end + + end.show([vm_nics].flatten,{}) + + while vm.has_elements?("/VM/TEMPLATE/NIC") + vm.delete_element("/VM/TEMPLATE/NIC") + end if !options[:all] + + puts + end + + if vm.has_elements?("/VM/TEMPLATE/SNAPSHOT") + CLIHelper.print_header(str_h1 % "SNAPSHOTS",false) + + CLIHelper::ShowTable.new(nil, self) do + + column :"ID", "", :size=>4 do |d| + d["SNAPSHOT_ID"] if !d.nil? + end + + column :"TIME", "", :size=>12 do |d| + OpenNebulaHelper.time_to_str(d["TIME"], false) if !d.nil? + end + + column :"NAME", "", :left, :size=>46 do |d| + d["NAME"] if !d.nil? + end + + column :"HYPERVISOR_ID", "", :left, :size=>15 do |d| + d["HYPERVISOR_ID"] if !d.nil? + end + + end.show([vm.to_hash['VM']['TEMPLATE']['SNAPSHOT']].flatten, {}) + + vm.delete_element("/VM/TEMPLATE/SNAPSHOT") + + puts + end if vm.has_elements?("/VM/HISTORY_RECORDS") puts - CLIHelper.print_header(str_h1 % "VIRTUAL MACHINE HISTORY",false) format_history(vm) end + + if vm.has_elements?("/VM/USER_TEMPLATE/SCHED_ACTION") + CLIHelper.print_header(str_h1 % "SCHEDULED ACTIONS",false) + + CLIHelper::ShowTable.new(nil, self) do + + column :"ID", "", :size=>2 do |d| + d["ID"] if !d.nil? + end + + column :"ACTION", "", :left, :size=>10 do |d| + d["ACTION"] if !d.nil? + end + + column :"SCHEDULED", "", :size=>12 do |d| + OpenNebulaHelper.time_to_str(d["TIME"], false) if !d.nil? + end + + column :"DONE", "", :size=>12 do |d| + OpenNebulaHelper.time_to_str(d["DONE"], false) if !d.nil? + end + + column :"MESSAGE", "", :left, :donottruncate, :size=>40 do |d| + d["MESSAGE"] if !d.nil? + end + end.show([vm.to_hash['VM']['USER_TEMPLATE']['SCHED_ACTION']].flatten, {}) + + puts + end + + if vm.has_elements?("/VM/USER_TEMPLATE") + puts + + if !options[:all] + vm.delete_element("/VM/USER_TEMPLATE/SCHED_ACTION") + end + + CLIHelper.print_header(str_h1 % "USER TEMPLATE",false) + puts vm.template_like_str('USER_TEMPLATE') + end + + CLIHelper.print_header(str_h1 % "VIRTUAL MACHINE TEMPLATE",false) + puts vm.template_str end def format_history(vm) diff --git a/src/cli/one_helper/onevnet_helper.rb b/src/cli/one_helper/onevnet_helper.rb index 90902d28cc..d56c89433f 100644 --- a/src/cli/one_helper/onevnet_helper.rb +++ b/src/cli/one_helper/onevnet_helper.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,6 +15,7 @@ #--------------------------------------------------------------------------- # require 'one_helper' +require 'one_helper/onevm_helper' class OneVNetHelper < OpenNebulaHelper::OneHelper def self.rname @@ -97,7 +98,7 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper OpenNebula::VirtualNetworkPool.new(@client, user_flag) end - def format_resource(vn) + def format_resource(vn, options = {}) str_h1="%-80s" CLIHelper.print_header(str_h1 % ["VIRTUAL NETWORK #{vn.id.to_s} INFORMATION"]) @@ -111,8 +112,10 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper puts str % ["TYPE", vn.type_str] puts str % ["BRIDGE", vn["BRIDGE"]] puts str % ["VLAN", OpenNebulaHelper.boolean_to_str(vn['VLAN'])] - puts str % ["PHYSICAL DEVICE", vn["PHYDEV"]] if vn["PHYDEV"] - puts str % ["VLAN ID", vn["VLAN_ID"]] if vn["VLAN_ID"] + puts str % ["PHYSICAL DEVICE", vn["PHYDEV"]] if !vn["PHYDEV"].empty? + puts str % ["VLAN ID", vn["VLAN_ID"]] if !vn["VLAN_ID"].empty? + puts str % ["GLOBAL PREFIX", vn["GLOBAL_PREFIX"]] if !vn["GLOBAL_PREFIX"].empty? + puts str % ["SITE PREFIX", vn["SITE_PREFIX"]] if !vn["SITE_PREFIX"].empty? puts str % ["USED LEASES", vn['TOTAL_LEASES']] puts @@ -152,5 +155,19 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper puts leases_str end } + + puts + CLIHelper.print_header("VIRTUAL MACHINES", false) + puts + + vms=vn.retrieve_elements("LEASES/LEASE/VID") + + if vms + vms=vms.delete_if {|vm| vm=="-1" } + vms.map!{|e| e.to_i } + onevm_helper=OneVMHelper.new + onevm_helper.client=@client + onevm_helper.list_pool({:ids=>vms}, false) + end end end diff --git a/src/cli/oneacct b/src/cli/oneacct index 178a39db7e..ee10867ece 100755 --- a/src/cli/oneacct +++ b/src/cli/oneacct @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -48,8 +48,8 @@ cmd = CommandParser::CmdParser.new(ARGV) do main do filter_flag = (options[:userfilter] || VirtualMachinePool::INFO_ALL) - start_time = options[:start] ? options[:start].to_i : -1 - end_time = options[:end] ? options[:end].to_i : -1 + start_time = options[:start_time] ? options[:start_time].to_i : -1 + end_time = options[:end_time] ? options[:end_time].to_i : -1 common_opts = { :start_time => start_time, @@ -83,7 +83,8 @@ cmd = CommandParser::CmdParser.new(ARGV) do order_by[:order_by_1] = 'VM/UID' order_by[:order_by_2] = 'VM/ID' if options[:split] - acct_hash = pool.accounting(filter_flag, common_opts.merge(order_by)) + acct_hash = pool.accounting(filter_flag, + common_opts.merge(order_by)) if OpenNebula.is_error?(acct_hash) puts acct_hash.message exit -1 diff --git a/src/cli/oneacl b/src/cli/oneacl index 9ad216f9a5..3e5994ebcf 100755 --- a/src/cli/oneacl +++ b/src/cli/oneacl @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/cli/onecluster b/src/cli/onecluster index 0362d908bb..11ddb04bd9 100755 --- a/src/cli/onecluster +++ b/src/cli/onecluster @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -69,7 +69,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do OpenNebulaHelper.rname_to_id(arg, "HOST") end - set :format, :datastoreid, OpenNebulaHelper.rname_to_id_desc("DATASTORE") do |arg| + set :format, :datastoreid, + OpenNebulaHelper.rname_to_id_desc("DATASTORE") do |arg| OpenNebulaHelper.rname_to_id(arg, "DATASTORE") end diff --git a/src/cli/onedatastore b/src/cli/onedatastore index 9f58d16f6c..5f23224acf 100755 --- a/src/cli/onedatastore +++ b/src/cli/onedatastore @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -62,7 +62,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do helper.list_to_id(arg) end - set :format, :clusterid, OpenNebulaHelper.rname_to_id_desc("CLUSTER") do |arg| + set :format, :clusterid, + OpenNebulaHelper.rname_to_id_desc("CLUSTER") do |arg| OpenNebulaHelper.rname_to_id(arg, "CLUSTER") end @@ -82,7 +83,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do Creates a new Datastore from the given template file EOT - command :create, create_desc, :file, :options=>[OneClusterHelper::CLUSTER] do + command :create, create_desc, :file, + :options=>[OneClusterHelper::CLUSTER] do cid = options[:cluster] || ClusterPool::NONE_CLUSTER_ID diff --git a/src/cli/onegroup b/src/cli/onegroup index 660bb7cebb..ebad8da4d5 100755 --- a/src/cli/onegroup +++ b/src/cli/onegroup @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -103,8 +103,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do end quota_desc = <<-EOT.unindent - Set the quota limits for the group. If a path is not provided the editor - will be launched to modify the current quotas. + Set the quota limits for the group. If a path is not provided the + editor will be launched to modify the current quotas. EOT command :quota, quota_desc, :groupid, [:file, nil] do @@ -131,7 +131,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do provided the editor will be launched to create new quotas. EOT - command :batchquota, batchquota_desc, [:range, :groupid_list], [:file, nil] do + command :batchquota, batchquota_desc, [:range, :groupid_list], + [:file, nil] do batch_str = OneQuotaHelper.get_batch_quota(args[1]) helper.perform_actions(args[0], options, "modified") do |group| diff --git a/src/cli/onehost b/src/cli/onehost index 364dfcaf61..b49ad5ed39 100755 --- a/src/cli/onehost +++ b/src/cli/onehost @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -44,7 +44,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do ######################################################################## # Global Options ######################################################################## - set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS + cmd_options=CommandParser::OPTIONS-[CommandParser::VERBOSE] + set :option, cmd_options+OpenNebulaHelper::CLIENT_OPTIONS IM = { :name => "im", diff --git a/src/cli/oneimage b/src/cli/oneimage index e57b1dd413..e70c44fa90 100755 --- a/src/cli/oneimage +++ b/src/cli/oneimage @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -81,7 +81,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do if Image::IMAGE_TYPES.include? type [0, type] else - [1, "Image type not supported. Must be #{Image::IMAGE_TYPES.join(", ")}."] + [1, "Image type not supported. Must be "<< + Image::IMAGE_TYPES.join(", ")<<"."] end end @@ -304,6 +305,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do end end + rename_desc = <<-EOT.unindent + Renames the Image + EOT + + command :rename, rename_desc, :imageid, :name do + helper.perform_action(args[0],options,"renamed") do |o| + o.rename(args[1]) + end + end + list_desc = <<-EOT.unindent Lists Images in the pool EOT diff --git a/src/cli/onetemplate b/src/cli/onetemplate index 396add5082..7604e4b457 100755 --- a/src/cli/onetemplate +++ b/src/cli/onetemplate @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -29,6 +29,7 @@ $: << RUBY_LIB_LOCATION+"/cli" require 'command_parser' require 'one_helper/onetemplate_helper' +require 'one_helper/onevm_helper' cmd=CommandParser::CmdParser.new(ARGV) do usage "`onetemplate` [] []" @@ -52,7 +53,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do instantiate_options = [ OneTemplateHelper::VM_NAME, - OneTemplateHelper::MULTIPLE + OneTemplateHelper::MULTIPLE, + OneVMHelper::HOLD ] ######################################################################## @@ -92,12 +94,13 @@ cmd=CommandParser::CmdParser.new(ARGV) do - new VM Template named "arch vm" with a disk and a nic: - onetemplate create --name "arch vm" --memory 128 --cpu 1 --disk arch \\ - --network private_lan + onetemplate create --name "arch vm" --memory 128 --cpu 1 \\ + --disk arch --network private_lan - using two disks: - onetempate create --name "test vm" --memory 128 --cpu 1 --disk arch,data + onetempate create --name "test vm" --memory 128 --cpu 1 \\ + --disk arch,data EOT @@ -170,16 +173,41 @@ cmd=CommandParser::CmdParser.new(ARGV) do managed with the 'onevm' command EOT - command :instantiate, instantiate_desc, :templateid, - :options=>instantiate_options do + command :instantiate, instantiate_desc, :templateid, [:file, nil], + :options=>instantiate_options+OpenNebulaHelper::TEMPLATE_OPTIONS do exit_code=0 + if args[1] && OpenNebulaHelper.create_template_options_used?(options) + STDERR.puts "You cannot use both template file and template"<< + " creation options." + next -1 + end + number = options[:multiple] || 1 number.times do |i| - exit_code=helper.perform_action(args[0],options,"instantiated") do |t| + exit_code=helper.perform_action(args[0], options, + "instantiated") do |t| name = options[:name] name = name.gsub("%i",i.to_s) if name - res = t.instantiate(name) + + on_hold = options[:hold] != nil + + extra_template = "" + + if args[1] + extra_template = File.read(args[1]) + else + res = OpenNebulaHelper.create_template(options) + + if res.first != 0 + STDERR.puts res.last + next -1 + end + + extra_template = res.last + end + + res = t.instantiate(name, on_hold, extra_template) if !OpenNebula.is_error?(res) puts "VM ID: #{res}" @@ -265,6 +293,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do Lists Templates in the pool EOT + rename_desc = <<-EOT.unindent + Renames the Template + EOT + + command :rename, rename_desc, :templateid, :name do + helper.perform_action(args[0],options,"renamed") do |o| + o.rename(args[1]) + end + end + command :list, list_desc, [:filterflag, nil], :options=>list_options do helper.list_pool(options, false, args[0]) end diff --git a/src/cli/oneuser b/src/cli/oneuser index 357cfa4887..64508a0e35 100755 --- a/src/cli/oneuser +++ b/src/cli/oneuser @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -228,7 +228,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do provided the editor will be launched to create new quotas. EOT - command :batchquota, batchquota_desc, [:range, :userid_list], [:file, nil] do + command :batchquota, batchquota_desc, [:range, :userid_list], + [:file, nil] do batch_str = OneQuotaHelper.get_batch_quota(args[1]) helper.perform_actions(args[0], options, "modified") do |user| @@ -270,6 +271,39 @@ cmd=CommandParser::CmdParser.new(ARGV) do exit 0 end + umask_desc = <<-EOT.unindent + Changes the umask used to create the default permissions. In a similar + way to the Unix umask command, the expected value is a three-digit + base-8 number. Each digit is a mask that disables permissions for the + owner, group and other, respectively. + + If mask is not given, or if it is an empty string, the umask will + be unset + EOT + + command :umask, umask_desc, [:range, :userid_list], [:mask, nil] do + helper.perform_actions(args[0],options, + "umask changed") do |user| + + rc = user.info + + if OpenNebula.is_error?(rc) + puts rc.message + exit -1 + end + + user.delete_element('/USER/TEMPLATE/UMASK') + + tmp_str = user.template_str + + if !args[1].nil? && args[1] != "" + tmp_str << "\nUMASK = #{args[1]}" + end + + user.update(tmp_str) + end + end + login_desc = <<-EOT.unindent Creates the Login token for authentication Examples: diff --git a/src/cli/onevm b/src/cli/onevm index a506f04952..e8792192ab 100755 --- a/src/cli/onevm +++ b/src/cli/onevm @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -64,6 +64,20 @@ cmd=CommandParser::CmdParser.new(ARGV) do :description => "IP address for the new NIC" } + CACHE={ + :name => "cache", + :large => "--cache cache_mode", + :format => String, + :description => "Hypervisor cache mode: default, none, writethrough,"<< + " writeback, directsync or unsafe. (Only KVM driver)" + } + + ENFORCE={ + :name => "enforce", + :short => "-e", + :large => "--enforce", + :description => "Enforce that the host capacity is not exceeded" + } ######################################################################## # Global Options @@ -106,8 +120,9 @@ cmd=CommandParser::CmdParser.new(ARGV) do ######################################################################## create_desc = <<-EOT.unindent - Creates a new VM from the given description instead of using a previously - defined template (see 'onetemplate create' and 'onetemplate instantiate'). + Creates a new VM from the given description instead of using a + previously defined template (see 'onetemplate create' and + 'onetemplate instantiate'). Examples: @@ -127,7 +142,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do EOT command :create, create_desc, [:file, nil], :options => - [OneVMHelper::MULTIPLE]+OpenNebulaHelper::TEMPLATE_OPTIONS_VM do + [OneVMHelper::MULTIPLE, OneVMHelper::HOLD]+ + OpenNebulaHelper::TEMPLATE_OPTIONS_VM do number = options[:multiple] || 1 exit_code = nil @@ -162,9 +178,11 @@ cmd=CommandParser::CmdParser.new(ARGV) do exit 0 end + on_hold = options[:hold] != nil + number.times do exit_code = helper.create_resource(options) do |vm| - error = vm.allocate(template) + error = vm.allocate(template, on_hold) end break if exit_code == -1 @@ -173,15 +191,33 @@ cmd=CommandParser::CmdParser.new(ARGV) do exit_code end + update_desc = <<-EOT.unindent + Update the user template contents. If a path is not provided the + editor will be launched to modify the current content. + EOT + + command :update, update_desc, :vmid, [:file, nil] do + helper.perform_action(args[0],options,"modified") do |vm| + str = OpenNebulaHelper.update_template(args[0], vm, args[1], + 'USER_TEMPLATE') + vm.update(str) + end + end + delete_desc = <<-EOT.unindent Deletes the given VM States: ANY EOT - command :delete, delete_desc, [:range, :vmid_list] do - helper.perform_actions(args[0],options,"deleted") do |vm| - vm.finalize + command :delete, delete_desc, [:range, :vmid_list], + :options => [OneVMHelper::SCHEDULE] do + if (!options[:schedule].nil?) + helper.schedule_actions(args[0], options, @comm_name) + else + helper.perform_actions(args[0],options,"deleted") do |vm| + vm.finalize + end end end @@ -192,9 +228,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do States: PENDING EOT - command :hold, hold_desc, [:range,:vmid_list] do - helper.perform_actions(args[0],options,"put on hold") do |vm| - vm.hold + command :hold, hold_desc, [:range,:vmid_list], + :options => [OneVMHelper::SCHEDULE] do + if (!options[:schedule].nil?) + helper.schedule_actions(args[0], options, @comm_name) + else + helper.perform_actions(args[0],options,"put on hold") do |vm| + vm.hold + end end end @@ -204,9 +245,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do States: HOLD EOT - command :release, release_desc, [:range,:vmid_list] do - helper.perform_actions(args[0],options,"released") do |vm| - vm.release + command :release, release_desc, [:range,:vmid_list], + :options => [OneVMHelper::SCHEDULE] do + if (!options[:schedule].nil?) + helper.schedule_actions(args[0], options, @comm_name) + else + helper.perform_actions(args[0],options,"released") do |vm| + vm.release + end end end @@ -219,7 +265,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do States: ANY EOT - command :saveas, saveas_desc, :vmid, :diskid, :img_name, :options=>[TYPE] do + command :saveas, saveas_desc, :vmid, :diskid, :img_name, + :options=>[TYPE] do disk_id = args[1].to_i image_name = args[2] image_type = options[:type] || "" @@ -244,9 +291,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do States: RUNNING EOT - command :shutdown, shutdown_desc, [:range,:vmid_list] do - helper.perform_actions(args[0],options,"shutting down") do |vm| - vm.shutdown + command :shutdown, shutdown_desc, [:range,:vmid_list], + :options => [OneVMHelper::SCHEDULE] do + if (!options[:schedule].nil?) + helper.schedule_actions(args[0], options, @comm_name) + else + helper.perform_actions(args[0],options,"shutting down") do |vm| + vm.shutdown + end end end @@ -257,9 +309,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do States: RUNNING EOT - command :poweroff, poweroff_desc, [:range,:vmid_list] do - helper.perform_actions(args[0],options,"shutting down") do |vm| - vm.poweroff + command :poweroff, poweroff_desc, [:range,:vmid_list], + :options => [OneVMHelper::SCHEDULE] do + if (!options[:schedule].nil?) + helper.schedule_actions(args[0], options, @comm_name) + else + helper.perform_actions(args[0],options,"shutting down") do |vm| + vm.poweroff + end end end @@ -270,9 +327,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do States: RUNNING EOT - command :reboot, reboot_desc, [:range,:vmid_list] do - helper.perform_actions(args[0],options,"rebooting") do |vm| - vm.reboot + command :reboot, reboot_desc, [:range,:vmid_list], + :options => [OneVMHelper::SCHEDULE] do + if (!options[:schedule].nil?) + helper.schedule_actions(args[0], options, @comm_name) + else + helper.perform_actions(args[0],options,"rebooting") do |vm| + vm.reboot + end end end @@ -282,9 +344,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do States: RUNNING EOT - command :reset, reset_desc, [:range,:vmid_list] do - helper.perform_actions(args[0],options,"resetting") do |vm| - vm.reset + command :reset, reset_desc, [:range,:vmid_list], + :options => [OneVMHelper::SCHEDULE] do + if (!options[:schedule].nil?) + helper.schedule_actions(args[0], options, @comm_name) + else + helper.perform_actions(args[0],options,"resetting") do |vm| + vm.reset + end end end @@ -296,12 +363,17 @@ cmd=CommandParser::CmdParser.new(ARGV) do States: PENDING EOT - command :deploy, deploy_desc, [:range,:vmid_list], :hostid do + command :deploy, deploy_desc, [:range,:vmid_list], :hostid, + :options=>[ENFORCE] do host_id = args[1] verbose = "deploying in host #{host_id}" helper.perform_actions(args[0],options,verbose) do |vm| - vm.deploy(host_id) + if !options[:enforce].nil? + vm.deploy(host_id, options[:enforce]) + else + vm.deploy(host_id) + end end end @@ -311,12 +383,17 @@ cmd=CommandParser::CmdParser.new(ARGV) do States: RUNNING EOT - command :livemigrate, livemigrate_desc, [:range,:vmid_list], :hostid do + command :livemigrate, livemigrate_desc, [:range,:vmid_list], :hostid, + :options=>[ENFORCE] do host_id = args[1] verbose = "live migrating to #{host_id}" helper.perform_actions(args[0],options,verbose) do |vm| - vm.live_migrate(host_id) + if !options[:enforce].nil? + vm.live_migrate(host_id, options[:enforce]) + else + vm.live_migrate(host_id) + end end end @@ -326,12 +403,17 @@ cmd=CommandParser::CmdParser.new(ARGV) do States: RUNNING EOT - command :migrate, migrate_desc, [:range,:vmid_list], :hostid do + command :migrate, migrate_desc, [:range,:vmid_list], :hostid, + :options=>[ENFORCE] do host_id = args[1] verbose = "migrating to #{host_id}" helper.perform_actions(args[0],options,verbose) do |vm| - vm.migrate(host_id) + if !options[:enforce].nil? + vm.migrate(host_id, options[:enforce]) + else + vm.migrate(host_id) + end end end @@ -341,9 +423,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do States: UNKNOWN, BOOT, POWEROFF EOT - command :restart, restart_desc, [:range,:vmid_list] do - helper.perform_actions(args[0],options,"restarting") do |vm| - vm.restart + command :restart, restart_desc, [:range,:vmid_list], + :options => [OneVMHelper::SCHEDULE] do + if (!options[:schedule].nil?) + helper.schedule_actions(args[0], options, @comm_name) + else + helper.perform_actions(args[0],options,"restarting") do |vm| + vm.restart + end end end @@ -355,9 +442,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do States: ANY, except SUSPENDED or DONE EOT - command :resubmit, resubmit_desc, [:range,:vmid_list] do - helper.perform_actions(args[0],options,"resubmiting") do |vm| - vm.resubmit + command :resubmit, resubmit_desc, [:range,:vmid_list], + :options => [OneVMHelper::SCHEDULE] do + if (!options[:schedule].nil?) + helper.schedule_actions(args[0], options, @comm_name) + else + helper.perform_actions(args[0],options,"resubmiting") do |vm| + vm.resubmit + end end end @@ -369,9 +461,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do States: RUNNING EOT - command :cancel, cancel_desc, [:range,:vmid_list] do - helper.perform_actions(args[0],options,"canceling") do |vm| - vm.cancel + command :cancel, cancel_desc, [:range,:vmid_list], + :options => [OneVMHelper::SCHEDULE] do + if (!options[:schedule].nil?) + helper.schedule_actions(args[0], options, @comm_name) + else + helper.perform_actions(args[0],options,"canceling") do |vm| + vm.cancel + end end end @@ -382,9 +479,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do States: RUNNING EOT - command :stop, stop_desc, [:range,:vmid_list] do - helper.perform_actions(args[0],options,"stopping") do |vm| - vm.stop + command :stop, stop_desc, [:range,:vmid_list], + :options => [OneVMHelper::SCHEDULE] do + if (!options[:schedule].nil?) + helper.schedule_actions(args[0], options, @comm_name) + else + helper.perform_actions(args[0],options,"stopping") do |vm| + vm.stop + end end end @@ -397,9 +499,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do States: RUNNING EOT - command :suspend, suspend_desc, [:range,:vmid_list] do - helper.perform_actions(args[0],options,"suspending") do |vm| - vm.suspend + command :suspend, suspend_desc, [:range,:vmid_list], + :options => [OneVMHelper::SCHEDULE] do + if (!options[:schedule].nil?) + helper.schedule_actions(args[0], options, @comm_name) + else + helper.perform_actions(args[0],options,"suspending") do |vm| + vm.suspend + end end end @@ -409,9 +516,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do States: STOPPED, SUSPENDED EOT - command :resume, resume_desc, [:range,:vmid_list] do - helper.perform_actions(args[0],options,"resuming") do |vm| - vm.resume + command :resume, resume_desc, [:range,:vmid_list], + :options => [OneVMHelper::SCHEDULE] do + if (!options[:schedule].nil?) + helper.schedule_actions(args[0], options, @comm_name) + else + helper.perform_actions(args[0],options,"resuming") do |vm| + vm.resume + end end end @@ -422,7 +534,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do EOT command :attachdisk, attachdisk_desc, :vmid, - :options => [OneVMHelper::FILE, OneVMHelper::IMAGE, TARGET] do + :options => [OneVMHelper::FILE, OneVMHelper::IMAGE, + TARGET, CACHE] do if options[:file].nil? and options[:image].nil? STDERR.puts "Provide a template file or an image:" @@ -438,11 +551,17 @@ cmd=CommandParser::CmdParser.new(ARGV) do target = options[:target] if target template = - "DISK = [ IMAGE_ID = #{image_id}, TARGET = #{target} ]" + "DISK = [ IMAGE_ID = #{image_id}, TARGET = #{target}" else template = - "DISK = [ IMAGE_ID = #{image_id}, DEV_PREFIX = sd ]" + "DISK = [ IMAGE_ID = #{image_id}, DEV_PREFIX = sd" end + + if options[:cache] + template<<", CACHE = \"#{options[:cache]}\"" + end + + template << " ]" end helper.perform_action(args[0],options,"Attach disk") do |vm| @@ -567,6 +686,58 @@ cmd=CommandParser::CmdParser.new(ARGV) do end end + rename_desc = <<-EOT.unindent + Renames the VM + EOT + + command :rename, rename_desc, :vmid, :name do + helper.perform_action(args[0],options,"renamed") do |o| + o.rename(args[1]) + end + end + + # TODO: Write a more complete description: + # what is a snapshot (system snapshot) + # how to revert to a snapshot + snapshot_create_desc = <<-EOT.unindent + Creates a new VM snapshot + EOT + + command :"snapshot-create", snapshot_create_desc, [:range,:vmid_list], + [:name, nil], :options => [OneVMHelper::SCHEDULE] do + + if (!options[:schedule].nil?) + helper.schedule_actions(args[0], options, @comm_name) + else + helper.perform_actions(args[0],options,"snapshot created") do |o| + o.snapshot_create(args[1]) + end + end + end + + # TODO: Write a more complete description: + snapshot_revert_desc = <<-EOT.unindent + Reverts a VM to a saved snapshot + EOT + + command :"snapshot-revert", snapshot_revert_desc, :vmid, :snapshot_id do + + helper.perform_action(args[0],options,"snapshot reverted") do |o| + o.snapshot_revert(args[1].to_i) + end + end + + # TODO: Write a more complete description: + snapshot_delete_desc = <<-EOT.unindent + Delets a snapshot of a VM + EOT + + command :"snapshot-delete", snapshot_delete_desc, :vmid, :snapshot_id do + helper.perform_action(args[0],options,"snapshot deleted") do |o| + o.snapshot_delete(args[1].to_i) + end + end + list_desc = <<-EOT.unindent Lists VMs in the pool EOT @@ -582,7 +753,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do EOT command :show, show_desc, :vmid, - :options=>OpenNebulaHelper::XML do + :options=>[OpenNebulaHelper::XML, OneVMHelper::ALL_TEMPLATE] do helper.show_resource(args[0],options) end @@ -594,4 +765,23 @@ cmd=CommandParser::CmdParser.new(ARGV) do :options=>CLIHelper::OPTIONS+OpenNebulaHelper::OPTIONS do helper.list_pool(options, true, args[0]) end + + resize_desc = <<-EOT.unindent + Resizes the capacity of a Virtual Machine (offline, the VM cannot be + RUNNING) + + EOT + + command :resize, resize_desc, :vmid, :options => + OpenNebulaHelper::CAPACITY_OPTIONS_VM + [ENFORCE] do + + cpu = options[:cpu] || 0.0 + memory = options[:memory] || 0 + vcpu = options[:vcpu] || 0 + enforce = options[:enforce] || false + + helper.perform_action(args[0], options, "Resizing VM") do |vm| + vm.resize(cpu, memory, vcpu, enforce) + end + end end diff --git a/src/cli/onevnet b/src/cli/onevnet index 12638fc2a8..2ada4c1e75 100755 --- a/src/cli/onevnet +++ b/src/cli/onevnet @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -228,4 +228,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do vnet.update(str) end end + + rename_desc = <<-EOT.unindent + Renames the Virtual Network + EOT + + command :rename, rename_desc, :vnetid, :name do + helper.perform_action(args[0],options,"renamed") do |o| + o.rename(args[1]) + end + end end diff --git a/src/cloud/common/CloudAuth.rb b/src/cloud/common/CloudAuth.rb index ddc1a4fa78..ab6ddea5ef 100644 --- a/src/cloud/common/CloudAuth.rb +++ b/src/cloud/common/CloudAuth.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -67,7 +67,7 @@ class CloudAuth end begin - require core_auth[0] + require "opennebula/#{core_auth[0]}" @server_auth = Kernel.const_get(core_auth[1]).new_client rescue => e raise e.message @@ -134,9 +134,18 @@ class CloudAuth # password:: _String_ the password # [return] _Hash_ with the username def get_username(password) - xpath = "USER[contains(PASSWORD, \"#{password}\")]/NAME" + # Trying to match password with each + # of the pipe-separated DNs stored in USER/PASSWORD + @lock.synchronize do + @user_pool.each_with_xpath( + "USER[contains(PASSWORD, \"#{password}\")]") do |user| + STDERR.puts user.inspect + return user["NAME"] if user["AUTH_DRIVER"] == "x509" && + user["PASSWORD"].split('|').include?(password) + end + end - retrieve_from_userpool(xpath) + nil end private @@ -158,4 +167,4 @@ class CloudAuth raise rc.message if OpenNebula.is_error?(rc) } end -end \ No newline at end of file +end diff --git a/src/cloud/common/CloudAuth/EC2CloudAuth.rb b/src/cloud/common/CloudAuth/EC2CloudAuth.rb index 8bae4cd704..8326caf846 100644 --- a/src/cloud/common/CloudAuth/EC2CloudAuth.rb +++ b/src/cloud/common/CloudAuth/EC2CloudAuth.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -23,6 +23,7 @@ module EC2CloudAuth signature = case params['SignatureVersion'] when "1" then signature_v1(params.clone,one_pass) when "2" then signature_v2(params.clone,one_pass,env,true,false) + else return nil end if params['Signature'] == signature diff --git a/src/cloud/common/CloudAuth/OCCICloudAuth.rb b/src/cloud/common/CloudAuth/OCCICloudAuth.rb index 8ad6fa07a6..015d96e6a6 100644 --- a/src/cloud/common/CloudAuth/OCCICloudAuth.rb +++ b/src/cloud/common/CloudAuth/OCCICloudAuth.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/cloud/common/CloudAuth/OpenNebulaCloudAuth.rb b/src/cloud/common/CloudAuth/OpenNebulaCloudAuth.rb index 33cb080898..48b026c0b7 100644 --- a/src/cloud/common/CloudAuth/OpenNebulaCloudAuth.rb +++ b/src/cloud/common/CloudAuth/OpenNebulaCloudAuth.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/cloud/common/CloudAuth/SunstoneCloudAuth.rb b/src/cloud/common/CloudAuth/SunstoneCloudAuth.rb index 1ac866ef6d..39f495afcf 100644 --- a/src/cloud/common/CloudAuth/SunstoneCloudAuth.rb +++ b/src/cloud/common/CloudAuth/SunstoneCloudAuth.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/cloud/common/CloudAuth/X509CloudAuth.rb b/src/cloud/common/CloudAuth/X509CloudAuth.rb index c6174e2358..cdae1f3893 100644 --- a/src/cloud/common/CloudAuth/X509CloudAuth.rb +++ b/src/cloud/common/CloudAuth/X509CloudAuth.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -14,6 +14,8 @@ # limitations under the License. # #--------------------------------------------------------------------------- # +require 'opennebula/x509_auth' + module X509CloudAuth def do_auth(env, params={}) # For https, the web service should be set to include the user cert in the environment. @@ -32,7 +34,8 @@ module X509CloudAuth end # Password should be DN with whitespace removed. - username = get_username(cert.subject.to_s.delete("\s")) + username = get_username( + OpenNebula::X509Auth.escape_dn(cert.subject.to_s)) return username if username diff --git a/src/cloud/common/CloudClient.rb b/src/cloud/common/CloudClient.rb index 1b797468e2..c89cf669e1 100644 --- a/src/cloud/common/CloudClient.rb +++ b/src/cloud/common/CloudClient.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -201,7 +201,7 @@ module CloudCLI def version_text version=< file_list.txt diff --git a/src/cloud/occi/lib/ui/locale/languages/SConstruct b/src/cloud/occi/lib/ui/locale/languages/SConstruct index 22e9a8ad31..994062f922 100644 --- a/src/cloud/occi/lib/ui/locale/languages/SConstruct +++ b/src/cloud/occi/lib/ui/locale/languages/SConstruct @@ -1,7 +1,7 @@ # SConstruct for share/man # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/cloud/occi/lib/ui/locale/languages/cs_CZ.po b/src/cloud/occi/lib/ui/locale/languages/cs_CZ.po index 049cde29d7..d42ec5f063 100644 --- a/src/cloud/occi/lib/ui/locale/languages/cs_CZ.po +++ b/src/cloud/occi/lib/ui/locale/languages/cs_CZ.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/cloud/occi/lib/ui/locale/languages/de.po b/src/cloud/occi/lib/ui/locale/languages/de.po index 3d1c5dba98..3d6a94815d 100644 --- a/src/cloud/occi/lib/ui/locale/languages/de.po +++ b/src/cloud/occi/lib/ui/locale/languages/de.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/cloud/occi/lib/ui/locale/languages/el_GR.po b/src/cloud/occi/lib/ui/locale/languages/el_GR.po index 45f294db42..67b3a27a35 100644 --- a/src/cloud/occi/lib/ui/locale/languages/el_GR.po +++ b/src/cloud/occi/lib/ui/locale/languages/el_GR.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/cloud/occi/lib/ui/locale/languages/en_US.po b/src/cloud/occi/lib/ui/locale/languages/en_US.po index 2aec480492..1c2607f7b4 100644 --- a/src/cloud/occi/lib/ui/locale/languages/en_US.po +++ b/src/cloud/occi/lib/ui/locale/languages/en_US.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # diff --git a/src/cloud/occi/lib/ui/locale/languages/es_ES.po b/src/cloud/occi/lib/ui/locale/languages/es_ES.po index b96b5df32d..90afc84c5a 100644 --- a/src/cloud/occi/lib/ui/locale/languages/es_ES.po +++ b/src/cloud/occi/lib/ui/locale/languages/es_ES.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/cloud/occi/lib/ui/locale/languages/fa_IR.po b/src/cloud/occi/lib/ui/locale/languages/fa_IR.po index fabb9928d5..b17f830a3a 100644 --- a/src/cloud/occi/lib/ui/locale/languages/fa_IR.po +++ b/src/cloud/occi/lib/ui/locale/languages/fa_IR.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/cloud/occi/lib/ui/locale/languages/fr_CA.po b/src/cloud/occi/lib/ui/locale/languages/fr_CA.po index 5278622d8f..d83fb001af 100644 --- a/src/cloud/occi/lib/ui/locale/languages/fr_CA.po +++ b/src/cloud/occi/lib/ui/locale/languages/fr_CA.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/cloud/occi/lib/ui/locale/languages/fr_FR.po b/src/cloud/occi/lib/ui/locale/languages/fr_FR.po index f07f8e0286..0062b99079 100644 --- a/src/cloud/occi/lib/ui/locale/languages/fr_FR.po +++ b/src/cloud/occi/lib/ui/locale/languages/fr_FR.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/cloud/occi/lib/ui/locale/languages/gl.po b/src/cloud/occi/lib/ui/locale/languages/gl.po index e849f93663..c5ec975f49 100644 --- a/src/cloud/occi/lib/ui/locale/languages/gl.po +++ b/src/cloud/occi/lib/ui/locale/languages/gl.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/cloud/occi/lib/ui/locale/languages/it_IT.po b/src/cloud/occi/lib/ui/locale/languages/it_IT.po index ec0983beab..7c3ca4b83b 100644 --- a/src/cloud/occi/lib/ui/locale/languages/it_IT.po +++ b/src/cloud/occi/lib/ui/locale/languages/it_IT.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/cloud/occi/lib/ui/locale/languages/nl_NL.po b/src/cloud/occi/lib/ui/locale/languages/nl_NL.po index b51d8bf6bb..1528b71b46 100644 --- a/src/cloud/occi/lib/ui/locale/languages/nl_NL.po +++ b/src/cloud/occi/lib/ui/locale/languages/nl_NL.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/cloud/occi/lib/ui/locale/languages/pt_BR.po b/src/cloud/occi/lib/ui/locale/languages/pt_BR.po index 419f67fd79..98a7e9ea65 100644 --- a/src/cloud/occi/lib/ui/locale/languages/pt_BR.po +++ b/src/cloud/occi/lib/ui/locale/languages/pt_BR.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/cloud/occi/lib/ui/locale/languages/pt_PT.po b/src/cloud/occi/lib/ui/locale/languages/pt_PT.po index 3af5192681..1207fba4f8 100644 --- a/src/cloud/occi/lib/ui/locale/languages/pt_PT.po +++ b/src/cloud/occi/lib/ui/locale/languages/pt_PT.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/cloud/occi/lib/ui/locale/languages/ru_RU.po b/src/cloud/occi/lib/ui/locale/languages/ru_RU.po index 9fc313831b..7aca937bd4 100644 --- a/src/cloud/occi/lib/ui/locale/languages/ru_RU.po +++ b/src/cloud/occi/lib/ui/locale/languages/ru_RU.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/cloud/occi/lib/ui/locale/languages/sk_SK.po b/src/cloud/occi/lib/ui/locale/languages/sk_SK.po index ce864fe9cd..9a3bf82f0f 100644 --- a/src/cloud/occi/lib/ui/locale/languages/sk_SK.po +++ b/src/cloud/occi/lib/ui/locale/languages/sk_SK.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/cloud/occi/lib/ui/locale/languages/zh_TW.po b/src/cloud/occi/lib/ui/locale/languages/zh_TW.po index 8f758dc14c..ec8d979efd 100644 --- a/src/cloud/occi/lib/ui/locale/languages/zh_TW.po +++ b/src/cloud/occi/lib/ui/locale/languages/zh_TW.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/cloud/occi/lib/ui/locale/messages.pot b/src/cloud/occi/lib/ui/locale/messages.pot index f5b4b87f72..b76bce7a50 100644 --- a/src/cloud/occi/lib/ui/locale/messages.pot +++ b/src/cloud/occi/lib/ui/locale/messages.pot @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # diff --git a/src/cloud/occi/lib/ui/locale/upgrade_po_translations.sh b/src/cloud/occi/lib/ui/locale/upgrade_po_translations.sh index 38c0b3a505..2d2a0dd4ea 100755 --- a/src/cloud/occi/lib/ui/locale/upgrade_po_translations.sh +++ b/src/cloud/occi/lib/ui/locale/upgrade_po_translations.sh @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/cloud/occi/lib/ui/public/css/application.css b/src/cloud/occi/lib/ui/public/css/application.css index faad452b97..5918b0591f 100644 --- a/src/cloud/occi/lib/ui/public/css/application.css +++ b/src/cloud/occi/lib/ui/public/css/application.css @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/cloud/occi/lib/ui/public/css/layout.css b/src/cloud/occi/lib/ui/public/css/layout.css index 6f113e7c6b..45d5022025 100644 --- a/src/cloud/occi/lib/ui/public/css/layout.css +++ b/src/cloud/occi/lib/ui/public/css/layout.css @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/cloud/occi/lib/ui/public/css/login.css b/src/cloud/occi/lib/ui/public/css/login.css index 63d50e9a45..997590aa42 100644 --- a/src/cloud/occi/lib/ui/public/css/login.css +++ b/src/cloud/occi/lib/ui/public/css/login.css @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/cloud/occi/lib/ui/public/customize/custom.js b/src/cloud/occi/lib/ui/public/customize/custom.js index c0d592ef65..edfc75f4b1 100644 --- a/src/cloud/occi/lib/ui/public/customize/custom.js +++ b/src/cloud/occi/lib/ui/public/customize/custom.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/cloud/occi/lib/ui/public/js/layout.js b/src/cloud/occi/lib/ui/public/js/layout.js index 673ad5892d..1c72ef789b 100644 --- a/src/cloud/occi/lib/ui/public/js/layout.js +++ b/src/cloud/occi/lib/ui/public/js/layout.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/cloud/occi/lib/ui/public/js/locale.js b/src/cloud/occi/lib/ui/public/js/locale.js index 792772954f..77eeca4cc9 100644 --- a/src/cloud/occi/lib/ui/public/js/locale.js +++ b/src/cloud/occi/lib/ui/public/js/locale.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/cloud/occi/lib/ui/public/js/login.js b/src/cloud/occi/lib/ui/public/js/login.js index b7b80e5908..3cd77acb69 100644 --- a/src/cloud/occi/lib/ui/public/js/login.js +++ b/src/cloud/occi/lib/ui/public/js/login.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/cloud/occi/lib/ui/public/js/occi.js b/src/cloud/occi/lib/ui/public/js/occi.js index 8c4780455d..2b4ef0a648 100644 --- a/src/cloud/occi/lib/ui/public/js/occi.js +++ b/src/cloud/occi/lib/ui/public/js/occi.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/cloud/occi/lib/ui/public/js/plugins/compute.js b/src/cloud/occi/lib/ui/public/js/plugins/compute.js index 602e28264c..02e5ebb8c7 100644 --- a/src/cloud/occi/lib/ui/public/js/plugins/compute.js +++ b/src/cloud/occi/lib/ui/public/js/plugins/compute.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/cloud/occi/lib/ui/public/js/plugins/configuration.js b/src/cloud/occi/lib/ui/public/js/plugins/configuration.js index 01738a07cf..be4dcc64fe 100644 --- a/src/cloud/occi/lib/ui/public/js/plugins/configuration.js +++ b/src/cloud/occi/lib/ui/public/js/plugins/configuration.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/cloud/occi/lib/ui/public/js/plugins/dashboard.js b/src/cloud/occi/lib/ui/public/js/plugins/dashboard.js index ce7647d22c..ffe0e27323 100644 --- a/src/cloud/occi/lib/ui/public/js/plugins/dashboard.js +++ b/src/cloud/occi/lib/ui/public/js/plugins/dashboard.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/cloud/occi/lib/ui/public/js/plugins/network.js b/src/cloud/occi/lib/ui/public/js/plugins/network.js index 609151d206..bf37b4873e 100644 --- a/src/cloud/occi/lib/ui/public/js/plugins/network.js +++ b/src/cloud/occi/lib/ui/public/js/plugins/network.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/cloud/occi/lib/ui/public/js/plugins/storage.js b/src/cloud/occi/lib/ui/public/js/plugins/storage.js index c8d73f35aa..4110a3032a 100644 --- a/src/cloud/occi/lib/ui/public/js/plugins/storage.js +++ b/src/cloud/occi/lib/ui/public/js/plugins/storage.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/cloud/occi/test/spec/occi_spec.rb b/src/cloud/occi/test/spec/occi_spec.rb index ba35ae94dd..a68b0c1b37 100644 --- a/src/cloud/occi/test/spec/occi_spec.rb +++ b/src/cloud/occi/test/spec/occi_spec.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/cloud/occi/test/spec/spec_helper.rb b/src/cloud/occi/test/spec/spec_helper.rb index 0d7423a2fc..acb8be43bb 100644 --- a/src/cloud/occi/test/spec/spec_helper.rb +++ b/src/cloud/occi/test/spec/spec_helper.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/cloud/occi/test/spec/user_spec.rb b/src/cloud/occi/test/spec/user_spec.rb index 805419e8f6..e2bc4c0b0a 100644 --- a/src/cloud/occi/test/spec/user_spec.rb +++ b/src/cloud/occi/test/spec/user_spec.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/cloud/occi/test/spec/vm_saveas_spec.rb b/src/cloud/occi/test/spec/vm_saveas_spec.rb index 21752739bc..337e8889be 100644 --- a/src/cloud/occi/test/spec/vm_saveas_spec.rb +++ b/src/cloud/occi/test/spec/vm_saveas_spec.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/cloud/occi/test/test.sh b/src/cloud/occi/test/test.sh index 4b5a3d7e4f..96a44d0a7f 100755 --- a/src/cloud/occi/test/test.sh +++ b/src/cloud/occi/test/test.sh @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/cluster/Cluster.cc b/src/cluster/Cluster.cc index 8c25673843..22a07c6dc4 100644 --- a/src/cluster/Cluster.cc +++ b/src/cluster/Cluster.cc @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------ */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -45,7 +45,8 @@ Cluster::Cluster( PoolObjectSQL(id,CLUSTER,name,-1,-1,"","",table), hosts("HOSTS"), datastores("DATASTORES"), - vnets("VNETS") + vnets("VNETS"), + system_ds(DatastorePool::SYSTEM_DS_ID) { if (cl_template != 0) { @@ -113,6 +114,69 @@ string& Cluster::get_ds_location(string &ds_location) return ds_location; } +/* ------------------------------------------------------------------------ */ +/* ------------------------------------------------------------------------ */ + +int Cluster::add_datastore(int id, Datastore::DatastoreType ds_type, string& error_msg) +{ + if ( id == DatastorePool::SYSTEM_DS_ID ) + { + ostringstream oss; + oss << "Datastore "<< DatastorePool::SYSTEM_DS_ID + << " cannot be added to any cluster."; + + error_msg = oss.str(); + + return -1; + } + + if ( ds_type == Datastore::SYSTEM_DS ) + { + if ( system_ds != DatastorePool::SYSTEM_DS_ID ) + { + ostringstream oss; + oss << "Cluster " << oid << " already contains the System Datastore " + << system_ds << "."; + + error_msg = oss.str(); + + return -1; + } + } + + int rc = datastores.add_collection_id(id); + + if ( rc < 0 ) + { + error_msg = "Datastore ID is already in the cluster set."; + } + else if ( ds_type == Datastore::SYSTEM_DS ) + { + system_ds = id; + } + + return rc; +} + +/* ------------------------------------------------------------------------ */ +/* ------------------------------------------------------------------------ */ + +int Cluster::del_datastore(int id, string& error_msg) +{ + int rc = datastores.del_collection_id(id); + + if ( rc < 0 ) + { + error_msg = "Datastore ID is not part of the cluster set."; + } + else if ( system_ds == id ) + { + system_ds = DatastorePool::SYSTEM_DS_ID; + } + + return rc; +} + /* ************************************************************************ */ /* Cluster :: Database Access Functions */ /* ************************************************************************ */ @@ -215,8 +279,9 @@ string& Cluster::to_xml(string& xml) const oss << "" << - "" << oid << "" << - "" << name << "" << + "" << oid << "" << + "" << name << "" << + "" << system_ds << "" << hosts.to_xml(host_collection_xml) << datastores.to_xml(ds_collection_xml) << @@ -241,8 +306,9 @@ int Cluster::from_xml(const string& xml) update_from_str(xml); // Get class base attributes - rc += xpath(oid, "/CLUSTER/ID", -1); - rc += xpath(name,"/CLUSTER/NAME", "not_found"); + rc += xpath(oid, "/CLUSTER/ID", -1); + rc += xpath(name, "/CLUSTER/NAME", "not_found"); + rc += xpath(system_ds, "/CLUSTER/SYSTEM_DS", -1); // Set oneadmin as the owner set_user(0,""); diff --git a/src/cluster/ClusterPool.cc b/src/cluster/ClusterPool.cc index b3ff69e26c..ee3af88eb6 100644 --- a/src/cluster/ClusterPool.cc +++ b/src/cluster/ClusterPool.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/cluster/SConstruct b/src/cluster/SConstruct index c088beebc3..840eb593ff 100644 --- a/src/cluster/SConstruct +++ b/src/cluster/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/group # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/common/ActionManager.cc b/src/common/ActionManager.cc index dd1504effc..8b69282f1d 100644 --- a/src/common/ActionManager.cc +++ b/src/common/ActionManager.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/common/Attribute.cc b/src/common/Attribute.cc index 2c90fa90c8..7d53506791 100644 --- a/src/common/Attribute.cc +++ b/src/common/Attribute.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -20,6 +20,7 @@ #include "Attribute.h" +#define TO_UPPER(S) transform(S.begin(),S.end(),S.begin(),(int(*)(int))toupper) const char * VectorAttribute::magic_sep = "@^_^@"; const int VectorAttribute::magic_sep_size = 5; @@ -145,7 +146,7 @@ void VectorAttribute::unmarshall(const string& sattr, const char * _sep) { continue; } - + if ( mpos + 1 == tmp.size() ) { attribute_value.insert(make_pair(tmp.substr(0,mpos),"")); @@ -154,7 +155,7 @@ void VectorAttribute::unmarshall(const string& sattr, const char * _sep) { attribute_value.insert(make_pair(tmp.substr(0,mpos), tmp.substr(mpos+1))); - } + } } } /* -------------------------------------------------------------------------- */ @@ -173,12 +174,12 @@ void VectorAttribute::replace(const string& name, const string& value) map::iterator it; it = attribute_value.find(name); - + if ( it != attribute_value.end() ) { attribute_value.erase(it); } - + attribute_value.insert(make_pair(name,value)); } @@ -215,6 +216,37 @@ string VectorAttribute::vector_value(const char *name) const return it->second; } } +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +int VectorAttribute::vector_value(const char *name, bool& value) const +{ + map::const_iterator it; + + value = false; + it = attribute_value.find(name); + + if (it == attribute_value.end()) + { + return -1; + } + + if (it->second.empty()) + { + return -1; + } + + string tmp = it->second; + + TO_UPPER(tmp); + + if (tmp == "YES") + { + value = true; + } + + return 0; +} /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -238,6 +270,11 @@ int VectorAttribute::vector_value(const char *name, int & value) const istringstream iss(it->second); iss >> value; + if (iss.fail() || !iss.eof()) + { + return -1; + } + return 0; } @@ -263,6 +300,11 @@ int VectorAttribute::vector_value(const char *name, float & value) const istringstream iss(it->second); iss >> value; + if (iss.fail() || !iss.eof()) + { + return -1; + } + return 0; } diff --git a/src/common/SSLTools.cc b/src/common/NebulaUtil.cc similarity index 54% rename from src/common/SSLTools.cc rename to src/common/NebulaUtil.cc index 14e4926c51..60ac444696 100644 --- a/src/common/SSLTools.cc +++ b/src/common/NebulaUtil.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -14,29 +14,66 @@ /* limitations under the License. */ /* -------------------------------------------------------------------------- */ +#include "NebulaUtil.h" + #include #include #include #include #include -#include "SSLTools.h" #include #include #include +#include +using namespace std; -//#include - - -//#include -//#include -//#include +string& one_util::toupper(string& st) +{ + transform(st.begin(),st.end(),st.begin(),(int(*)(int))std::toupper); + return st; +}; /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -string * SSLTools::base64_encode(const string& in) +string& one_util::tolower(string& st) +{ + transform(st.begin(),st.end(),st.begin(),(int(*)(int))std::tolower); + return st; +}; + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +string one_util::log_time(time_t the_time) +{ + char time_str[26]; + +#ifdef SOLARIS + ctime_r(&(the_time),time_str,sizeof(char)*26); +#else + ctime_r(&(the_time),time_str); +#endif + + time_str[24] = '\0'; // Get rid of final enter character + + return string(time_str); +}; + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +string one_util::log_time() +{ + return log_time( time(0) ); +}; + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +string * one_util::base64_encode(const string& in) { BIO * bio_mem; BIO * bio_64; @@ -49,7 +86,7 @@ string * SSLTools::base64_encode(const string& in) BIO_push(bio_64, bio_mem); - BIO_set_flags(bio_64,BIO_FLAGS_BASE64_NO_NL); + BIO_set_flags(bio_64, BIO_FLAGS_BASE64_NO_NL); BIO_write(bio_64, in.c_str(), in.length()); @@ -70,7 +107,48 @@ string * SSLTools::base64_encode(const string& in) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -string SSLTools::sha1_digest(const string& in) +string * one_util::base64_decode(const string& in) +{ + BIO * bio_mem_in; + BIO * bio_mem_out; + BIO * bio_64; + + char inbuf[512]; + int inlen; + + char * decoded_c; + long int size; + + bio_64 = BIO_new(BIO_f_base64()); + + bio_mem_in = BIO_new(BIO_s_mem()); + bio_mem_out = BIO_new(BIO_s_mem()); + + bio_64 = BIO_push(bio_64, bio_mem_in); + + BIO_set_flags(bio_64, BIO_FLAGS_BASE64_NO_NL); + + BIO_write(bio_mem_in, in.c_str(), in.length()); + + while((inlen = BIO_read(bio_64, inbuf, 512)) > 0) + { + BIO_write(bio_mem_out, inbuf, inlen); + } + + size = BIO_get_mem_data(bio_mem_out, &decoded_c); + + string * decoded = new string(decoded_c, size); + + BIO_free_all(bio_64); + BIO_free_all(bio_mem_out); + + return decoded; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +string one_util::sha1_digest(const string& in) { EVP_MD_CTX mdctx; unsigned char md_value[EVP_MAX_MD_SIZE]; diff --git a/src/common/SConstruct b/src/common/SConstruct index e4dc088b57..92f46fd2f4 100644 --- a/src/common/SConstruct +++ b/src/common/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/common # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -25,7 +25,7 @@ source_files=[ 'ActionManager.cc', 'Attribute.cc', 'mem_collector.c', - 'SSLTools.cc' + 'NebulaUtil.cc' ] # Build library diff --git a/src/common/mem_collector.c b/src/common/mem_collector.c index d351359365..e96263f3fa 100644 --- a/src/common/mem_collector.c +++ b/src/common/mem_collector.c @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/common/test/SConstruct b/src/common/test/SConstruct index d1775b677d..76bb4f4ce5 100644 --- a/src/common/test/SConstruct +++ b/src/common/test/SConstruct @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/common/test/action_manager.cc b/src/common/test/action_manager.cc index f8629b8c99..9ba00fdd21 100644 --- a/src/common/test/action_manager.cc +++ b/src/common/test/action_manager.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/common/test/mem_collector.cc b/src/common/test/mem_collector.cc index 402d94c789..b9d251a308 100644 --- a/src/common/test/mem_collector.cc +++ b/src/common/test/mem_collector.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/common/test/single_attribute.cc b/src/common/test/single_attribute.cc index 3fbdcc0038..4787cbd083 100644 --- a/src/common/test/single_attribute.cc +++ b/src/common/test/single_attribute.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/common/test/vector_attribute.cc b/src/common/test/vector_attribute.cc index 0b52afa843..c10c3f0115 100644 --- a/src/common/test/vector_attribute.cc +++ b/src/common/test/vector_attribute.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/datastore/Datastore.cc b/src/datastore/Datastore.cc index 6e93122920..2b2af549cd 100644 --- a/src/datastore/Datastore.cc +++ b/src/datastore/Datastore.cc @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------ */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -24,13 +24,13 @@ const char * Datastore::table = "datastore_pool"; const char * Datastore::db_names = - "oid, name, body, uid, gid, owner_u, group_u, other_u"; + "oid, name, body, uid, gid, owner_u, group_u, other_u, cid"; const char * Datastore::db_bootstrap = "CREATE TABLE IF NOT EXISTS datastore_pool (" "oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, " "gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER, " - "UNIQUE(name))"; + "cid INTEGER, UNIQUE(name))"; /* ************************************************************************ */ /* Datastore :: Constructor/Destructor */ @@ -41,6 +41,7 @@ Datastore::Datastore( int gid, const string& uname, const string& gname, + int umask, DatastoreTemplate* ds_template, int cluster_id, const string& cluster_name): @@ -52,8 +53,6 @@ Datastore::Datastore( base_path(""), type(IMAGE_DS) { - group_u = 1; - if (ds_template != 0) { obj_template = ds_template; @@ -62,6 +61,10 @@ Datastore::Datastore( { obj_template = new DatastoreTemplate; } + + set_umask(umask); + + group_u = 1; } /* ------------------------------------------------------------------------ */ @@ -171,7 +174,7 @@ int Datastore::insert(SqlDB *db, string& error_str) if ( type == IMAGE_DS ) { - get_template_attribute("DISK_TYPE", s_disk_type); + erase_template_attribute("DISK_TYPE", s_disk_type); if (s_disk_type == "BLOCK") { @@ -181,6 +184,10 @@ int Datastore::insert(SqlDB *db, string& error_str) { disk_type = Image::CD_ROM; } + else if (s_disk_type == "RBD") + { + disk_type = Image::RBD; + } } if ( tm_mad.empty() == true ) @@ -265,7 +272,8 @@ int Datastore::insert_replace(SqlDB *db, bool replace, string& error_str) << gid << "," << owner_u << "," << group_u << "," - << other_u << ")"; + << other_u << "," + << cluster_id << ")"; rc = db->exec(oss); @@ -411,18 +419,67 @@ int Datastore::replace_template(const string& tmpl_str, string& error_str) string new_tm_mad; string s_ds_type; - int rc; + DatastoreType new_ds_type; + Template * new_tmpl = new DatastoreTemplate; - rc = PoolObjectSQL::replace_template(tmpl_str, error_str); - - if ( rc != 0 ) + if ( new_tmpl == 0 ) { - return rc; + error_str = "Cannot allocate a new template"; + return -1; } - get_template_attribute("DS_MAD", new_ds_mad); - get_template_attribute("TYPE", s_ds_type); + if ( new_tmpl->parse_str_or_xml(tmpl_str, error_str) != 0 ) + { + delete new_tmpl; + return -1; + } + /* ---------------------------------------------------------------------- */ + /* Set the TYPE of the Datastore (class & template) */ + /* ---------------------------------------------------------------------- */ + + new_tmpl->get("TYPE", s_ds_type); + + if (!s_ds_type.empty()) + { + new_ds_type = str_to_type(s_ds_type); + + if (get_cluster_id() != ClusterPool::NONE_CLUSTER_ID)//It's in a cluster + { + if (type == SYSTEM_DS && new_ds_type != SYSTEM_DS) + { + error_str = "Datastore is associated to a cluster, and it is " + "the SYSTEM_DS, remove it from cluster first to " + "update its type."; + + delete new_tmpl; + return -1; + } + else if (new_ds_type == SYSTEM_DS && type != SYSTEM_DS) + { + error_str = "Datastore is associated to a cluster, cannot set " + "type to SYSTEM_DS. Remove it from cluster first " + "to update its type."; + + delete new_tmpl; + return -1; + } + } + } + else //No TYPE in the new Datastore template + { + new_ds_type = type; + } + + /* --- Update the Datastore template --- */ + + delete obj_template; + + obj_template = new_tmpl; + + /* ---------------------------------------------------------------------- */ + /* Set the TYPE of the Datastore (class & template) */ + /* ---------------------------------------------------------------------- */ if ( oid == DatastorePool::SYSTEM_DS_ID ) { @@ -430,15 +487,23 @@ int Datastore::replace_template(const string& tmpl_str, string& error_str) } else { - type = str_to_type(s_ds_type); - - replace_template_attribute("TYPE", type_to_str(type)); + type = new_ds_type; } + replace_template_attribute("TYPE", type_to_str(type)); + + /* ---------------------------------------------------------------------- */ + /* Set the DS_MAD of the Datastore (class & template) */ + /* ---------------------------------------------------------------------- */ + if ( type == SYSTEM_DS ) { new_ds_mad = "-"; } + else + { + get_template_attribute("DS_MAD", new_ds_mad); + } if ( !new_ds_mad.empty() ) { @@ -447,6 +512,10 @@ int Datastore::replace_template(const string& tmpl_str, string& error_str) replace_template_attribute("DS_MAD", ds_mad); + /* ---------------------------------------------------------------------- */ + /* Set the TM_MAD of the Datastore (class & template) */ + /* ---------------------------------------------------------------------- */ + get_template_attribute("TM_MAD", new_tm_mad); if ( !new_tm_mad.empty() ) diff --git a/src/datastore/DatastorePool.cc b/src/datastore/DatastorePool.cc index 676e894357..deee907538 100644 --- a/src/datastore/DatastorePool.cc +++ b/src/datastore/DatastorePool.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -47,7 +47,6 @@ DatastorePool::DatastorePool(SqlDB * db): if (get_lastOID() == -1) //lastOID is set in PoolSQL::init_cb { DatastoreTemplate * ds_tmpl; - Datastore * ds; int rc; @@ -71,6 +70,7 @@ DatastorePool::DatastorePool(SqlDB * db): GroupPool::ONEADMIN_ID, UserPool::oneadmin_name, GroupPool::ONEADMIN_NAME, + 0137, ds_tmpl, &rc, ClusterPool::NONE_CLUSTER_ID, @@ -104,6 +104,7 @@ DatastorePool::DatastorePool(SqlDB * db): GroupPool::ONEADMIN_ID, UserPool::oneadmin_name, GroupPool::ONEADMIN_NAME, + 0133, ds_tmpl, &rc, ClusterPool::NONE_CLUSTER_ID, @@ -115,18 +116,6 @@ DatastorePool::DatastorePool(SqlDB * db): goto error_bootstrap; } - ds = get(rc, true); - - ds->set_permissions( - -1,-1,-1, - -1,-1,-1, - 1,-1,-1, - error_str); - - update(ds); - - ds->unlock(); - // --------------------------------------------------------------------- // Create the default file datastore // --------------------------------------------------------------------- @@ -149,6 +138,7 @@ DatastorePool::DatastorePool(SqlDB * db): GroupPool::ONEADMIN_ID, UserPool::oneadmin_name, GroupPool::ONEADMIN_NAME, + 0133, ds_tmpl, &rc, ClusterPool::NONE_CLUSTER_ID, @@ -160,18 +150,6 @@ DatastorePool::DatastorePool(SqlDB * db): goto error_bootstrap; } - ds = get(rc, true); - - ds->set_permissions( - -1,-1,-1, - -1,-1,-1, - 1,-1,-1, - error_str); - - update(ds); - - ds->unlock(); - // User created datastores will start from ID 100 set_update_lastOID(99); } @@ -194,6 +172,7 @@ int DatastorePool::allocate( int gid, const string& uname, const string& gname, + int umask, DatastoreTemplate * ds_template, int * oid, int cluster_id, @@ -205,7 +184,7 @@ int DatastorePool::allocate( string name; ostringstream oss; - ds = new Datastore(uid, gid, uname, gname, + ds = new Datastore(uid, gid, uname, gname, umask, ds_template, cluster_id, cluster_name); // ------------------------------------------------------------------------- diff --git a/src/datastore/SConstruct b/src/datastore/SConstruct index 36514ca0b9..6dd5e51b1b 100644 --- a/src/datastore/SConstruct +++ b/src/datastore/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/datastore # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/datastore_mad/one_datastore b/src/datastore_mad/one_datastore index ba5653805b..60214272a6 100755 --- a/src/datastore_mad/one_datastore +++ b/src/datastore_mad/one_datastore @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/datastore_mad/one_datastore.rb b/src/datastore_mad/one_datastore.rb index 641b7aac7b..626572ea4c 100755 --- a/src/datastore_mad/one_datastore.rb +++ b/src/datastore_mad/one_datastore.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- */ -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # 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 */ diff --git a/src/datastore_mad/remotes/ceph/ceph.conf b/src/datastore_mad/remotes/ceph/ceph.conf new file mode 100644 index 0000000000..36d4df0058 --- /dev/null +++ b/src/datastore_mad/remotes/ceph/ceph.conf @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# 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. # +#--------------------------------------------------------------------------- # + +# Default POOL_NAME +POOL_NAME=one + +# Default Ceph server host. Storage operations will be performed in this host. +HOST=localhost + +# Staging directory +# A directory in the Ceph server host where image will be transferred to +# temporarily during the create/mkfs processes. This directoy MUST exist, +# have enough space and be writeable by 'oneadmin' +STAGING_DIR=/var/tmp diff --git a/src/datastore_mad/remotes/ceph/clone b/src/datastore_mad/remotes/ceph/clone new file mode 100755 index 0000000000..54c49b4cf2 --- /dev/null +++ b/src/datastore_mad/remotes/ceph/clone @@ -0,0 +1,71 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# 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. # +#--------------------------------------------------------------------------- # + +############################################################################### +# This script is used to copy a VM image (SRC) to the image repository as DST +# Several SRC types are supported +############################################################################### +# -------- Set up the environment to source common tools & conf ------------ +if [ -z "${ONE_LOCATION}" ]; then + LIB_LOCATION=/usr/lib/one +else + LIB_LOCATION=$ONE_LOCATION/lib +fi + +. $LIB_LOCATION/sh/scripts_common.sh + +DRIVER_PATH=$(dirname $0) +source ${DRIVER_PATH}/../libfs.sh +source ${DRIVER_PATH}/ceph.conf + +# -------- Get cp and datastore arguments from OpenNebula core ------------ + +DRV_ACTION=$1 +ID=$2 + +XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION" + +unset i XPATH_ELEMENTS + +while IFS= read -r -d '' element; do + XPATH_ELEMENTS[i++]="$element" +done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/UMASK \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/HOST \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/POOL_NAME \ + /DS_DRIVER_ACTION_DATA/IMAGE/PATH \ + /DS_DRIVER_ACTION_DATA/IMAGE/SIZE) + +unset i + +BASE_PATH="${XPATH_ELEMENTS[i++]}" +UMASK="${XPATH_ELEMENTS[i++]}" +DST_HOST="${XPATH_ELEMENTS[i++]:-$HOST}" +POOL_NAME="${XPATH_ELEMENTS[i++]:-$POOL_NAME}" +SRC="${XPATH_ELEMENTS[i++]}" +SIZE="${XPATH_ELEMENTS[i++]}" + +SAFE_DIRS="" + +IMAGE_NAME="one-${ID}" +RBD_DST="${POOL_NAME}/${IMAGE_NAME}" + +ssh_exec_and_log "$DST_HOST" "$RBD copy $SRC $RBD_DST" \ + "Error cloning $SRC to $RBD_DST in $DST_HOST" + +echo "$RBD_DST" diff --git a/src/datastore_mad/remotes/ceph/cp b/src/datastore_mad/remotes/ceph/cp new file mode 100755 index 0000000000..e72268c6a7 --- /dev/null +++ b/src/datastore_mad/remotes/ceph/cp @@ -0,0 +1,130 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# 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. # +#--------------------------------------------------------------------------- # + +############################################################################### +# This script is used to copy a VM image (SRC) to the image repository as DST +# Several SRC types are supported +############################################################################### + +# -------- Set up the environment to source common tools & conf ------------ + +if [ -z "${ONE_LOCATION}" ]; then + LIB_LOCATION=/usr/lib/one +else + LIB_LOCATION=$ONE_LOCATION/lib +fi + +. $LIB_LOCATION/sh/scripts_common.sh + +DRIVER_PATH=$(dirname $0) +source ${DRIVER_PATH}/../libfs.sh +source ${DRIVER_PATH}/ceph.conf + +# -------- Get cp and datastore arguments from OpenNebula core ------------ + +DRV_ACTION=$1 +ID=$2 + +UTILS_PATH="${DRIVER_PATH}/.." + +XPATH="$UTILS_PATH/xpath.rb -b $DRV_ACTION" + +unset i XPATH_ELEMENTS + +while IFS= read -r -d '' element; do + XPATH_ELEMENTS[i++]="$element" +done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/RESTRICTED_DIRS \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/SAFE_DIRS \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/UMASK \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/HOST \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/POOL_NAME \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/STAGING_DIR \ + /DS_DRIVER_ACTION_DATA/IMAGE/PATH \ + /DS_DRIVER_ACTION_DATA/IMAGE/SIZE \ + /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/MD5 \ + /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1 \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/NO_DECOMPRESS \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/LIMIT_TRANSFER_BW) + +unset i + +BASE_PATH="${XPATH_ELEMENTS[i++]}" +RESTRICTED_DIRS="${XPATH_ELEMENTS[i++]}" +SAFE_DIRS="${XPATH_ELEMENTS[i++]}" +UMASK="${XPATH_ELEMENTS[i++]}" +DST_HOST="${XPATH_ELEMENTS[i++]:-$HOST}" +POOL_NAME="${XPATH_ELEMENTS[i++]:-$POOL_NAME}" +STAGING_DIR="${XPATH_ELEMENTS[i++]:-$STAGING_DIR}" +SRC="${XPATH_ELEMENTS[i++]}" +SIZE="${XPATH_ELEMENTS[i++]}" +MD5="${XPATH_ELEMENTS[i++]}" +SHA1="${XPATH_ELEMENTS[i++]}" +NO_DECOMPRESS="${XPATH_ELEMENTS[i++]}" +LIMIT_TRANSFER_BW="${XPATH_ELEMENTS[i++]}" + +set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" "$UMASK" + +IMAGE_HASH=`generate_image_hash` +TMP_DST="$STAGING_DIR/$IMAGE_HASH" + +IMAGE_NAME="one-${ID}" +RBD_SOURCE="${POOL_NAME}/${IMAGE_NAME}" + +DOWNLOADER_ARGS=`set_downloader_args "$MD5" "$SHA1" "$NO_DECOMPRESS" "$LIMIT_TRANSFER_BW" "$SRC" -` + +COPY_COMMAND="$UTILS_PATH/downloader.sh $DOWNLOADER_ARGS" + +case $SRC in +http://*|https://*) + log "Downloading $SRC to the image repository" + + DUMP="$COPY_COMMAND" + ;; + +*) + if [ `check_restricted $SRC` -eq 1 ]; then + log_error "Not allowed to copy images from $RESTRICTED_DIRS" + error_message "Not allowed to copy image file $SRC" + exit -1 + fi + + log "Copying local image $SRC to the image repository" + + DUMP="$COPY_COMMAND" + ;; +esac + +exec_and_log "eval $DUMP | $SSH $DST_HOST $SUDO $DD of=$TMP_DST bs=64k" \ + "Error dumping $SRC to $DST_HOST:$TMP_DST" + +REGISTER_CMD=$(cat < /dev/null + + if [ $? = 0 ]; then + STAT_CMD="stat -c %s" + else + STAT_CMD="stat -f %z" + fi + + $STAT_CMD "$*" +} + #------------------------------------------------------------------------------- # Computes the size of an image # @param $1 - Path to the image @@ -147,7 +174,7 @@ function fs_size { SIZE=`du -sb "$1" | cut -f1` error=$? else - SIZE=`stat -c %s "$1"` + SIZE=$(file_size "$1") error=$? fi ;; diff --git a/src/datastore_mad/remotes/lvm/clone b/src/datastore_mad/remotes/lvm/clone index 8af3b3bbdf..e04c9b703f 100755 --- a/src/datastore_mad/remotes/lvm/clone +++ b/src/datastore_mad/remotes/lvm/clone @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/datastore_mad/remotes/lvm/cp b/src/datastore_mad/remotes/lvm/cp index 28d2a533e7..74ea475255 100755 --- a/src/datastore_mad/remotes/lvm/cp +++ b/src/datastore_mad/remotes/lvm/cp @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/datastore_mad/remotes/lvm/lvm.conf b/src/datastore_mad/remotes/lvm/lvm.conf index 534ae1db85..c063085ade 100644 --- a/src/datastore_mad/remotes/lvm/lvm.conf +++ b/src/datastore_mad/remotes/lvm/lvm.conf @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/datastore_mad/remotes/lvm/mkfs b/src/datastore_mad/remotes/lvm/mkfs index 5eb699d9ce..adea971511 100755 --- a/src/datastore_mad/remotes/lvm/mkfs +++ b/src/datastore_mad/remotes/lvm/mkfs @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/datastore_mad/remotes/lvm/rm b/src/datastore_mad/remotes/lvm/rm index 5b01159919..ba629cd015 100755 --- a/src/datastore_mad/remotes/lvm/rm +++ b/src/datastore_mad/remotes/lvm/rm @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/datastore_mad/remotes/vmfs/clone b/src/datastore_mad/remotes/vmfs/clone index 39c259fa13..fbe6f190c3 100755 --- a/src/datastore_mad/remotes/vmfs/clone +++ b/src/datastore_mad/remotes/vmfs/clone @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/datastore_mad/remotes/vmfs/cp b/src/datastore_mad/remotes/vmfs/cp index 90a8a254be..3d9895c51c 100755 --- a/src/datastore_mad/remotes/vmfs/cp +++ b/src/datastore_mad/remotes/vmfs/cp @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/datastore_mad/remotes/vmfs/mkfs b/src/datastore_mad/remotes/vmfs/mkfs index a76c503239..cf70ddcee9 100755 --- a/src/datastore_mad/remotes/vmfs/mkfs +++ b/src/datastore_mad/remotes/vmfs/mkfs @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/datastore_mad/remotes/vmfs/rm b/src/datastore_mad/remotes/vmfs/rm index a5a6b1eed2..29738acfaf 100755 --- a/src/datastore_mad/remotes/vmfs/rm +++ b/src/datastore_mad/remotes/vmfs/rm @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/datastore_mad/remotes/vmfs/vmfs.conf b/src/datastore_mad/remotes/vmfs/vmfs.conf index 34add2dd41..92211d06db 100644 --- a/src/datastore_mad/remotes/vmfs/vmfs.conf +++ b/src/datastore_mad/remotes/vmfs/vmfs.conf @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/datastore_mad/remotes/vmware/cp b/src/datastore_mad/remotes/vmware/cp index 7f22712a75..5964296c5e 100755 --- a/src/datastore_mad/remotes/vmware/cp +++ b/src/datastore_mad/remotes/vmware/cp @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -102,7 +102,7 @@ http://*|https://* ) ;; esac -if [ ! -f $DST/disk.vmdk ]; then +if [ -d "$DST" -a ! -f "$DST/disk.vmdk" ]; then BASE_DISK_FILE=`ls $DST | grep -v '\-\(flat\|delta\|s[0-9]*\)\.vmdk$'` diff --git a/src/datastore_mad/remotes/vmware/mkfs b/src/datastore_mad/remotes/vmware/mkfs index 13cd67afdf..9b31586d49 100755 --- a/src/datastore_mad/remotes/vmware/mkfs +++ b/src/datastore_mad/remotes/vmware/mkfs @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/datastore_mad/remotes/vmware/rm b/src/datastore_mad/remotes/vmware/rm index bb3ac1601f..8126d04480 100755 --- a/src/datastore_mad/remotes/vmware/rm +++ b/src/datastore_mad/remotes/vmware/rm @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/datastore_mad/remotes/xpath.rb b/src/datastore_mad/remotes/xpath.rb index d17f6f8a5d..ac91f5d52f 100755 --- a/src/datastore_mad/remotes/xpath.rb +++ b/src/datastore_mad/remotes/xpath.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- */ -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # 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 */ diff --git a/src/dm/DispatchManager.cc b/src/dm/DispatchManager.cc index efdb55d3a2..cc2fef385d 100644 --- a/src/dm/DispatchManager.cc +++ b/src/dm/DispatchManager.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/dm/DispatchManagerActions.cc b/src/dm/DispatchManagerActions.cc index 10e02c1bf6..144322db26 100644 --- a/src/dm/DispatchManagerActions.cc +++ b/src/dm/DispatchManagerActions.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -868,7 +868,7 @@ int DispatchManager::resubmit(int vid) case VirtualMachine::FAILED: //Cleanup VM host files vm->log("DiM", Log::INFO, "New VM state is CLEANUP."); - vm->set_state(VirtualMachine::CLEANUP); + vm->set_state(VirtualMachine::CLEANUP_RESUBMIT); vm->set_state(VirtualMachine::ACTIVE); vmpool->update(vm); @@ -1077,6 +1077,198 @@ int DispatchManager::detach( /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +int DispatchManager::snapshot_create( + int vid, + string& name, + int& snap_id, + string& error_str) +{ + ostringstream oss; + + Nebula& nd = Nebula::instance(); + VirtualMachineManager* vmm = nd.get_vmm(); + + VirtualMachine * vm = vmpool->get(vid, true); + + if ( vm == 0 ) + { + oss << "Could not create a new snapshot for VM " << vid + << ", VM does not exist" ; + error_str = oss.str(); + + NebulaLog::log("DiM", Log::ERROR, error_str); + + return -1; + } + + if ( vm->get_state() != VirtualMachine::ACTIVE || + vm->get_lcm_state() != VirtualMachine::RUNNING ) + { + oss << "Could not create a new snapshot for VM " << vid + << ", wrong state."; + error_str = oss.str(); + + NebulaLog::log("DiM", Log::ERROR, error_str); + + vm->unlock(); + return -1; + } + + vm->set_state(VirtualMachine::HOTPLUG_SNAPSHOT); + + vm->set_resched(false); + + vm->new_snapshot(name, snap_id); + + vmpool->update(vm); + + vm->unlock(); + + vmm->trigger(VirtualMachineManager::SNAPSHOT_CREATE,vid); + + return 0; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +int DispatchManager::snapshot_revert( + int vid, + int snap_id, + string& error_str) +{ + ostringstream oss; + + int rc; + + Nebula& nd = Nebula::instance(); + VirtualMachineManager* vmm = nd.get_vmm(); + + VirtualMachine * vm = vmpool->get(vid, true); + + if ( vm == 0 ) + { + oss << "Could not revert VM " << vid << " to snapshot " << snap_id + << ", VM does not exist" ; + error_str = oss.str(); + + NebulaLog::log("DiM", Log::ERROR, error_str); + + return -1; + } + + if ( vm->get_state() != VirtualMachine::ACTIVE || + vm->get_lcm_state() != VirtualMachine::RUNNING ) + { + oss << "Could not revert VM " << vid << " to snapshot " << snap_id + << ", wrong state."; + error_str = oss.str(); + + NebulaLog::log("DiM", Log::ERROR, error_str); + + vm->unlock(); + return -1; + } + + + rc = vm->set_active_snapshot(snap_id); + + if ( rc == -1 ) + { + oss << "Could not revert VM " << vid << " to snapshot " << snap_id + << ", it does not exist."; + error_str = oss.str(); + + NebulaLog::log("DiM", Log::ERROR, error_str); + + vm->unlock(); + return -1; + } + + vm->set_state(VirtualMachine::HOTPLUG_SNAPSHOT); + + vm->set_resched(false); + + vmpool->update(vm); + + vm->unlock(); + + vmm->trigger(VirtualMachineManager::SNAPSHOT_REVERT,vid); + + return 0; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +int DispatchManager::snapshot_delete( + int vid, + int snap_id, + string& error_str) +{ + ostringstream oss; + + int rc; + + Nebula& nd = Nebula::instance(); + VirtualMachineManager* vmm = nd.get_vmm(); + + VirtualMachine * vm = vmpool->get(vid, true); + + if ( vm == 0 ) + { + oss << "Could not delete snapshot " << snap_id << " for VM " << vid + << ", VM does not exist" ; + error_str = oss.str(); + + NebulaLog::log("DiM", Log::ERROR, error_str); + + return -1; + } + + if ( vm->get_state() != VirtualMachine::ACTIVE || + vm->get_lcm_state() != VirtualMachine::RUNNING ) + { + oss << "Could not delete snapshot " << snap_id << " for VM " << vid + << ", wrong state."; + error_str = oss.str(); + + NebulaLog::log("DiM", Log::ERROR, error_str); + + vm->unlock(); + return -1; + } + + rc = vm->set_active_snapshot(snap_id); + + if ( rc == -1 ) + { + oss << "Could not delete snapshot " << snap_id << " for VM " << vid + << ", it does not exist."; + error_str = oss.str(); + + NebulaLog::log("DiM", Log::ERROR, error_str); + + vm->unlock(); + return -1; + } + + vm->set_state(VirtualMachine::HOTPLUG_SNAPSHOT); + + vm->set_resched(false); + + vmpool->update(vm); + + vm->unlock(); + + vmm->trigger(VirtualMachineManager::SNAPSHOT_DELETE,vid); + + return 0; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + int DispatchManager::attach_nic( int vid, VirtualMachineTemplate* tmpl, @@ -1238,3 +1430,6 @@ int DispatchManager::detach_nic( return 0; } + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ diff --git a/src/dm/DispatchManagerStates.cc b/src/dm/DispatchManagerStates.cc index 98053f2565..f363f50af6 100644 --- a/src/dm/DispatchManagerStates.cc +++ b/src/dm/DispatchManagerStates.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -161,7 +161,7 @@ void DispatchManager::done_action(int vid) if ((dm_state == VirtualMachine::ACTIVE) && (lcm_state == VirtualMachine::EPILOG || lcm_state == VirtualMachine::CANCEL || - lcm_state == VirtualMachine::CLEANUP )) + lcm_state == VirtualMachine::CLEANUP_DELETE)) { vm->set_state(VirtualMachine::DONE); @@ -180,11 +180,11 @@ void DispatchManager::done_action(int vid) uid = vm->get_uid(); gid = vm->get_gid(); tmpl = vm->clone_template(); - + vm->unlock(); Quotas::vm_del(uid, gid, tmpl); - + delete tmpl; } else @@ -196,7 +196,7 @@ void DispatchManager::done_action(int vid) vm->unlock(); } - + return; } @@ -247,7 +247,7 @@ void DispatchManager::resubmit_action(int vid) return; } - if (vm->get_lcm_state() == VirtualMachine::CLEANUP) + if (vm->get_lcm_state() == VirtualMachine::CLEANUP_RESUBMIT) { vm->set_state(VirtualMachine::LCM_INIT); diff --git a/src/dm/SConstruct b/src/dm/SConstruct index 5e42c448f9..50b4341793 100644 --- a/src/dm/SConstruct +++ b/src/dm/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/vm # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/document/Document.cc b/src/document/Document.cc index ea6e630007..b6481e9010 100644 --- a/src/document/Document.cc +++ b/src/document/Document.cc @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------ */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -25,6 +25,7 @@ Document::Document( int id, int _gid, const string& _uname, const string& _gname, + int _umask, int _type, Template * _template_contents): PoolObjectSQL(id,DOCUMENT,"",_uid,_gid,_uname,_gname,table), type(_type) @@ -37,6 +38,8 @@ Document::Document( int id, { obj_template = new Template; } + + set_umask(_umask); } /* ------------------------------------------------------------------------ */ diff --git a/src/document/SConstruct b/src/document/SConstruct index f11904d074..11c8128522 100644 --- a/src/document/SConstruct +++ b/src/document/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/document # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/group/Group.cc b/src/group/Group.cc index 02588502b2..2f4910a099 100644 --- a/src/group/Group.cc +++ b/src/group/Group.cc @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------ */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/group/GroupPool.cc b/src/group/GroupPool.cc index b7138c54b5..9d89354544 100644 --- a/src/group/GroupPool.cc +++ b/src/group/GroupPool.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/group/SConstruct b/src/group/SConstruct index 72dabada4f..0b31ef62a2 100644 --- a/src/group/SConstruct +++ b/src/group/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/group # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/group/test/GroupPoolTest.cc b/src/group/test/GroupPoolTest.cc index 01d663fdbd..60f4238ab6 100644 --- a/src/group/test/GroupPoolTest.cc +++ b/src/group/test/GroupPoolTest.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/group/test/SConstruct b/src/group/test/SConstruct index 2439c9babc..09b3d5dac8 100644 --- a/src/group/test/SConstruct +++ b/src/group/test/SConstruct @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # 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 diff --git a/src/hm/Hook.cc b/src/hm/Hook.cc index b21a24b323..0ca992003f 100644 --- a/src/hm/Hook.cc +++ b/src/hm/Hook.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/hm/HookManager.cc b/src/hm/HookManager.cc index f49a21ea92..6c2310d515 100644 --- a/src/hm/HookManager.cc +++ b/src/hm/HookManager.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/hm/HookManagerDriver.cc b/src/hm/HookManagerDriver.cc index 83a8e62e24..9f49ba55ea 100644 --- a/src/hm/HookManagerDriver.cc +++ b/src/hm/HookManagerDriver.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/hm/SConstruct b/src/hm/SConstruct index b5d62c88f2..f3dd3688bf 100755 --- a/src/hm/SConstruct +++ b/src/hm/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/hm # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/hm_mad/hmrc b/src/hm_mad/hmrc index 1e12168116..90c559ab5d 100644 --- a/src/hm_mad/hmrc +++ b/src/hm_mad/hmrc @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/hm_mad/one_hm b/src/hm_mad/one_hm index eff8f2e295..27cfe92f5e 100755 --- a/src/hm_mad/one_hm +++ b/src/hm_mad/one_hm @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/hm_mad/one_hm.rb b/src/hm_mad/one_hm.rb index 1c0df8a728..6c055f0cb8 100755 --- a/src/hm_mad/one_hm.rb +++ b/src/hm_mad/one_hm.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/hm_mad/test/dummy b/src/hm_mad/test/dummy index e5232114ca..ae2453d9d7 100755 --- a/src/hm_mad/test/dummy +++ b/src/hm_mad/test/dummy @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/host/Host.cc b/src/host/Host.cc index f6c9fe7743..6a12e1c9fe 100644 --- a/src/host/Host.cc +++ b/src/host/Host.cc @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------ */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -62,12 +62,12 @@ Host::~Host() const char * Host::table = "host_pool"; const char * Host::db_names = - "oid, name, body, state, last_mon_time, uid, gid, owner_u, group_u, other_u"; + "oid, name, body, state, last_mon_time, uid, gid, owner_u, group_u, other_u, cid"; const char * Host::db_bootstrap = "CREATE TABLE IF NOT EXISTS host_pool (" "oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, state INTEGER, " "last_mon_time INTEGER, uid INTEGER, gid INTEGER, owner_u INTEGER, " - "group_u INTEGER, other_u INTEGER, UNIQUE(name))"; + "group_u INTEGER, other_u INTEGER, cid INTEGER, UNIQUE(name))"; const char * Host::monit_table = "host_monitoring"; @@ -136,7 +136,8 @@ int Host::insert_replace(SqlDB *db, bool replace, string& error_str) << gid << "," << owner_u << "," << group_u << "," - << other_u << ")"; + << other_u << "," + << cluster_id << ")"; rc = db->exec(oss); @@ -169,22 +170,60 @@ error_common: /* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */ -int Host::update_info(string &parse_str) +int Host::update_info(string &parse_str, + bool &with_vm_info, + set &lost, + map &found) { - char * error_msg; - int rc; - float fv; + char * error_msg; + Template* tmpl; + VectorAttribute* vatt; + vector::iterator it; + vector vm_att; + + int rc; + int vmid; + float fv; + + ostringstream zombie; + ostringstream wild; + + int num_zombies = 0; + int num_wilds = 0; + + // + // ---------------------------------------------------------------------- // + // Parse Template (twice because of repeated VM values) // + // ---------------------------------------------------------------------- // rc = obj_template->parse(parse_str, &error_msg); if ( rc != 0 ) { - NebulaLog::log("ONE", Log::ERROR, error_msg); + ostringstream ess; + + ess << "Error parsing host information: " << error_msg + << ". Monitoring information: " << endl << parse_str; + + NebulaLog::log("ONE", Log::ERROR, ess); + + touch(false); + + set_template_error_message("Error parsing monitor information." + " Check oned.log for more details."); free(error_msg); + return -1; } + tmpl = new Template(); + + tmpl->parse(parse_str, &error_msg); + + // ---------------------------------------------------------------------- // + // Extract share information // + // ---------------------------------------------------------------------- // get_template_attribute("TOTALCPU", fv); host_share.max_cpu = static_cast(fv); get_template_attribute("TOTALMEMORY", fv); @@ -200,12 +239,113 @@ int Host::update_info(string &parse_str) get_template_attribute("USEDMEMORY", fv); host_share.used_mem = static_cast(fv); + // ---------------------------------------------------------------------- // + // Remove expired information // + // ---------------------------------------------------------------------- // + clear_template_error_message(); + + remove_template_attribute("ZOMBIES"); + remove_template_attribute("TOTAL_ZOMBIES"); + + remove_template_attribute("WILDS"); + remove_template_attribute("TOTAL_WILDS"); + + remove_template_attribute("VM"); + + get_template_attribute("VM_POLL", with_vm_info); + remove_template_attribute("VM_POLL"); + + // ---------------------------------------------------------------------- // + // Correlate VM information with the list of running VMs // + // ---------------------------------------------------------------------- // + tmpl->remove("VM", vm_att); + + lost = vm_collection.get_collection_copy(); + + for (it = vm_att.begin(); it != vm_att.end(); it++) + { + vatt = dynamic_cast(*it); + + if (vatt == 0) + { + delete *it; + continue; + } + + rc = vatt->vector_value("ID", vmid); + + if (rc == 0 && vmid != -1) + { + if (lost.erase(vmid) == 1) //Good, known + { + found.insert(make_pair(vmid, vatt->vector_value("POLL"))); + } + else //Bad, known but should not be here + { + if (num_zombies++ > 0) + { + zombie << ", "; + } + + zombie << vatt->vector_value("DEPLOY_ID"); + } + } + else if (rc == 0) //not ours + { + if (num_wilds++ > 0) + { + wild << ", "; + } + + wild << vatt->vector_value("DEPLOY_ID"); + } + + delete *it; + } + + if (num_wilds > 0) + { + add_template_attribute("TOTAL_WILDS", num_wilds); + add_template_attribute("WILDS", wild.str()); + } + + if (num_zombies > 0) + { + add_template_attribute("TOTAL_ZOMBIES", num_zombies); + add_template_attribute("ZOMBIES", zombie.str()); + } + + delete tmpl; + + // Touch the host to update its last_monitored timestamp and state + + touch(true); + return 0; } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +void Host::error_info(const string& message, set &vm_ids) +{ + ostringstream oss; + + vm_ids = vm_collection.get_collection_copy(); + + oss << "Error monitoring Host " << get_name() << " (" << get_oid() << ")" + << ": " << message; + + NebulaLog::log("ONE", Log::ERROR, oss); + + touch(false); + + set_template_error_message(oss.str()); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + int Host::update_monitoring(SqlDB * db) { ostringstream oss; diff --git a/src/host/HostHook.cc b/src/host/HostHook.cc index 2cdbeffc54..134116930d 100644 --- a/src/host/HostHook.cc +++ b/src/host/HostHook.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/host/HostPool.cc b/src/host/HostPool.cc index 2bf113f4a0..f0362280fa 100644 --- a/src/host/HostPool.cc +++ b/src/host/HostPool.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -57,7 +57,6 @@ HostPool::HostPool(SqlDB* db, string on; string cmd; string arg; - string rmt; bool remote; bool state_hook = false; @@ -70,7 +69,7 @@ HostPool::HostPool(SqlDB* db, on = vattr->vector_value("ON"); cmd = vattr->vector_value("COMMAND"); arg = vattr->vector_value("ARGUMENTS"); - rmt = vattr->vector_value("REMOTE"); + vattr->vector_value("REMOTE", remote); transform (on.begin(),on.end(),on.begin(),(int(*)(int))toupper); @@ -90,33 +89,21 @@ HostPool::HostPool(SqlDB* db, name = cmd; } - remote = false; - - if ( !rmt.empty() ) - { - transform(rmt.begin(),rmt.end(),rmt.begin(),(int(*)(int))toupper); - - if ( rmt == "YES" ) - { - remote = true; - } - } - if (cmd[0] != '/') { ostringstream cmd_os; if ( remote ) { - cmd_os << hook_location << "/" << cmd; + cmd_os << hook_location << "/" << cmd; } else { cmd_os << remotes_location << "/hooks/" << cmd; - } + } cmd = cmd_os.str(); - } + } if ( on == "CREATE" ) { @@ -256,36 +243,32 @@ error_common: /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -int HostPool::discover_cb(void * _map, int num, char **values, char **names) +int HostPool::discover_cb(void * _set, int num, char **values, char **names) { - map * discovered_hosts; - string im_mad; - int hid; - int rc; + set * discovered_hosts; + string im_mad; + int hid; - discovered_hosts = static_cast *>(_map); + discovered_hosts = static_cast *>(_set); - if ( (num<2) || (values[0] == 0) || (values[1] == 0) ) + if ( (num<1) || (values[0] == 0) ) { return -1; } hid = atoi(values[0]); - rc = ObjectXML::xpath_value(im_mad,values[1],"/HOST/IM_MAD"); - if( rc != 0) - { - return -1; - } - - discovered_hosts->insert(make_pair(hid,im_mad)); + discovered_hosts->insert(hid); return 0; } /* -------------------------------------------------------------------------- */ -int HostPool::discover(map * discovered_hosts, int host_limit) +int HostPool::discover( + set * discovered_hosts, + int host_limit, + time_t target_time) { ostringstream sql; int rc; @@ -293,9 +276,9 @@ int HostPool::discover(map * discovered_hosts, int host_limit) set_callback(static_cast(&HostPool::discover_cb), static_cast(discovered_hosts)); - sql << "SELECT oid, body FROM " - << Host::table << " WHERE state != " - << Host::DISABLED << " ORDER BY last_mon_time ASC LIMIT " << host_limit; + sql << "SELECT oid FROM " << Host::table + << " WHERE last_mon_time <= " << target_time + << " ORDER BY last_mon_time ASC LIMIT " << host_limit; rc = db->exec(sql,this); diff --git a/src/host/HostShare.cc b/src/host/HostShare.cc index 81a1864ad1..7e9832b4d0 100644 --- a/src/host/HostShare.cc +++ b/src/host/HostShare.cc @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------*/ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/host/SConstruct b/src/host/SConstruct index 3c0b857325..9c39f598cc 100644 --- a/src/host/SConstruct +++ b/src/host/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/vm # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/host/test/HostHookTest.cc b/src/host/test/HostHookTest.cc index f3d8932073..1564b591e6 100644 --- a/src/host/test/HostHookTest.cc +++ b/src/host/test/HostHookTest.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/host/test/HostPoolTest.cc b/src/host/test/HostPoolTest.cc index 2bb8623c73..64c9fef251 100644 --- a/src/host/test/HostPoolTest.cc +++ b/src/host/test/HostPoolTest.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/host/test/NebulaTestHost.h b/src/host/test/NebulaTestHost.h index fa9c5c839e..df3a4cd3c4 100644 --- a/src/host/test/NebulaTestHost.h +++ b/src/host/test/NebulaTestHost.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/host/test/SConstruct b/src/host/test/SConstruct index c1359e3518..0d92a1dbf8 100644 --- a/src/host/test/SConstruct +++ b/src/host/test/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/host/test # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/im/InformationManager.cc b/src/im/InformationManager.cc index 0b2ecc2aea..99436fa033 100644 --- a/src/im/InformationManager.cc +++ b/src/im/InformationManager.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -19,9 +19,10 @@ #include #include +#include -const time_t InformationManager::monitor_expire = 600; +const time_t InformationManager::monitor_expire = 300; /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -97,6 +98,8 @@ int InformationManager::start() return -1; } + utime(remotes_location.c_str(), 0); + NebulaLog::log("InM",Log::INFO,"Starting Information Manager..."); pthread_attr_init (&pattr); @@ -144,8 +147,8 @@ void InformationManager::timer_action() struct stat sb; - map discovered_hosts; - map::iterator it; + set discovered_hosts; + set::iterator it; const InformationManagerDriver * imd; @@ -153,6 +156,7 @@ void InformationManager::timer_action() istringstream iss; time_t monitor_length; + time_t target_time; mark = mark + timer_period; @@ -165,15 +169,17 @@ void InformationManager::timer_action() // Clear the expired monitoring records hpool->clean_expired_monitoring(); - rc = hpool->discover(&discovered_hosts, host_limit); + now = time(0); + + target_time = now - monitor_period; + + rc = hpool->discover(&discovered_hosts, host_limit, target_time); if ((rc != 0) || (discovered_hosts.empty() == true)) { return; } - now = time(0); - if (stat(remotes_location.c_str(), &sb) == -1) { sb.st_mtime = 0; @@ -184,7 +190,7 @@ void InformationManager::timer_action() for(it=discovered_hosts.begin();it!=discovered_hosts.end();it++) { - host = hpool->get(it->first,true); + host = hpool->get(*it,true); if (host == 0) { @@ -200,21 +206,21 @@ void InformationManager::timer_action() hpool->update(host); } - if ( host->isEnabled() && !(host->isMonitoring()) && - (monitor_length >= monitor_period)) + if ( !(host->isMonitoring()) && + (host->isEnabled() || host->get_share_running_vms() != 0) ) { oss.str(""); oss << "Monitoring host " << host->get_name() - << " (" << it->first << ")"; + << " (" << host->get_oid() << ")"; NebulaLog::log("InM",Log::INFO,oss); - imd = get(it->second); + imd = get(host->get_im_mad()); if (imd == 0) { oss.str(""); - oss << "Could not find information driver " << it->second; + oss << "Could not find information driver " << host->get_im_mad(); NebulaLog::log("InM",Log::ERROR,oss); host->set_state(Host::ERROR); @@ -229,7 +235,7 @@ void InformationManager::timer_action() update_remotes = true; } - imd->monitor(it->first,host->get_name(),update_remotes); + imd->monitor(host->get_oid(),host->get_name(),update_remotes); host->set_monitoring_state(); } diff --git a/src/im/InformationManagerDriver.cc b/src/im/InformationManagerDriver.cc index 990638f0f3..fdd60e58f4 100644 --- a/src/im/InformationManagerDriver.cc +++ b/src/im/InformationManagerDriver.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -16,6 +16,9 @@ #include "InformationManagerDriver.h" #include "NebulaLog.h" +#include "Nebula.h" +#include "NebulaUtil.h" +#include "VirtualMachineManagerDriver.h" #include @@ -45,13 +48,18 @@ void InformationManagerDriver::protocol( string action; //stores the action result string result; - //stores the action id of the asociated HOSR + //stores the action id of the associated HOST int id; ostringstream ess; - string hinfo; + Host * host; + set vm_ids; + + string hinfo64; + string* hinfo; + // Parse the driver message if ( is.good() ) @@ -87,6 +95,13 @@ void InformationManagerDriver::protocol( if ( action == "MONITOR" ) { + bool vm_poll; + + set lost; + map found; + + int rc; + host = hpool->get(id,true); if ( host == 0 ) @@ -94,43 +109,72 @@ void InformationManagerDriver::protocol( goto error_host; } - if (result == "SUCCESS") + getline (is, hinfo64); + + hinfo = one_util::base64_decode(hinfo64); + + if (result != "SUCCESS") { - size_t pos; - int rc; + set vm_ids; - ostringstream oss; + host->error_info(*hinfo, vm_ids); - getline (is,hinfo); + Nebula &ne = Nebula::instance(); + LifeCycleManager *lcm = ne.get_lcm(); - for (pos=hinfo.find(',');pos!=string::npos;pos=hinfo.find(',')) + for (set::iterator it = vm_ids.begin(); it != vm_ids.end(); it++) { - hinfo.replace(pos,1,"\n"); + lcm->trigger(LifeCycleManager::MONITOR_DONE, *it); } - hinfo += "\n"; + delete hinfo; - oss << "Host " << id << " successfully monitored."; - NebulaLog::log("InM",Log::DEBUG,oss); + hpool->update(host); + host->unlock(); - rc = host->update_info(hinfo); - - if (rc != 0) - { - goto error_parse_info; - } - } - else - { - goto error_driver_info; + return; } - host->touch(true); + rc = host->update_info(*hinfo, vm_poll, lost, found); + + delete hinfo; hpool->update(host); + + if (rc != 0) + { + host->unlock(); + + return; + } + hpool->update_monitoring(host); + ess << "Host " << host->get_name() << " (" << host->get_oid() << ")" + << " successfully monitored."; + + NebulaLog::log("InM", Log::DEBUG, ess); + host->unlock(); + + if (vm_poll) + { + set::iterator its; + map::iterator itm; + + Nebula &ne = Nebula::instance(); + LifeCycleManager *lcm = ne.get_lcm(); + + for (its = lost.begin(); its != lost.end(); its++) + { + lcm->trigger(LifeCycleManager::MONITOR_DONE, *its); + } + + for (itm = found.begin(); itm != found.end(); itm++) + { + VirtualMachineManagerDriver::process_poll(itm->first, itm->second); + } + } } else if (action == "LOG") { @@ -142,27 +186,6 @@ void InformationManagerDriver::protocol( return; -error_driver_info: - ess << "Error monitoring host " << id << " : " << is.str(); - goto error_common_info; - -error_parse_info: - ess << "Error parsing host information: " << hinfo; - goto error_common_info; - -error_common_info: - NebulaLog::log("InM",Log::ERROR,ess); - - host->set_template_error_message(ess.str()); - - host->touch(false); - - hpool->update(host); - - host->unlock(); - - return; - error_host: ess << "Could not get host " << id; NebulaLog::log("InM",Log::ERROR,ess); @@ -170,7 +193,6 @@ error_host: return; error_parse: - ess << "Error while parsing driver message: " << message; NebulaLog::log("InM",Log::ERROR,ess); diff --git a/src/im/SConstruct b/src/im/SConstruct index 19045828e7..217720e533 100755 --- a/src/im/SConstruct +++ b/src/im/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/im # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/im_mad/dummy/one_im_dummy b/src/im_mad/dummy/one_im_dummy index 4f33b23cbe..a79e7e851e 100755 --- a/src/im_mad/dummy/one_im_dummy +++ b/src/im_mad/dummy/one_im_dummy @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/im_mad/dummy/one_im_dummy.rb b/src/im_mad/dummy/one_im_dummy.rb index 6e34cabb58..60ed2bd1be 100755 --- a/src/im_mad/dummy/one_im_dummy.rb +++ b/src/im_mad/dummy/one_im_dummy.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -30,6 +30,7 @@ $: << RUBY_LIB_LOCATION require 'OpenNebulaDriver' require 'CommandManager' +require 'base64' # The SSH Information Manager Driver @@ -48,20 +49,22 @@ class DummyInformationManager < OpenNebulaDriver # Execute the sensor array in the remote host def action_monitor(number, host, not_used) - results = "HYPERVISOR=dummy," - results << "HOSTNAME=#{host}," + results = "HYPERVISOR=dummy\n" + results << "HOSTNAME=#{host}\n" - results << "CPUSPEED=2.2GHz," + results << "CPUSPEED=2.2GHz\n" used_memory = rand(16777216) - results << "TOTALMEMORY=16777216," - results << "USEDMEMORY=#{used_memory}," - results << "FREEMEMORY=#{16777216-used_memory}," + results << "TOTALMEMORY=16777216\n" + results << "USEDMEMORY=#{used_memory}\n" + results << "FREEMEMORY=#{16777216-used_memory}\n" used_cpu = rand(800) - results << "TOTALCPU=800," - results << "USEDCPU=#{used_cpu}," - results << "FREECPU=#{800-used_cpu}" + results << "TOTALCPU=800\n" + results << "USEDCPU=#{used_cpu}\n" + results << "FREECPU=#{800-used_cpu}\n" + + results = Base64::encode64(results).strip.delete("\n") send_message("MONITOR", RESULT[:success], number, results) end diff --git a/src/im_mad/ec2/im_ec2rc b/src/im_mad/ec2/im_ec2rc index 1e12168116..90c559ab5d 100644 --- a/src/im_mad/ec2/im_ec2rc +++ b/src/im_mad/ec2/im_ec2rc @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/im_mad/ec2/one_im_ec2 b/src/im_mad/ec2/one_im_ec2 index c42810c643..7f8b1345f9 100755 --- a/src/im_mad/ec2/one_im_ec2 +++ b/src/im_mad/ec2/one_im_ec2 @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/im_mad/ec2/one_im_ec2.rb b/src/im_mad/ec2/one_im_ec2.rb index b0a0f01836..cbe5b54025 100755 --- a/src/im_mad/ec2/one_im_ec2.rb +++ b/src/im_mad/ec2/one_im_ec2.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -28,6 +28,7 @@ $: << RUBY_LIB_LOCATION require 'pp' require 'OpenNebulaDriver' +require 'base64' # The EC2 Information Manager Driver class EC2InformationManagerDriver < OpenNebulaDriver @@ -57,15 +58,16 @@ class EC2InformationManagerDriver < OpenNebulaDriver totalmemory = smem + lmem + xlmem totalcpu = scpu + lcpu + xlcpu - @info="HYPERVISOR=ec2,TOTALMEMORY=#{totalmemory},"<< - "TOTALCPU=#{totalcpu},CPUSPEED=1000,FREEMEMORY=#{totalmemory},"<< - "FREECPU=#{totalcpu}" + @info="HYPERVISOR=ec2\nTOTALMEMORY=#{totalmemory}\n"<< + "TOTALCPU=#{totalcpu}\nCPUSPEED=1000\nFREEMEMORY=#{totalmemory}"<< + "\nFREECPU=#{totalcpu}\n" end # The monitor action, just print the capacity info and hostname def action_monitor(num, host, not_used) - send_message("MONITOR", RESULT[:success], num, - "HOSTNAME=#{host},#{@info}") + info = "HOSTNAME=\"#{host}\"\n#{@info}" + info64 = Base64::encode64(info).strip.delete("\n") + send_message("MONITOR", RESULT[:success], num, info64) end end diff --git a/src/im_mad/im_exec/one_im_exec b/src/im_mad/im_exec/one_im_exec index 9e73f5990e..d54602a47c 100755 --- a/src/im_mad/im_exec/one_im_exec +++ b/src/im_mad/im_exec/one_im_exec @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/im_mad/im_exec/one_im_exec.rb b/src/im_mad/im_exec/one_im_exec.rb index a6c98e3fa7..94d04c3a47 100755 --- a/src/im_mad/im_exec/one_im_exec.rb +++ b/src/im_mad/im_exec/one_im_exec.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -71,8 +71,9 @@ class InformationManagerDriver < OpenNebulaDriver end end end + do_action("#{@hypervisor}", number, host, :MONITOR, - :script_name => 'run_probes') + :script_name => 'run_probes', :base64 => true) end end @@ -102,7 +103,7 @@ begin when '--local' local_actions={ 'MONITOR' => nil } when '--force-copy' - force_copy=true + force_copy=true end end rescue Exception => e diff --git a/src/im_mad/im_exec/one_im_sh b/src/im_mad/im_exec/one_im_sh index 8ff231bca3..4f4b991866 100755 --- a/src/im_mad/im_exec/one_im_sh +++ b/src/im_mad/im_exec/one_im_sh @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/im_mad/im_exec/one_im_ssh b/src/im_mad/im_exec/one_im_ssh index 2a7fe3f17d..1d0698d008 100755 --- a/src/im_mad/im_exec/one_im_ssh +++ b/src/im_mad/im_exec/one_im_ssh @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/im_mad/remotes/ganglia.d/ganglia_probe b/src/im_mad/remotes/ganglia.d/ganglia_probe index 1fc6a43071..2be364e322 100755 --- a/src/im_mad/remotes/ganglia.d/ganglia_probe +++ b/src/im_mad/remotes/ganglia.d/ganglia_probe @@ -87,5 +87,5 @@ info.each do |key, value| GangliaHost.print_info(key, value) end - +system("../../vmm/kvm/poll_ganglia #{host}") diff --git a/src/im_mad/remotes/kvm.d/architecture.sh b/src/im_mad/remotes/kvm.d/architecture.sh index 146fefa486..b203be16c3 100755 --- a/src/im_mad/remotes/kvm.d/architecture.sh +++ b/src/im_mad/remotes/kvm.d/architecture.sh @@ -1,7 +1,7 @@ #!/bin/sh # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/im_mad/remotes/kvm.d/cpu.sh b/src/im_mad/remotes/kvm.d/cpu.sh index 5a635ae24a..b0a4a76555 100755 --- a/src/im_mad/remotes/kvm.d/cpu.sh +++ b/src/im_mad/remotes/kvm.d/cpu.sh @@ -1,7 +1,7 @@ #!/bin/sh # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/im_mad/remotes/kvm.d/kvm.rb b/src/im_mad/remotes/kvm.d/kvm.rb index b8ca924aca..70d75b1c7d 100755 --- a/src/im_mad/remotes/kvm.d/kvm.rb +++ b/src/im_mad/remotes/kvm.d/kvm.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/im_mad/remotes/kvm.d/name.sh b/src/im_mad/remotes/kvm.d/name.sh index c58156197a..ea9f65692d 100755 --- a/src/im_mad/remotes/kvm.d/name.sh +++ b/src/im_mad/remotes/kvm.d/name.sh @@ -1,7 +1,7 @@ #!/bin/sh # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/im_mad/remotes/kvm.d/poll.sh b/src/im_mad/remotes/kvm.d/poll.sh new file mode 100755 index 0000000000..915f0a1a0a --- /dev/null +++ b/src/im_mad/remotes/kvm.d/poll.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# 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. # +#--------------------------------------------------------------------------- # + +../../vmm/kvm/poll --kvm -t + diff --git a/src/im_mad/remotes/run_probes b/src/im_mad/remotes/run_probes index 7afe8c7b48..02508eedbb 100755 --- a/src/im_mad/remotes/run_probes +++ b/src/im_mad/remotes/run_probes @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -50,7 +50,7 @@ data=$( EXIT_CODE=$? -echo $data | tr '\n' ' ' +echo "$data" if [ "x$EXIT_CODE" != "x0" ]; then exit $EXIT_CODE diff --git a/src/im_mad/remotes/vmware.d/vmware.rb b/src/im_mad/remotes/vmware.d/vmware.rb index cd02f42fbe..13b52785be 100755 --- a/src/im_mad/remotes/vmware.d/vmware.rb +++ b/src/im_mad/remotes/vmware.d/vmware.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # ---------------------------------------------------------------------------- # -# Copyright 2010-2012, C12G Labs S.L # +# Copyright 2010-2013, C12G Labs S.L # # # # 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 # @@ -41,7 +41,7 @@ ENV['LANG'] = 'C' require "scripts_common" require 'yaml' require "CommandManager" -require 'OpenNebula' +require 'opennebula' include OpenNebula begin @@ -77,13 +77,46 @@ end def add_info(name, value) value = "0" if value.nil? or value.to_s.empty? - @result_str << "#{name}=#{value} " + @result_str << "#{name}=#{value}\n" end def print_info puts @result_str end +def get_vm_names + rc, data = do_action("virsh -c #{@uri} --readonly list") + return [] if !rc + + data.gsub!(/^.*----$/m, '').strip! + lines=data.split(/\n/) + + lines.map do |line| + line.split(/\s+/).delete_if {|d| d.empty? }[1] + end.compact +end + +def get_vm_info(host, vm) + `../../vmm/vmware/poll #{vm} #{host}`.strip +end + +def get_all_vm_info(host, vms) + puts "VM_POLL=YES" + vms.each do |vm| + info=get_vm_info(host, vm) + + number = -1 + if (vm =~ /^one-\d*$/) + number = vm.split('-').last + end + + puts "VM=[" + puts " ID=#{number}," + puts " DEPLOY_ID=#{vm}," + puts " POLL=\"#{info}\" ]" + end +end + # ######################################################################## # # Main Procedure # # ######################################################################## # @@ -165,3 +198,5 @@ add_info("TOTALMEMORY",$total_memory) add_info("FREEMEMORY",free_memory.to_i) print_info + +get_all_vm_info(host, get_vm_names) diff --git a/src/im_mad/remotes/xen.d/architecture.sh b/src/im_mad/remotes/xen.d/architecture.sh index 146fefa486..b203be16c3 100755 --- a/src/im_mad/remotes/xen.d/architecture.sh +++ b/src/im_mad/remotes/xen.d/architecture.sh @@ -1,7 +1,7 @@ #!/bin/sh # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/im_mad/remotes/xen.d/cpu.sh b/src/im_mad/remotes/xen.d/cpu.sh index 5a635ae24a..b0a4a76555 100755 --- a/src/im_mad/remotes/xen.d/cpu.sh +++ b/src/im_mad/remotes/xen.d/cpu.sh @@ -1,7 +1,7 @@ #!/bin/sh # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/im_mad/remotes/xen.d/name.sh b/src/im_mad/remotes/xen.d/name.sh index c58156197a..ea9f65692d 100755 --- a/src/im_mad/remotes/xen.d/name.sh +++ b/src/im_mad/remotes/xen.d/name.sh @@ -1,7 +1,7 @@ #!/bin/sh # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/im_mad/remotes/xen.d/poll.sh b/src/im_mad/remotes/xen.d/poll.sh new file mode 100755 index 0000000000..18959738a8 --- /dev/null +++ b/src/im_mad/remotes/xen.d/poll.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# 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. # +#--------------------------------------------------------------------------- # + +../../vmm/xen4/poll --xen -t + diff --git a/src/im_mad/remotes/xen.d/xen.rb b/src/im_mad/remotes/xen.d/xen.rb index f11260a804..5a32098509 100755 --- a/src/im_mad/remotes/xen.d/xen.rb +++ b/src/im_mad/remotes/xen.d/xen.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/image/Image.cc b/src/image/Image.cc index 0548a02797..bcd358bd83 100644 --- a/src/image/Image.cc +++ b/src/image/Image.cc @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------ */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -38,6 +38,7 @@ Image::Image(int _uid, int _gid, const string& _uname, const string& _gname, + int _umask, ImageTemplate * _image_template): PoolObjectSQL(-1,IMAGE,"",_uid,_gid,_uname,_gname,table), type(OS), @@ -64,6 +65,8 @@ Image::Image(int _uid, { obj_template = new ImageTemplate; } + + set_umask(_umask); } Image::~Image() @@ -474,6 +477,8 @@ int Image::disk_attribute( VectorAttribute * disk, string driver; string disk_attr_type; + bool ro; + ostringstream iid; img_type = type; @@ -484,13 +489,17 @@ int Image::disk_attribute( VectorAttribute * disk, string template_target; string template_driver; + string template_ptype; get_template_attribute("TARGET", template_target); get_template_attribute("DRIVER", template_driver); + get_template_attribute("PERSISTENT_TYPE", template_ptype); - //--------------------------------------------------------------------------- - // DEV_PREFIX ATTRIBUTE - //--------------------------------------------------------------------------- + TO_UPPER(template_ptype); + + //--------------------------------------------------------------------------- + // DEV_PREFIX ATTRIBUTE + //--------------------------------------------------------------------------- if ( dev_prefix.empty() ) //DEV_PEFIX not in DISK, check for it in IMAGE { get_template_attribute("DEV_PREFIX", dev_prefix); @@ -503,9 +512,9 @@ int Image::disk_attribute( VectorAttribute * disk, disk->replace("DEV_PREFIX", dev_prefix); } - //--------------------------------------------------------------------------- - // BASE DISK ATTRIBUTES - //--------------------------------------------------------------------------- + //-------------------------------------------------------------------------- + // BASE DISK ATTRIBUTES + //-------------------------------------------------------------------------- disk->replace("IMAGE", name); disk->replace("IMAGE_ID", iid.str()); disk->replace("SOURCE", source); @@ -515,44 +524,72 @@ int Image::disk_attribute( VectorAttribute * disk, disk->replace("DRIVER",template_driver); } - //--------------------------------------------------------------------------- - // TYPE, READONLY, CLONE, and SAVE attributes - //--------------------------------------------------------------------------- + //-------------------------------------------------------------------------- + // READONLY attribute + //-------------------------------------------------------------------------- + if ( type == CDROM || template_ptype == "IMMUTABLE" ) + { + disk->replace("READONLY", "YES"); + } + else if ( disk->vector_value("READONLY", ro) != 0 ) + { + if ( get_template_attribute("READONLY", ro) ) + { + disk->replace("READONLY", ro); + } + else + { + disk->replace("READONLY", "NO"); + } + } + + //-------------------------------------------------------------------------- + // CLONE & SAVE attributes + //-------------------------------------------------------------------------- if ( persistent_img ) { - disk->replace("CLONE","NO"); - disk->replace("SAVE","YES"); - disk->replace("PERSISTENT","YES"); + disk->replace("PERSISTENT", "YES"); + disk->replace("CLONE", "NO"); + + if ( template_ptype == "IMMUTABLE" ) + { + disk->replace("SAVE", "NO"); + } + else + { + disk->replace("SAVE", "YES"); + } } else { - disk->replace("CLONE","YES"); - disk->replace("SAVE","NO"); + disk->replace("CLONE", "YES"); + disk->replace("SAVE", "NO"); } + //-------------------------------------------------------------------------- + // TYPE attribute + //-------------------------------------------------------------------------- switch(type) { case OS: - case DATABLOCK: //Type is FILE or BLOCK as inherited from the DS - disk_attr_type = disk_type_to_str(disk_type); - disk->replace("READONLY","NO"); + case DATABLOCK: + case RBD: //Type is FILE or BLOCK as inherited from the DS + disk_attr_type = disk_type_to_str(disk_type); break; case CDROM: //Always use CDROM type for these ones - disk_attr_type = "CDROM"; - disk->replace("READONLY","YES"); + disk_attr_type = "CDROM"; break; default: //Other file types should not be never a DISK break; } - disk->replace("TYPE",disk_attr_type); + disk->replace("TYPE", disk_attr_type); - //--------------------------------------------------------------------------- + //-------------------------------------------------------------------------- // TARGET attribute - //--------------------------------------------------------------------------- - + //-------------------------------------------------------------------------- // TARGET defined in the Image template, but not in the DISK attribute if ( target.empty() && !template_target.empty() ) { diff --git a/src/image/ImageManager.cc b/src/image/ImageManager.cc index d3a9744cd2..aa128c081d 100644 --- a/src/image/ImageManager.cc +++ b/src/image/ImageManager.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/image/ImageManagerActions.cc b/src/image/ImageManagerActions.cc index dfcc911403..31bd636bbd 100644 --- a/src/image/ImageManagerActions.cc +++ b/src/image/ImageManagerActions.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -17,7 +17,6 @@ #include "ImageManager.h" #include "NebulaLog.h" #include "ImagePool.h" -#include "SSLTools.h" #include "SyncRequest.h" #include "Template.h" #include "Nebula.h" @@ -36,7 +35,7 @@ Image * ImageManager::acquire_image(int vm_id, int image_id, string& error) if ( img == 0 ) { ostringstream oss; - oss << "Image with ID: " << image_id << " does not exists"; + oss << "Image with ID: " << image_id << " does not exist"; error = oss.str(); return 0; @@ -65,7 +64,7 @@ Image * ImageManager::acquire_image(int vm_id, const string& name, int uid, stri if ( img == 0 ) { ostringstream oss; - oss << "Image " << name << " does not exists for user " << uid; + oss << "Image " << name << " does not exist for user " << uid; error = oss.str(); return 0; @@ -812,7 +811,7 @@ string * ImageManager::format_message( << ds_data << ""; - return SSLTools::base64_encode(oss.str()); + return one_util::base64_encode(oss.str()); } /* -------------------------------------------------------------------------- */ diff --git a/src/image/ImageManagerDriver.cc b/src/image/ImageManagerDriver.cc index da7a6bb1e3..a252e219ae 100644 --- a/src/image/ImageManagerDriver.cc +++ b/src/image/ImageManagerDriver.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/image/ImagePool.cc b/src/image/ImagePool.cc index 5473b188d2..1ca4984d97 100644 --- a/src/image/ImagePool.cc +++ b/src/image/ImagePool.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -67,6 +67,7 @@ int ImagePool::allocate ( int gid, const string& uname, const string& gname, + int umask, ImageTemplate * img_template, int ds_id, const string& ds_name, @@ -86,7 +87,7 @@ int ImagePool::allocate ( string type; ostringstream oss; - img = new Image(uid, gid, uname, gname, img_template); + img = new Image(uid, gid, uname, gname, umask, img_template); // ------------------------------------------------------------------------- // Check name & duplicates diff --git a/src/image/ImageTemplate.cc b/src/image/ImageTemplate.cc index 3ef5145020..802569bfc0 100644 --- a/src/image/ImageTemplate.cc +++ b/src/image/ImageTemplate.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/image/SConstruct b/src/image/SConstruct index 26d5f70e35..db33b27a96 100644 --- a/src/image/SConstruct +++ b/src/image/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/vm # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/image/test/ImagePoolTest.cc b/src/image/test/ImagePoolTest.cc index 01e00378e2..e2dd1c22e9 100644 --- a/src/image/test/ImagePoolTest.cc +++ b/src/image/test/ImagePoolTest.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/image/test/SConstruct b/src/image/test/SConstruct index b1f7b9ac8a..670d2ec087 100644 --- a/src/image/test/SConstruct +++ b/src/image/test/SConstruct @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # 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 diff --git a/src/lcm/LifeCycleActions.cc b/src/lcm/LifeCycleActions.cc index 3833945405..b0478eaf71 100644 --- a/src/lcm/LifeCycleActions.cc +++ b/src/lcm/LifeCycleActions.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -573,6 +573,7 @@ void LifeCycleManager::delete_action(int vid) Nebula& nd = Nebula::instance(); DispatchManager * dm = nd.get_dm(); + TransferManager * tm = nd.get_tm(); vm = vmpool->get(vid,true); @@ -581,17 +582,41 @@ void LifeCycleManager::delete_action(int vid) return; } - if ( vm->get_state() == VirtualMachine::ACTIVE && - (vm->get_lcm_state() != VirtualMachine::LCM_INIT && - vm->get_lcm_state() != VirtualMachine::CLEANUP)) - { - clean_up_vm(vm); - dm->trigger(DispatchManager::DONE,vid); - } - else + if ( vm->get_state() != VirtualMachine::ACTIVE ) { - vm->log("LCM", Log::ERROR, "delete_action, VM in a wrong state."); + vm->log("LCM", Log::ERROR, "clean_action, VM in a wrong state."); + vm->unlock(); + + return; + } + + switch(vm->get_lcm_state()) + { + case VirtualMachine::LCM_INIT: + vm->log("LCM", Log::ERROR, "clean_action, VM in a wrong state."); + break; + + case VirtualMachine::CLEANUP_RESUBMIT: + case VirtualMachine::CLEANUP_DELETE: + vm->set_state(VirtualMachine::CLEANUP_DELETE); + vmpool->update(vm); + + dm->trigger(DispatchManager::DONE, vid); + break; + + case VirtualMachine::FAILURE: + vm->set_state(VirtualMachine::CLEANUP_DELETE); + vmpool->update(vm); + + tm->trigger(TransferManager::EPILOG_DELETE,vid); + dm->trigger(DispatchManager::DONE, vid); + break; + + default: + clean_up_vm(vm, true); + dm->trigger(DispatchManager::DONE, vid); + break; } vm->unlock(); @@ -606,6 +631,10 @@ void LifeCycleManager::clean_action(int vid) { VirtualMachine * vm; + Nebula& nd = Nebula::instance(); + DispatchManager * dm = nd.get_dm(); + TransferManager * tm = nd.get_tm(); + vm = vmpool->get(vid,true); if ( vm == 0 ) @@ -613,16 +642,35 @@ void LifeCycleManager::clean_action(int vid) return; } - - if ( vm->get_state() == VirtualMachine::ACTIVE && - (vm->get_lcm_state() != VirtualMachine::LCM_INIT && - vm->get_lcm_state() != VirtualMachine::CLEANUP)) - { - clean_up_vm(vm); - } - else + if ( vm->get_state() != VirtualMachine::ACTIVE ) { vm->log("LCM", Log::ERROR, "clean_action, VM in a wrong state."); + vm->unlock(); + + return; + } + + switch(vm->get_lcm_state()) + { + case VirtualMachine::LCM_INIT: + case VirtualMachine::CLEANUP_DELETE: + vm->log("LCM", Log::ERROR, "clean_action, VM in a wrong state."); + break; + + case VirtualMachine::CLEANUP_RESUBMIT: + dm->trigger(DispatchManager::RESUBMIT, vid); + break; + + case VirtualMachine::FAILURE: + vm->set_state(VirtualMachine::CLEANUP_RESUBMIT); + vmpool->update(vm); + + tm->trigger(TransferManager::EPILOG_DELETE,vid); + break; + + default: + clean_up_vm(vm, false); + break; } vm->unlock(); @@ -631,7 +679,7 @@ void LifeCycleManager::clean_action(int vid) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -void LifeCycleManager::clean_up_vm(VirtualMachine * vm) +void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose) { int cpu, mem, disk; time_t the_time = time(0); @@ -646,8 +694,19 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm) vm->log("LCM", Log::INFO, "New VM state is CLEANUP."); - vm->set_state(VirtualMachine::CLEANUP); + if (dispose) + { + vm->set_state(VirtualMachine::CLEANUP_DELETE); + } + else + { + vm->set_state(VirtualMachine::CLEANUP_RESUBMIT); + } + vm->set_resched(false); + + vm->delete_snapshots(); + vmpool->update(vm); vm->set_etime(the_time); @@ -679,13 +738,12 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm) case VirtualMachine::SHUTDOWN_POWEROFF: case VirtualMachine::CANCEL: case VirtualMachine::HOTPLUG: + case VirtualMachine::HOTPLUG_SNAPSHOT: vm->set_running_etime(the_time); vmpool->update_history(vm); vmm->trigger(VirtualMachineManager::DRIVER_CANCEL,vid); - vmm->trigger(VirtualMachineManager::CANCEL,vid); - - tm->trigger(TransferManager::EPILOG_DELETE,vid); + vmm->trigger(VirtualMachineManager::CLEANUP,vid); break; case VirtualMachine::MIGRATE: @@ -701,11 +759,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm) hpool->del_capacity(vm->get_previous_hid(), vm->get_oid(), cpu, mem, disk); vmm->trigger(VirtualMachineManager::DRIVER_CANCEL,vid); - - vmm->trigger(VirtualMachineManager::CANCEL,vid); - vmm->trigger(VirtualMachineManager::CANCEL_PREVIOUS,vid); - - tm->trigger(TransferManager::EPILOG_DELETE,vid); + vmm->trigger(VirtualMachineManager::CLEANUP_BOTH,vid); break; case VirtualMachine::SAVE_STOP: @@ -714,9 +768,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm) vmpool->update_history(vm); vmm->trigger(VirtualMachineManager::DRIVER_CANCEL,vid); - vmm->trigger(VirtualMachineManager::CANCEL,vid); - - tm->trigger(TransferManager::EPILOG_DELETE,vid); + vmm->trigger(VirtualMachineManager::CLEANUP,vid); break; case VirtualMachine::SAVE_MIGRATE: @@ -732,9 +784,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm) hpool->del_capacity(vm->get_previous_hid(), vm->get_oid(), cpu, mem, disk); vmm->trigger(VirtualMachineManager::DRIVER_CANCEL,vid); - vmm->trigger(VirtualMachineManager::CANCEL_PREVIOUS,vid); - - tm->trigger(TransferManager::EPILOG_DELETE_PREVIOUS,vid); + vmm->trigger(VirtualMachineManager::CLEANUP_PREVIOUS,vid); break; case VirtualMachine::PROLOG_MIGRATE: @@ -742,8 +792,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm) vmpool->update_history(vm); tm->trigger(TransferManager::DRIVER_CANCEL,vid); - tm->trigger(TransferManager::EPILOG_DELETE,vid); - tm->trigger(TransferManager::EPILOG_DELETE_PREVIOUS,vid); + tm->trigger(TransferManager::EPILOG_DELETE_BOTH,vid); break; case VirtualMachine::EPILOG_STOP: @@ -755,12 +804,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm) tm->trigger(TransferManager::EPILOG_DELETE,vid); break; - case VirtualMachine::FAILURE: - vmpool->update_history(vm); - tm->trigger(TransferManager::EPILOG_DELETE,vid); - break; - - default: //LCM_INIT,CLEANUP + default: //LCM_INIT,CLEANUP_RESUBMIT, CLEANUP_DELETE, FAILURE break; } } diff --git a/src/lcm/LifeCycleManager.cc b/src/lcm/LifeCycleManager.cc index eb46d8fba1..dfe3f1e4ed 100644 --- a/src/lcm/LifeCycleManager.cc +++ b/src/lcm/LifeCycleManager.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -159,6 +159,37 @@ void LifeCycleManager::trigger(Actions action, int _vid) case DETACH_NIC_FAILURE: aname = "DETACH_NIC_FAILURE"; + + case CLEANUP_SUCCESS: + aname = "CLEANUP_SUCCESS"; + break; + + case CLEANUP_FAILURE: + aname = "CLEANUP_FAILURE"; + break; + + case SNAPSHOT_CREATE_SUCCESS: + aname = "SNAPSHOT_CREATE_SUCCESS"; + break; + + case SNAPSHOT_CREATE_FAILURE: + aname = "SNAPSHOT_CREATE_FAILURE"; + break; + + case SNAPSHOT_REVERT_SUCCESS: + aname = "SNAPSHOT_REVERT_SUCCESS"; + break; + + case SNAPSHOT_REVERT_FAILURE: + aname = "SNAPSHOT_REVERT_FAILURE"; + break; + + case SNAPSHOT_DELETE_SUCCESS: + aname = "SNAPSHOT_DELETE_SUCCESS"; + break; + + case SNAPSHOT_DELETE_FAILURE: + aname = "SNAPSHOT_DELETE_FAILURE"; break; case DEPLOY: @@ -330,6 +361,38 @@ void LifeCycleManager::do_action(const string &action, void * arg) { detach_nic_failure_action(vid); } + else if (action == "CLEANUP_SUCCESS") + { + cleanup_callback_action(vid); + } + else if (action == "CLEANUP_FAILURE") + { + cleanup_callback_action(vid); + } + else if (action == "SNAPSHOT_CREATE_SUCCESS") + { + snapshot_create_success(vid); + } + else if (action == "SNAPSHOT_CREATE_FAILURE") + { + snapshot_create_failure(vid); + } + else if (action == "SNAPSHOT_REVERT_SUCCESS") + { + snapshot_revert_success(vid); + } + else if (action == "SNAPSHOT_REVERT_FAILURE") + { + snapshot_revert_failure(vid); + } + else if (action == "SNAPSHOT_DELETE_SUCCESS") + { + snapshot_delete_success(vid); + } + else if (action == "SNAPSHOT_DELETE_FAILURE") + { + snapshot_delete_failure(vid); + } else if (action == "DEPLOY") { deploy_action(vid); diff --git a/src/lcm/LifeCycleStates.cc b/src/lcm/LifeCycleStates.cc index 72d6c58d91..b2a5785de8 100644 --- a/src/lcm/LifeCycleStates.cc +++ b/src/lcm/LifeCycleStates.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -45,6 +45,8 @@ void LifeCycleManager::save_success_action(int vid) vm->set_state(VirtualMachine::PROLOG_MIGRATE); + vm->delete_snapshots(); + vmpool->update(vm); vm->set_previous_etime(the_time); @@ -81,6 +83,10 @@ void LifeCycleManager::save_success_action(int vid) // SUSPENDED STATE //---------------------------------------------------- + vm->delete_snapshots(); + + vmpool->update(vm); + vm->set_running_etime(the_time); vm->set_etime(the_time); @@ -107,6 +113,8 @@ void LifeCycleManager::save_success_action(int vid) vm->set_state(VirtualMachine::EPILOG_STOP); + vm->delete_snapshots(); + vmpool->update(vm); vm->set_epilog_stime(the_time); @@ -272,6 +280,8 @@ void LifeCycleManager::deploy_success_action(int vid) vm->set_state(VirtualMachine::RUNNING); + vm->delete_snapshots(); + vmpool->update(vm); vm->log("LCM", Log::INFO, "New VM state is RUNNING"); @@ -464,6 +474,8 @@ void LifeCycleManager::shutdown_success_action(int vid) vm->set_state(VirtualMachine::EPILOG); + vm->delete_snapshots(); + vmpool->update(vm); vm->set_epilog_stime(the_time); @@ -484,6 +496,10 @@ void LifeCycleManager::shutdown_success_action(int vid) // POWEROFF STATE //---------------------------------------------------- + vm->delete_snapshots(); + + vmpool->update(vm); + vm->set_running_etime(the_time); vm->set_etime(the_time); @@ -722,7 +738,7 @@ void LifeCycleManager::epilog_success_action(int vid) { action = DispatchManager::DONE; } - else if ( state == VirtualMachine::CLEANUP ) + else if ( state == VirtualMachine::CLEANUP_RESUBMIT ) { dm->trigger(DispatchManager::RESUBMIT, vid); @@ -762,6 +778,42 @@ void LifeCycleManager::epilog_success_action(int vid) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +void LifeCycleManager::cleanup_callback_action(int vid) +{ + Nebula& nd = Nebula::instance(); + DispatchManager * dm = nd.get_dm(); + + VirtualMachine * vm; + + VirtualMachine::LcmState state; + + vm = vmpool->get(vid,true); + + if ( vm == 0 ) + { + return; + } + + state = vm->get_lcm_state(); + + if ( state == VirtualMachine::CLEANUP_RESUBMIT ) + { + dm->trigger(DispatchManager::RESUBMIT, vid); + + } + else + { + vm->log("LCM",Log::ERROR,"cleanup_callback_action, VM in a wrong state"); + } + + vm->unlock(); + + return; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + void LifeCycleManager::epilog_failure_action(int vid) { VirtualMachine * vm; @@ -774,7 +826,7 @@ void LifeCycleManager::epilog_failure_action(int vid) return; } - if ( vm->get_lcm_state() == VirtualMachine::CLEANUP ) + if ( vm->get_lcm_state() == VirtualMachine::CLEANUP_RESUBMIT ) { Nebula& nd = Nebula::instance(); DispatchManager * dm = nd.get_dm(); @@ -823,6 +875,8 @@ void LifeCycleManager::cancel_success_action(int vid) vm->set_state(VirtualMachine::EPILOG); + vm->delete_snapshots(); + vmpool->update(vm); vm->set_reason(History::CANCEL); @@ -951,6 +1005,8 @@ void LifeCycleManager::monitor_suspend_action(int vid) vm->set_resched(false); + vm->delete_snapshots(); + vmpool->update(vm); vm->set_running_etime(the_time); @@ -1037,6 +1093,8 @@ void LifeCycleManager::failure_action(VirtualMachine * vm) vm->set_resched(false); + vm->delete_snapshots(); + vmpool->update(vm); vm->set_etime(the_time); @@ -1162,6 +1220,169 @@ void LifeCycleManager::detach_failure_action(int vid) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +void LifeCycleManager::snapshot_create_success(int vid) +{ + VirtualMachine * vm; + + vm = vmpool->get(vid,true); + + if ( vm == 0 ) + { + return; + } + + if ( vm->get_lcm_state() == VirtualMachine::HOTPLUG_SNAPSHOT ) + { + vm->clear_active_snapshot(); + + vm->set_state(VirtualMachine::RUNNING); + + vmpool->update(vm); + } + else + { + vm->log("LCM",Log::ERROR,"snapshot_create_success, VM in a wrong state"); + } + + vm->unlock(); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void LifeCycleManager::snapshot_create_failure(int vid) +{ + VirtualMachine * vm; + + vm = vmpool->get(vid,true); + + if ( vm == 0 ) + { + return; + } + + if ( vm->get_lcm_state() == VirtualMachine::HOTPLUG_SNAPSHOT ) + { + vm->delete_active_snapshot(); + + vm->set_state(VirtualMachine::RUNNING); + + vmpool->update(vm); + } + else + { + vm->log("LCM",Log::ERROR,"snapshot_create_failure, VM in a wrong state"); + } + + vm->unlock(); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void LifeCycleManager::snapshot_revert_success(int vid) +{ + // TODO: snapshot list may be inconsistent with hypervisor info + // after a revert operation + + VirtualMachine * vm; + + vm = vmpool->get(vid,true); + + if ( vm == 0 ) + { + return; + } + + if ( vm->get_lcm_state() == VirtualMachine::HOTPLUG_SNAPSHOT ) + { + vm->clear_active_snapshot(); + + vm->set_state(VirtualMachine::RUNNING); + + vmpool->update(vm); + } + else + { + vm->log("LCM",Log::ERROR,"snapshot_revert_success, VM in a wrong state"); + } + + vm->unlock(); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void LifeCycleManager::snapshot_revert_failure(int vid) +{ + // TODO: for now, it is the same code + + snapshot_revert_success(vid); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void LifeCycleManager::snapshot_delete_success(int vid) +{ + VirtualMachine * vm; + + vm = vmpool->get(vid,true); + + if ( vm == 0 ) + { + return; + } + + if ( vm->get_lcm_state() == VirtualMachine::HOTPLUG_SNAPSHOT ) + { + vm->delete_active_snapshot(); + + vm->set_state(VirtualMachine::RUNNING); + + vmpool->update(vm); + } + else + { + vm->log("LCM",Log::ERROR,"snapshot_delete_success, VM in a wrong state"); + } + + vm->unlock(); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void LifeCycleManager::snapshot_delete_failure(int vid) +{ + VirtualMachine * vm; + + vm = vmpool->get(vid,true); + + if ( vm == 0 ) + { + return; + } + + if ( vm->get_lcm_state() == VirtualMachine::HOTPLUG_SNAPSHOT ) + { + vm->clear_active_snapshot(); + + vm->set_state(VirtualMachine::RUNNING); + + vmpool->update(vm); + } + else + { + vm->log("LCM",Log::ERROR,"snapshot_delete_failure, VM in a wrong state"); + } + + vm->unlock(); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + void LifeCycleManager::attach_nic_success_action(int vid) { VirtualMachine * vm; diff --git a/src/lcm/SConstruct b/src/lcm/SConstruct index c309a5344f..922704b762 100644 --- a/src/lcm/SConstruct +++ b/src/lcm/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/vm # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/lcm/test/DummyManager.h b/src/lcm/test/DummyManager.h index bbed8166a2..9fab509cf3 100644 --- a/src/lcm/test/DummyManager.h +++ b/src/lcm/test/DummyManager.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/lcm/test/LifeCycleManagerTest.cc b/src/lcm/test/LifeCycleManagerTest.cc index 3ba2c1e2d0..d545c4e73c 100644 --- a/src/lcm/test/LifeCycleManagerTest.cc +++ b/src/lcm/test/LifeCycleManagerTest.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/lcm/test/NebulaTestLCM.h b/src/lcm/test/NebulaTestLCM.h index 6d388debb1..04e8a153e8 100644 --- a/src/lcm/test/NebulaTestLCM.h +++ b/src/lcm/test/NebulaTestLCM.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/lcm/test/SConstruct b/src/lcm/test/SConstruct index bd5dc5bfd2..45e65fcb23 100644 --- a/src/lcm/test/SConstruct +++ b/src/lcm/test/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/lcm/test # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/log/Log.cc b/src/log/Log.cc index 6780e2de68..86784f4a80 100644 --- a/src/log/Log.cc +++ b/src/log/Log.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -22,6 +22,21 @@ #include #include +#include +#include + +#ifdef SYSLOG_LOG +# include + +# include "log4cpp/Category.hh" +# include "log4cpp/CategoryStream.hh" +# include "log4cpp/Appender.hh" +# include "log4cpp/SyslogAppender.hh" +# include "log4cpp/Layout.hh" +# include "log4cpp/PatternLayout.hh" +# include "log4cpp/Priority.hh" +#endif /* SYSLOG_LOG */ + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -141,3 +156,166 @@ void CerrLog::log( cerr.flush(); } } + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +#ifdef SYSLOG_LOG + +const char * SysLog::CATEGORY = "ROOT"; +string SysLog::LABEL; + +/* -------------------------------------------------------------------------- */ + +SysLog::SysLog(const MessageType level, + const string& label):Log(level) +{ + static bool initialized = false; + + if (!initialized) //Initialize just once for all SysLog instances + { + ostringstream oss; + log4cpp::Appender *appender; + + oss << label << "[" << getpid() << "]"; + + LABEL = oss.str(); + + appender = new log4cpp::SyslogAppender(CATEGORY, LABEL, LOG_DAEMON); + appender->setLayout(new log4cpp::PatternLayout()); + + log4cpp::Category& root = log4cpp::Category::getRoot(); + + root.setPriority(SysLog::get_priority_level(level)); + root.addAppender(appender); + + initialized = true; + } +}; + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void SysLog::log( + const char * module, + const MessageType type, + const char * message) +{ + log4cpp::Category& root = log4cpp::Category::getRoot(); + log4cpp::Priority::PriorityLevel level = get_priority_level(type); + + istringstream smessage; + string line; + + smessage.str(message); + + while ( getline(smessage, line) ) + { + root << level << "[" << module << "]" + << "[" << error_names[type] << "]: " + << line; + } +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +log4cpp::Priority::PriorityLevel SysLog::get_priority_level( + const MessageType level) +{ + log4cpp::Priority::PriorityLevel priority_level; + + switch (level) + { + case Log::ERROR: + priority_level = log4cpp::Priority::ERROR; + break; + + case Log::WARNING: + priority_level = log4cpp::Priority::WARN; + break; + + case Log::INFO: + priority_level = log4cpp::Priority::INFO; + break; + + case Log::DEBUG: + case Log::DDEBUG: + case Log::DDDEBUG: + priority_level = log4cpp::Priority::DEBUG; + break; + + default: + priority_level = log4cpp::Priority::NOTSET; + break; + } + + return priority_level; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +const char * SysLogResource::CATEGORY = "RESOURCE"; + +/* -------------------------------------------------------------------------- */ + +SysLogResource::SysLogResource( + int oid, + const PoolObjectSQL::ObjectType obj_type, + const MessageType clevel):SysLog(clevel) +{ + static bool initialized = false; + ostringstream oss_label; + string obj_type_str; + + if (!initialized) + { + log4cpp::Appender *appender; + + appender = new log4cpp::SyslogAppender(CATEGORY, + SysLog::LABEL, + LOG_DAEMON); + + appender->setLayout(new log4cpp::PatternLayout()); + + log4cpp::Category& res = log4cpp::Category::getInstance(CATEGORY); + + res.addAppender(appender); + res.setPriority(SysLog::get_priority_level(clevel)); + + initialized = true; + } + + obj_type_str = PoolObjectSQL::type_to_str(obj_type); + + oss_label << "[" << obj_type_str << " " << oid << "]"; + obj_label = oss_label.str(); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void SysLogResource::log( + const char * module, + const MessageType type, + const char * message) +{ + log4cpp::Category& res = log4cpp::Category::getInstance(CATEGORY); + log4cpp::Priority::PriorityLevel level = get_priority_level(type); + + istringstream smessage; + string line; + + smessage.str(message); + + while ( getline(smessage, line) ) + { + res << level << obj_label + << "[" << module << "]" + << "[" << error_names[type] << "]: " + << line; + } +} + +#endif /* SYSLOG_LOG */ diff --git a/src/log/NebulaLog.cc b/src/log/NebulaLog.cc index 2ee2b508f0..df6f7cdcaa 100644 --- a/src/log/NebulaLog.cc +++ b/src/log/NebulaLog.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/log/SConstruct b/src/log/SConstruct index 32c3201757..b7c05fb822 100644 --- a/src/log/SConstruct +++ b/src/log/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/log # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/mad/Mad.cc b/src/mad/Mad.cc index e33c04cfdb..0f5ef2750e 100644 --- a/src/mad/Mad.cc +++ b/src/mad/Mad.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/mad/MadManager.cc b/src/mad/MadManager.cc index 287b61c0ba..ead10b39d6 100644 --- a/src/mad/MadManager.cc +++ b/src/mad/MadManager.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/mad/SConstruct b/src/mad/SConstruct index 8439c4f263..060d9af7a7 100644 --- a/src/mad/SConstruct +++ b/src/mad/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/mad # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/mad/ruby/ActionManager.rb b/src/mad/ruby/ActionManager.rb index 88e7079a44..e013fa4e34 100644 --- a/src/mad/ruby/ActionManager.rb +++ b/src/mad/ruby/ActionManager.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- */ -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # 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 */ diff --git a/src/mad/ruby/CommandManager.rb b/src/mad/ruby/CommandManager.rb index fff4ca3929..16ba8eecef 100644 --- a/src/mad/ruby/CommandManager.rb +++ b/src/mad/ruby/CommandManager.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # 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 diff --git a/src/mad/ruby/DriverExecHelper.rb b/src/mad/ruby/DriverExecHelper.rb index f179a55d03..d462db9cc1 100644 --- a/src/mad/ruby/DriverExecHelper.rb +++ b/src/mad/ruby/DriverExecHelper.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/mad/ruby/Ganglia.rb b/src/mad/ruby/Ganglia.rb index e7ba2701d3..668f667b34 100644 --- a/src/mad/ruby/Ganglia.rb +++ b/src/mad/ruby/Ganglia.rb @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # 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 diff --git a/src/mad/ruby/OpenNebulaDriver.rb b/src/mad/ruby/OpenNebulaDriver.rb index 97cf5dd134..b5ba44ff95 100644 --- a/src/mad/ruby/OpenNebulaDriver.rb +++ b/src/mad/ruby/OpenNebulaDriver.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -18,6 +18,7 @@ require "ActionManager" require "CommandManager" require "DriverExecHelper" +require 'base64' # This class provides basic messaging and logging functionality # to implement OpenNebula Drivers. A driver is a program that @@ -29,7 +30,7 @@ require "DriverExecHelper" # with the action name through the register_action function class OpenNebulaDriver < ActionManager include DriverExecHelper - + # @return [String] Base path for scripts attr_reader :local_scripts_base_path, :remote_scripts_base_path # @return [String] Path for scripts @@ -57,10 +58,10 @@ class OpenNebulaDriver < ActionManager super(@options[:concurrency], @options[:threaded]) - @retries = @options[:retries] + @retries = @options[:retries] #Set default values - initialize_helper(directory, @options) + initialize_helper(directory, @options) register_action(:INIT, method("init")) end @@ -78,13 +79,15 @@ class OpenNebulaDriver < ActionManager # @option ops [String] :stdin text to be writen to stdin # @option ops [String] :script_name default script name for the action, # action name is used by defaults - # @option ops [String] :respond if defined will send result to ONE core + # @option ops [Bool] :respond if defined will send result to ONE core + # @option ops [Bool] :base64 encode the information sent to ONE core def do_action(parameters, id, host, aname, ops={}) options={ :stdin => nil, :script_name => nil, :respond => true, - :ssh_stream => nil + :ssh_stream => nil, + :base64 => false }.merge(ops) params = parameters + " #{id} #{host}" @@ -115,7 +118,8 @@ class OpenNebulaDriver < ActionManager result, info = get_info_from_execution(execution) if options[:respond] - send_message(aname,result,id,info) + info = Base64::encode64(info).strip.delete("\n") if options[:base64] + send_message(aname, result, id, info) end [result, info] diff --git a/src/mad/ruby/VirtualMachineDriver.rb b/src/mad/ruby/VirtualMachineDriver.rb index 330c6602b3..7d1665ef75 100644 --- a/src/mad/ruby/VirtualMachineDriver.rb +++ b/src/mad/ruby/VirtualMachineDriver.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -42,8 +42,12 @@ class VirtualMachineDriver < OpenNebulaDriver :log => "LOG", :attach_disk => "ATTACHDISK", :detach_disk => "DETACHDISK", + :snapshot_create => "SNAPSHOTCREATE", + :snapshot_revert => "SNAPSHOTREVERT", + :snapshot_delete => "SNAPSHOTDELETE", + :cleanup => "CLEANUP", :attach_nic => "ATTACHNIC", - :detach_nic => "DETACHNIC", + :detach_nic => "DETACHNIC" } POLL_ATTRIBUTE = { @@ -80,17 +84,24 @@ class VirtualMachineDriver < OpenNebulaDriver @hosts = Array.new - register_action(ACTION[:deploy].to_sym, method("deploy")) - register_action(ACTION[:shutdown].to_sym, method("shutdown")) - register_action(ACTION[:reboot].to_sym, method("reboot")) - register_action(ACTION[:reset].to_sym, method("reset")) - register_action(ACTION[:cancel].to_sym, method("cancel")) - register_action(ACTION[:save].to_sym, method("save")) - register_action(ACTION[:restore].to_sym, method("restore")) - register_action(ACTION[:migrate].to_sym, method("migrate")) - register_action(ACTION[:poll].to_sym, method("poll")) - register_action(ACTION[:attach_disk].to_sym, method("attach_disk")) - register_action(ACTION[:detach_disk].to_sym, method("detach_disk")) + register_action(ACTION[:deploy].to_sym, method("deploy")) + register_action(ACTION[:shutdown].to_sym, method("shutdown")) + register_action(ACTION[:reboot].to_sym, method("reboot")) + register_action(ACTION[:reset].to_sym, method("reset")) + register_action(ACTION[:cancel].to_sym, method("cancel")) + register_action(ACTION[:save].to_sym, method("save")) + register_action(ACTION[:restore].to_sym, method("restore")) + register_action(ACTION[:migrate].to_sym, method("migrate")) + register_action(ACTION[:poll].to_sym, method("poll")) + register_action(ACTION[:attach_disk].to_sym, method("attach_disk")) + register_action(ACTION[:detach_disk].to_sym, method("detach_disk")) + register_action(ACTION[:snapshot_create].to_sym, + method("snapshot_create")) + register_action(ACTION[:snapshot_revert].to_sym, + method("snapshot_revert")) + register_action(ACTION[:snapshot_delete].to_sym, + method("snapshot_delete")) + register_action(ACTION[:cleanup].to_sym, method("cleanup")) register_action(ACTION[:attach_nic].to_sym, method("attach_nic")) register_action(ACTION[:detach_nic].to_sym, method("detach_nic")) end @@ -180,6 +191,25 @@ class VirtualMachineDriver < OpenNebulaDriver def detach_nic(id, drv_message) error = "Action not implemented by driver #{self.class}" send_message(ACTION[:detach_nic],RESULT[:failure],id,error) + + def snapshot_create(id, drv_message) + error = "Action not implemented by driver #{self.class}" + send_message(ACTION[:snapshot_create],RESULT[:failure],id,error) + end + + def snapshot_revert(id, drv_message) + error = "Action not implemented by driver #{self.class}" + send_message(ACTION[:snapshot_revert],RESULT[:failure],id,error) + end + + def snapshot_delete(id, drv_message) + error = "Action not implemented by driver #{self.class}" + send_message(ACTION[:snapshot_delete],RESULT[:failure],id,error) + end + + def cleanup(id, drv_message) + error = "Action not implemented by driver #{self.class}" + send_message(ACTION[:cleanup],RESULT[:failure],id,error) end private diff --git a/src/mad/ruby/scripts_common.rb b/src/mad/ruby/scripts_common.rb index 5288ab6e54..2824c2de98 100644 --- a/src/mad/ruby/scripts_common.rb +++ b/src/mad/ruby/scripts_common.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/mad/ruby/ssh_stream.rb b/src/mad/ruby/ssh_stream.rb index 85bbb1427c..e10293dd91 100644 --- a/src/mad/ruby/ssh_stream.rb +++ b/src/mad/ruby/ssh_stream.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/mad/sh/madcommon.sh b/src/mad/sh/madcommon.sh index 5ac13551a2..2b171c191c 100644 --- a/src/mad/sh/madcommon.sh +++ b/src/mad/sh/madcommon.sh @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/mad/sh/scripts_common.sh b/src/mad/sh/scripts_common.sh index 74ae5eb7e9..86efa9a7e8 100644 --- a/src/mad/sh/scripts_common.sh +++ b/src/mad/sh/scripts_common.sh @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -28,6 +28,7 @@ GREP=grep ISCSIADM=iscsiadm LVCREATE=lvcreate LVREMOVE=lvremove +LVRENAME=lvrename LVS=lvs LN=ln MD5SUM=md5sum @@ -35,7 +36,9 @@ MKFS=mkfs MKISOFS=genisoimage MKSWAP=mkswap QEMU_IMG=qemu-img +RBD=rbd READLINK=readlink +RM=rm SCP=scp SED=sed SSH=ssh @@ -44,6 +47,7 @@ SYNC=sync TAR=tar TGTADM=tgtadm TGTADMIN=tgt-admin +TGTSETUPLUN=tgt-setup-lun-one VMKFSTOOLS=vmkfstools WGET=wget @@ -242,7 +246,7 @@ function mkfs_command { "jfs") OPTS="-q" ;; - "raw") + "raw"|"") echo "" return 0 ;; @@ -349,12 +353,12 @@ function tgtadm_target_delete { function tgtadm_get_tid_for_iqn { IQN="$1" - echo "$TGTADM --lld iscsi --op show --mode target | \ + echo "$TGTADM --lld iscsi --op show --mode target | strings | \ grep \"$IQN\" | awk '{split(\$2,tmp,\":\"); print(tmp[1]);}'" } function tgtadm_next_tid { - echo "$TGTADM --lld iscsi --op show --mode target | \ + echo "$TGTADM --lld iscsi --op show --mode target | strings | \ $GREP \"Target\" | tail -n 1 | \ $AWK '{split(\$2,tmp,\":\"); print tmp[1]+1;}'" } @@ -402,6 +406,30 @@ function iqn_get_vg_name { echo $TARGET|$AWK -F. '{print $(NF-1)}' } +function tgt_setup_lun_install { + DST_HOST="$1" + BASE_PATH="$2" + + CHECK_FILE="$BASE_PATH/.tgt-setup-lun" + + if [ ! -f "$CHECK_FILE" ]; then + $SSH "$DST_HOST" "$SUDO $TGTSETUPLUN" 2>&1 | \ + $GREP -q "command not found" + if [ "$?" = "0" ]; then + error_message "$TGTSETUPLUN is not installed in $DST_HOST." + exit 127 + else + touch "$CHECK_FILE" + fi + fi +} + +function tgt_setup_lun { + IQN="$1" + DEV="$2" + echo "$TGTSETUPLUN -d $DEV -n $IQN 1>&2" +} + function iqn_get_host { IQN="$1" TARGET=`echo "$IQN"|$CUT -d: -f2` @@ -426,10 +454,10 @@ function vmfs_set_up { if [ "$USE_SSH" != "yes" ]; then USERNAME=`echo $(cat $VMWARERC |grep ":username:"|cut -d":" -f 3|tr -d '"')` PASSWORD=`echo $(cat $VMWARERC |grep ":password:"|cut -d":" -f 3|tr -d '"')` - if [ -z $PASSWORD ]; then - VI_PARAMS="--server $DST_HOST --username $USERNAME --password \"\"" - else - VI_PARAMS="--server $DST_HOST --username $USERNAME --password $PASSWORD" + if [ -z $PASSWORD ]; then + VI_PARAMS="--server $DST_HOST --username $USERNAME --password \"\"" + else + VI_PARAMS="--server $DST_HOST --username $USERNAME --password $PASSWORD" fi fi } diff --git a/src/mad/test/dummy b/src/mad/test/dummy index df4f999d96..6a44103353 100755 --- a/src/mad/test/dummy +++ b/src/mad/test/dummy @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/mad/utils/SConstruct b/src/mad/utils/SConstruct index f9479f344a..4df299a2f2 100644 --- a/src/mad/utils/SConstruct +++ b/src/mad/utils/SConstruct @@ -1,5 +1,5 @@ # ---------------------------------------------------------------------------- # -# Copyright 2010-2012, C12G Labs S.L # +# Copyright 2010-2013, C12G Labs S.L # # # # 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 # diff --git a/src/mad/utils/tty_expect.c b/src/mad/utils/tty_expect.c index e81d662933..a00ebe286e 100644 --- a/src/mad/utils/tty_expect.c +++ b/src/mad/utils/tty_expect.c @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2010-2012, C12G Labs S.L. */ +/* Copyright 2010-2013, C12G Labs S.L. */ /* */ /* 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 */ diff --git a/src/nebula/Nebula.cc b/src/nebula/Nebula.cc index de2e0645cd..a736c860d8 100644 --- a/src/nebula/Nebula.cc +++ b/src/nebula/Nebula.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -317,18 +317,28 @@ void Nebula::start() try { - string log_fname; - Log::MessageType clevel; + Log::MessageType clevel; + NebulaLog::LogType log_system; - log_fname = log_location + "oned.log"; - clevel = get_debug_level(); + log_system = get_log_system(); + clevel = get_debug_level(); // Initializing ONE Daemon log system + if ( log_system != NebulaLog::UNDEFINED ) + { + string log_fname; + log_fname = log_location + "oned.log"; - NebulaLog::init_log_system(NebulaLog::FILE_TS, - clevel, - log_fname.c_str(), - ios_base::trunc); + NebulaLog::init_log_system(log_system, + clevel, + log_fname.c_str(), + ios_base::trunc, + "oned"); + } + else + { + throw runtime_error("Unknown LOG_SYSTEM."); + } os << "Starting " << version() << endl; os << "----------------------------------------\n"; @@ -517,6 +527,8 @@ void Nebula::start() time_t vm_expiration; time_t host_expiration; + bool vm_submit_on_hold; + vector vm_hooks; vector host_hooks; vector vnet_hooks; @@ -543,12 +555,15 @@ void Nebula::start() nebula_configuration->get("VM_MONITORING_EXPIRATION_TIME",vm_expiration); nebula_configuration->get("HOST_MONITORING_EXPIRATION_TIME",host_expiration); + nebula_configuration->get("VM_SUBMIT_ON_HOLD",vm_submit_on_hold); + vmpool = new VirtualMachinePool(db, vm_hooks, hook_location, remotes_location, vm_restricted_attrs, - vm_expiration); + vm_expiration, + vm_submit_on_hold); hpool = new HostPool(db, host_hooks, hook_location, @@ -623,17 +638,19 @@ void Nebula::start() MadManager::mad_manager_system_init(); time_t timer_period; + time_t monitor_period; nebula_configuration->get("MANAGER_TIMER", timer_period); + nebula_configuration->get("MONITORING_INTERVAL", monitor_period); // ---- Virtual Machine Manager ---- try { - time_t poll_period; vector vmm_mads; int vm_limit; + time_t poll_period; - nebula_configuration->get("VM_POLLING_INTERVAL", poll_period); + poll_period = monitor_period * 2.5; nebula_configuration->get("VM_PER_INTERVAL", vm_limit); @@ -680,11 +697,8 @@ void Nebula::start() try { vector im_mads; - time_t monitor_period; int host_limit; - nebula_configuration->get("HOST_MONITORING_INTERVAL", monitor_period); - nebula_configuration->get("HOST_PER_INTERVAL", host_limit); nebula_configuration->get("IM_MAD", im_mads); diff --git a/src/nebula/NebulaTemplate.cc b/src/nebula/NebulaTemplate.cc index 7a86acdda2..5d1c4c4041 100644 --- a/src/nebula/NebulaTemplate.cc +++ b/src/nebula/NebulaTemplate.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -78,6 +78,7 @@ void OpenNebulaTemplate::set_conf_default() SingleAttribute * attribute; VectorAttribute * vattribute; string value; + map vvalue; // MANAGER_TIMER value = "15"; @@ -88,22 +89,22 @@ void OpenNebulaTemplate::set_conf_default() #******************************************************************************* # Daemon configuration attributes #------------------------------------------------------------------------------- -# HOST_MONITORING_INTERVAL +# MONITORING_INTERVAL # HOST_PER_INTERVAL # HOST_MONITORING_EXPIRATION_TIME -# VM_POLLING_INTERVAL # VM_PER_INTERVAL # VM_MONITORING_EXPIRATION_TIME # PORT # DB # VNC_BASE_PORT # SCRIPTS_REMOTE_DIR +# VM_SUBMIT_ON_HOLD #******************************************************************************* */ - // MONITOR_INTERVAL - value = "600"; + // MONITORING_INTERVAL + value = "300"; - attribute = new SingleAttribute("HOST_MONITORING_INTERVAL",value); + attribute = new SingleAttribute("MONITORING_INTERVAL",value); conf_default.insert(make_pair(attribute->name(),attribute)); // HOST_PER_INTERVAL @@ -118,12 +119,6 @@ void OpenNebulaTemplate::set_conf_default() attribute = new SingleAttribute("HOST_MONITORING_EXPIRATION_TIME",value); conf_default.insert(make_pair(attribute->name(),attribute)); - // POLL_INTERVAL - value = "600"; - - attribute = new SingleAttribute("VM_POLLING_INTERVAL",value); - conf_default.insert(make_pair(attribute->name(),attribute)); - // VM_PER_INTERVAL value = "5"; @@ -143,7 +138,6 @@ void OpenNebulaTemplate::set_conf_default() conf_default.insert(make_pair(attribute->name(),attribute)); //DB CONFIGURATION - map vvalue; vvalue.insert(make_pair("BACKEND","sqlite")); vattribute = new VectorAttribute("DB",vvalue); @@ -167,6 +161,19 @@ void OpenNebulaTemplate::set_conf_default() attribute = new SingleAttribute("SCRIPTS_REMOTE_DIR",value); conf_default.insert(make_pair(attribute->name(),attribute)); + // VM_SUBMIT_ON_HOLD + value = "NO"; + + attribute = new SingleAttribute("VM_SUBMIT_ON_HOLD",value); + conf_default.insert(make_pair(attribute->name(),attribute)); + + // LOG CONFIGURATION + vvalue.clear(); + vvalue.insert(make_pair("SYSTEM","file")); + vvalue.insert(make_pair("DEBUG_LEVEL","3")); + + vattribute = new VectorAttribute("LOG",vvalue); + conf_default.insert(make_pair(vattribute->name(),vattribute)); /* #******************************************************************************* # Physical Networks configuration @@ -218,6 +225,7 @@ void OpenNebulaTemplate::set_conf_default() #******************************************************************************* # SESSION_EXPIRATION_TIME # ENABLE_OTHER_PERMISSIONS +# DEFAULT_UMASK #******************************************************************************* */ // SESSION_EXPIRATION_TIME @@ -231,5 +239,11 @@ void OpenNebulaTemplate::set_conf_default() attribute = new SingleAttribute("ENABLE_OTHER_PERMISSIONS",value); conf_default.insert(make_pair(attribute->name(),attribute)); + + // DEFAULT_UMASK + value = "177"; + + attribute = new SingleAttribute("DEFAULT_UMASK",value); + conf_default.insert(make_pair(attribute->name(),attribute)); } diff --git a/src/nebula/SConstruct b/src/nebula/SConstruct index 2483ba74d2..7d389a5159 100644 --- a/src/nebula/SConstruct +++ b/src/nebula/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/nebula # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -25,7 +25,7 @@ lib_name='nebula_core' source_files=[ 'SystemDB.cc', 'Nebula.cc', - 'NebulaTemplate.cc', + 'NebulaTemplate.cc' ] # Build library diff --git a/src/nebula/SystemDB.cc b/src/nebula/SystemDB.cc index 444033a917..8c8178f9bb 100644 --- a/src/nebula/SystemDB.cc +++ b/src/nebula/SystemDB.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/nebula/oned.cc b/src/nebula/oned.cc index cfe7968607..39101586a0 100644 --- a/src/nebula/oned.cc +++ b/src/nebula/oned.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -44,7 +44,7 @@ static const char * susage = static void print_license() { - cout<< "Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)\n\n" + cout<< "Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs\n\n" << Nebula::version() << " is distributed and licensed for use under the" << " terms of the\nApache License, Version 2.0 " << "(http://www.apache.org/licenses/LICENSE-2.0).\n"; diff --git a/src/oca/java/build.sh b/src/oca/java/build.sh index 14d3ad1694..425708b9b8 100755 --- a/src/oca/java/build.sh +++ b/src/oca/java/build.sh @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -83,8 +83,8 @@ do_documentation() -doctitle 'OpenNebula Cloud API Specification' \ -header 'OpenNebula
Cloud API' \ -bottom 'Visit OpenNebula.org
Copyright 2002-2012 © -OpenNebula Project Leads (OpenNebula.org).' +href="http://opennebula.org/">OpenNebula.org
Copyright 2002-2013 © +OpenNebula Project (OpenNebula.org), C12G Labs.' } do_jar() diff --git a/src/oca/java/share/examples/SessionInit.java b/src/oca/java/share/examples/SessionInit.java index 9d01ce8771..6d9fd2a088 100644 --- a/src/oca/java/share/examples/SessionInit.java +++ b/src/oca/java/share/examples/SessionInit.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/share/examples/UserSample.java b/src/oca/java/share/examples/UserSample.java index a1a0b5acee..4154d9462a 100644 --- a/src/oca/java/share/examples/UserSample.java +++ b/src/oca/java/share/examples/UserSample.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/share/examples/VMachineSample.java b/src/oca/java/share/examples/VMachineSample.java index 56ec256da5..aaedce071a 100644 --- a/src/oca/java/share/examples/VMachineSample.java +++ b/src/oca/java/share/examples/VMachineSample.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/src/org/opennebula/client/Client.java b/src/oca/java/src/org/opennebula/client/Client.java index 2fff759a34..1c0233a605 100644 --- a/src/oca/java/src/org/opennebula/client/Client.java +++ b/src/oca/java/src/org/opennebula/client/Client.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -129,16 +129,6 @@ public class Client{ return call("system.version"); } - /** - * Calls OpenNebula and retrieves oned configuration - * - * @return The server's xml-rpc response encapsulated - */ - public OneResponse get_config() - { - return call("system.config"); - } - //-------------------------------------------------------------------------- // PRIVATE ATTRIBUTES AND METHODS //-------------------------------------------------------------------------- diff --git a/src/oca/java/src/org/opennebula/client/ClientConfigurationException.java b/src/oca/java/src/org/opennebula/client/ClientConfigurationException.java index 34f05a1054..fa8a1d76d8 100644 --- a/src/oca/java/src/org/opennebula/client/ClientConfigurationException.java +++ b/src/oca/java/src/org/opennebula/client/ClientConfigurationException.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/src/org/opennebula/client/OneException.java b/src/oca/java/src/org/opennebula/client/OneException.java index 679782d228..509efcd34b 100644 --- a/src/oca/java/src/org/opennebula/client/OneException.java +++ b/src/oca/java/src/org/opennebula/client/OneException.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/src/org/opennebula/client/OneResponse.java b/src/oca/java/src/org/opennebula/client/OneResponse.java index 52ac04c178..b5242ebe2d 100644 --- a/src/oca/java/src/org/opennebula/client/OneResponse.java +++ b/src/oca/java/src/org/opennebula/client/OneResponse.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/src/org/opennebula/client/OneSystem.java b/src/oca/java/src/org/opennebula/client/OneSystem.java index d40aa83bae..433e8a523d 100644 --- a/src/oca/java/src/org/opennebula/client/OneSystem.java +++ b/src/oca/java/src/org/opennebula/client/OneSystem.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,12 +32,84 @@ public class OneSystem private static final String GROUP_QUOTA_INFO = "groupquota.info"; private static final String GROUP_QUOTA_UPDATE = "groupquota.update"; + public static final String VERSION = "3.9.0"; public OneSystem(Client client) { this.client = client; } + /** + * Calls OpenNebula and retrieves the oned version + * + * @return The server's xml-rpc response encapsulated + */ + public OneResponse getOnedVersion() + { + return client.call("system.version"); + } + + /** + * Returns whether of not the oned version is the same as the OCA version + * + * @return true if oned is the same version + */ + public boolean compatibleVersion() + { + OneResponse r = getOnedVersion(); + + if (r.isError()) + { + return false; + } + + String[] ocaVersion = VERSION.split("\\.", 3); + String[] onedVersion = r.getMessage().split("\\.", 3); + + return ocaVersion.length == onedVersion.length && + ocaVersion[0].equals(onedVersion[0]) && + ocaVersion[1].equals(onedVersion[1]); + } + + /** + * Calls OpenNebula and retrieves oned configuration + * + * @return The server's xml-rpc response encapsulated + */ + public OneResponse getConfiguration() + { + return client.call("system.config"); + } + + /** + * Calls OpenNebula and retrieves oned configuration + * + * @return The xml root node in case of success, null otherwise + */ + public Node getConfigurationXML() + { + OneResponse r = getConfiguration(); + Node xml = null; + + if (r.isError()) + { + return null; + } + + try + { + DocumentBuilder builder = + DocumentBuilderFactory.newInstance().newDocumentBuilder(); + Document doc = builder.parse( + new ByteArrayInputStream(r.getMessage().getBytes())); + + xml = doc.getDocumentElement(); + } + catch (Exception e) {} + + return xml; + } + /** * Gets the default user quota limits * diff --git a/src/oca/java/src/org/opennebula/client/Pool.java b/src/oca/java/src/org/opennebula/client/Pool.java index 6afc200198..49472a15ae 100644 --- a/src/oca/java/src/org/opennebula/client/Pool.java +++ b/src/oca/java/src/org/opennebula/client/Pool.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/src/org/opennebula/client/PoolElement.java b/src/oca/java/src/org/opennebula/client/PoolElement.java index 28f1831772..c5caf3a5b5 100644 --- a/src/oca/java/src/org/opennebula/client/PoolElement.java +++ b/src/oca/java/src/org/opennebula/client/PoolElement.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/src/org/opennebula/client/acl/Acl.java b/src/oca/java/src/org/opennebula/client/acl/Acl.java index bd82d71312..3b257b387b 100644 --- a/src/oca/java/src/org/opennebula/client/acl/Acl.java +++ b/src/oca/java/src/org/opennebula/client/acl/Acl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,6 +52,7 @@ public class Acl extends PoolElement{ tmpUsers.put("#", 0x0000000100000000L); tmpUsers.put("@", 0x0000000200000000L); tmpUsers.put("*", 0x0000000400000000L); + tmpUsers.put("%", 0x0000000800000000L); USERS = Collections.unmodifiableMap(tmpUsers); @@ -339,7 +340,7 @@ public class Acl extends PoolElement{ */ private static long calculateIds(String id) throws RuleParseException { - if( !id.matches("^([#@]\\d+|\\*)$") ) + if( !id.matches("^([#@%]\\d+|\\*)$") ) { throw new RuleParseException("ID string '" + id + "' malformed"); } diff --git a/src/oca/java/src/org/opennebula/client/acl/AclPool.java b/src/oca/java/src/org/opennebula/client/acl/AclPool.java index 05022419a9..1ce82b07d0 100644 --- a/src/oca/java/src/org/opennebula/client/acl/AclPool.java +++ b/src/oca/java/src/org/opennebula/client/acl/AclPool.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/src/org/opennebula/client/acl/RuleParseException.java b/src/oca/java/src/org/opennebula/client/acl/RuleParseException.java index e3f5a7baab..d2df808e26 100644 --- a/src/oca/java/src/org/opennebula/client/acl/RuleParseException.java +++ b/src/oca/java/src/org/opennebula/client/acl/RuleParseException.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/src/org/opennebula/client/cluster/Cluster.java b/src/oca/java/src/org/opennebula/client/cluster/Cluster.java index 1edbe4a934..f88a73d6e5 100644 --- a/src/oca/java/src/org/opennebula/client/cluster/Cluster.java +++ b/src/oca/java/src/org/opennebula/client/cluster/Cluster.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/src/org/opennebula/client/cluster/ClusterPool.java b/src/oca/java/src/org/opennebula/client/cluster/ClusterPool.java index 403f7d86ba..5b3f0a073f 100644 --- a/src/oca/java/src/org/opennebula/client/cluster/ClusterPool.java +++ b/src/oca/java/src/org/opennebula/client/cluster/ClusterPool.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/src/org/opennebula/client/datastore/Datastore.java b/src/oca/java/src/org/opennebula/client/datastore/Datastore.java index f2bca4788c..fde6ee827a 100644 --- a/src/oca/java/src/org/opennebula/client/datastore/Datastore.java +++ b/src/oca/java/src/org/opennebula/client/datastore/Datastore.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/src/org/opennebula/client/datastore/DatastorePool.java b/src/oca/java/src/org/opennebula/client/datastore/DatastorePool.java index 299e622621..01e0739ba6 100644 --- a/src/oca/java/src/org/opennebula/client/datastore/DatastorePool.java +++ b/src/oca/java/src/org/opennebula/client/datastore/DatastorePool.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/src/org/opennebula/client/document/Document.java b/src/oca/java/src/org/opennebula/client/document/Document.java index 281e9617b6..94f5c5e975 100644 --- a/src/oca/java/src/org/opennebula/client/document/Document.java +++ b/src/oca/java/src/org/opennebula/client/document/Document.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,6 +65,7 @@ public abstract class Document extends PoolElement private static final String CHOWN = METHOD_PREFIX + "chown"; private static final String CHMOD = METHOD_PREFIX + "chmod"; private static final String CLONE = METHOD_PREFIX + "clone"; + private static final String RENAME = METHOD_PREFIX + "rename"; /** * Creates a new Document representation. @@ -215,6 +216,17 @@ public abstract class Document extends PoolElement return client.call(CLONE, id, name); } + /** + * Renames this document + * + * @param name New name for the document. + * @return If an error occurs the error message contains the reason. + */ + public OneResponse rename(String name) + { + return client.call(RENAME, id, name); + } + // ================================= // Helpers // ================================= diff --git a/src/oca/java/src/org/opennebula/client/document/DocumentPool.java b/src/oca/java/src/org/opennebula/client/document/DocumentPool.java index 80e588627f..31ae5e55b5 100644 --- a/src/oca/java/src/org/opennebula/client/document/DocumentPool.java +++ b/src/oca/java/src/org/opennebula/client/document/DocumentPool.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/src/org/opennebula/client/group/Group.java b/src/oca/java/src/org/opennebula/client/group/Group.java index 1a159e55a4..956b1d4c19 100644 --- a/src/oca/java/src/org/opennebula/client/group/Group.java +++ b/src/oca/java/src/org/opennebula/client/group/Group.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/src/org/opennebula/client/group/GroupPool.java b/src/oca/java/src/org/opennebula/client/group/GroupPool.java index 14925af4ab..0bcb4468f3 100644 --- a/src/oca/java/src/org/opennebula/client/group/GroupPool.java +++ b/src/oca/java/src/org/opennebula/client/group/GroupPool.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/src/org/opennebula/client/host/Host.java b/src/oca/java/src/org/opennebula/client/host/Host.java index f8af74e012..e76f54e5e4 100644 --- a/src/oca/java/src/org/opennebula/client/host/Host.java +++ b/src/oca/java/src/org/opennebula/client/host/Host.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/src/org/opennebula/client/host/HostPool.java b/src/oca/java/src/org/opennebula/client/host/HostPool.java index b6dd182136..fb8247708b 100644 --- a/src/oca/java/src/org/opennebula/client/host/HostPool.java +++ b/src/oca/java/src/org/opennebula/client/host/HostPool.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/src/org/opennebula/client/image/Image.java b/src/oca/java/src/org/opennebula/client/image/Image.java index 62d8185790..045cca8e4f 100644 --- a/src/oca/java/src/org/opennebula/client/image/Image.java +++ b/src/oca/java/src/org/opennebula/client/image/Image.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,7 @@ public class Image extends PoolElement private static final String CHMOD = METHOD_PREFIX + "chmod"; private static final String CHTYPE = METHOD_PREFIX + "chtype"; private static final String CLONE = METHOD_PREFIX + "clone"; + private static final String RENAME = METHOD_PREFIX + "rename"; private static final String[] IMAGE_STATES = {"INIT", "READY", "USED", "DISABLED", "LOCKED", @@ -265,6 +266,19 @@ public class Image extends PoolElement return client.call(CLONE, id, name); } + /** + * Renames this Image + * + * @param client XML-RPC Client. + * @param id The Image id of the target Image. + * @param name New name for the Image. + * @return If an error occurs the error message contains the reason. + */ + public static OneResponse rename(Client client, int id, String name) + { + return client.call(RENAME, id, name); + } + // ================================= // Instanced object XML-RPC methods // ================================= @@ -498,6 +512,17 @@ public class Image extends PoolElement return clone(client, id, name); } + /** + * Renames this Image + * + * @param name New name for the Image. + * @return If an error occurs the error message contains the reason. + */ + public OneResponse rename(String name) + { + return rename(client, id, name); + } + // ================================= // Helpers // ================================= diff --git a/src/oca/java/src/org/opennebula/client/image/ImagePool.java b/src/oca/java/src/org/opennebula/client/image/ImagePool.java index 99ee470f1c..d54244eb92 100644 --- a/src/oca/java/src/org/opennebula/client/image/ImagePool.java +++ b/src/oca/java/src/org/opennebula/client/image/ImagePool.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/src/org/opennebula/client/template/Template.java b/src/oca/java/src/org/opennebula/client/template/Template.java index dd48c96254..42def6a923 100644 --- a/src/oca/java/src/org/opennebula/client/template/Template.java +++ b/src/oca/java/src/org/opennebula/client/template/Template.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ public class Template extends PoolElement private static final String CHMOD = METHOD_PREFIX + "chmod"; private static final String INSTANTIATE = METHOD_PREFIX + "instantiate"; private static final String CLONE = METHOD_PREFIX + "clone"; + private static final String RENAME = METHOD_PREFIX + "rename"; /** * Creates a new Template representation. @@ -199,11 +200,15 @@ public class Template extends PoolElement * @param client XML-RPC Client. * @param id The template id of the target template. * @param name A string containing the name of the VM instance, can be empty. + * @param onHold False to create this VM in pending state, true on hold + * @param template User provided Template to merge with the one + * being instantiated * @return If successful the message contains the VM Instance ID. */ - public static OneResponse instantiate(Client client, int id, String name) + public static OneResponse instantiate(Client client, int id, String name, + boolean onHold, String template) { - return client.call(INSTANTIATE, id, name); + return client.call(INSTANTIATE, id, name, onHold, template); } /** @@ -219,6 +224,19 @@ public class Template extends PoolElement return client.call(CLONE, id, name); } + /** + * Renames this Template + * + * @param client XML-RPC Client. + * @param id The Template id of the target Template. + * @param name New name for the Template. + * @return If an error occurs the error message contains the reason. + */ + public static OneResponse rename(Client client, int id, String name) + { + return client.call(RENAME, id, name); + } + // ================================= // Instanced object XML-RPC methods // ================================= @@ -368,6 +386,20 @@ public class Template extends PoolElement return chmod(client, id, octet); } + /** + * Creates a VM instance from a Template + * + * @param name A string containing the name of the VM instance, can be empty. + * @param onHold False to create this VM in pending state, true on hold + * @param template User provided Template to merge with the one + * being instantiated + * @return If successful the message contains the VM Instance ID. + */ + public OneResponse instantiate(String name, boolean onHold, String template) + { + return instantiate(client, id, name, onHold, template); + } + /** * Creates a VM instance from a Template * @@ -376,7 +408,7 @@ public class Template extends PoolElement */ public OneResponse instantiate(String name) { - return instantiate(client, id, name); + return instantiate(client, id, name, false, ""); } /** @@ -386,7 +418,7 @@ public class Template extends PoolElement */ public OneResponse instantiate() { - return instantiate(client, id, ""); + return instantiate(client, id, "", false, ""); } /** @@ -400,6 +432,17 @@ public class Template extends PoolElement return clone(client, id, name); } + /** + * Renames this Template + * + * @param name New name for the Template. + * @return If an error occurs the error message contains the reason. + */ + public OneResponse rename(String name) + { + return rename(client, id, name); + } + // ================================= // Helpers // ================================= diff --git a/src/oca/java/src/org/opennebula/client/template/TemplatePool.java b/src/oca/java/src/org/opennebula/client/template/TemplatePool.java index 640b8dd75a..8141ffe312 100644 --- a/src/oca/java/src/org/opennebula/client/template/TemplatePool.java +++ b/src/oca/java/src/org/opennebula/client/template/TemplatePool.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/src/org/opennebula/client/user/User.java b/src/oca/java/src/org/opennebula/client/user/User.java index 3bacbfa47f..869eaa36f7 100644 --- a/src/oca/java/src/org/opennebula/client/user/User.java +++ b/src/oca/java/src/org/opennebula/client/user/User.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/src/org/opennebula/client/user/UserPool.java b/src/oca/java/src/org/opennebula/client/user/UserPool.java index 58e4cb5a2a..5836c64831 100644 --- a/src/oca/java/src/org/opennebula/client/user/UserPool.java +++ b/src/oca/java/src/org/opennebula/client/user/UserPool.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 dde9c87f85..678361eadd 100644 --- a/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java +++ b/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,21 +26,22 @@ import org.w3c.dom.Node; * It also offers static XML-RPC call wrappers. */ public class VirtualMachine extends PoolElement{ - - private static final String METHOD_PREFIX = "vm."; - private static final String ALLOCATE = METHOD_PREFIX + "allocate"; - private static final String INFO = METHOD_PREFIX + "info"; - private static final String DEPLOY = METHOD_PREFIX + "deploy"; - private static final String ACTION = METHOD_PREFIX + "action"; - private static final String MIGRATE = METHOD_PREFIX + "migrate"; - private static final String SAVEDISK = METHOD_PREFIX + "savedisk"; - private static final String CHOWN = METHOD_PREFIX + "chown"; - private static final String CHMOD = METHOD_PREFIX + "chmod"; - private static final String MONITORING = METHOD_PREFIX + "monitoring"; - private static final String ATTACH = METHOD_PREFIX + "attach"; - private static final String DETACH = METHOD_PREFIX + "detach"; - private static final String ATTACHNIC = METHOD_PREFIX + "attachnic"; - private static final String DETACHNIC = METHOD_PREFIX + "detachnic"; + private static final String ALLOCATE = METHOD_PREFIX + "allocate"; + private static final String INFO = METHOD_PREFIX + "info"; + private static final String DEPLOY = METHOD_PREFIX + "deploy"; + private static final String ACTION = METHOD_PREFIX + "action"; + private static final String MIGRATE = METHOD_PREFIX + "migrate"; + private static final String SAVEDISK = METHOD_PREFIX + "savedisk"; + private static final String CHOWN = METHOD_PREFIX + "chown"; + private static final String CHMOD = METHOD_PREFIX + "chmod"; + private static final String MONITORING = METHOD_PREFIX + "monitoring"; + private static final String ATTACH = METHOD_PREFIX + "attach"; + private static final String DETACH = METHOD_PREFIX + "detach"; + private static final String RENAME = METHOD_PREFIX + "rename"; + private static final String UPDATE = METHOD_PREFIX + "update"; + private static final String RESIZE = METHOD_PREFIX + "resize"; + private static final String ATTACHNIC = METHOD_PREFIX + "attachnic"; + private static final String DETACHNIC = METHOD_PREFIX + "detachnic"; private static final String[] VM_STATES = { @@ -83,14 +84,16 @@ public class VirtualMachine extends PoolElement{ "SHUTDOWN", "CANCEL", "FAILURE", - "CLEANUP", + "CLEANUP_RESUBMIT", "UNKNOWN", "HOTPLUG", "SHUTDOWN_POWEROFF", "BOOT_UNKNOWN", "BOOT_POWEROFF", "BOOT_SUSPENDED", - "BOOT_STOPPED" }; + "BOOT_STOPPED", + "CLEANUP_DELETE", + "HOTPLUG_SNAPSHOT" }; private static final String[] SHORT_LCM_STATES = { @@ -116,7 +119,9 @@ public class VirtualMachine extends PoolElement{ "boot", "boot", "boot", - "boot" }; + "boot", + "clea", + "snap" }; /** * Creates a new VM representation. @@ -151,7 +156,54 @@ public class VirtualMachine extends PoolElement{ */ public static OneResponse allocate(Client client, String description) { - return client.call(ALLOCATE, description); + return allocate(client, description, false); + } + + /** + * Allocates a new VM in OpenNebula. + * + * @param client XML-RPC Client. + * @param description A string containing the template of the vm. + * @param onHold False to create this VM in pending state, true on hold + * @return If successful the message contains the associated + * id generated for this VM. + */ + public static OneResponse allocate(Client client, String description, + boolean onHold) + { + return client.call(ALLOCATE, description, onHold); + } + + /** + * Replaces the user template contents for the given VM. + * + * @param client XML-RPC Client. + * @param id The id of the target vm. + * @param new_template New template contents + * @return If an error occurs the error message contains the reason. + */ + public static OneResponse update(Client client, int id, String new_template) + { + return client.call(UPDATE, id, new_template); + } + + /** + * Resizes the VM capacity + * + * @param client XML-RPC Client. + * @param id The id of the target vm. + * @param cpu the new CPU value + * @param memory the new MEMORY value + * @param vcpu the new VCPU value + * @param enforce If it is set to true, the host capacity + * will be checked. This will only affect oneadmin requests, regular users + * resize requests will always be enforced + * @return If an error occurs the error message contains the reason. + */ + public static OneResponse resize(Client client, int id, + double cpu, int memory, int vcpu, boolean enforce) + { + return client.call(RESIZE, id, cpu, memory, vcpu, enforce); } /** @@ -303,6 +355,19 @@ public class VirtualMachine extends PoolElement{ return client.call(DETACHNIC, id, nicId); } + /** + * Renames this VM + * + * @param client XML-RPC Client. + * @param id The VM id of the target VM. + * @param name New name for the VM. + * @return If an error occurs the error message contains the reason. + */ + public static OneResponse rename(Client client, int id, String name) + { + return client.call(RENAME, id, name); + } + // ================================= // Instanced object XML-RPC methods // ================================= @@ -320,6 +385,21 @@ public class VirtualMachine extends PoolElement{ return response; } + /** + * Initiates the instance of the VM on the target host. + * + * @param hostId The host id (hid) of the target host where + * the VM will be instantiated. + * @param enforce If it is set to true, the host capacity + * will be checked, and the deployment will fail if the host is + * overcommited. Defaults to false + * @return If an error occurs the error message contains the reason. + */ + public OneResponse deploy(int hostId, boolean enforce) + { + return client.call(DEPLOY, id, hostId, enforce); + } + /** * Initiates the instance of the VM on the target host. * @@ -329,7 +409,7 @@ public class VirtualMachine extends PoolElement{ */ public OneResponse deploy(int hostId) { - return client.call(DEPLOY, id, hostId); + return deploy(hostId, false); } /** @@ -367,11 +447,14 @@ public class VirtualMachine extends PoolElement{ * the vm. * @param live If true we are indicating that we want livemigration, * otherwise false. + * @param enforce If it is set to true, the host capacity + * will be checked, and the deployment will fail if the host is + * overcommited. Defaults to false * @return If an error occurs the error message contains the reason. */ - public OneResponse migrate(int hostId, boolean live) + public OneResponse migrate(int hostId, boolean live, boolean enforce) { - return client.call(MIGRATE, id, hostId, live); + return client.call(MIGRATE, id, hostId, live, enforce); } /** @@ -538,6 +621,44 @@ public class VirtualMachine extends PoolElement{ return detachnic(client, id, nicId); } + /** + * Renames this VM + * + * @param name New name for the VM. + * @return If an error occurs the error message contains the reason. + */ + public OneResponse rename(String name) + { + return rename(client, id, name); + } + + /** + * Replaces this VM's user template contents. + * + * @param new_template New template contents + * @return If an error occurs the error message contains the reason. + */ + public OneResponse update(String new_template) + { + return client.call(UPDATE, id, new_template); + } + + /** + * Resizes this VM's capacity + * + * @param cpu the new CPU value + * @param memory the new MEMORY value + * @param vcpu the new VCPU value + * @param enforce If it is set to true, the host capacity + * will be checked. This will only affect oneadmin requests, regular users + * resize requests will always be enforced + * @return If an error occurs the error message contains the reason. + */ + public OneResponse resize(double cpu, int memory, int vcpu, boolean enforce) + { + return client.call(RESIZE, id, cpu, memory, vcpu, enforce); + } + // ================================= // Helpers // ================================= @@ -680,6 +801,24 @@ public class VirtualMachine extends PoolElement{ return action("unresched"); } + /** + * Migrates the virtual machine to the target host (hid). + *
+ * It does the same as {@link VirtualMachine#migrate(int, boolean)} + * with live set to false. + * + * @param hostId The target host id (hid) where we want to migrate + * the vm. + * @param enforce If it is set to true, the host capacity + * will be checked, and the deployment will fail if the host is + * overcommited. Defaults to false + * @return If an error occurs the error message contains the reason. + */ + public OneResponse migrate(int hostId, boolean enforce) + { + return migrate(hostId, false, enforce); + } + /** * Migrates the virtual machine to the target host (hid). *
@@ -695,6 +834,25 @@ public class VirtualMachine extends PoolElement{ return migrate(hostId, false); } + /** + * Performs a live migration of the virtual machine to the + * target host (hid). + *
+ * It does the same as {@link VirtualMachine#migrate(int, boolean)} + * with live set to true. + * + * @param hostId The target host id (hid) where we want to migrate + * the vm. + * @param enforce If it is set to true, the host capacity + * will be checked, and the deployment will fail if the host is + * overcommited. Defaults to false + * @return If an error occurs the error message contains the reason. + */ + public OneResponse liveMigrate(int hostId, boolean enforce) + { + return migrate(hostId, true, enforce); + } + /** * Performs a live migration of the virtual machine to the * target host (hid). @@ -708,7 +866,7 @@ public class VirtualMachine extends PoolElement{ */ public OneResponse liveMigrate(int hostId) { - return migrate(hostId, true); + return liveMigrate(hostId, false); } public int state() diff --git a/src/oca/java/src/org/opennebula/client/vm/VirtualMachinePool.java b/src/oca/java/src/org/opennebula/client/vm/VirtualMachinePool.java index a15b379ebd..ec2655dc2f 100644 --- a/src/oca/java/src/org/opennebula/client/vm/VirtualMachinePool.java +++ b/src/oca/java/src/org/opennebula/client/vm/VirtualMachinePool.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/src/org/opennebula/client/vnet/VirtualNetwork.java b/src/oca/java/src/org/opennebula/client/vnet/VirtualNetwork.java index 112d4adec5..f1a03436a7 100644 --- a/src/oca/java/src/org/opennebula/client/vnet/VirtualNetwork.java +++ b/src/oca/java/src/org/opennebula/client/vnet/VirtualNetwork.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,7 @@ public class VirtualNetwork extends PoolElement{ private static final String UPDATE = METHOD_PREFIX + "update"; private static final String HOLD = METHOD_PREFIX + "hold"; private static final String RELEASE = METHOD_PREFIX + "release"; + private static final String RENAME = METHOD_PREFIX + "rename"; /** * Creates a new virtual network representation. @@ -263,7 +264,7 @@ public class VirtualNetwork extends PoolElement{ * Replaces the VirtualNetwork template contents. * * @param client XML-RPC Client. - * @param id The user id of the target vnet we want to modify. + * @param id The vnet id of the target vnet we want to modify. * @param new_template New template contents. * @return If successful the message contains the vnet id. */ @@ -272,6 +273,19 @@ public class VirtualNetwork extends PoolElement{ return client.call(UPDATE, id, new_template); } + /** + * Renames this VirtualNetwork + * + * @param client XML-RPC Client. + * @param id The VirtualNetwork id of the target VirtualNetwork. + * @param name New name for the VirtualNetwork. + * @return If an error occurs the error message contains the reason. + */ + public static OneResponse rename(Client client, int id, String name) + { + return client.call(RENAME, id, name); + } + // ================================= // Instanced object XML-RPC methods // ================================= @@ -491,6 +505,17 @@ public class VirtualNetwork extends PoolElement{ return update(client, id, new_template); } + /** + * Renames this VirtualNetwork + * + * @param name New name for the VirtualNetwork. + * @return If an error occurs the error message contains the reason. + */ + public OneResponse rename(String name) + { + return rename(client, id, name); + } + // ================================= // Helpers // ================================= diff --git a/src/oca/java/src/org/opennebula/client/vnet/VirtualNetworkPool.java b/src/oca/java/src/org/opennebula/client/vnet/VirtualNetworkPool.java index 2b3ca56125..29996b7324 100644 --- a/src/oca/java/src/org/opennebula/client/vnet/VirtualNetworkPool.java +++ b/src/oca/java/src/org/opennebula/client/vnet/VirtualNetworkPool.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/test/AclTest.java b/src/oca/java/test/AclTest.java index 73b55e6b6b..ea23b597cc 100644 --- a/src/oca/java/test/AclTest.java +++ b/src/oca/java/test/AclTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -157,6 +157,8 @@ public class AclTest "* VM+IMAGE+TEMPLATE/@100 CREATE+USE", "#2345 VM+IMAGE+TEMPLATE/* CREATE+USE", "@7 HOST/@100 USE+MANAGE", + "* HOST+DATASTORE/%100 MANAGE+USE", + "@107 NET/%100 USE" }; long[] users = { @@ -165,7 +167,9 @@ public class AclTest 0x20000006bL, 0x400000000L, 0x100000929L, - 0x200000007L + 0x200000007L, + 0x400000000L, + 0x20000006bL }; long[] resources = { @@ -174,7 +178,9 @@ public class AclTest 0x28200000064L, 0x29200000064L, 0x29400000000L, - 0x2200000064L + 0x2200000064L, + 0x102800000064L, + 0x4800000064L }; long[] rights = { @@ -183,7 +189,9 @@ public class AclTest 0x1L, 0x9L, 0x9L, - 0x3L + 0x3L, + 0x3L, + 0x1L }; for( int i = 0; i < rules.length; i++ ) @@ -254,6 +262,7 @@ public class AclTest "#3 TEMPLATE+HOS/#0 USE", "#3 /#0 USE", "#3 TEMPLATE/# USE", + "#3 TEMPLATE/% USE", "#3 TEMPLATE/#5 USE CREATE", "#3 TEMPLATE/#5", "#3 ", diff --git a/src/oca/java/test/DocumentTest.java b/src/oca/java/test/DocumentTest.java index 31456e1963..cfaac7ad58 100644 --- a/src/oca/java/test/DocumentTest.java +++ b/src/oca/java/test/DocumentTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/test/GroupTest.java b/src/oca/java/test/GroupTest.java index 42029b4627..5d2a7015ca 100644 --- a/src/oca/java/test/GroupTest.java +++ b/src/oca/java/test/GroupTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/test/HostTest.java b/src/oca/java/test/HostTest.java index f868b77552..8b1990ec83 100644 --- a/src/oca/java/test/HostTest.java +++ b/src/oca/java/test/HostTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/test/ImageTest.java b/src/oca/java/test/ImageTest.java index 770def7218..d124d5f624 100644 --- a/src/oca/java/test/ImageTest.java +++ b/src/oca/java/test/ImageTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/test/SessionTest.java b/src/oca/java/test/SessionTest.java index 2bb971162b..177d3b3219 100644 --- a/src/oca/java/test/SessionTest.java +++ b/src/oca/java/test/SessionTest.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) - * + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs + * * 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. @@ -17,6 +17,7 @@ import static org.junit.Assert.*; import org.junit.Test; import org.opennebula.client.*; +import org.w3c.dom.Node; public class SessionTest { @@ -51,7 +52,7 @@ public class SessionTest { } assertNull("Client should complain about misspelled url", oneClient); - } + } @Test public void version() @@ -63,11 +64,24 @@ public class SessionTest { } catch (Exception e) { - System.out.println(e.getMessage()); + assertTrue( e.getMessage(), false ); } - OneResponse res = oneClient.get_version(); + OneSystem system = new OneSystem(oneClient); + OneResponse res = system.getOnedVersion(); assertTrue( res.getErrorMessage(), !res.isError() ); + + res = system.getConfiguration(); + assertTrue( res.getErrorMessage(), !res.isError() ); + + Node config = system.getConfigurationXML(); + assertTrue( "XML configuration is null", config != null ); + + boolean compatible = system.compatibleVersion(); + assertTrue( + "Incompatible version reported, " + + OneSystem.VERSION + ", " + system.getOnedVersion().getMessage(), + compatible ); } } diff --git a/src/oca/java/test/TemplateTest.java b/src/oca/java/test/TemplateTest.java index 7070e0840d..e225a7f0a8 100644 --- a/src/oca/java/test/TemplateTest.java +++ b/src/oca/java/test/TemplateTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/test/UserTest.java b/src/oca/java/test/UserTest.java index e0ee277e4a..b5875e5242 100644 --- a/src/oca/java/test/UserTest.java +++ b/src/oca/java/test/UserTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/test/VirtualMachineTest.java b/src/oca/java/test/VirtualMachineTest.java index 897d956d1b..5abcf065b6 100644 --- a/src/oca/java/test/VirtualMachineTest.java +++ b/src/oca/java/test/VirtualMachineTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -341,4 +341,14 @@ public class VirtualMachineTest res = vm.info(); assertTrue( res.getErrorMessage(), !res.isError() ); } + + @Test + public void resize() + { + res = vm.resize(2.5, 512, 0, true); + assertTrue( res.getErrorMessage(), !res.isError() ); + + res = vm.resize(1, 128, 2, false); + assertTrue( res.getErrorMessage(), !res.isError() ); + } } diff --git a/src/oca/java/test/VirtualNetworkTest.java b/src/oca/java/test/VirtualNetworkTest.java index 93960a502c..9a545644f5 100644 --- a/src/oca/java/test/VirtualNetworkTest.java +++ b/src/oca/java/test/VirtualNetworkTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) + * Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/oca/java/test/all_tests.sh b/src/oca/java/test/all_tests.sh index cffeb16dff..c3887f26dd 100755 --- a/src/oca/java/test/all_tests.sh +++ b/src/oca/java/test/all_tests.sh @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/oca/java/test/test.sh b/src/oca/java/test/test.sh index d021c7fa8c..4b3f30c4c6 100755 --- a/src/oca/java/test/test.sh +++ b/src/oca/java/test/test.sh @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/oca/ruby/deprecated/OpenNebula.rb b/src/oca/ruby/deprecated/OpenNebula.rb new file mode 100644 index 0000000000..8a7f70471c --- /dev/null +++ b/src/oca/ruby/deprecated/OpenNebula.rb @@ -0,0 +1,26 @@ +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# 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. # +#--------------------------------------------------------------------------- # + +# OCA file names use snake case (excep for opennebula that is a single +# word). This file will be deleted in a future release. Use instead: + +# require "opennebula" + + +$stderr.puts 'Requiring "OpenNebula" is deprecated. Use "opennebula".' + +require "opennebula" + diff --git a/src/oca/ruby/opennebula.rb b/src/oca/ruby/opennebula.rb new file mode 100644 index 0000000000..1c679430d5 --- /dev/null +++ b/src/oca/ruby/opennebula.rb @@ -0,0 +1,58 @@ +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# 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. # +#--------------------------------------------------------------------------- # + + +begin # require 'rubygems' + require 'rubygems' +rescue Exception +end + +require 'digest/sha1' +require 'rexml/document' +require 'pp' + +require 'opennebula/xml_utils' +require 'opennebula/client' +require 'opennebula/error' +require 'opennebula/virtual_machine' +require 'opennebula/virtual_machine_pool' +require 'opennebula/virtual_network' +require 'opennebula/virtual_network_pool' +require 'opennebula/image' +require 'opennebula/image_pool' +require 'opennebula/user' +require 'opennebula/user_pool' +require 'opennebula/host' +require 'opennebula/host_pool' +require 'opennebula/template' +require 'opennebula/template_pool' +require 'opennebula/group' +require 'opennebula/group_pool' +require 'opennebula/acl' +require 'opennebula/acl_pool' +require 'opennebula/datastore' +require 'opennebula/datastore_pool' +require 'opennebula/cluster' +require 'opennebula/cluster_pool' +require 'opennebula/document' +require 'opennebula/document_pool' +require 'opennebula/system' + +module OpenNebula + + # OpenNebula version + VERSION = '3.9.0' +end diff --git a/src/oca/ruby/OpenNebula/Acl.rb b/src/oca/ruby/opennebula/acl.rb similarity index 94% rename from src/oca/ruby/OpenNebula/Acl.rb rename to src/oca/ruby/opennebula/acl.rb index a443be8eda..cfdd153dc0 100644 --- a/src/oca/ruby/OpenNebula/Acl.rb +++ b/src/oca/ruby/opennebula/acl.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -22,7 +22,7 @@ module OpenNebula # USER -> # # @ # ALL - # RESOURCE -> + separated list and "/{#,@}|ALL" + # RESOURCE -> + separated list and "/{#,@,%}|ALL" # VM, # HOST # NET @@ -41,7 +41,8 @@ module OpenNebula USERS = { "UID" => 0x100000000, "GID" => 0x200000000, - "ALL" => 0x400000000 + "ALL" => 0x400000000, + "CLUSTER" => 0x800000000 } RESOURCES = @@ -125,6 +126,8 @@ module OpenNebula return nil end + alias_method :info!, :info + # Parses a rule string, e.g. "#5 HOST+VM/@12 INFO+CREATE+DELETE" # # @param rule_str [String] an ACL rule in string format @@ -236,7 +239,7 @@ private # @return [Integer] the numeric value for the given id_str def self.calculate_ids(id_str) raise "ID string '#{id_str}' malformed" if - !id_str.match(/^([\#@]\d+|\*)$/) + !id_str.match(/^([\#@\%]\d+|\*)$/) value = 0 @@ -251,6 +254,10 @@ private when "*" users_value = USERS["ALL"] + + when "%" + value = USERS["CLUSTER"] + users_value = id_str[1..-1].to_i + value end return users_value diff --git a/src/oca/ruby/OpenNebula/AclPool.rb b/src/oca/ruby/opennebula/acl_pool.rb similarity index 93% rename from src/oca/ruby/OpenNebula/AclPool.rb rename to src/oca/ruby/opennebula/acl_pool.rb index 4c7a1deef1..02e4263e13 100644 --- a/src/oca/ruby/OpenNebula/AclPool.rb +++ b/src/oca/ruby/opennebula/acl_pool.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,7 +15,7 @@ #--------------------------------------------------------------------------- # -require 'OpenNebula/Pool' +require 'opennebula/pool' module OpenNebula class AclPool < Pool @@ -49,5 +49,7 @@ module OpenNebula # Retrieves all the Acls in the pool. super(ACL_POOL_METHODS[:info]) end + + alias_method :info!, :info end end diff --git a/src/oca/ruby/OpenNebula.rb b/src/oca/ruby/opennebula/client.rb similarity index 61% rename from src/oca/ruby/OpenNebula.rb rename to src/oca/ruby/opennebula/client.rb index a2e7f4f8ca..2e7d658048 100644 --- a/src/oca/ruby/OpenNebula.rb +++ b/src/oca/ruby/opennebula/client.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -14,82 +14,9 @@ # limitations under the License. # #--------------------------------------------------------------------------- # - -begin # require 'rubygems' - require 'rubygems' -rescue Exception -end - require 'xmlrpc/client' -require 'digest/sha1' -require 'rexml/document' -require 'pp' - -require 'OpenNebula/XMLUtils' -require 'OpenNebula/VirtualMachine' -require 'OpenNebula/VirtualMachinePool' -require 'OpenNebula/VirtualNetwork' -require 'OpenNebula/VirtualNetworkPool' -require 'OpenNebula/Image' -require 'OpenNebula/ImagePool' -require 'OpenNebula/User' -require 'OpenNebula/UserPool' -require 'OpenNebula/Host' -require 'OpenNebula/HostPool' -require 'OpenNebula/Template' -require 'OpenNebula/TemplatePool' -require 'OpenNebula/Group' -require 'OpenNebula/GroupPool' -require 'OpenNebula/Acl' -require 'OpenNebula/AclPool' -require 'OpenNebula/Datastore' -require 'OpenNebula/DatastorePool' -require 'OpenNebula/Cluster' -require 'OpenNebula/ClusterPool' -require 'OpenNebula/Document' -require 'OpenNebula/DocumentPool' -require 'OpenNebula/System' module OpenNebula - - # OpenNebula version - VERSION = '3.9.0' - - # The Error Class represents a generic error in the OpenNebula - # library. It contains a readable representation of the error. - # Any function in the OpenNebula module will return an Error - # object in case of error. - class Error - ESUCCESS = 0x0000 - EAUTHENTICATION = 0x0100 - EAUTHORIZATION = 0x0200 - ENO_EXISTS = 0x0400 - EACTION = 0x0800 - EXML_RPC_API = 0x1000 - EINTERNAL = 0x2000 - ENOTDEFINED = 0x1111 - - attr_reader :message, :errno - - # +message+ Description of the error - # +errno+ OpenNebula code error - def initialize(message=nil, errno=0x1111) - @message = message - @errno = errno - end - - def to_str() - @message - end - end - - # Returns true if the object returned by a method of the OpenNebula - # library is an Error - def self.is_error?(value) - value.class==OpenNebula::Error - end - - if OpenNebula::NOKOGIRI class NokogiriStreamParser < XMLRPC::XMLParser::AbstractStreamParser def initialize @@ -112,7 +39,6 @@ module OpenNebula end end - # The client class, represents the connection with the core and handles the # xml-rpc calls. class Client @@ -125,10 +51,24 @@ module OpenNebula XMLPARSER=false end - def initialize(secret=nil, endpoint=nil) + # Creates a new client object that will be used to call OpenNebula + # functions. + # + # @param [String, nil] secret user credentials ("user:password") or + # nil to get the credentials from user auth file + # @param [String, nil] endpoint OpenNebula server endpoint + # (http://host:2633/RPC2) or nil to get it form the environment + # variable ONE_XMLRPC or use the default endpoint + # @param [Hash] options + # @option params [Integer] :timeout connection timeout in seconds, + # defaults to 30 + # + # @return [OpenNebula::Client] + def initialize(secret=nil, endpoint=nil, options={}) if secret @one_auth = secret - elsif ENV["ONE_AUTH"] and !ENV["ONE_AUTH"].empty? and File.file?(ENV["ONE_AUTH"]) + elsif ENV["ONE_AUTH"] and !ENV["ONE_AUTH"].empty? and + File.file?(ENV["ONE_AUTH"]) @one_auth = File.read(ENV["ONE_AUTH"]) elsif File.file?(ENV["HOME"]+"/.one/one_auth") @one_auth = File.read(ENV["HOME"]+"/.one/one_auth") @@ -146,7 +86,10 @@ module OpenNebula @one_endpoint = "http://localhost:2633/RPC2" end - @server = XMLRPC::Client.new2(@one_endpoint) + timeout=nil + timeout=options[:timeout] if options[:timeout] + + @server = XMLRPC::Client.new2(@one_endpoint, nil, timeout) if OpenNebula::NOKOGIRI @server.set_parser(NokogiriStreamParser.new) @@ -172,9 +115,5 @@ module OpenNebula def get_version() call("system.version") end - - def get_config() - call("system.config") - end end end diff --git a/src/oca/ruby/OpenNebula/Cluster.rb b/src/oca/ruby/opennebula/cluster.rb similarity index 98% rename from src/oca/ruby/OpenNebula/Cluster.rb rename to src/oca/ruby/opennebula/cluster.rb index e6abb4c7a3..a44012f3d9 100644 --- a/src/oca/ruby/OpenNebula/Cluster.rb +++ b/src/oca/ruby/opennebula/cluster.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,7 +15,7 @@ #--------------------------------------------------------------------------- # -require 'OpenNebula/Pool' +require 'opennebula/pool_element' module OpenNebula class Cluster < PoolElement @@ -67,6 +67,8 @@ module OpenNebula super(CLUSTER_METHODS[:info], 'CLUSTER') end + alias_method :info!, :info + # Allocates a new Cluster in OpenNebula # # +clustername+ A string containing the name of the Cluster. diff --git a/src/oca/ruby/OpenNebula/ClusterPool.rb b/src/oca/ruby/opennebula/cluster_pool.rb similarity index 94% rename from src/oca/ruby/OpenNebula/ClusterPool.rb rename to src/oca/ruby/opennebula/cluster_pool.rb index 780b72a347..6cf024dec6 100644 --- a/src/oca/ruby/OpenNebula/ClusterPool.rb +++ b/src/oca/ruby/opennebula/cluster_pool.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,7 +15,7 @@ #--------------------------------------------------------------------------- # -require 'OpenNebula/Pool' +require 'opennebula/pool' module OpenNebula class ClusterPool < Pool @@ -52,5 +52,7 @@ module OpenNebula def info() super(CLUSTER_POOL_METHODS[:info]) end + + alias_method :info!, :info end end diff --git a/src/oca/ruby/OpenNebula/Datastore.rb b/src/oca/ruby/opennebula/datastore.rb similarity index 97% rename from src/oca/ruby/OpenNebula/Datastore.rb rename to src/oca/ruby/opennebula/datastore.rb index fa1410203a..21d3a73a81 100644 --- a/src/oca/ruby/OpenNebula/Datastore.rb +++ b/src/oca/ruby/opennebula/datastore.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,7 +15,7 @@ #--------------------------------------------------------------------------- # -require 'OpenNebula/Pool' +require 'opennebula/pool_element' module OpenNebula class Datastore < PoolElement @@ -85,6 +85,8 @@ module OpenNebula super(DATASTORE_METHODS[:info], 'DATASTORE') end + alias_method :info!, :info + # Allocates a new Datastore in OpenNebula # # @param description [String] The template of the Datastore. diff --git a/src/oca/ruby/OpenNebula/DatastorePool.rb b/src/oca/ruby/opennebula/datastore_pool.rb similarity index 94% rename from src/oca/ruby/OpenNebula/DatastorePool.rb rename to src/oca/ruby/opennebula/datastore_pool.rb index b491d394fe..25bfef832d 100644 --- a/src/oca/ruby/OpenNebula/DatastorePool.rb +++ b/src/oca/ruby/opennebula/datastore_pool.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,7 +15,7 @@ #--------------------------------------------------------------------------- # -require 'OpenNebula/Pool' +require 'opennebula/pool' module OpenNebula class DatastorePool < Pool @@ -49,5 +49,7 @@ module OpenNebula def info() super(DATASTORE_POOL_METHODS[:info]) end + + alias_method :info!, :info end end diff --git a/src/oca/ruby/OpenNebula/Document.rb b/src/oca/ruby/opennebula/document.rb similarity index 93% rename from src/oca/ruby/OpenNebula/Document.rb rename to src/oca/ruby/opennebula/document.rb index 494ebcf3dd..73c1c4aef8 100644 --- a/src/oca/ruby/OpenNebula/Document.rb +++ b/src/oca/ruby/opennebula/document.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -14,14 +14,14 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -require 'OpenNebula/Pool' +require 'opennebula/pool_element' module OpenNebula # All subclasses must define the DOCUMENT_TYPE constant. # # @example - # require 'OpenNebula/Document' + # require 'opennebula/document' # # module OpenNebula # class CustomObject < Document @@ -44,6 +44,7 @@ module OpenNebula :chown => "document.chown", :chmod => "document.chmod", :clone => "document.clone", + :rename => "document.rename" } # Creates a Document Object description with just its identifier @@ -93,6 +94,8 @@ module OpenNebula return rc end + alias_method :info!, :info + # Allocates a new Document in OpenNebula # # @param description [String] The contents of the Document. @@ -185,6 +188,16 @@ module OpenNebula return rc end + # Renames this Document + # + # @param name [String] New name for the Document. + # + # @return [nil, OpenNebula::Error] nil in case of success, Error + # otherwise + def rename(name) + return call(DOCUMENT_METHODS[:rename], @pe_id, name) + end + ####################################################################### # Helpers to get Document information ####################################################################### diff --git a/src/oca/ruby/OpenNebula/DocumentJSON.rb b/src/oca/ruby/opennebula/document_json.rb similarity index 97% rename from src/oca/ruby/OpenNebula/DocumentJSON.rb rename to src/oca/ruby/opennebula/document_json.rb index 4e3ed5715d..861c63c961 100644 --- a/src/oca/ruby/OpenNebula/DocumentJSON.rb +++ b/src/oca/ruby/opennebula/document_json.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -50,6 +50,8 @@ module OpenNebula load_body end + alias_method :info!, :info + # Updates the current state of this Service in the OpenNebula DB # # @params [String, nil] template_json string to be inserted in the diff --git a/src/oca/ruby/OpenNebula/DocumentPool.rb b/src/oca/ruby/opennebula/document_pool.rb similarity index 91% rename from src/oca/ruby/OpenNebula/DocumentPool.rb rename to src/oca/ruby/opennebula/document_pool.rb index 3b428aa698..dfd1c96943 100644 --- a/src/oca/ruby/OpenNebula/DocumentPool.rb +++ b/src/oca/ruby/opennebula/document_pool.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -14,7 +14,7 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -require 'OpenNebula/Pool' +require 'opennebula/pool' module OpenNebula @@ -22,7 +22,7 @@ module OpenNebula # and the factory method. # # @example - # require 'OpenNebula/DocumentPool' + # require 'opennebuña/document_pool' # # module OpenNebula # class CustomObjectPool < DocumentPool @@ -90,6 +90,11 @@ module OpenNebula return super(DOCUMENT_POOL_METHODS[:info], document_type) end + alias_method :info!, :info + alias_method :info_all!, :info_all + alias_method :info_mine!, :info_mine + alias_method :info_group!, :info_group + def document_type self.class::DOCUMENT_TYPE end diff --git a/src/oca/ruby/OpenNebula/DocumentPoolJSON.rb b/src/oca/ruby/opennebula/document_pool_json.rb similarity index 96% rename from src/oca/ruby/OpenNebula/DocumentPoolJSON.rb rename to src/oca/ruby/opennebula/document_pool_json.rb index 678b149e1c..8097dca44c 100644 --- a/src/oca/ruby/OpenNebula/DocumentPoolJSON.rb +++ b/src/oca/ruby/opennebula/document_pool_json.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/oca/ruby/opennebula/error.rb b/src/oca/ruby/opennebula/error.rb new file mode 100644 index 0000000000..e3081b0782 --- /dev/null +++ b/src/oca/ruby/opennebula/error.rb @@ -0,0 +1,52 @@ +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + + +module OpenNebula + # The Error Class represents a generic error in the OpenNebula + # library. It contains a readable representation of the error. + # Any function in the OpenNebula module will return an Error + # object in case of error. + class Error + ESUCCESS = 0x0000 + EAUTHENTICATION = 0x0100 + EAUTHORIZATION = 0x0200 + ENO_EXISTS = 0x0400 + EACTION = 0x0800 + EXML_RPC_API = 0x1000 + EINTERNAL = 0x2000 + ENOTDEFINED = 0x1111 + + attr_reader :message, :errno + + # +message+ Description of the error + # +errno+ OpenNebula code error + def initialize(message=nil, errno=0x1111) + @message = message + @errno = errno + end + + def to_str() + @message + end + end + + # Returns true if the object returned by a method of the OpenNebula + # library is an Error + def self.is_error?(value) + value.class==OpenNebula::Error + end +end diff --git a/src/oca/ruby/OpenNebula/Group.rb b/src/oca/ruby/opennebula/group.rb similarity index 97% rename from src/oca/ruby/OpenNebula/Group.rb rename to src/oca/ruby/opennebula/group.rb index fcfefe8e38..6a8fc1561b 100644 --- a/src/oca/ruby/OpenNebula/Group.rb +++ b/src/oca/ruby/opennebula/group.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,7 +15,7 @@ #--------------------------------------------------------------------------- # -require 'OpenNebula/Pool' +require 'opennebula/pool_element' module OpenNebula class Group < PoolElement @@ -108,6 +108,8 @@ module OpenNebula super(GROUP_METHODS[:info], 'GROUP') end + alias_method :info!, :info + # Allocates a new Group in OpenNebula # # +groupname+ A string containing the name of the Group. diff --git a/src/oca/ruby/OpenNebula/GroupPool.rb b/src/oca/ruby/opennebula/group_pool.rb similarity index 94% rename from src/oca/ruby/OpenNebula/GroupPool.rb rename to src/oca/ruby/opennebula/group_pool.rb index 20ebdeed08..bd5deee409 100644 --- a/src/oca/ruby/OpenNebula/GroupPool.rb +++ b/src/oca/ruby/opennebula/group_pool.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,7 +15,7 @@ #--------------------------------------------------------------------------- # -require 'OpenNebula/Pool' +require 'opennebula/pool' module OpenNebula class GroupPool < Pool @@ -50,5 +50,7 @@ module OpenNebula def info() super(GROUP_POOL_METHODS[:info]) end + + alias_method :info!, :info end end diff --git a/src/oca/ruby/OpenNebula/Host.rb b/src/oca/ruby/opennebula/host.rb similarity index 97% rename from src/oca/ruby/OpenNebula/Host.rb rename to src/oca/ruby/opennebula/host.rb index 1519351f80..e2456b9b12 100644 --- a/src/oca/ruby/OpenNebula/Host.rb +++ b/src/oca/ruby/opennebula/host.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,7 +15,7 @@ #--------------------------------------------------------------------------- # -require 'OpenNebula/Pool' +require 'opennebula/pool_element' module OpenNebula class Host < PoolElement @@ -78,6 +78,8 @@ module OpenNebula super(HOST_METHODS[:info], 'HOST') end + alias_method :info!, :info + # Allocates a new Host in OpenNebula # # @param hostname [String] Name of the new Host. diff --git a/src/oca/ruby/OpenNebula/HostPool.rb b/src/oca/ruby/opennebula/host_pool.rb similarity index 96% rename from src/oca/ruby/OpenNebula/HostPool.rb rename to src/oca/ruby/opennebula/host_pool.rb index 8d71712d5a..c36ff0beb2 100644 --- a/src/oca/ruby/OpenNebula/HostPool.rb +++ b/src/oca/ruby/opennebula/host_pool.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,7 +15,7 @@ #--------------------------------------------------------------------------- # -require 'OpenNebula/Pool' +require 'opennebula/pool' module OpenNebula class HostPool < Pool @@ -53,6 +53,8 @@ module OpenNebula super(HOST_POOL_METHODS[:info]) end + alias_method :info!, :info + # Retrieves the monitoring data for all the Hosts in the pool # # @param [Array] xpath_expressions Elements to retrieve. diff --git a/src/oca/ruby/OpenNebula/Image.rb b/src/oca/ruby/opennebula/image.rb similarity index 93% rename from src/oca/ruby/OpenNebula/Image.rb rename to src/oca/ruby/opennebula/image.rb index e8224871f8..d798d08d72 100644 --- a/src/oca/ruby/OpenNebula/Image.rb +++ b/src/oca/ruby/opennebula/image.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,7 +15,7 @@ #--------------------------------------------------------------------------- # -require 'OpenNebula/Pool' +require 'opennebula/pool_element' require 'fileutils' module OpenNebula @@ -35,7 +35,8 @@ module OpenNebula :chown => "image.chown", :chmod => "image.chmod", :chtype => "image.chtype", - :clone => "image.clone" + :clone => "image.clone", + :rename => "image.rename" } IMAGE_STATES=%w{INIT READY USED DISABLED LOCKED ERROR CLONE DELETE USED_PERS} @@ -63,6 +64,8 @@ module OpenNebula "CONTEXT" => "CX" } + DISK_TYPES=%w{FILE CD_ROM BLOCK RBD} + # Creates an Image description with just its identifier # this method should be used to create plain Image objects. # +id+ the id of the image @@ -96,6 +99,8 @@ module OpenNebula super(IMAGE_METHODS[:info], 'IMAGE') end + alias_method :info!, :info + # Allocates a new Image in OpenNebula # # @param description [String] A string containing the template of the Image. @@ -205,6 +210,16 @@ module OpenNebula return rc end + # Renames this Image + # + # @param name [String] New name for the Image. + # + # @return [nil, OpenNebula::Error] nil in case of success, Error + # otherwise + def rename(name) + return call(IMAGE_METHODS[:rename], @pe_id, name) + end + ####################################################################### # Helpers to get Image information ####################################################################### diff --git a/src/oca/ruby/OpenNebula/ImagePool.rb b/src/oca/ruby/opennebula/image_pool.rb similarity index 91% rename from src/oca/ruby/OpenNebula/ImagePool.rb rename to src/oca/ruby/opennebula/image_pool.rb index 97cab2eb67..545742d424 100644 --- a/src/oca/ruby/OpenNebula/ImagePool.rb +++ b/src/oca/ruby/opennebula/image_pool.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,7 +15,7 @@ #--------------------------------------------------------------------------- # -require 'OpenNebula/Pool' +require 'opennebula/pool' module OpenNebula class ImagePool < Pool @@ -70,5 +70,10 @@ module OpenNebula def info_group() return super(IMAGE_POOL_METHODS[:info]) end + + alias_method :info!, :info + alias_method :info_all!, :info_all + alias_method :info_mine!, :info_mine + alias_method :info_group!, :info_group end end diff --git a/src/oca/ruby/opennebula/pool.rb b/src/oca/ruby/opennebula/pool.rb new file mode 100644 index 0000000000..59b832e96c --- /dev/null +++ b/src/oca/ruby/opennebula/pool.rb @@ -0,0 +1,160 @@ +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +require 'opennebula/xml_utils' + +module OpenNebula + + # The Pool class represents a generic OpenNebula Pool in XML format + # and provides the basic functionality to handle the Pool elements + class Pool < XMLPool + include Enumerable + alias_method :each_with_xpath, :each + + protected + #pool:: _String_ XML name of the root element + #element:: _String_ XML name of the Pool elements + #client:: _Client_ represents a XML-RPC connection + def initialize(pool,element,client) + super(nil) + + @pool_name = pool.upcase + @element_name = element.upcase + + @client = client + end + + # Default Factory Method for the Pools. The factory method returns an + # suitable PoolElement object. Each Pool MUST implement the + # corresponding factory method + # element_xml:: _XML_ XML element describing the pool element + # [return] a PoolElement object + def factory(element_xml) + OpenNebula::PoolElement.new(element_xml,client) + end + + ####################################################################### + # Common XML-RPC Methods for all the Pool Types + ####################################################################### + + #Gets the pool without any filter. Host, Group and User Pools + # xml_method:: _String_ the name of the XML-RPC method + def info(xml_method) + return xmlrpc_info(xml_method) + end + + alias_method :info!, :info + + def info_all(xml_method, *args) + return xmlrpc_info(xml_method,INFO_ALL,-1,-1, *args) + end + + def info_mine(xml_method, *args) + return xmlrpc_info(xml_method,INFO_MINE,-1,-1, *args) + end + + def info_group(xml_method, *args) + return xmlrpc_info(xml_method,INFO_GROUP,-1,-1, *args) + end + + def info_filter(xml_method, who, start_id, end_id, *args) + return xmlrpc_info(xml_method,who, start_id, end_id, *args) + end + + # Retrieves the monitoring data for all the Objects in the pool + # + # @param [String] xml_method xml-rcp method + # @param [String] root_elem Root for each individual PoolElement + # @param [String] timestamp_elem Name of the XML element with the last + # monitorization timestamp + # @param [Array] xpath_expressions Elements to retrieve. + # @param args arguemnts for the xml_method call + # + # @return [Hash>>>>, + # OpenNebula::Error] The first level hash uses the Object ID as keys, + # and as value a Hash with the requested xpath expressions, + # and an Array of 'timestamp, value'. + def monitoring(xml_method, root_elem, timestamp_elem, xpath_expressions, + *args) + + rc = @client.call(xml_method, *args) + + if ( OpenNebula.is_error?(rc) ) + return rc + end + + xmldoc = XMLElement.new + xmldoc.initialize_xml(rc, 'MONITORING_DATA') + + hash = {} + + # Get all existing Object IDs + ids = xmldoc.retrieve_elements("#{root_elem}/ID") + + if ids.nil? + return hash + else + ids.uniq! + end + + ids.each { |id| + hash[id] = OpenNebula.process_monitoring( + xmldoc, root_elem, timestamp_elem, id, xpath_expressions) + + } + + return hash + end + + private + # Calls to the corresponding info method to retreive the pool + # representation in XML format + # xml_method:: _String_ the name of the XML-RPC method + # args:: _Array_ with additional arguments for the info call + # [return] nil in case of success or an Error object + def xmlrpc_info(xml_method,*args) + rc = @client.call(xml_method,*args) + + if !OpenNebula.is_error?(rc) + initialize_xml(rc,@pool_name) + rc = nil + end + + return rc + end + + public + # Constants for info queries (include/RequestManagerPoolInfoFilter.h) + INFO_GROUP = -1 + INFO_ALL = -2 + INFO_MINE = -3 + + # Iterates over every PoolElement in the Pool and calls the block with a + # a PoolElement obtained calling the factory method + # block:: _Block_ + def each(&block) + each_element(block) if @xml + end + + # DO NOT USE - ONLY REXML BACKEND + def to_str + str = "" + REXML::Formatters::Pretty.new(1).write(@xml,str) + + return str + end + end +end diff --git a/src/oca/ruby/OpenNebula/Pool.rb b/src/oca/ruby/opennebula/pool_element.rb similarity index 68% rename from src/oca/ruby/OpenNebula/Pool.rb rename to src/oca/ruby/opennebula/pool_element.rb index e917f7bb32..b65675ce28 100644 --- a/src/oca/ruby/OpenNebula/Pool.rb +++ b/src/oca/ruby/opennebula/pool_element.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -14,146 +14,9 @@ # limitations under the License. # #--------------------------------------------------------------------------- # +require 'opennebula/pool' module OpenNebula - - # The Pool class represents a generic OpenNebula Pool in XML format - # and provides the basic functionality to handle the Pool elements - class Pool < XMLPool - include Enumerable - - protected - #pool:: _String_ XML name of the root element - #element:: _String_ XML name of the Pool elements - #client:: _Client_ represents a XML-RPC connection - def initialize(pool,element,client) - super(nil) - - @pool_name = pool.upcase - @element_name = element.upcase - - @client = client - end - - # Default Factory Method for the Pools. The factory method returns an - # suitable PoolElement object. Each Pool MUST implement the - # corresponding factory method - # element_xml:: _XML_ XML element describing the pool element - # [return] a PoolElement object - def factory(element_xml) - OpenNebula::PoolElement.new(element_xml,client) - end - - ####################################################################### - # Common XML-RPC Methods for all the Pool Types - ####################################################################### - - #Gets the pool without any filter. Host, Group and User Pools - # xml_method:: _String_ the name of the XML-RPC method - def info(xml_method) - return xmlrpc_info(xml_method) - end - - def info_all(xml_method, *args) - return xmlrpc_info(xml_method,INFO_ALL,-1,-1, *args) - end - - def info_mine(xml_method, *args) - return xmlrpc_info(xml_method,INFO_MINE,-1,-1, *args) - end - - def info_group(xml_method, *args) - return xmlrpc_info(xml_method,INFO_GROUP,-1,-1, *args) - end - - def info_filter(xml_method, who, start_id, end_id, *args) - return xmlrpc_info(xml_method,who, start_id, end_id, *args) - end - - # Retrieves the monitoring data for all the Objects in the pool - # - # @param [String] xml_method xml-rcp method - # @param [String] root_elem Root for each individual PoolElement - # @param [String] timestamp_elem Name of the XML element with the last - # monitorization timestamp - # @param [Array] xpath_expressions Elements to retrieve. - # @param args arguemnts for the xml_method call - # - # @return [Hash>>>>, - # OpenNebula::Error] The first level hash uses the Object ID as keys, - # and as value a Hash with the requested xpath expressions, - # and an Array of 'timestamp, value'. - def monitoring(xml_method, root_elem, timestamp_elem, xpath_expressions, - *args) - - rc = @client.call(xml_method, *args) - - if ( OpenNebula.is_error?(rc) ) - return rc - end - - xmldoc = XMLElement.new - xmldoc.initialize_xml(rc, 'MONITORING_DATA') - - hash = {} - - # Get all existing Object IDs - ids = xmldoc.retrieve_elements("#{root_elem}/ID") - - if ids.nil? - return hash - else - ids.uniq! - end - - ids.each { |id| - hash[id] = OpenNebula.process_monitoring( - xmldoc, root_elem, timestamp_elem, id, xpath_expressions) - - } - - return hash - end - - private - # Calls to the corresponding info method to retreive the pool - # representation in XML format - # xml_method:: _String_ the name of the XML-RPC method - # args:: _Array_ with additional arguments for the info call - # [return] nil in case of success or an Error object - def xmlrpc_info(xml_method,*args) - rc = @client.call(xml_method,*args) - - if !OpenNebula.is_error?(rc) - initialize_xml(rc,@pool_name) - rc = nil - end - - return rc - end - - public - # Constants for info queries (include/RequestManagerPoolInfoFilter.h) - INFO_GROUP = -1 - INFO_ALL = -2 - INFO_MINE = -3 - - # Iterates over every PoolElement in the Pool and calls the block with a - # a PoolElement obtained calling the factory method - # block:: _Block_ - def each(&block) - each_element(block) if @xml - end - - # DO NOT USE - ONLY REXML BACKEND - def to_str - str = "" - REXML::Formatters::Pretty.new(1).write(@xml,str) - - return str - end - end - # The PoolElement Class represents a generic element of a Pool in # XML format class PoolElement < XMLElement diff --git a/src/oca/ruby/OpenNebula/System.rb b/src/oca/ruby/opennebula/system.rb similarity index 72% rename from src/oca/ruby/OpenNebula/System.rb rename to src/oca/ruby/opennebula/system.rb index d7e0b1aa78..ab3eae4aa9 100644 --- a/src/oca/ruby/OpenNebula/System.rb +++ b/src/oca/ruby/opennebula/system.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,7 +15,7 @@ #--------------------------------------------------------------------------- # -require 'OpenNebula/Pool' +require 'opennebula/pool' module OpenNebula class System @@ -27,7 +27,9 @@ module OpenNebula :userquotainfo => "userquota.info", :userquotaupdate => "userquota.update", :groupquotainfo => "groupquota.info", - :groupquotaupdate => "groupquota.update" + :groupquotaupdate => "groupquota.update", + :version => "system.version", + :config => "system.config" } ####################################################################### @@ -44,6 +46,46 @@ module OpenNebula # XML-RPC Methods ####################################################################### + # Gets the oned version + # + # @return [String, OpenNebula::Error] the oned version in case + # of success, Error otherwise + def get_oned_version() + return @client.call("system.version") + end + + # Returns whether of not the oned version is the same as the OCA version + # + # @return [true, false, OpenNebula::Error] true if oned is the same + # version + def compatible_version() + no_revision = VERSION[/^\d+\.\d+\./] + oned_v = get_oned_version + + if OpenNebula.is_error?(oned_v) + return oned_v + end + + return (oned_v =~ /#{no_revision}/) != nil + end + + # Gets the oned configuration + # + # @return [XMLElement, OpenNebula::Error] the oned configuration in case + # of success, Error otherwise + def get_configuration() + rc = @client.call(SYSTEM_METHODS[:config]) + + if OpenNebula.is_error?(rc) + return rc + end + + config = XMLElement.new + config.initialize_xml(rc, 'TEMPLATE') + + return config + end + # Gets the default user quota limits # # @return [XMLElement, OpenNebula::Error] the default user quota in case diff --git a/src/oca/ruby/OpenNebula/Template.rb b/src/oca/ruby/opennebula/template.rb similarity index 83% rename from src/oca/ruby/OpenNebula/Template.rb rename to src/oca/ruby/opennebula/template.rb index aa209d3f3d..802c91cf23 100644 --- a/src/oca/ruby/OpenNebula/Template.rb +++ b/src/oca/ruby/opennebula/template.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,7 +15,7 @@ #--------------------------------------------------------------------------- # -require 'OpenNebula/Pool' +require 'opennebula/pool_element' module OpenNebula class Template < PoolElement @@ -32,7 +32,8 @@ module OpenNebula :delete => "template.delete", :chown => "template.chown", :chmod => "template.chmod", - :clone => "template.clone" + :clone => "template.clone", + :rename => "template.rename" } # Creates a Template description with just its identifier @@ -68,6 +69,8 @@ module OpenNebula super(TEMPLATE_METHODS[:info], 'VMTEMPLATE') end + alias_method :info!, :info + # Allocates a new Template in OpenNebula # # @param description [String] The contents of the Template. @@ -85,13 +88,23 @@ module OpenNebula # Creates a VM instance from a Template # - # +name+ A string containing the name of the VM instance. - # [return] The new VM Instance ID, or an Error object - def instantiate(name="") + # @param name [String] Name for the VM instance. If it is an empty + # string OpenNebula will set a default name + # @param hold [true,false] false to create the VM in pending state, + # true to create it on hold + # @param template [String] User provided Template to merge with the + # one being instantiated + # + # @return [Integer, OpenNebula::Error] The new VM id, Error + # otherwise + def instantiate(name="", hold=false, template="") return Error.new('ID not defined') if !@pe_id name ||= "" - rc = @client.call(TEMPLATE_METHODS[:instantiate], @pe_id, name) + template ||= "" + + rc = @client.call( + TEMPLATE_METHODS[:instantiate], @pe_id, name, hold, template) return rc end @@ -157,6 +170,16 @@ module OpenNebula return rc end + # Renames this Template + # + # @param name [String] New name for the Template. + # + # @return [nil, OpenNebula::Error] nil in case of success, Error + # otherwise + def rename(name) + return call(TEMPLATE_METHODS[:rename], @pe_id, name) + end + ####################################################################### # Helpers to get Template information ####################################################################### diff --git a/src/oca/ruby/OpenNebula/TemplatePool.rb b/src/oca/ruby/opennebula/template_pool.rb similarity index 91% rename from src/oca/ruby/OpenNebula/TemplatePool.rb rename to src/oca/ruby/opennebula/template_pool.rb index 820d7c8d7b..10bfd93fde 100644 --- a/src/oca/ruby/OpenNebula/TemplatePool.rb +++ b/src/oca/ruby/opennebula/template_pool.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,7 +15,7 @@ #--------------------------------------------------------------------------- # -require 'OpenNebula/Pool' +require 'opennebula/pool' module OpenNebula class TemplatePool < Pool @@ -70,5 +70,10 @@ module OpenNebula def info_group() return super(TEMPLATE_POOL_METHODS[:info]) end + + alias_method :info!, :info + alias_method :info_all!, :info_all + alias_method :info_mine!, :info_mine + alias_method :info_group!, :info_group end end diff --git a/src/oca/ruby/OpenNebula/User.rb b/src/oca/ruby/opennebula/user.rb similarity index 97% rename from src/oca/ruby/OpenNebula/User.rb rename to src/oca/ruby/opennebula/user.rb index a4c381ccb6..c01494ec03 100644 --- a/src/oca/ruby/OpenNebula/User.rb +++ b/src/oca/ruby/opennebula/user.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,7 +15,7 @@ #--------------------------------------------------------------------------- # -require 'OpenNebula/Pool' +require 'opennebula/pool_element' module OpenNebula class User < PoolElement @@ -84,6 +84,8 @@ module OpenNebula super(USER_METHODS[:info], 'USER') end + alias_method :info!, :info + # Allocates a new User in OpenNebula # # +username+ Name of the new user. diff --git a/src/oca/ruby/OpenNebula/UserPool.rb b/src/oca/ruby/opennebula/user_pool.rb similarity index 94% rename from src/oca/ruby/OpenNebula/UserPool.rb rename to src/oca/ruby/opennebula/user_pool.rb index b4d9b733a6..6e87507bfa 100644 --- a/src/oca/ruby/OpenNebula/UserPool.rb +++ b/src/oca/ruby/opennebula/user_pool.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,7 +15,7 @@ #--------------------------------------------------------------------------- # -require 'OpenNebula/Pool' +require 'opennebula/pool' module OpenNebula class UserPool < Pool @@ -49,5 +49,7 @@ module OpenNebula def info() super(USER_POOL_METHODS[:info]) end + + alias_method :info!, :info end end diff --git a/src/oca/ruby/OpenNebula/VirtualMachine.rb b/src/oca/ruby/opennebula/virtual_machine.rb similarity index 65% rename from src/oca/ruby/OpenNebula/VirtualMachine.rb rename to src/oca/ruby/opennebula/virtual_machine.rb index 130142c64b..18e19f4410 100644 --- a/src/oca/ruby/OpenNebula/VirtualMachine.rb +++ b/src/oca/ruby/opennebula/virtual_machine.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,7 +15,7 @@ #--------------------------------------------------------------------------- # -require 'OpenNebula/Pool' +require 'opennebula/pool_element' module OpenNebula class VirtualMachine < PoolElement @@ -23,7 +23,6 @@ module OpenNebula # Constants and Class Methods ####################################################################### - VM_METHODS = { :info => "vm.info", :allocate => "vm.allocate", @@ -36,17 +35,24 @@ module OpenNebula :monitoring => "vm.monitoring", :attach => "vm.attach", :detach => "vm.detach", + :rename => "vm.rename", + :update => "vm.update", + :resize => "vm.resize", + :snapshotcreate => "vm.snapshotcreate", + :snapshotrevert => "vm.snapshotrevert", + :snapshotdelete => "vm.snapshotdelete", :attachnic => "vm.attachnic", :detachnic => "vm.detachnic" } - VM_STATE=%w{INIT PENDING HOLD ACTIVE STOPPED SUSPENDED DONE FAILED + VM_STATE=%w{INIT PENDING HOLD ACTIVE STOPPED SUSPENDED DONE FAILED POWEROFF} LCM_STATE=%w{LCM_INIT PROLOG BOOT RUNNING MIGRATE SAVE_STOP SAVE_SUSPEND SAVE_MIGRATE PROLOG_MIGRATE PROLOG_RESUME EPILOG_STOP EPILOG - SHUTDOWN CANCEL FAILURE CLEANUP UNKNOWN HOTPLUG SHUTDOWN_POWEROFF - BOOT_UNKNOWN BOOT_POWEROFF BOOT_SUSPENDED BOOT_STOPPED} + SHUTDOWN CANCEL FAILURE CLEANUP_RESUBMIT UNKNOWN HOTPLUG SHUTDOWN_POWEROFF + BOOT_UNKNOWN BOOT_POWEROFF BOOT_SUSPENDED BOOT_STOPPED CLEANUP_DELETE + HOTPLUG_SNAPSHOT} SHORT_VM_STATES={ "INIT" => "init", @@ -61,28 +67,30 @@ module OpenNebula } SHORT_LCM_STATES={ - "PROLOG" => "prol", - "BOOT" => "boot", - "RUNNING" => "runn", - "MIGRATE" => "migr", - "SAVE_STOP" => "save", - "SAVE_SUSPEND" => "save", - "SAVE_MIGRATE" => "save", - "PROLOG_MIGRATE"=> "migr", - "PROLOG_RESUME" => "prol", - "EPILOG_STOP" => "epil", - "EPILOG" => "epil", - "SHUTDOWN" => "shut", - "CANCEL" => "shut", - "FAILURE" => "fail", - "CLEANUP" => "clea", - "UNKNOWN" => "unkn", - "HOTPLUG" => "hotp", + "PROLOG" => "prol", + "BOOT" => "boot", + "RUNNING" => "runn", + "MIGRATE" => "migr", + "SAVE_STOP" => "save", + "SAVE_SUSPEND" => "save", + "SAVE_MIGRATE" => "save", + "PROLOG_MIGRATE" => "migr", + "PROLOG_RESUME" => "prol", + "EPILOG_STOP" => "epil", + "EPILOG" => "epil", + "SHUTDOWN" => "shut", + "CANCEL" => "shut", + "FAILURE" => "fail", + "CLEANUP_RESUBMIT" => "clea", + "UNKNOWN" => "unkn", + "HOTPLUG" => "hotp", "SHUTDOWN_POWEROFF" => "shut", - "BOOT_UNKNOWN" => "boot", - "BOOT_POWEROFF" => "boot", - "BOOT_SUSPENDED" => "boot", - "BOOT_STOPPED" => "boot" + "BOOT_UNKNOWN" => "boot", + "BOOT_POWEROFF" => "boot", + "BOOT_SUSPENDED" => "boot", + "BOOT_STOPPED" => "boot", + "CLEANUP_DELETE" => "clea", + "HOTPLUG_SNAPSHOT" => "snap" } MIGRATE_REASON=%w{NONE ERROR STOP_RESUME USER CANCEL} @@ -133,24 +141,62 @@ module OpenNebula super(VM_METHODS[:info], 'VM') end + alias_method :info!, :info + # Allocates a new VirtualMachine in OpenNebula # - # +description+ A string containing the template of the VirtualMachine. - def allocate(description) - super(VM_METHODS[:allocate],description) + # @param description [String] A string containing the template of + # the VirtualMachine. + # @param hold [true,false] false to create the VM in pending state, + # true to create it on hold + # + # @return [nil, OpenNebula::Error] nil in case of success, Error + # otherwise + def allocate(description, hold=false) + super(VM_METHODS[:allocate], description, hold) end + # Replaces the template contents + # + # @param new_template New template contents. If no argument is provided + # the object will be updated using the @xml variable + def update(new_template=nil) + super(VM_METHODS[:update], new_template) + end + + # Returns the element in text form + # + # @param indent [true,false] indents the resulting string, defaults to true + # + # @return [String] The USER_TEMPLATE + def user_template_str(indent=true) + template_like_str('USER_TEMPLATE', indent) + end + + # Returns the element in XML form + # + # @return [String] The USER_TEMPLATE + def user_template_xml + if NOKOGIRI + @xml.xpath('TEMPLATE').to_s + else + @xml.elements['TEMPLATE'].to_s + end + end + + # Initiates the instance of the VM on the target host. # - # +host_id+ The host id (hid) of the target host where - # the VM will be instantiated. - def deploy(host_id) - return Error.new('ID not defined') if !@pe_id - - rc = @client.call(VM_METHODS[:deploy], @pe_id, host_id.to_i) - rc = nil if !OpenNebula.is_error?(rc) - - return rc + # @param host_id [Interger] The host id (hid) of the target host where + # the VM will be instantiated. + # @param enforce [true|false] If it is set to true, the host capacity + # will be checked, and the deployment will fail if the host is + # overcommited. Defaults to false + # + # @return [nil, OpenNebula::Error] nil in case of success, Error + # otherwise + def deploy(host_id, enforce=false) + return call(VM_METHODS[:deploy], @pe_id, host_id.to_i, enforce) end # Shutdowns an already deployed VM @@ -265,23 +311,31 @@ module OpenNebula end # Saves a running VM and starts it again in the specified host - def migrate(host_id) - return Error.new('ID not defined') if !@pe_id - - rc = @client.call(VM_METHODS[:migrate], @pe_id, host_id.to_i, false) - rc = nil if !OpenNebula.is_error?(rc) - - return rc + # + # @param host_id [Interger] The host id (hid) of the target host where + # the VM will be migrated. + # @param enforce [true|false] If it is set to true, the host capacity + # will be checked, and the deployment will fail if the host is + # overcommited. Defaults to false + # + # @return [nil, OpenNebula::Error] nil in case of success, Error + # otherwise + def migrate(host_id, enforce=false) + return call(VM_METHODS[:migrate], @pe_id, host_id.to_i, false, enforce) end # Migrates a running VM to another host without downtime - def live_migrate(host_id) - return Error.new('ID not defined') if !@pe_id - - rc = @client.call(VM_METHODS[:migrate], @pe_id, host_id.to_i, true) - rc = nil if !OpenNebula.is_error?(rc) - - return rc + # + # @param host_id [Interger] The host id (hid) of the target host where + # the VM will be migrated. + # @param enforce [true|false] If it is set to true, the host capacity + # will be checked, and the deployment will fail if the host is + # overcommited. Defaults to false + # + # @return [nil, OpenNebula::Error] nil in case of success, Error + # otherwise + def live_migrate(host_id, enforce=false) + return call(VM_METHODS[:migrate], @pe_id, host_id.to_i, true, enforce) end # Set the specified vm's disk to be saved in a new image @@ -307,6 +361,21 @@ module OpenNebula return rc end + # Resize the VM + # + # @param cpu [Float] the new CPU value + # @param memory [Integer] the new MEMORY value + # @param vcpu [Integer] the new VCPU value + # @param enforce [true|false] If it is set to true, the host capacity + # will be checked. This will only affect oneadmin requests, regular users + # resize requests will always be enforced + # + # @return [nil, OpenNebula::Error] nil in case of success, Error + # otherwise + def resize(cpu, memory, vcpu, enforce) + return call(VM_METHODS[:resize], @pe_id, cpu, memory, vcpu, enforce) + end + # Changes the owner/group # uid:: _Integer_ the new owner id. Set to -1 to leave the current one # gid:: _Integer_ the new group id. Set to -1 to leave the current one @@ -370,6 +439,49 @@ module OpenNebula return @client.call(VM_METHODS[:monitoring], @pe_id) end + # Renames this VM + # + # @param name [String] New name for the VM. + # + # @return [nil, OpenNebula::Error] nil in case of success, Error + # otherwise + def rename(name) + return call(VM_METHODS[:rename], @pe_id, name) + end + + # Creates a new VM snapshot + # + # @param name [String] Name for the snapshot. + # + # @return [Integer, OpenNebula::Error] The new snaphost ID in case + # of success, Error otherwise + def snapshot_create(name="") + return Error.new('ID not defined') if !@pe_id + + name ||= "" + return @client.call(VM_METHODS[:snapshotcreate], @pe_id, name) + end + + # Reverts to a snapshot + # + # @param snap_id [Integer] Id of the snapshot + # + # @return [nil, OpenNebula::Error] nil in case of success, Error + # otherwise + def snapshot_revert(snap_id) + return call(VM_METHODS[:snapshotrevert], @pe_id, snap_id) + end + + # Deletes a VM snapshot + # + # @param snap_id [Integer] Id of the snapshot + # + # @return [nil, OpenNebula::Error] nil in case of success, Error + # otherwise + def snapshot_delete(snap_id) + return call(VM_METHODS[:snapshotdelete], @pe_id, snap_id) + end + ####################################################################### # Helpers to get VirtualMachine information ####################################################################### diff --git a/src/oca/ruby/OpenNebula/VirtualMachinePool.rb b/src/oca/ruby/opennebula/virtual_machine_pool.rb similarity index 97% rename from src/oca/ruby/OpenNebula/VirtualMachinePool.rb rename to src/oca/ruby/opennebula/virtual_machine_pool.rb index b0a06af35a..2932bf3c1d 100644 --- a/src/oca/ruby/OpenNebula/VirtualMachinePool.rb +++ b/src/oca/ruby/opennebula/virtual_machine_pool.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,7 +15,7 @@ #--------------------------------------------------------------------------- # -require 'OpenNebula/Pool' +require 'opennebula/pool' module OpenNebula class VirtualMachinePool < Pool @@ -113,6 +113,11 @@ module OpenNebula INFO_NOT_DONE) end + alias_method :info!, :info + alias_method :info_all!, :info_all + alias_method :info_mine!, :info_mine + alias_method :info_group!, :info_group + # Retrieves the monitoring data for all the VMs in the pool # # @param [Array] xpath_expressions Elements to retrieve. diff --git a/src/oca/ruby/OpenNebula/VirtualNetwork.rb b/src/oca/ruby/opennebula/virtual_network.rb similarity index 93% rename from src/oca/ruby/OpenNebula/VirtualNetwork.rb rename to src/oca/ruby/opennebula/virtual_network.rb index bb5c0933b3..26edd487d4 100644 --- a/src/oca/ruby/OpenNebula/VirtualNetwork.rb +++ b/src/oca/ruby/opennebula/virtual_network.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,7 +15,7 @@ #--------------------------------------------------------------------------- # -require 'OpenNebula/Pool' +require 'opennebula/pool_element' module OpenNebula class VirtualNetwork < PoolElement @@ -34,7 +34,8 @@ module OpenNebula :chmod => "vn.chmod", :update => "vn.update", :hold => "vn.hold", - :release => "vn.release" + :release => "vn.release", + :rename => "vn.rename" } VN_TYPES=%w{RANGED FIXED} @@ -75,6 +76,8 @@ module OpenNebula super(VN_METHODS[:info], 'VNET') end + alias_method :info!, :info + # Allocates a new VirtualNetwork in OpenNebula # # @param description [String] The template of the VirtualNetwork. @@ -191,6 +194,16 @@ module OpenNebula super(VN_METHODS[:chmod], owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a) end + + # Renames this virtual network + # + # @param name [String] New name for the virtual network. + # + # @return [nil, OpenNebula::Error] nil in case of success, Error + # otherwise + def rename(name) + return call(VN_METHODS[:rename], @pe_id, name) + end ####################################################################### # Helpers to get VirtualNetwork information diff --git a/src/oca/ruby/OpenNebula/VirtualNetworkPool.rb b/src/oca/ruby/opennebula/virtual_network_pool.rb similarity index 91% rename from src/oca/ruby/OpenNebula/VirtualNetworkPool.rb rename to src/oca/ruby/opennebula/virtual_network_pool.rb index 135da47e72..38a8acc1f0 100644 --- a/src/oca/ruby/OpenNebula/VirtualNetworkPool.rb +++ b/src/oca/ruby/opennebula/virtual_network_pool.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -15,7 +15,7 @@ #--------------------------------------------------------------------------- # -require 'OpenNebula/Pool' +require 'opennebula/pool' module OpenNebula class VirtualNetworkPool < Pool @@ -70,5 +70,10 @@ module OpenNebula def info_group() return super(VN_POOL_METHODS[:info]) end + + alias_method :info!, :info + alias_method :info_all!, :info_all + alias_method :info_mine!, :info_mine + alias_method :info_group!, :info_group end end diff --git a/src/oca/ruby/OpenNebula/XMLUtils.rb b/src/oca/ruby/opennebula/xml_element.rb similarity index 97% rename from src/oca/ruby/OpenNebula/XMLUtils.rb rename to src/oca/ruby/opennebula/xml_element.rb index 9a244312c0..a39f566898 100644 --- a/src/oca/ruby/OpenNebula/XMLUtils.rb +++ b/src/oca/ruby/opennebula/xml_element.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -16,21 +16,6 @@ module OpenNebula - - begin - require 'nokogiri' - NOKOGIRI=true - rescue LoadError - NOKOGIRI=false - end - - begin - require 'rexml/formatters/pretty' - REXML_FORMATTERS=true - rescue LoadError - REXML_FORMATTERS=false - end - # The XMLElement class provides an abstraction of the underlying # XML parser engine. It provides XML-related methods for the Pool and # PoolElement classes diff --git a/src/oca/ruby/opennebula/xml_pool.rb b/src/oca/ruby/opennebula/xml_pool.rb new file mode 100644 index 0000000000..0d5f65b382 --- /dev/null +++ b/src/oca/ruby/opennebula/xml_pool.rb @@ -0,0 +1,45 @@ +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +require 'opennebula/xml_element' + +module OpenNebula + # The XMLUtilsPool module provides an abstraction of the underlying + # XML parser engine. It provides XML-related methods for the Pools + class XMLPool < XMLElement + + def initialize(xml=nil) + super(xml) + end + + #Executes the given block for each element of the Pool + #block:: _Block_ + def each_element(block) + if NOKOGIRI + @xml.xpath( + "#{@element_name}").each {|pelem| + block.call self.factory(pelem) + } + else + @xml.elements.each( + "#{@element_name}") {|pelem| + block.call self.factory(pelem) + } + end + end + end + +end diff --git a/src/oca/ruby/opennebula/xml_utils.rb b/src/oca/ruby/opennebula/xml_utils.rb new file mode 100644 index 0000000000..e4088caa0c --- /dev/null +++ b/src/oca/ruby/opennebula/xml_utils.rb @@ -0,0 +1,34 @@ +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +require 'opennebula/xml_pool' + +module OpenNebula + + begin + require 'nokogiri' + NOKOGIRI=true + rescue LoadError + NOKOGIRI=false + end + + begin + require 'rexml/formatters/pretty' + REXML_FORMATTERS=true + rescue LoadError + REXML_FORMATTERS=false + end +end diff --git a/src/oca/ruby/test/HostPool_spec.rb b/src/oca/ruby/test/HostPool_spec.rb index 7c2d083330..b2acda5e22 100644 --- a/src/oca/ruby/test/HostPool_spec.rb +++ b/src/oca/ruby/test/HostPool_spec.rb @@ -1,7 +1,7 @@ $: << '../' \ << './' -require 'OpenNebula' +require 'opennebula' require 'helpers/MockClient' module OpenNebula diff --git a/src/oca/ruby/test/Host_spec.rb b/src/oca/ruby/test/Host_spec.rb index 5d0a585b19..fa255dc4c6 100644 --- a/src/oca/ruby/test/Host_spec.rb +++ b/src/oca/ruby/test/Host_spec.rb @@ -1,7 +1,7 @@ $: << '../' \ << './' -require 'OpenNebula' +require 'opennebula' require 'helpers/MockClient' module OpenNebula diff --git a/src/oca/ruby/test/UserPool_spec.rb b/src/oca/ruby/test/UserPool_spec.rb index 22f208b6af..9f471d1fb3 100644 --- a/src/oca/ruby/test/UserPool_spec.rb +++ b/src/oca/ruby/test/UserPool_spec.rb @@ -1,7 +1,7 @@ $: << '../' \ << './' -require 'OpenNebula' +require 'opennebula' require 'helpers/MockClient' module OpenNebula diff --git a/src/oca/ruby/test/User_spec.rb b/src/oca/ruby/test/User_spec.rb index c3f25fdbc6..dfe158656a 100644 --- a/src/oca/ruby/test/User_spec.rb +++ b/src/oca/ruby/test/User_spec.rb @@ -1,7 +1,7 @@ $: << '../' \ << './' -require 'OpenNebula' +require 'opennebula' require 'helpers/MockClient' module OpenNebula diff --git a/src/oca/ruby/test/VirtualMachinePool_spec.rb b/src/oca/ruby/test/VirtualMachinePool_spec.rb index 5d08cce65f..eb3988dd4e 100644 --- a/src/oca/ruby/test/VirtualMachinePool_spec.rb +++ b/src/oca/ruby/test/VirtualMachinePool_spec.rb @@ -1,7 +1,7 @@ $: << '../' \ << './' -require 'OpenNebula' +require 'opennebula' require 'helpers/MockClient' module OpenNebula diff --git a/src/oca/ruby/test/VirtualMachine_spec.rb b/src/oca/ruby/test/VirtualMachine_spec.rb index 982916fa5a..a26308ba13 100644 --- a/src/oca/ruby/test/VirtualMachine_spec.rb +++ b/src/oca/ruby/test/VirtualMachine_spec.rb @@ -1,7 +1,7 @@ $: << '../' \ << './' -require 'OpenNebula' +require 'opennebula' require 'helpers/MockClient' module OpenNebula diff --git a/src/oca/ruby/test/VirtualNetworkPool_spec.rb b/src/oca/ruby/test/VirtualNetworkPool_spec.rb index 5bebce9fa0..4904b2fbfc 100644 --- a/src/oca/ruby/test/VirtualNetworkPool_spec.rb +++ b/src/oca/ruby/test/VirtualNetworkPool_spec.rb @@ -1,7 +1,7 @@ $: << '../' \ << './' -require 'OpenNebula' +require 'opennebula' require 'helpers/MockClient' module OpenNebula diff --git a/src/oca/ruby/test/VirtualNetwork_spec.rb b/src/oca/ruby/test/VirtualNetwork_spec.rb index 3d3431da2f..e061932653 100644 --- a/src/oca/ruby/test/VirtualNetwork_spec.rb +++ b/src/oca/ruby/test/VirtualNetwork_spec.rb @@ -1,7 +1,7 @@ $: << '../' \ << './' -require 'OpenNebula' +require 'opennebula' require 'helpers/MockClient' module OpenNebula diff --git a/src/oca/ruby/test/XMLUtils_spec.rb b/src/oca/ruby/test/XMLUtils_spec.rb index 45b9fdacf6..a11723500a 100644 --- a/src/oca/ruby/test/XMLUtils_spec.rb +++ b/src/oca/ruby/test/XMLUtils_spec.rb @@ -2,7 +2,7 @@ $: << '..' require 'rexml/document' -require 'OpenNebula/XMLUtils' +require 'opennebula/XMLUtils' shared_examples "modifying XML" do it "add a new element '.', 'B2' => 'bdos'" do @@ -97,4 +97,4 @@ require 'OpenNebula/XMLUtils' end it_behaves_like "modifying XML" - end \ No newline at end of file + end diff --git a/src/onedb/2.0_to_2.9.80.rb b/src/onedb/2.0_to_2.9.80.rb index 8650fe8d45..3be93d420b 100644 --- a/src/onedb/2.0_to_2.9.80.rb +++ b/src/onedb/2.0_to_2.9.80.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/onedb/2.9.80_to_2.9.85.rb b/src/onedb/2.9.80_to_2.9.85.rb index cc80dc470d..52d4a2ca49 100644 --- a/src/onedb/2.9.80_to_2.9.85.rb +++ b/src/onedb/2.9.80_to_2.9.85.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/onedb/2.9.85_to_2.9.90.rb b/src/onedb/2.9.85_to_2.9.90.rb index 8857c15d5a..a60f34120b 100644 --- a/src/onedb/2.9.85_to_2.9.90.rb +++ b/src/onedb/2.9.85_to_2.9.90.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/onedb/2.9.90_to_3.0.0.rb b/src/onedb/2.9.90_to_3.0.0.rb index 97d320df2e..bf02ea017f 100644 --- a/src/onedb/2.9.90_to_3.0.0.rb +++ b/src/onedb/2.9.90_to_3.0.0.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/onedb/3.0.0_to_3.1.0.rb b/src/onedb/3.0.0_to_3.1.0.rb index 8a29680eb0..75bec2a248 100644 --- a/src/onedb/3.0.0_to_3.1.0.rb +++ b/src/onedb/3.0.0_to_3.1.0.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/onedb/3.1.0_to_3.1.80.rb b/src/onedb/3.1.0_to_3.1.80.rb index 0c6fdfacba..badbc54392 100644 --- a/src/onedb/3.1.0_to_3.1.80.rb +++ b/src/onedb/3.1.0_to_3.1.80.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/onedb/3.1.80_to_3.2.0.rb b/src/onedb/3.1.80_to_3.2.0.rb index 0932268498..44f3b608ab 100644 --- a/src/onedb/3.1.80_to_3.2.0.rb +++ b/src/onedb/3.1.80_to_3.2.0.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/onedb/3.2.0_to_3.2.1.rb b/src/onedb/3.2.0_to_3.2.1.rb index c6f0754fa8..6706bc5a50 100644 --- a/src/onedb/3.2.0_to_3.2.1.rb +++ b/src/onedb/3.2.0_to_3.2.1.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/onedb/3.2.1_to_3.3.0.rb b/src/onedb/3.2.1_to_3.3.0.rb index 9044892d14..6464d3d031 100644 --- a/src/onedb/3.2.1_to_3.3.0.rb +++ b/src/onedb/3.2.1_to_3.3.0.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/onedb/3.3.0_to_3.3.80.rb b/src/onedb/3.3.0_to_3.3.80.rb index a82d58d6e9..0b5e713d48 100644 --- a/src/onedb/3.3.0_to_3.3.80.rb +++ b/src/onedb/3.3.0_to_3.3.80.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/onedb/3.3.80_to_3.4.0.rb b/src/onedb/3.3.80_to_3.4.0.rb index 4b5974e5de..16e271115b 100644 --- a/src/onedb/3.3.80_to_3.4.0.rb +++ b/src/onedb/3.3.80_to_3.4.0.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/onedb/3.4.0_to_3.4.1.rb b/src/onedb/3.4.0_to_3.4.1.rb index b11206ad1d..de5519d619 100644 --- a/src/onedb/3.4.0_to_3.4.1.rb +++ b/src/onedb/3.4.0_to_3.4.1.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/onedb/3.4.1_to_3.5.80.rb b/src/onedb/3.4.1_to_3.5.80.rb index eab4951d38..b314facbef 100644 --- a/src/onedb/3.4.1_to_3.5.80.rb +++ b/src/onedb/3.4.1_to_3.5.80.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/onedb/3.5.80_to_3.6.0.rb b/src/onedb/3.5.80_to_3.6.0.rb index cf8b892eb9..dffc0a9d1e 100644 --- a/src/onedb/3.5.80_to_3.6.0.rb +++ b/src/onedb/3.5.80_to_3.6.0.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # 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 c920092f26..ff71bbd0b4 100644 --- a/src/onedb/3.6.0_to_3.7.80.rb +++ b/src/onedb/3.6.0_to_3.7.80.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/onedb/3.7.80_to_3.8.0.rb b/src/onedb/3.7.80_to_3.8.0.rb index 7162c26d4a..8809730d12 100644 --- a/src/onedb/3.7.80_to_3.8.0.rb +++ b/src/onedb/3.7.80_to_3.8.0.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/onedb/3.8.0_to_3.8.1.rb b/src/onedb/3.8.0_to_3.8.1.rb index e37bb9b247..d060e714ad 100644 --- a/src/onedb/3.8.0_to_3.8.1.rb +++ b/src/onedb/3.8.0_to_3.8.1.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/onedb/3.8.1_to_3.9.80.rb b/src/onedb/3.8.1_to_3.9.80.rb index c65b5c4ff1..3c3d285fbd 100644 --- a/src/onedb/3.8.1_to_3.9.80.rb +++ b/src/onedb/3.8.1_to_3.9.80.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -112,14 +112,74 @@ module Migrator @db.run("DROP TABLE image_pool") @db.run("ALTER TABLE image_pool_new RENAME TO image_pool") + ######################################################################## + # Feature #1565: New cid column in host, ds and vnet tables + ######################################################################## + + @db.run "ALTER TABLE host_pool RENAME TO old_host_pool;" + @db.run "CREATE TABLE host_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, state INTEGER, last_mon_time INTEGER, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER, cid INTEGER, UNIQUE(name));" + + @db.fetch("SELECT * FROM old_host_pool") do |row| + doc = Document.new(row[:body]) + + cluster_id = doc.root.get_text('CLUSTER_ID').to_s + + @db[:host_pool].insert( + :oid => row[:oid], + :name => row[:name], + :body => row[:body], + :state => row[:state], + :last_mon_time => row[:last_mon_time], + :uid => row[:uid], + :gid => row[:gid], + :owner_u => row[:owner_u], + :group_u => row[:group_u], + :other_u => row[:other_u], + :cid => cluster_id) + end + + @db.run "DROP TABLE old_host_pool;" + + ######################################################################## + # Feature #1565: New cid column + # Feature #471: IPv6 addresses + ######################################################################## + + @db.run "ALTER TABLE network_pool RENAME TO old_network_pool;" + @db.run "CREATE TABLE network_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER, cid INTEGER, UNIQUE(name,uid));" + + @db.fetch("SELECT * FROM old_network_pool") do |row| + doc = Document.new(row[:body]) + + cluster_id = doc.root.get_text('CLUSTER_ID').to_s + + doc.root.add_element("GLOBAL_PREFIX") + doc.root.add_element("SITE_PREFIX") + + @db[:network_pool].insert( + :oid => row[:oid], + :name => row[:name], + :body => doc.root.to_s, + :uid => row[:uid], + :gid => row[:gid], + :owner_u => row[:owner_u], + :group_u => row[:group_u], + :other_u => row[:other_u], + :cid => cluster_id) + end + + @db.run "DROP TABLE old_network_pool;" + ######################################################################## # Feature #1617 # New datastore, 2 "files" # DATASTORE/SYSTEM is now DATASTORE/TYPE + # + # Feature #1565: New cid column in host, ds and vnet tables ######################################################################## @db.run "ALTER TABLE datastore_pool RENAME TO old_datastore_pool;" - @db.run "CREATE TABLE datastore_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER, UNIQUE(name));" + @db.run "CREATE TABLE datastore_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER, cid INTEGER, UNIQUE(name));" @db.fetch("SELECT * FROM old_datastore_pool") do |row| doc = Document.new(row[:body]) @@ -139,6 +199,8 @@ module Migrator e.add_element("TYPE").text = type == "0" ? "IMAGE_DS" : "SYSTEM_DS" end + cluster_id = doc.root.get_text('CLUSTER_ID').to_s + @db[:datastore_pool].insert( :oid => row[:oid], :name => row[:name], @@ -147,7 +209,8 @@ module Migrator :gid => row[:gid], :owner_u => row[:owner_u], :group_u => row[:group_u], - :other_u => row[:other_u]) + :other_u => row[:other_u], + :cid => cluster_id) end @db.run "DROP TABLE old_datastore_pool;" @@ -176,7 +239,7 @@ module Migrator end end - @db.run "INSERT INTO datastore_pool VALUES(2,'files','200#{user_0_name}#{group_0_name}files110100100fsssh#{base_path}20-1',0,0,1,1,1);" + @db.run "INSERT INTO datastore_pool VALUES(2,'files','200#{user_0_name}#{group_0_name}files110100100fsssh#{base_path}20-1',0,0,1,1,1,-1);" ######################################################################## @@ -258,6 +321,184 @@ module Migrator @db.run "DROP TABLE old_group_pool;" + ######################################################################## + # Bug #1694: SYSTEM_DS is now set with the method adddatastore + ######################################################################## + + @db.run "ALTER TABLE cluster_pool RENAME TO old_cluster_pool;" + @db.run "CREATE TABLE cluster_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER, UNIQUE(name));" + + @db.fetch("SELECT * FROM old_cluster_pool") do |row| + doc = Document.new(row[:body]) + + system_ds = 0 + + doc.root.each_element("TEMPLATE") do |e| + elem = e.delete_element("SYSTEM_DS") + + if !elem.nil? + system_ds = elem.text.to_i + end + end + + if system_ds != 0 + updated_body = nil + + @db.fetch("SELECT body FROM datastore_pool WHERE oid=#{system_ds}") do |ds_row| + ds_doc = Document.new(ds_row[:body]) + + type = "0" # IMAGE_DS + + ds_doc.root.each_element("TYPE") do |e| + type = e.text + end + + if type != "1" + puts " > Cluster #{row[:oid]} has the "<< + "System Datastore set to Datastore #{system_ds}, "<< + "but its type is not SYSTEM_DS. The System Datastore "<< + "for this Cluster will be set to 0" + + system_ds = 0 + else + cluster_id = "-1" + + ds_doc.root.each_element("CLUSTER_ID") do |e| + cluster_id = e.text + end + + if row[:oid] != cluster_id.to_i + puts " > Cluster #{row[:oid]} has the "<< + "System Datastore set to Datastore #{system_ds}, "<< + "but it is not part of the Cluster. It will be added now." + + ds_doc.root.each_element("CLUSTER_ID") do |e| + e.text = row[:oid] + end + + ds_doc.root.each_element("CLUSTER") do |e| + e.text = row[:name] + end + + updated_body = ds_doc.root.to_s + end + end + end + + if !updated_body.nil? + @db[:datastore_pool].where(:oid => system_ds).update( + :body => updated_body) + end + end + + doc.root.add_element("SYSTEM_DS").text = system_ds.to_s + + @db[:cluster_pool].insert( + :oid => row[:oid], + :name => row[:name], + :body => doc.root.to_s, + :uid => row[:uid], + :gid => row[:gid], + :owner_u => row[:owner_u], + :group_u => row[:group_u], + :other_u => row[:other_u]) + end + + @db.run "DROP TABLE old_cluster_pool;" + + + ######################################################################## + # Feature #1556: New elem USER_TEMPLATE + # + # Feature #1483: Move scheduling attributes + # /VM/TEMPLATE/REQUIREMENTS -> USER_TEMPLATE/SCHED_REQUIREMENTS + # /VM/TEMPLATE/RANK -> USER_TEMPLATE/SCHED_RANK + ######################################################################## + + @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| + + doc = Document.new(row[:body]) + user_template = doc.root.add_element("USER_TEMPLATE") + + doc.root.each_element("TEMPLATE") do |e| + elem = e.delete_element("REQUIREMENTS") + + if !elem.nil? + user_template.add_element("SCHED_REQUIREMENTS").text = elem.text + end + + elem = e.delete_element("RANK") + + if !elem.nil? + user_template.add_element("SCHED_RANK").text = elem.text + end + end + + @db[:vm_pool].insert( + :oid => row[:oid], + :name => row[:name], + :body => doc.root.to_s, + :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;" + + + ######################################################################## + # Feature #1483: Move scheduling attributes + # /VMTEMPLATE/TEMPLATE/REQUIREMENTS -> /VMTEMPLATE/TEMPLATE/SCHED_REQUIREMENTS + # /VMTEMPLATE/TEMPLATE/RANK -> /VMTEMPLATE/TEMPLATE/SCHED_RANK + ######################################################################## + + @db.run "ALTER TABLE template_pool RENAME TO old_template_pool;" + @db.run "CREATE TABLE template_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER);" + + @db.fetch("SELECT * FROM old_template_pool") do |row| + + doc = Document.new(row[:body]) + + template = nil + + doc.root.each_element("TEMPLATE") do |e| + template = e + end + + doc.root.each_element("TEMPLATE") do |e| + elem = e.delete_element("REQUIREMENTS") + + if !elem.nil? + template.add_element("SCHED_REQUIREMENTS").text = elem.text + end + + elem = e.delete_element("RANK") + + if !elem.nil? + template.add_element("SCHED_RANK").text = elem.text + end + end + + @db[:template_pool].insert( + :oid => row[:oid], + :name => row[:name], + :body => doc.root.to_s, + :uid => row[:uid], + :gid => row[:gid], + :owner_u => row[:owner_u], + :group_u => row[:group_u], + :other_u => row[:other_u]) + end + + @db.run "DROP TABLE old_template_pool;" ######################################################################## # Feature #1691 Add new attribute NIC/NIC_ID @@ -298,7 +539,6 @@ module Migrator @db.run "DROP TABLE old_vm_pool;" - ######################################################################## # # Banner for the new /var/lib/one/vms directory diff --git a/src/onedb/fsck.rb b/src/onedb/fsck.rb index 9a252c01fd..2c743595b4 100644 --- a/src/onedb/fsck.rb +++ b/src/onedb/fsck.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -20,12 +20,14 @@ require 'ipaddr' require 'set' module OneDBFsck + VERSION = "3.9.0" + def db_version - "4.0.0" + VERSION end def one_version - "OpenNebula 4.0.0" + "OpenNebula #{VERSION}" end IMAGE_STATES=%w{INIT READY USED DISABLED LOCKED ERROR CLONE DELETE USED_PERS} @@ -249,6 +251,7 @@ module OneDBFsck ######################################################################## # Clusters # + # CLUSTER/SYSTEM_DS # CLUSTER/HOSTS/ID # CLUSTER/DATASTORES/ID # CLUSTER/VNETS/ID @@ -277,6 +280,8 @@ module OneDBFsck cluster[row[:oid]][:hosts] = [] cluster[row[:oid]][:datastores] = [] cluster[row[:oid]][:vnets] = [] + + cluster[row[:oid]][:system_ds] = 0 end hosts_fix = {} @@ -308,7 +313,7 @@ module OneDBFsck end hosts_fix.each do |id, body| - @db[:host_pool].where(:oid => id).update(:body => body) + @db[:host_pool].where(:oid => id).update(:body => body, :cid => -1) end @@ -331,13 +336,32 @@ module OneDBFsck datastores_fix[row[:oid]] = doc.to_s else - cluster[cluster_id][:datastores] << row[:oid] + if doc.root.get_text('TYPE').to_s != "1" + cluster[cluster_id][:datastores] << row[:oid] + else + if cluster[cluster_id][:system_ds] == 0 + cluster[cluster_id][:datastores] << row[:oid] + cluster[cluster_id][:system_ds] = row[:oid] + else + log_error("System Datastore #{row[:oid]} is in Cluster #{cluster_id}, but it already contains System Datastore #{cluster[cluster_id][:system_ds]}") + + doc.root.each_element('CLUSTER_ID') do |e| + e.text = "-1" + end + + doc.root.each_element('CLUSTER') do |e| + e.text = "" + end + + datastores_fix[row[:oid]] = doc.to_s + end + end end end end datastores_fix.each do |id, body| - @db[:datastore_pool].where(:oid => id).update(:body => body) + @db[:datastore_pool].where(:oid => id).update(:body => body, :cid => -1) end @@ -366,7 +390,7 @@ module OneDBFsck end vnets_fix.each do |id, body| - @db[:network_pool].where(:oid => id).update(:body => body) + @db[:network_pool].where(:oid => id).update(:body => body, :cid => -1) end @@ -401,6 +425,16 @@ module OneDBFsck ds_new_elem = doc.root.add_element("DATASTORES") + doc.root.each_element("SYSTEM_DS") do |e| + system_ds = e.text.to_i + + if system_ds != cluster[cluster_id][:system_ds] + log_error("Cluster #{cluster_id} has System Datastore set to #{system_ds}, but it should be #{cluster[cluster_id][:system_ds]}") + + e.text = cluster[cluster_id][:system_ds].to_s + end + end + cluster[cluster_id][:datastores].each do |id| id_elem = ds_elem.elements.delete("ID[.=#{id}]") @@ -498,7 +532,7 @@ module OneDBFsck end - @db.run "CREATE TABLE datastore_pool_new (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER, UNIQUE(name));" + @db.run "CREATE TABLE datastore_pool_new (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER, cid INTEGER, UNIQUE(name));" @db.fetch("SELECT * from datastore_pool") do |row| ds_id = row[:oid] @@ -676,7 +710,7 @@ module OneDBFsck "name VARCHAR(128), body TEXT, state INTEGER, " << "last_mon_time INTEGER, uid INTEGER, gid INTEGER, " << "owner_u INTEGER, group_u INTEGER, other_u INTEGER, " << - "UNIQUE(name));" + "cid INTEGER, UNIQUE(name));" # Calculate the host's xml and write them to host_pool_new @db[:host_pool].each do |row| @@ -1003,7 +1037,7 @@ module OneDBFsck ######################################################################## # Create a new empty table where we will store the new calculated values - @db.run "CREATE TABLE network_pool_new (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER, UNIQUE(name,uid));" + @db.run "CREATE TABLE network_pool_new (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER, cid INTEGER, UNIQUE(name,uid));" @db[:network_pool].each do |row| doc = Document.new(row[:body]) diff --git a/src/onedb/onedb b/src/onedb/onedb index 7c95f48804..6768e0af65 100755 --- a/src/onedb/onedb +++ b/src/onedb/onedb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/onedb/onedb.rb b/src/onedb/onedb.rb index 09ab881b8b..f253222d98 100644 --- a/src/onedb/onedb.rb +++ b/src/onedb/onedb.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/onedb/onedb_backend.rb b/src/onedb/onedb_backend.rb index fdd7e33b35..1bf6ea9690 100644 --- a/src/onedb/onedb_backend.rb +++ b/src/onedb/onedb_backend.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/ozones/Client/bin/onevdc b/src/ozones/Client/bin/onevdc index 2872771b1a..3b38c001ed 100755 --- a/src/ozones/Client/bin/onevdc +++ b/src/ozones/Client/bin/onevdc @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/ozones/Client/bin/onezone b/src/ozones/Client/bin/onezone index ccef51e094..4a36d16bd6 100755 --- a/src/ozones/Client/bin/onezone +++ b/src/ozones/Client/bin/onezone @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/ozones/Client/lib/cli/ozones_helper.rb b/src/ozones/Client/lib/cli/ozones_helper.rb index cf13653354..1a4afefbaf 100644 --- a/src/ozones/Client/lib/cli/ozones_helper.rb +++ b/src/ozones/Client/lib/cli/ozones_helper.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb b/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb index 808a099e3f..35bb6e687c 100644 --- a/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb +++ b/src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/ozones/Client/lib/zona.rb b/src/ozones/Client/lib/zona.rb index a7af045d60..4010b1898d 100644 --- a/src/ozones/Client/lib/zona.rb +++ b/src/ozones/Client/lib/zona.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -47,7 +47,7 @@ module Zona # Should match server's oZones version. OZONES_VERSION = < error_value; - - char str[26]; - time_t the_time; + SingleAttribute * attr; + ostringstream error_value; - the_time = time(NULL); - -#ifdef SOLARIS - ctime_r(&(the_time),str,sizeof(char)*26); -#else - ctime_r(&(the_time),str); -#endif - - str[24] = '\0'; // Get rid of final enter character - - error_value.insert(make_pair("TIMESTAMP",str)); - error_value.insert(make_pair("MESSAGE",message)); + error_value << one_util::log_time() << " : " << message; //Replace previous error message and insert the new one - attr = new VectorAttribute(error_attribute_name,error_value); + attr = new SingleAttribute(error_attribute_name, error_value.str()); obj_template->erase(error_attribute_name); obj_template->set(attr); @@ -166,6 +154,14 @@ void PoolObjectSQL::set_template_error_message(const string& message) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +void PoolObjectSQL::clear_template_error_message() +{ + remove_template_attribute(error_attribute_name); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + int PoolObjectSQL::replace_template(const string& tmpl_str, string& error) { Template * new_tmpl = get_new_template(); @@ -175,18 +171,22 @@ int PoolObjectSQL::replace_template(const string& tmpl_str, string& error) error = "Cannot allocate a new template"; return -1; } - + if ( new_tmpl->parse_str_or_xml(tmpl_str, error) != 0 ) { + delete new_tmpl; return -1; } - delete obj_template; + if ( obj_template != 0 ) + { + delete obj_template; + } obj_template = new_tmpl; return 0; -} +} /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -256,6 +256,13 @@ void PoolObjectSQL::get_permissions(PoolObjectAuth& auth) auth.other_u = other_u; auth.other_m = other_m; auth.other_a = other_a; + + Clusterable* cl = dynamic_cast(this); + + if(cl != 0) + { + auth.cid = cl->get_cluster_id(); + } } /* -------------------------------------------------------------------------- */ @@ -301,3 +308,41 @@ error_value: /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ + +void PoolObjectSQL::set_umask(int umask) +{ + int perms; + bool enable_other; + + Nebula::instance().get_configuration_attribute( + "ENABLE_OTHER_PERMISSIONS", enable_other); + + if (uid == 0 || gid == 0) + { + perms = 0777; + } + else if (enable_other) + { + perms = 0666; + } + else + { + perms = 0660; + } + + perms = perms & ~umask; + + owner_u = ( (perms & 0400) != 0 ) ? 1 : 0; + owner_m = ( (perms & 0200) != 0 ) ? 1 : 0; + owner_a = ( (perms & 0100) != 0 ) ? 1 : 0; + group_u = ( (perms & 0040) != 0 ) ? 1 : 0; + group_m = ( (perms & 0020) != 0 ) ? 1 : 0; + group_a = ( (perms & 0010) != 0 ) ? 1 : 0; + other_u = ( (perms & 0004) != 0 ) ? 1 : 0; + other_m = ( (perms & 0002) != 0 ) ? 1 : 0; + other_a = ( (perms & 0001) != 0 ) ? 1 : 0; + +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ diff --git a/src/pool/PoolSQL.cc b/src/pool/PoolSQL.cc index 2acc5a662d..d641d88dfc 100644 --- a/src/pool/PoolSQL.cc +++ b/src/pool/PoolSQL.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -364,6 +364,7 @@ void PoolSQL::update_cache_index(string& old_name, int new_uid) { map::iterator index; + PoolObjectSQL * the_object; lock(); @@ -380,11 +381,13 @@ void PoolSQL::update_cache_index(string& old_name, if ( index != name_pool.end() ) { + the_object = index->second; + name_pool.erase(old_key); if ( name_pool.find(new_key) == name_pool.end()) { - name_pool.insert(make_pair(new_key, index->second)); + name_pool.insert(make_pair(new_key, the_object)); } } @@ -590,6 +593,7 @@ void PoolSQL::acl_filter(int uid, vector oids; vector gids; + vector cids; aclm->reverse_search(uid, gid, @@ -597,7 +601,8 @@ void PoolSQL::acl_filter(int uid, AuthRequest::USE, all, oids, - gids); + gids, + cids); for ( it = oids.begin(); it < oids.end(); it++ ) { @@ -609,6 +614,11 @@ void PoolSQL::acl_filter(int uid, acl_filter << " OR gid = " << *it; } + for ( it = cids.begin(); it < cids.end(); it++ ) + { + acl_filter << " OR cid = " << *it; + } + filter = acl_filter.str(); } diff --git a/src/pool/SConstruct b/src/pool/SConstruct index 1a899f3038..fb1e0c03c9 100644 --- a/src/pool/SConstruct +++ b/src/pool/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/pool # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/pool/test/SConstruct b/src/pool/test/SConstruct index e993a160c9..029786cb2d 100644 --- a/src/pool/test/SConstruct +++ b/src/pool/test/SConstruct @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # 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 diff --git a/src/pool/test/TestPoolSQL.cc b/src/pool/test/TestPoolSQL.cc index b27fa2d322..5cc4af2dac 100644 --- a/src/pool/test/TestPoolSQL.cc +++ b/src/pool/test/TestPoolSQL.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/pool/test/TestPoolSQL.h b/src/pool/test/TestPoolSQL.h index 8b53e41e74..553683f334 100644 --- a/src/pool/test/TestPoolSQL.h +++ b/src/pool/test/TestPoolSQL.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/pool/test/pool.cc b/src/pool/test/pool.cc index 742ab03bda..7ba8457bd3 100644 --- a/src/pool/test/pool.cc +++ b/src/pool/test/pool.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/rm/Request.cc b/src/rm/Request.cc index 21c3624c65..231705d4d7 100644 --- a/src/rm/Request.cc +++ b/src/rm/Request.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -470,7 +470,7 @@ void Request::quota_rollback(Template * tmpl, if ( att.gid != GroupPool::ONEADMIN_ID && att.gid != -1 ) { - group_quota_rollback(tmpl, qtype, att);; + group_quota_rollback(tmpl, qtype, att); } } diff --git a/src/rm/RequestManager.cc b/src/rm/RequestManager.cc index e69719e207..600364a563 100644 --- a/src/rm/RequestManager.cc +++ b/src/rm/RequestManager.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -26,6 +26,7 @@ #include "RequestManagerChown.h" #include "RequestManagerChmod.h" #include "RequestManagerClone.h" +#include "RequestManagerRename.h" #include "RequestManagerVirtualNetwork.h" #include "RequestManagerVirtualMachine.h" @@ -45,9 +46,9 @@ #include #include #include -#include +#include #include - + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -63,41 +64,41 @@ extern "C" void * rm_action_loop(void *arg) NebulaLog::log("ReM",Log::INFO,"Request Manager started."); rm = static_cast(arg); - + rm->am.loop(0,0); NebulaLog::log("ReM",Log::INFO,"Request Manager stopped."); - + return 0; } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ - + extern "C" void * rm_xml_server_loop(void *arg) { RequestManager * rm; - + if ( arg == 0 ) { return 0; } rm = static_cast(arg); - + // Set cancel state for the thread - + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,0); pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,0); - + //Start the server - + rm->AbyssServer = new xmlrpc_c::serverAbyss(xmlrpc_c::serverAbyss::constrOpt() .registryP(&rm->RequestManagerRegistry) .logFileName(rm->xml_log_file) .socketFd(rm->socket_fd)); - + rm->AbyssServer->run(); return 0; @@ -111,20 +112,20 @@ int RequestManager::setup_socket() int rc; int yes = 1; struct sockaddr_in rm_addr; - + socket_fd = socket(AF_INET, SOCK_STREAM, 0); - + if ( socket_fd == -1 ) { ostringstream oss; oss << "Cannot open server socket: " << strerror(errno); NebulaLog::log("ReM",Log::ERROR,oss); - - return -1; + + return -1; } - - rc = setsockopt(socket_fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)); + + rc = setsockopt(socket_fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)); if ( rc == -1 ) { @@ -132,29 +133,29 @@ int RequestManager::setup_socket() oss << "Cannot set socket options: " << strerror(errno); NebulaLog::log("ReM",Log::ERROR,oss); - + close(socket_fd); - - return -1; + + return -1; } - + fcntl(socket_fd,F_SETFD,FD_CLOEXEC); // Close socket in MADs - + rm_addr.sin_family = AF_INET; rm_addr.sin_port = htons(port); rm_addr.sin_addr.s_addr = INADDR_ANY; rc = bind(socket_fd,(struct sockaddr *) &(rm_addr),sizeof(struct sockaddr)); - if ( rc == -1) + if ( rc == -1) { ostringstream oss; oss << "Cannot bind to port " << port << " : " << strerror(errno); NebulaLog::log("ReM",Log::ERROR,oss); - + close(socket_fd); - + return -1; } @@ -168,29 +169,29 @@ int RequestManager::start() { pthread_attr_t pattr; ostringstream oss; - + NebulaLog::log("ReM",Log::INFO,"Starting Request Manager..."); - + int rc = setup_socket(); - + if ( rc != 0 ) { return -1; } - + register_xml_methods(); - + pthread_attr_init (&pattr); pthread_attr_setdetachstate (&pattr, PTHREAD_CREATE_JOINABLE); - + pthread_create(&rm_thread,&pattr,rm_action_loop,(void *)this); - + pthread_attr_init (&pattr); pthread_attr_setdetachstate (&pattr, PTHREAD_CREATE_JOINABLE); - + oss << "Starting XML-RPC server, port " << port << " ..."; NebulaLog::log("ReM",Log::INFO,oss); - + pthread_create(&rm_xml_server_thread,&pattr,rm_xml_server_loop,(void *)this); return 0; @@ -198,7 +199,7 @@ int RequestManager::start() /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ - + void RequestManager::do_action( const string & action, void * arg) @@ -206,15 +207,15 @@ void RequestManager::do_action( if (action == ACTION_FINALIZE) { NebulaLog::log("ReM",Log::INFO,"Stopping Request Manager..."); - - pthread_cancel(rm_xml_server_thread); + + pthread_cancel(rm_xml_server_thread); pthread_join(rm_xml_server_thread,0); NebulaLog::log("ReM",Log::INFO,"XML-RPC server stopped."); delete AbyssServer; - + if ( socket_fd != -1 ) { close(socket_fd); @@ -224,14 +225,14 @@ void RequestManager::do_action( { ostringstream oss; oss << "Unknown action name: " << action; - + NebulaLog::log("ReM", Log::ERROR, oss); - } + } }; /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ - + void RequestManager::register_xml_methods() { // User Methods @@ -248,13 +249,18 @@ void RequestManager::register_xml_methods() // VirtualMachine Methods xmlrpc_c::methodPtr vm_deploy(new VirtualMachineDeploy()); xmlrpc_c::methodPtr vm_migrate(new VirtualMachineMigrate()); - xmlrpc_c::methodPtr vm_action(new VirtualMachineAction()); + xmlrpc_c::methodPtr vm_action(new VirtualMachineAction()); xmlrpc_c::methodPtr vm_savedisk(new VirtualMachineSaveDisk()); xmlrpc_c::methodPtr vm_monitoring(new VirtualMachineMonitoring()); xmlrpc_c::methodPtr vm_attach(new VirtualMachineAttach()); xmlrpc_c::methodPtr vm_detach(new VirtualMachineDetach()); xmlrpc_c::methodPtr vm_attachnic(new VirtualMachineAttachNic()); xmlrpc_c::methodPtr vm_detachnic(new VirtualMachineDetachNic()); + xmlrpc_c::methodPtr vm_resize(new VirtualMachineResize()); + xmlrpc_c::methodPtr vm_snap_create(new VirtualMachineSnapshotCreate()); + xmlrpc_c::methodPtr vm_snap_revert(new VirtualMachineSnapshotRevert()); + xmlrpc_c::methodPtr vm_snap_delete(new VirtualMachineSnapshotDelete()); + xmlrpc_c::methodPtr vm_pool_acct(new VirtualMachinePoolAccounting()); xmlrpc_c::methodPtr vm_pool_monitoring(new VirtualMachinePoolMonitoring()); @@ -266,6 +272,7 @@ void RequestManager::register_xml_methods() // Update Template Methods xmlrpc_c::methodPtr image_update(new ImageUpdateTemplate()); + xmlrpc_c::methodPtr vm_update(new VirtualMachineUpdateTemplate()); xmlrpc_c::methodPtr template_update(new TemplateUpdateTemplate()); xmlrpc_c::methodPtr host_update(new HostUpdateTemplate()); xmlrpc_c::methodPtr vn_update(new VirtualNetworkUpdateTemplate()); @@ -313,7 +320,7 @@ void RequestManager::register_xml_methods() xmlrpc_c::methodPtr cluster_info(new ClusterInfo()); xmlrpc_c::methodPtr doc_info(new DocumentInfo()); - // PoolInfo Methods + // PoolInfo Methods xmlrpc_c::methodPtr hostpool_info(new HostPoolInfo()); xmlrpc_c::methodPtr grouppool_info(new GroupPoolInfo()); xmlrpc_c::methodPtr userpool_info(new UserPoolInfo()); @@ -376,7 +383,14 @@ void RequestManager::register_xml_methods() xmlrpc_c::methodPtr group_get_default_quota(new GroupQuotaInfo()); xmlrpc_c::methodPtr group_set_default_quota(new GroupQuotaUpdate()); - /* VM related methods */ + // Rename Methods + xmlrpc_c::methodPtr vm_rename(new VirtualMachineRename()); + xmlrpc_c::methodPtr template_rename(new TemplateRename()); + xmlrpc_c::methodPtr vn_rename(new VirtualNetworkRename()); + xmlrpc_c::methodPtr image_rename(new ImageRename()); + xmlrpc_c::methodPtr doc_rename(new DocumentRename()); + + /* VM related methods */ RequestManagerRegistry.addMethod("one.vm.deploy", vm_deploy); RequestManagerRegistry.addMethod("one.vm.action", vm_action); RequestManagerRegistry.addMethod("one.vm.migrate", vm_migrate); @@ -390,6 +404,12 @@ void RequestManager::register_xml_methods() RequestManagerRegistry.addMethod("one.vm.detach", vm_detach); RequestManagerRegistry.addMethod("one.vm.attachnic", vm_attachnic); RequestManagerRegistry.addMethod("one.vm.detachnic", vm_detachnic); + RequestManagerRegistry.addMethod("one.vm.rename", vm_rename); + RequestManagerRegistry.addMethod("one.vm.resize", vm_resize); + RequestManagerRegistry.addMethod("one.vm.update", vm_update); + RequestManagerRegistry.addMethod("one.vm.snapshotcreate", vm_snap_create); + RequestManagerRegistry.addMethod("one.vm.snapshotrevert", vm_snap_revert); + RequestManagerRegistry.addMethod("one.vm.snapshotdelete", vm_snap_delete); RequestManagerRegistry.addMethod("one.vmpool.info", vm_pool_info); RequestManagerRegistry.addMethod("one.vmpool.accounting", vm_pool_acct); @@ -404,18 +424,19 @@ void RequestManager::register_xml_methods() RequestManagerRegistry.addMethod("one.template.chown", template_chown); RequestManagerRegistry.addMethod("one.template.chmod", template_chmod); RequestManagerRegistry.addMethod("one.template.clone", template_clone); + RequestManagerRegistry.addMethod("one.template.rename", template_rename); RequestManagerRegistry.addMethod("one.templatepool.info",template_pool_info); /* Host related methods*/ RequestManagerRegistry.addMethod("one.host.enable", host_enable); RequestManagerRegistry.addMethod("one.host.update", host_update); - RequestManagerRegistry.addMethod("one.host.allocate", host_allocate); + RequestManagerRegistry.addMethod("one.host.allocate", host_allocate); RequestManagerRegistry.addMethod("one.host.delete", host_delete); RequestManagerRegistry.addMethod("one.host.info", host_info); RequestManagerRegistry.addMethod("one.host.monitoring", host_monitoring); - RequestManagerRegistry.addMethod("one.hostpool.info", hostpool_info); + RequestManagerRegistry.addMethod("one.hostpool.info", hostpool_info); RequestManagerRegistry.addMethod("one.hostpool.monitoring", host_pool_monitoring); /* Group related methods */ @@ -437,12 +458,13 @@ void RequestManager::register_xml_methods() RequestManagerRegistry.addMethod("one.vn.allocate", vn_allocate); RequestManagerRegistry.addMethod("one.vn.update", vn_update); RequestManagerRegistry.addMethod("one.vn.delete", vn_delete); - RequestManagerRegistry.addMethod("one.vn.info", vn_info); + RequestManagerRegistry.addMethod("one.vn.info", vn_info); RequestManagerRegistry.addMethod("one.vn.chown", vn_chown); RequestManagerRegistry.addMethod("one.vn.chmod", vn_chmod); + RequestManagerRegistry.addMethod("one.vn.rename", vn_rename); + + RequestManagerRegistry.addMethod("one.vnpool.info", vnpool_info); - RequestManagerRegistry.addMethod("one.vnpool.info", vnpool_info); - /* User related methods*/ RequestManagerRegistry.addMethod("one.user.allocate", user_allocate); RequestManagerRegistry.addMethod("one.user.update", user_update); @@ -457,11 +479,11 @@ void RequestManager::register_xml_methods() RequestManagerRegistry.addMethod("one.userquota.info", user_get_default_quota); RequestManagerRegistry.addMethod("one.userquota.update", user_set_default_quota); - + /* Image related methods*/ RequestManagerRegistry.addMethod("one.image.persistent", image_persistent); RequestManagerRegistry.addMethod("one.image.enable", image_enable); - RequestManagerRegistry.addMethod("one.image.update", image_update); + RequestManagerRegistry.addMethod("one.image.update", image_update); RequestManagerRegistry.addMethod("one.image.allocate", image_allocate); RequestManagerRegistry.addMethod("one.image.delete", image_delete); RequestManagerRegistry.addMethod("one.image.info", image_info); @@ -469,6 +491,7 @@ void RequestManager::register_xml_methods() RequestManagerRegistry.addMethod("one.image.chmod", image_chmod); RequestManagerRegistry.addMethod("one.image.chtype", image_chtype); RequestManagerRegistry.addMethod("one.image.clone", image_clone); + RequestManagerRegistry.addMethod("one.image.rename", image_rename); RequestManagerRegistry.addMethod("one.imagepool.info", imagepool_info); @@ -510,6 +533,7 @@ void RequestManager::register_xml_methods() RequestManagerRegistry.addMethod("one.document.chown", doc_chown); RequestManagerRegistry.addMethod("one.document.chmod", doc_chmod); RequestManagerRegistry.addMethod("one.document.clone", doc_clone); + RequestManagerRegistry.addMethod("one.document.rename", doc_rename); RequestManagerRegistry.addMethod("one.documentpool.info",docpool_info); @@ -520,4 +544,4 @@ void RequestManager::register_xml_methods() /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ - + diff --git a/src/rm/RequestManagerAcl.cc b/src/rm/RequestManagerAcl.cc index b100cf989a..2560f532d1 100644 --- a/src/rm/RequestManagerAcl.cc +++ b/src/rm/RequestManagerAcl.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/rm/RequestManagerAllocate.cc b/src/rm/RequestManagerAllocate.cc index 84dcd007c0..726d18ea31 100644 --- a/src/rm/RequestManagerAllocate.cc +++ b/src/rm/RequestManagerAllocate.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -131,13 +131,31 @@ void RequestManagerAllocate::request_execute(xmlrpc_c::paramList const& params, Template * tmpl = 0; string error_str; - int rc, id; + int rc, id, umask; Cluster * cluster = 0; int cluster_id = ClusterPool::NONE_CLUSTER_ID; string cluster_name = ClusterPool::NONE_CLUSTER_NAME; PoolObjectAuth cluster_perms; + User * user; + UserPool * upool = Nebula::instance().get_upool(); + + user = upool->get(att.uid, true); + + if ( user == 0 ) + { + failure_response(NO_EXISTS, + get_error(object_name(PoolObjectSQL::USER), att.uid), + att); + + return; + } + + umask = user->get_umask(); + + user->unlock(); + if ( do_template == true ) { string str_tmpl = xmlrpc_c::value_string(params.getString(1)); @@ -179,7 +197,7 @@ void RequestManagerAllocate::request_execute(xmlrpc_c::paramList const& params, return; } - rc = pool_allocate(params, tmpl, id, error_str, att, cluster_id, cluster_name); + rc = pool_allocate(params, tmpl, id, error_str, att, cluster_id, cluster_name, umask); if ( rc < 0 ) { @@ -189,6 +207,8 @@ void RequestManagerAllocate::request_execute(xmlrpc_c::paramList const& params, if ( cluster_id != ClusterPool::NONE_CLUSTER_ID ) { + Datastore::DatastoreType ds_type = get_ds_type(id); + cluster = clpool->get(cluster_id, true); if ( cluster == 0 ) @@ -200,7 +220,7 @@ void RequestManagerAllocate::request_execute(xmlrpc_c::paramList const& params, return; } - rc = add_to_cluster(cluster, id, error_str); + rc = add_to_cluster(cluster, id, ds_type, error_str); if ( rc < 0 ) { @@ -232,19 +252,28 @@ void RequestManagerAllocate::request_execute(xmlrpc_c::paramList const& params, /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -int VirtualMachineAllocate::pool_allocate(xmlrpc_c::paramList const& paramList, - Template * tmpl, - int& id, - string& error_str, - RequestAttributes& att) +int VirtualMachineAllocate::pool_allocate( + xmlrpc_c::paramList const& paramList, + Template * tmpl, + int& id, + string& error_str, + RequestAttributes& att, + int umask) { + bool on_hold = false; + + if ( paramList.size() > 2 ) + { + on_hold = xmlrpc_c::value_boolean(paramList.getBoolean(2)); + } + VirtualMachineTemplate * ttmpl= static_cast(tmpl); VirtualMachinePool * vmpool = static_cast(pool); Template tmpl_back(*tmpl); - int rc = vmpool->allocate(att.uid, att.gid, att.uname, att.gname, ttmpl, &id, - error_str, false); + int rc = vmpool->allocate(att.uid, att.gid, att.uname, att.gname, umask, + ttmpl, &id, error_str, on_hold); if ( rc < 0 ) { @@ -265,13 +294,14 @@ int VirtualNetworkAllocate::pool_allocate( string& error_str, RequestAttributes& att, int cluster_id, - const string& cluster_name) + const string& cluster_name, + int umask) { VirtualNetworkPool * vpool = static_cast(pool); VirtualNetworkTemplate * vtmpl=static_cast(tmpl); - return vpool->allocate(att.uid, att.gid, att.uname, att.gname, vtmpl, &id, - cluster_id, cluster_name, error_str); + return vpool->allocate(att.uid, att.gid, att.uname, att.gname, umask, + vtmpl, &id, cluster_id, cluster_name, error_str); } /* -------------------------------------------------------------------------- */ @@ -300,18 +330,41 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params, Nebula& nd = Nebula::instance(); + UserPool * upool = nd.get_upool(); DatastorePool * dspool = nd.get_dspool(); ImagePool * ipool = static_cast(pool); ImageManager * imagem = nd.get_imagem(); - ImageTemplate * tmpl = new ImageTemplate; + ImageTemplate * tmpl; Template img_usage; + User * user; Datastore * ds; Image::DiskType ds_disk_type; + int umask; + + // ------------------------- Get user's umask ------------------------------ + + user = upool->get(att.uid, true); + + if ( user == 0 ) + { + failure_response(NO_EXISTS, + get_error(object_name(PoolObjectSQL::USER), att.uid), + att); + + return; + } + + umask = user->get_umask(); + + user->unlock(); + // ------------------------- Parse image template -------------------------- + tmpl = new ImageTemplate; + rc = tmpl->parse_str_or_xml(str_tmpl, error_str); if ( rc != 0 ) @@ -447,6 +500,7 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params, att.gid, att.uname, att.gname, + umask, tmpl, ds_id, ds_name, @@ -481,18 +535,20 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params, /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -int TemplateAllocate::pool_allocate(xmlrpc_c::paramList const& _paramList, - Template * tmpl, - int& id, - string& error_str, - RequestAttributes& att) +int TemplateAllocate::pool_allocate( + xmlrpc_c::paramList const& paramList, + Template * tmpl, + int& id, + string& error_str, + RequestAttributes& att, + int umask) { VMTemplatePool * tpool = static_cast(pool); VirtualMachineTemplate * ttmpl=static_cast(tmpl); - return tpool->allocate(att.uid, att.gid, att.uname, att.gname, ttmpl, &id, - error_str); + return tpool->allocate(att.uid, att.gid, att.uname, att.gname, umask, ttmpl, + &id, error_str); } /* -------------------------------------------------------------------------- */ @@ -505,7 +561,8 @@ int HostAllocate::pool_allocate( string& error_str, RequestAttributes& att, int cluster_id, - const string& cluster_name) + const string& cluster_name, + int umask) { string host = xmlrpc_c::value_string(paramList.getString(1)); string im_mad = xmlrpc_c::value_string(paramList.getString(2)); @@ -522,11 +579,13 @@ int HostAllocate::pool_allocate( /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -int UserAllocate::pool_allocate(xmlrpc_c::paramList const& paramList, - Template * tmpl, - int& id, - string& error_str, - RequestAttributes& att) +int UserAllocate::pool_allocate( + xmlrpc_c::paramList const& paramList, + Template * tmpl, + int& id, + string& error_str, + RequestAttributes& att, + int umask) { string uname = xmlrpc_c::value_string(paramList.getString(1)); string passwd = xmlrpc_c::value_string(paramList.getString(2)); @@ -571,11 +630,13 @@ void UserAllocate::log_xmlrpc_param( /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -int GroupAllocate::pool_allocate(xmlrpc_c::paramList const& paramList, - Template * tmpl, - int& id, - string& error_str, - RequestAttributes& att) +int GroupAllocate::pool_allocate( + xmlrpc_c::paramList const& paramList, + Template * tmpl, + int& id, + string& error_str, + RequestAttributes& att, + int umask) { string gname = xmlrpc_c::value_string(paramList.getString(1)); @@ -594,24 +655,27 @@ int DatastoreAllocate::pool_allocate( string& error_str, RequestAttributes& att, int cluster_id, - const string& cluster_name) + const string& cluster_name, + int umask) { DatastorePool * dspool = static_cast(pool); DatastoreTemplate * ds_tmpl = static_cast(tmpl); - return dspool->allocate(att.uid, att.gid, att.uname, att.gname, + return dspool->allocate(att.uid, att.gid, att.uname, att.gname, umask, ds_tmpl, &id, cluster_id, cluster_name, error_str); } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -int ClusterAllocate::pool_allocate(xmlrpc_c::paramList const& paramList, - Template * tmpl, - int& id, - string& error_str, - RequestAttributes& att) +int ClusterAllocate::pool_allocate( + xmlrpc_c::paramList const& paramList, + Template * tmpl, + int& id, + string& error_str, + RequestAttributes& att, + int umask) { string name = xmlrpc_c::value_string(paramList.getString(1)); @@ -623,16 +687,18 @@ int ClusterAllocate::pool_allocate(xmlrpc_c::paramList const& paramList, /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -int DocumentAllocate::pool_allocate(xmlrpc_c::paramList const& paramList, - Template * tmpl, - int& id, - string& error_str, - RequestAttributes& att) +int DocumentAllocate::pool_allocate( + xmlrpc_c::paramList const& paramList, + Template * tmpl, + int& id, + string& error_str, + RequestAttributes& att, + int umask) { int type = xmlrpc_c::value_int(paramList.getInt(2)); DocumentPool * docpool = static_cast(pool); - return docpool->allocate(att.uid, att.gid, att.uname, att.gname, type, - tmpl, &id, error_str); + return docpool->allocate(att.uid, att.gid, att.uname, att.gname, umask, + type, tmpl, &id, error_str); } diff --git a/src/rm/RequestManagerChmod.cc b/src/rm/RequestManagerChmod.cc index 105a7449bb..1e2c2de782 100644 --- a/src/rm/RequestManagerChmod.cc +++ b/src/rm/RequestManagerChmod.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -19,8 +19,6 @@ #include "NebulaLog.h" #include "Nebula.h" -#define TO_UPPER(S) transform(S.begin(),S.end(),S.begin(),(int(*)(int))toupper) - /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -95,14 +93,12 @@ void RequestManagerChmod::request_execute(xmlrpc_c::paramList const& paramList, if ( other_u != -1 || other_m != -1 || other_a != -1 ) { - string enable_other; + bool enable_other; Nebula::instance().get_configuration_attribute( "ENABLE_OTHER_PERMISSIONS", enable_other); - TO_UPPER(enable_other); - - if ( enable_other != "YES" ) + if ( !enable_other ) { failure_response(AUTHORIZATION, "Management of 'other' permissions is disabled in oned.conf", @@ -130,13 +126,13 @@ void RequestManagerChmod::request_execute(xmlrpc_c::paramList const& paramList, object = pool->get(oid,true); - if ( object == 0 ) - { + if ( object == 0 ) + { failure_response(NO_EXISTS, get_error(object_name(auth_object),oid), att); return; - } + } int rc = object->set_permissions(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a, error_str); diff --git a/src/rm/RequestManagerChown.cc b/src/rm/RequestManagerChown.cc index a7b0afa6a5..a542c231dd 100644 --- a/src/rm/RequestManagerChown.cc +++ b/src/rm/RequestManagerChown.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/rm/RequestManagerClone.cc b/src/rm/RequestManagerClone.cc index 12eeebabcb..02619348fb 100644 --- a/src/rm/RequestManagerClone.cc +++ b/src/rm/RequestManagerClone.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -28,15 +28,33 @@ void RequestManagerClone::request_execute( int source_id = xmlrpc_c::value_int(paramList.getInt(1)); string name = xmlrpc_c::value_string(paramList.getString(2)); - int rc, new_id; + int rc, new_id, umask; PoolObjectAuth perms; Template * tmpl; PoolObjectSQL * source_obj; + User * user; + + UserPool * upool = Nebula::instance().get_upool(); string error_str; + user = upool->get(att.uid, true); + + if ( user == 0 ) + { + failure_response(NO_EXISTS, + get_error(object_name(PoolObjectSQL::USER), att.uid), + att); + + return; + } + + umask = user->get_umask(); + + user->unlock(); + source_obj = pool->get(source_id, true); if ( source_obj == 0 ) @@ -80,7 +98,7 @@ void RequestManagerClone::request_execute( } } - rc = pool_allocate(source_id, tmpl, new_id, error_str, att); + rc = pool_allocate(source_id, tmpl, new_id, error_str, att, umask); if ( rc < 0 ) { diff --git a/src/rm/RequestManagerCluster.cc b/src/rm/RequestManagerCluster.cc index 73bcd3da75..876b286915 100644 --- a/src/rm/RequestManagerCluster.cc +++ b/src/rm/RequestManagerCluster.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -45,6 +45,8 @@ void RequestManagerCluster::add_generic( int old_cluster_id; string old_cluster_name; + Datastore::DatastoreType ds_type; + if ( cluster_id != ClusterPool::NONE_CLUSTER_ID ) { rc = get_info(clpool, cluster_id, PoolObjectSQL::CLUSTER, att, c_perms, cluster_name); @@ -102,6 +104,8 @@ void RequestManagerCluster::add_generic( old_cluster_id = cluster_obj->get_cluster_id(); old_cluster_name = cluster_obj->get_cluster_name(); + ds_type = get_ds_type(object); + if ( old_cluster_id == cluster_id ) { object->unlock(); @@ -141,7 +145,7 @@ void RequestManagerCluster::add_generic( return; } - if ( add_object(cluster, object_id, err_msg) < 0 ) + if ( add_object(cluster, object_id, ds_type, err_msg) < 0 ) { cluster->unlock(); @@ -149,6 +153,18 @@ void RequestManagerCluster::add_generic( request_error("Cannot add object to cluster", err_msg), att); + // Rollback + get(object_id, true, &object, &cluster_obj); + + if ( object != 0 ) + { + cluster_obj->set_cluster(old_cluster_id, old_cluster_name); + + pool->update(object); + + object->unlock(); + } + return; } diff --git a/src/rm/RequestManagerDelete.cc b/src/rm/RequestManagerDelete.cc index 7ba88bae47..d0295a9d38 100644 --- a/src/rm/RequestManagerDelete.cc +++ b/src/rm/RequestManagerDelete.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -210,6 +210,21 @@ int GroupDelete::drop(int oid, PoolObjectSQL * object, string& error_msg) /* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */ +int ClusterDelete::drop(int oid, PoolObjectSQL * object, string& error_msg) +{ + int rc = RequestManagerDelete::drop(oid, object, error_msg); + + if ( rc == 0 ) + { + aclm->del_cid_rules(oid); + } + + return rc; +} + +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + int UserDelete::drop(int oid, PoolObjectSQL * object, string& error_msg) { User * user = static_cast(object); diff --git a/src/rm/RequestManagerGroup.cc b/src/rm/RequestManagerGroup.cc index 84c62612ea..ee50c5a27b 100644 --- a/src/rm/RequestManagerGroup.cc +++ b/src/rm/RequestManagerGroup.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/rm/RequestManagerHost.cc b/src/rm/RequestManagerHost.cc index e59a6b3dcf..6c4d6576f4 100644 --- a/src/rm/RequestManagerHost.cc +++ b/src/rm/RequestManagerHost.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/rm/RequestManagerImage.cc b/src/rm/RequestManagerImage.cc index 6b0722c0c1..86bb1db118 100644 --- a/src/rm/RequestManagerImage.cc +++ b/src/rm/RequestManagerImage.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -229,7 +229,7 @@ void ImageClone::request_execute( int clone_id = xmlrpc_c::value_int(paramList.getInt(1)); string name = xmlrpc_c::value_string(paramList.getString(2)); - int rc, new_id, ds_id, size; + int rc, new_id, ds_id, size, umask; string error_str, ds_name, ds_data; Image::DiskType disk_type; @@ -239,11 +239,30 @@ void ImageClone::request_execute( Template img_usage; Image * img; Datastore * ds; + User * user; Nebula& nd = Nebula::instance(); DatastorePool * dspool = nd.get_dspool(); ImagePool * ipool = static_cast(pool); + UserPool * upool = nd.get_upool(); + + // ------------------------- Get user's umask ------------------------------ + + user = upool->get(att.uid, true); + + if ( user == 0 ) + { + failure_response(NO_EXISTS, + get_error(object_name(PoolObjectSQL::USER), att.uid), + att); + + return; + } + + umask = user->get_umask(); + + user->unlock(); // ------------------------- Get source Image info ------------------------- @@ -360,6 +379,7 @@ void ImageClone::request_execute( att.gid, att.uname, att.gname, + umask, tmpl, ds_id, ds_name, diff --git a/src/rm/RequestManagerInfo.cc b/src/rm/RequestManagerInfo.cc index 4051cb5ee1..047f5d0a35 100644 --- a/src/rm/RequestManagerInfo.cc +++ b/src/rm/RequestManagerInfo.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/rm/RequestManagerPoolInfoFilter.cc b/src/rm/RequestManagerPoolInfoFilter.cc index 0251c6200c..9ad3e0cc6c 100644 --- a/src/rm/RequestManagerPoolInfoFilter.cc +++ b/src/rm/RequestManagerPoolInfoFilter.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/rm/RequestManagerRename.cc b/src/rm/RequestManagerRename.cc new file mode 100644 index 0000000000..bd6b43c6d5 --- /dev/null +++ b/src/rm/RequestManagerRename.cc @@ -0,0 +1,113 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ +/* */ +/* 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 "RequestManagerRename.h" +#include "PoolObjectSQL.h" + +#include "NebulaLog.h" +#include "Nebula.h" + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void RequestManagerRename::request_execute(xmlrpc_c::paramList const& paramList, + RequestAttributes& att) +{ + int oid = xmlrpc_c::value_int(paramList.getInt(1)); + string new_name = xmlrpc_c::value_string(paramList.getString(2)); + + int rc; + string old_name; + + PoolObjectAuth operms; + PoolObjectSQL * object; + + rc = get_info(pool, oid, auth_object, att, operms, old_name); + + if ( rc == -1 ) + { + return; + } + + if (old_name == new_name) + { + success_response(oid, att); + return; + } + + // ------------- Set authorization request for non-oneadmin's -------------- + + if ( att.uid != 0 ) + { + AuthRequest ar(att.uid, att.gid); + + ar.add_auth(auth_op, operms); // MANAGE OBJECT + + if (UserPool::authorize(ar) == -1) + { + failure_response(AUTHORIZATION, + authorization_error(ar.message, att), + att); + + return; + } + } + + // --------------- Check name uniqueness ----------------------------------- + + object = get(new_name, operms.uid, true); + + if ( object != 0 ) + { + ostringstream oss; + int id = object->get_oid(); + + object->unlock(); + + oss << PoolObjectSQL::type_to_str(auth_object) + << " cannot be renamed to " << new_name + << " because it collides with " + << PoolObjectSQL::type_to_str(auth_object) << " " + << id; + + failure_response(INTERNAL, request_error(oss.str(), ""), att); + return; + } + + // --------------- Update the object --------------------------------------- + + object = pool->get(oid, true); + + if ( object == 0 ) + { + failure_response(NO_EXISTS, + get_error(object_name(auth_object), oid), + att); + } + + object->set_name(new_name); + + pool->update(object); + + object->unlock(); + + pool->update_cache_index(old_name, operms.uid, new_name, operms.uid); + + success_response(oid, att); + + return; +} + diff --git a/src/rm/RequestManagerSystem.cc b/src/rm/RequestManagerSystem.cc index f020f4e84a..0c0db004c7 100644 --- a/src/rm/RequestManagerSystem.cc +++ b/src/rm/RequestManagerSystem.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/rm/RequestManagerUpdateTemplate.cc b/src/rm/RequestManagerUpdateTemplate.cc index 1c8988ccbb..b3d7523d88 100644 --- a/src/rm/RequestManagerUpdateTemplate.cc +++ b/src/rm/RequestManagerUpdateTemplate.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/rm/RequestManagerUser.cc b/src/rm/RequestManagerUser.cc index 9e9da50eaa..c026c398c9 100644 --- a/src/rm/RequestManagerUser.cc +++ b/src/rm/RequestManagerUser.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -15,6 +15,7 @@ /* -------------------------------------------------------------------------- */ #include "RequestManagerUser.h" +#include "NebulaUtil.h" using namespace std; @@ -47,14 +48,14 @@ void RequestManagerUser:: failure_response(ACTION, request_error(error_str,""), att); return; } - + success_response(id, att); } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -int UserChangePassword::user_action(int user_id, +int UserChangePassword::user_action(int user_id, xmlrpc_c::paramList const& paramList, string& error_str) { @@ -71,7 +72,7 @@ int UserChangePassword::user_action(int user_id, if (user->get_auth_driver() == UserPool::CORE_AUTH) { - new_pass = SSLTools::sha1_digest(new_pass); + new_pass = one_util::sha1_digest(new_pass); } int rc = user->set_password(new_pass, error_str); @@ -128,7 +129,7 @@ int UserChangeAuth::user_action(int user_id, { if ( new_auth == UserPool::CORE_AUTH) { - new_pass = SSLTools::sha1_digest(new_pass); + new_pass = one_util::sha1_digest(new_pass); } // The password may be invalid, try to change it first @@ -170,7 +171,7 @@ void UserChangeAuth::log_xmlrpc_param( /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -int UserSetQuota::user_action(int user_id, +int UserSetQuota::user_action(int user_id, xmlrpc_c::paramList const& paramList, string& error_str) { diff --git a/src/rm/RequestManagerVMTemplate.cc b/src/rm/RequestManagerVMTemplate.cc index 043230638d..5f0952f115 100644 --- a/src/rm/RequestManagerVMTemplate.cc +++ b/src/rm/RequestManagerVMTemplate.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -26,21 +26,63 @@ void VMTemplateInstantiate::request_execute(xmlrpc_c::paramList const& paramList { int id = xmlrpc_c::value_int(paramList.getInt(1)); string name = xmlrpc_c::value_string(paramList.getString(2)); + bool on_hold = false; //Optional XML-RPC argument + string str_uattrs; //Optional XML-RPC argument - int rc, vid; + int rc; + int vid; + int umask; + + ostringstream sid; PoolObjectAuth perms; Nebula& nd = Nebula::instance(); - VirtualMachinePool* vmpool = nd.get_vmpool(); - VMTemplatePool * tpool = static_cast(pool); + + VirtualMachinePool* vmpool = nd.get_vmpool(); + VMTemplatePool * tpool = static_cast(pool); + UserPool * upool = nd.get_upool(); VirtualMachineTemplate * tmpl; + VirtualMachineTemplate uattrs; VMTemplate * rtmpl; + User * user; string error_str; string aname; + string tmpl_name; + + if ( paramList.size() > 3 ) + { + on_hold = xmlrpc_c::value_boolean(paramList.getBoolean(3)); + + str_uattrs = xmlrpc_c::value_string(paramList.getString(4)); + } + + /* ---------------------------------------------------------------------- */ + /* Get user's umask */ + /* ---------------------------------------------------------------------- */ + + user = upool->get(att.uid, true); + + if ( user == 0 ) + { + failure_response(NO_EXISTS, + get_error(object_name(PoolObjectSQL::USER), att.uid), + att); + + return; + } + + umask = user->get_umask(); + + user->unlock(); + + /* ---------------------------------------------------------------------- */ + /* Get, check and clone the template */ + /* ---------------------------------------------------------------------- */ + rtmpl = tpool->get(id,true); if ( rtmpl == 0 ) @@ -52,16 +94,15 @@ void VMTemplateInstantiate::request_execute(xmlrpc_c::paramList const& paramList return; } - tmpl = rtmpl->clone_template(); + tmpl_name = rtmpl->get_name(); + tmpl = rtmpl->clone_template(); rtmpl->get_permissions(perms); rtmpl->unlock(); - // Check template for restricted attributes, but only if the Template owner - // is not oneadmin - - if ( perms.uid != UserPool::ONEADMIN_ID && perms.gid != GroupPool::ONEADMIN_ID ) + // Check template for restricted attributes, only if owner is not oneadmin + if (perms.uid!=UserPool::ONEADMIN_ID && perms.gid!=GroupPool::ONEADMIN_ID) { if (tmpl->check(aname)) { @@ -78,8 +119,61 @@ void VMTemplateInstantiate::request_execute(xmlrpc_c::paramList const& paramList } } + // Parse & merge user attributes (check if the request user is not oneadmin) + if (!str_uattrs.empty()) + { + rc = uattrs.parse_str_or_xml(str_uattrs, error_str); + + if ( rc != 0 ) + { + failure_response(INTERNAL, error_str, att); + delete tmpl; + return; + } + + if (att.uid!=UserPool::ONEADMIN_ID && att.gid!=GroupPool::ONEADMIN_ID) + { + if (uattrs.check(aname)) + { + ostringstream oss; + + oss << "User Template includes a restricted attribute "<< aname; + + failure_response(AUTHORIZATION, + authorization_error(oss.str(), att), + att); + + delete tmpl; + return; + } + } + + rc = tmpl->merge(&uattrs, error_str); + + if ( rc != 0 ) + { + failure_response(INTERNAL, error_str, att); + delete tmpl; + return; + } + } + + /* ---------------------------------------------------------------------- */ + /* Store the template attributes in the VM */ + /* ---------------------------------------------------------------------- */ tmpl->erase("NAME"); - tmpl->set(new SingleAttribute("NAME",name)); + tmpl->erase("TEMPLATE_NAME"); + tmpl->erase("TEMPLATE_ID"); + + sid << id; + + tmpl->set(new SingleAttribute("TEMPLATE_NAME", tmpl_name)); + tmpl->set(new SingleAttribute("TEMPLATE_ID", sid.str())); + + if (!name.empty()) + { + tmpl->set(new SingleAttribute("NAME",name)); + } if ( att.uid != 0 ) { @@ -87,6 +181,15 @@ void VMTemplateInstantiate::request_execute(xmlrpc_c::paramList const& paramList ar.add_auth(auth_op, perms); //USE TEMPLATE + if (!str_uattrs.empty()) + { + string tmpl_str; + + tmpl->to_xml(tmpl_str); + + ar.add_create_auth(auth_object, tmpl_str); // CREATE TEMPLATE + } + VirtualMachine::set_auth_request(att.uid, ar, tmpl); if (UserPool::authorize(ar) == -1) @@ -108,8 +211,8 @@ void VMTemplateInstantiate::request_execute(xmlrpc_c::paramList const& paramList Template tmpl_back(*tmpl); - rc = vmpool->allocate(att.uid, att.gid, att.uname, att.gname, tmpl, &vid, - error_str, false); + rc = vmpool->allocate(att.uid, att.gid, att.uname, att.gname, umask, + tmpl, &vid, error_str, on_hold); if ( rc < 0 ) { @@ -118,10 +221,10 @@ void VMTemplateInstantiate::request_execute(xmlrpc_c::paramList const& paramList att); quota_rollback(&tmpl_back, Quotas::VIRTUALMACHINE, att); - + return; } - + success_response(vid, att); } diff --git a/src/rm/RequestManagerVirtualMachine.cc b/src/rm/RequestManagerVirtualMachine.cc index 40088e7c3a..ccab67fdee 100644 --- a/src/rm/RequestManagerVirtualMachine.cc +++ b/src/rm/RequestManagerVirtualMachine.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -17,6 +17,7 @@ #include "RequestManagerVirtualMachine.h" #include "PoolObjectAuth.h" #include "Nebula.h" +#include "Quotas.h" /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -200,6 +201,46 @@ int RequestManagerVirtualMachine::get_host_information(int hid, /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +bool RequestManagerVirtualMachine::check_host(int hid, + int cpu, + int mem, + int disk, + string& error) +{ + Nebula& nd = Nebula::instance(); + HostPool * hpool = nd.get_hpool(); + + Host * host; + bool test; + + host = hpool->get(hid, true); + + if (host == 0) + { + error = "Host no longer exists"; + return false; + } + + test = host->test_capacity(cpu, mem, disk); + + if (!test) + { + ostringstream oss; + + oss << object_name(PoolObjectSQL::HOST) + << " " << hid << " does not have enough capacity."; + + error = oss.str(); + } + + host->unlock(); + + return test; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + VirtualMachine * RequestManagerVirtualMachine::get_vm(int id, RequestAttributes& att) { @@ -387,31 +428,43 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList, string ds_location; int ds_id; - int id = xmlrpc_c::value_int(paramList.getInt(1)); - int hid = xmlrpc_c::value_int(paramList.getInt(2)); + int id = xmlrpc_c::value_int(paramList.getInt(1)); + int hid = xmlrpc_c::value_int(paramList.getInt(2)); + bool enforce = false; bool auth = false; - if (get_host_information( - hid, hostname, vmm_mad, vnm_mad, tm_mad, ds_location, ds_id, att, - host_perms) != 0) + if ( paramList.size() > 3 ) + { + enforce = xmlrpc_c::value_boolean(paramList.getBoolean(3)); + } + + if (get_host_information(hid, + hostname, + vmm_mad, + vnm_mad, + tm_mad, + ds_location, + ds_id, + att, + host_perms) != 0) { return; } auth = vm_authorization(id, 0, 0, att, &host_perms, 0, auth_op); - if ( auth == false ) + if (auth == false) { return; } - if ( (vm = get_vm(id, att)) == 0 ) + if ((vm = get_vm(id, att)) == 0) { return; } - if ( vm->get_state() != VirtualMachine::PENDING ) + if (vm->get_state() != VirtualMachine::PENDING) { failure_response(ACTION, request_error("Wrong state to perform action",""), @@ -421,8 +474,36 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList, return; } - if ( add_history( - vm,hid,hostname,vmm_mad,vnm_mad,tm_mad,ds_location,ds_id,att) != 0) + if (enforce) + { + int cpu, mem, disk; + string error; + + vm->get_requirements(cpu, mem, disk); + + vm->unlock(); + + if (check_host(hid, cpu, mem, disk, error) == false) + { + failure_response(ACTION, request_error(error,""), att); + return; + } + + if ((vm = get_vm(id, att)) == 0) + { + return; + } + } + + if (add_history(vm, + hid, + hostname, + vmm_mad, + vnm_mad, + tm_mad, + ds_location, + ds_id, + att) != 0) { vm->unlock(); return; @@ -459,27 +540,39 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList string aux_st; int current_hid; - int id = xmlrpc_c::value_int(paramList.getInt(1)); - int hid = xmlrpc_c::value_int(paramList.getInt(2)); - bool live = xmlrpc_c::value_boolean(paramList.getBoolean(3)); + int id = xmlrpc_c::value_int(paramList.getInt(1)); + int hid = xmlrpc_c::value_int(paramList.getInt(2)); + bool live = xmlrpc_c::value_boolean(paramList.getBoolean(3)); + bool enforce = false; + + if ( paramList.size() > 4 ) + { + enforce = xmlrpc_c::value_boolean(paramList.getBoolean(4)); + } bool auth = false; - if (get_host_information( - hid, hostname, vmm_mad, vnm_mad, tm_mad, ds_location, ds_id, att, - host_perms) != 0) + if (get_host_information(hid, + hostname, + vmm_mad, + vnm_mad, + tm_mad, + ds_location, + ds_id, + att, + host_perms) != 0) { return; } auth = vm_authorization(id, 0, 0, att, &host_perms, 0, auth_op); - if ( auth == false ) + if (auth == false) { return; } - if ( (vm = get_vm(id, att)) == 0 ) + if ((vm = get_vm(id, att)) == 0) { return; } @@ -498,11 +591,35 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList current_hid = vm->get_hid(); - vm->unlock(); + if (enforce) + { + int cpu, mem, disk; + string error; - if (get_host_information( - current_hid, aux_st, aux_st, aux_st, aux_st, aux_st, current_ds_id, - att, aux_perms) != 0) + vm->get_requirements(cpu, mem, disk); + + vm->unlock(); + + if (check_host(hid, cpu, mem, disk, error) == false) + { + failure_response(ACTION, request_error(error,""), att); + return; + } + } + else + { + vm->unlock(); + } + + if (get_host_information(current_hid, + aux_st, + aux_st, + aux_st, + aux_st, + aux_st, + current_ds_id, + att, + aux_perms) != 0) { return; } @@ -529,14 +646,21 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList return; } - if ( add_history(vm, hid, hostname, vmm_mad, vnm_mad, tm_mad, ds_location, - ds_id, att) != 0) + if (add_history(vm, + hid, + hostname, + vmm_mad, + vnm_mad, + tm_mad, + ds_location, + ds_id, + att) != 0) { vm->unlock(); return; } - if ( live == true ) + if (live == true) { dm->live_migrate(vm); } @@ -558,8 +682,9 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis { Nebula& nd = Nebula::instance(); - ImagePool * ipool = nd.get_ipool(); - DatastorePool * dspool = nd.get_dspool(); + ImagePool * ipool = nd.get_ipool(); + DatastorePool * dspool = nd.get_dspool(); + UserPool * upool = nd.get_upool(); int id = xmlrpc_c::value_int(paramList.getInt(1)); int disk_id = xmlrpc_c::value_int(paramList.getInt(2)); @@ -572,8 +697,10 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis Image * img; Datastore * ds; + User * user; Image::DiskType ds_disk_type; + int umask; int rc; string error_str; @@ -607,6 +734,25 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis return; } + // ------------------------------------------------------------------------- + // Get user's umask + // ------------------------------------------------------------------------- + + user = upool->get(att.uid, true); + + if ( user == 0 ) + { + failure_response(NO_EXISTS, + get_error(object_name(PoolObjectSQL::USER), att.uid), + att); + + return; + } + + umask = user->get_umask(); + + user->unlock(); + // ------------------------------------------------------------------------- // Get the data of the Image to be saved // ------------------------------------------------------------------------- @@ -736,6 +882,7 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis att.gid, att.uname, att.gname, + umask, itemplate, ds_id, ds_name, @@ -911,6 +1058,459 @@ void VirtualMachineDetach::request_execute(xmlrpc_c::paramList const& paramList, /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +void VirtualMachineResize::request_execute(xmlrpc_c::paramList const& paramList, + RequestAttributes& att) +{ + int id = xmlrpc_c::value_int(paramList.getInt(1)); + float ncpu = xmlrpc_c::value_double(paramList.getDouble(2)); + int nmemory = xmlrpc_c::value_int(paramList.getInt(3)); + int nvcpu = xmlrpc_c::value_int(paramList.getInt(4)); + bool enforce_param = xmlrpc_c::value_boolean(paramList.getBoolean(5)); + + float ocpu, dcpu; + int omemory, dmemory; + int ovcpu; + + Nebula& nd = Nebula::instance(); + UserPool* upool = nd.get_upool(); + GroupPool* gpool = nd.get_gpool(); + Quotas dquotas = nd.get_default_user_quota(); + HostPool * hpool = nd.get_hpool(); + + Host * host; + + Template deltas; + string error_str; + bool rc; + int ret; + int hid = -1; + + PoolObjectAuth vm_perms; + + VirtualMachinePool * vmpool = static_cast(pool); + VirtualMachine * vm; + + bool enforce = true; + + if (att.uid == UserPool::ONEADMIN_ID || att.gid == GroupPool::ONEADMIN_ID) + { + enforce = enforce_param; + } + + /* ---------------------------------------------------------------------- */ + /* Authorize the operation */ + /* ---------------------------------------------------------------------- */ + + if ( vm_authorization(id, 0, 0, att, 0, 0, auth_op) == false ) + { + return; + } + + /* ---------------------------------------------------------------------- */ + /* Get the resize values */ + /* ---------------------------------------------------------------------- */ + + vm = vmpool->get(id, true); + + if (vm == 0) + { + failure_response(NO_EXISTS, + get_error(object_name(PoolObjectSQL::VM),id), + att); + return; + } + + vm->get_permissions(vm_perms); + + vm->get_template_attribute("MEMORY", omemory); + vm->get_template_attribute("CPU", ocpu); + vm->get_template_attribute("VCPU", ovcpu); + + if (nmemory == 0) + { + nmemory = omemory; + } + + if (ncpu == 0) + { + ncpu = ocpu; + } + + if (nvcpu == 0) + { + nvcpu = ovcpu; + } + + dcpu = ncpu - ocpu; + dmemory = nmemory - omemory; + + deltas.add("MEMORY", dmemory); + deltas.add("CPU", dcpu); + + switch (vm->get_state()) + { + case VirtualMachine::POWEROFF: //Only check host capacity in POWEROFF + if (vm->hasHistory() == true) + { + hid = vm->get_hid(); + } + break; + + case VirtualMachine::INIT: + case VirtualMachine::PENDING: + case VirtualMachine::HOLD: + case VirtualMachine::FAILED: + break; + + case VirtualMachine::STOPPED: + case VirtualMachine::DONE: + case VirtualMachine::SUSPENDED: + case VirtualMachine::ACTIVE: + failure_response(ACTION, + request_error("Wrong state to perform action",""), + att); + + vm->unlock(); + return; + } + + ret = vm->check_resize(ncpu, nmemory, nvcpu, error_str); + + vm->unlock(); + + if (ret != 0) + { + failure_response(INTERNAL, + request_error("Could resize the VM", error_str), + att); + return; + } + + /* ---------------------------------------------------------------------- */ + /* Check quotas */ + /* ---------------------------------------------------------------------- */ + + if (vm_perms.uid != UserPool::ONEADMIN_ID) + { + User * user = upool->get(vm_perms.uid, true); + + if ( user != 0 ) + { + rc = user->quota.quota_update(Quotas::VM, &deltas, dquotas, error_str); + + if (rc == false) + { + ostringstream oss; + + oss << object_name(PoolObjectSQL::USER) + << " [" << vm_perms.uid << "] " + << error_str; + + failure_response(AUTHORIZATION, + request_error(oss.str(), ""), + att); + + user->unlock(); + + return; + } + + upool->update(user); + + user->unlock(); + } + } + + if (vm_perms.gid != GroupPool::ONEADMIN_ID) + { + Group * group = gpool->get(vm_perms.gid, true); + + if ( group != 0 ) + { + rc = group->quota.quota_update(Quotas::VM, &deltas, dquotas, error_str); + + if (rc == false) + { + ostringstream oss; + RequestAttributes att_tmp(vm_perms.uid, -1, att); + + oss << object_name(PoolObjectSQL::GROUP) + << " [" << vm_perms.gid << "] " + << error_str; + + failure_response(AUTHORIZATION, + request_error(oss.str(), ""), + att); + + group->unlock(); + + quota_rollback(&deltas, Quotas::VM, att_tmp); + + return; + } + + gpool->update(group); + + group->unlock(); + } + } + + /* ---------------------------------------------------------------------- */ + /* Check & update host capacity */ + /* ---------------------------------------------------------------------- */ + + if (hid != -1) + { + int dcpu_host = (int) (dcpu * 100);//now in 100% + int dmem_host = dmemory * 1024; //now in Kilobytes + + host = hpool->get(hid, true); + + if (host == 0) + { + failure_response(NO_EXISTS, + get_error(object_name(PoolObjectSQL::HOST),hid), + att); + + quota_rollback(&deltas, Quotas::VM, att); + + return; + } + + if ( enforce && host->test_capacity(dcpu_host, dmem_host, 0) == false) + { + ostringstream oss; + + oss << object_name(PoolObjectSQL::HOST) + << " " << hid << " does not have enough capacity."; + + failure_response(ACTION, request_error(oss.str(),""), att); + + host->unlock(); + + quota_rollback(&deltas, Quotas::VM, att); + + return; + } + + host->update_capacity(dcpu_host, dmem_host, 0); + + hpool->update(host); + + host->unlock(); + } + + /* ---------------------------------------------------------------------- */ + /* Resize the VM */ + /* ---------------------------------------------------------------------- */ + + vm = vmpool->get(id, true); + + if (vm == 0) + { + failure_response(NO_EXISTS, + get_error(object_name(PoolObjectSQL::VM),id), + att); + + quota_rollback(&deltas, Quotas::VM, att); + + if (hid != -1) + { + host = hpool->get(hid, true); + + if (host != 0) + { + host->update_capacity(-dcpu, -dmemory, 0); + hpool->update(host); + + host->unlock(); + } + } + return; + } + + //Check again state as the VM may transit to active (e.g. scheduled) + switch (vm->get_state()) + { + case VirtualMachine::INIT: + case VirtualMachine::PENDING: + case VirtualMachine::HOLD: + case VirtualMachine::FAILED: + case VirtualMachine::POWEROFF: + ret = vm->resize(ncpu, nmemory, nvcpu, error_str); + + if (ret != 0) + { + vm->unlock(); + + failure_response(INTERNAL, + request_error("Could not resize the VM", error_str), + att); + return; + } + + vmpool->update(vm); + break; + + case VirtualMachine::STOPPED: + case VirtualMachine::DONE: + case VirtualMachine::SUSPENDED: + case VirtualMachine::ACTIVE: + failure_response(ACTION, + request_error("Wrong state to perform action",""), + att); + + vm->unlock(); + + quota_rollback(&deltas, Quotas::VM, att); + + if (hid != -1) + { + host = hpool->get(hid, true); + + if (host != 0) + { + host->update_capacity(ocpu - ncpu, omemory - nmemory, 0); + hpool->update(host); + + host->unlock(); + } + } + return; + } + + vm->unlock(); + + success_response(id, att); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void VirtualMachineSnapshotCreate::request_execute( + xmlrpc_c::paramList const& paramList, + RequestAttributes& att) +{ + Nebula& nd = Nebula::instance(); + DispatchManager * dm = nd.get_dm(); + + int rc; + int snap_id; + string error_str; + + int id = xmlrpc_c::value_int(paramList.getInt(1)); + string name = xmlrpc_c::value_string(paramList.getString(2)); + + // ------------------------------------------------------------------------- + // Authorize the operation + // ------------------------------------------------------------------------- + + if ( vm_authorization(id, 0, 0, att, 0, 0, auth_op) == false ) + { + return; + } + + rc = dm->snapshot_create(id, name, snap_id, error_str); + + if ( rc != 0 ) + { + failure_response(ACTION, + request_error(error_str, ""), + att); + } + else + { + success_response(snap_id, att); + } + + return; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void VirtualMachineSnapshotRevert::request_execute( + xmlrpc_c::paramList const& paramList, + RequestAttributes& att) +{ + Nebula& nd = Nebula::instance(); + DispatchManager * dm = nd.get_dm(); + + int rc; + string error_str; + + int id = xmlrpc_c::value_int(paramList.getInt(1)); + int snap_id = xmlrpc_c::value_int(paramList.getInt(2)); + + // ------------------------------------------------------------------------- + // Authorize the operation + // ------------------------------------------------------------------------- + + if ( vm_authorization(id, 0, 0, att, 0, 0, auth_op) == false ) + { + return; + } + + rc = dm->snapshot_revert(id, snap_id, error_str); + + if ( rc != 0 ) + { + failure_response(ACTION, + request_error(error_str, ""), + att); + } + else + { + success_response(id, att); + } + + return; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void VirtualMachineSnapshotDelete::request_execute( + xmlrpc_c::paramList const& paramList, + RequestAttributes& att) +{ + Nebula& nd = Nebula::instance(); + DispatchManager * dm = nd.get_dm(); + + int rc; + string error_str; + + int id = xmlrpc_c::value_int(paramList.getInt(1)); + int snap_id = xmlrpc_c::value_int(paramList.getInt(2)); + + // ------------------------------------------------------------------------- + // Authorize the operation + // ------------------------------------------------------------------------- + + if ( vm_authorization(id, 0, 0, att, 0, 0, auth_op) == false ) + { + return; + } + + rc = dm->snapshot_delete(id, snap_id, error_str); + + if ( rc != 0 ) + { + failure_response(ACTION, + request_error(error_str, ""), + att); + } + else + { + success_response(id, att); + } + + return; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + void VirtualMachineAttachNic::request_execute( xmlrpc_c::paramList const& paramList, RequestAttributes& att) diff --git a/src/rm/RequestManagerVirtualNetwork.cc b/src/rm/RequestManagerVirtualNetwork.cc index 33ce01e512..478cf2c6dd 100644 --- a/src/rm/RequestManagerVirtualNetwork.cc +++ b/src/rm/RequestManagerVirtualNetwork.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/rm/SConstruct b/src/rm/SConstruct index 4420593001..806111c126 100644 --- a/src/rm/SConstruct +++ b/src/rm/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/rm # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -41,7 +41,8 @@ source_files=[ 'RequestManagerChmod.cc', 'RequestManagerCluster.cc', 'RequestManagerClone.cc', - 'RequestManagerSystem.cc' + 'RequestManagerSystem.cc', + 'RequestManagerRename.cc' ] # Build library diff --git a/src/scheduler/SConstruct b/src/scheduler/SConstruct index 30eab8a30c..f8c70e8ba3 100644 --- a/src/scheduler/SConstruct +++ b/src/scheduler/SConstruct @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/scheduler/etc/sched.conf b/src/scheduler/etc/sched.conf index 543a274078..d5be6c0d4b 100644 --- a/src/scheduler/etc/sched.conf +++ b/src/scheduler/etc/sched.conf @@ -9,31 +9,37 @@ # # SCHED_INTERVAL: Seconds between two scheduling actions # -# MAX_VM: Maximum number of Virtual Machines scheduled in each scheduling +# MAX_VM: Maximum number of Virtual Machines scheduled in each scheduling # action # # MAX_DISPATCH: Maximum number of Virtual Machines actually dispatched to a # host in each scheduling action # -# MAX_HOST: Maximum number of Virtual Machines dispatched to a given host in +# MAX_HOST: Maximum number of Virtual Machines dispatched to a given host in # each scheduling action # # LIVE_RESCHEDS: Perform live (1) or cold migrations (0) when rescheduling a VM # -# HYPERVISOR_MEM: Fraction of total MEMORY reserved for the hypervisor. +# HYPERVISOR_MEM: Fraction of total MEMORY reserved for the hypervisor. # E.g. 0.1 means that only 90% of the total MEMORY will be used # # DEFAULT_SCHED: Definition of the default scheduling algorithm -# - policy: -# 0 = Packing. Heuristic that minimizes the number of hosts in use by +# - policy: +# 0 = Packing. Heuristic that minimizes the number of hosts in use by # packing the VMs in the hosts to reduce VM fragmentation -# 1 = Striping. Heuristic that tries to maximize resources available for +# 1 = Striping. Heuristic that tries to maximize resources available for # the VMs by spreading the VMs in the hosts # 2 = Load-aware. Heuristic that tries to maximize resources available for # the VMs by usingthose nodes with less load -# 3 = Custom. +# 3 = Custom. # - rank: Custom arithmetic exprission to rank suitable hosts based in their # attributes +# +# LOG: Configuration for the logging system +# - system: defines the logging system: +# file to log in the sched.log file +# syslog to use the syslog facilities +# - debug_level: 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBU #******************************************************************************* ONED_PORT = 2633 @@ -49,10 +55,15 @@ LIVE_RESCHEDS = 0 HYPERVISOR_MEM = 0.1 DEFAULT_SCHED = [ - policy = 1 + policy = 1 ] #DEFAULT_SCHED = [ -# policy = 3, +# policy = 3, # rank = "- (RUNNING_VMS * 50 + FREE_CPU)" #] + +LOG = [ + system = "file", + debug_level = 3 +] diff --git a/src/scheduler/include/AclXML.h b/src/scheduler/include/AclXML.h index 5ad46040f7..809fb7816c 100644 --- a/src/scheduler/include/AclXML.h +++ b/src/scheduler/include/AclXML.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/scheduler/include/Client.h b/src/scheduler/include/Client.h index 8b7516b69c..2a7ad2f632 100644 --- a/src/scheduler/include/Client.h +++ b/src/scheduler/include/Client.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/scheduler/include/ClusterPoolXML.h b/src/scheduler/include/ClusterPoolXML.h new file mode 100644 index 0000000000..31915c0d78 --- /dev/null +++ b/src/scheduler/include/ClusterPoolXML.h @@ -0,0 +1,56 @@ +/* -------------------------------------------------------------------------- */ +/* 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 CLUSTER_POOL_XML_H_ +#define CLUSTER_POOL_XML_H_ + +#include "PoolXML.h" +#include "ClusterXML.h" + +using namespace std; + +class ClusterPoolXML : public PoolXML +{ +public: + + ClusterPoolXML(Client* client):PoolXML(client) + {}; + + /** + * Gets an object from the pool + * @param oid the object unique identifier + * + * @return a pointer to the object, 0 in case of failure + */ + ClusterXML * get(int oid) const + { + return static_cast(PoolXML::get(oid)); + }; + +protected: + + int get_suitable_nodes(vector& content) + { + return get_nodes("/CLUSTER_POOL/CLUSTER", content); + }; + + void add_object(xmlNodePtr node); + + int load_info(xmlrpc_c::value &result); +}; + +#endif /* CLUSTER_POOL_XML_H_ */ diff --git a/src/scheduler/include/ClusterXML.h b/src/scheduler/include/ClusterXML.h new file mode 100644 index 0000000000..01ef1604f0 --- /dev/null +++ b/src/scheduler/include/ClusterXML.h @@ -0,0 +1,52 @@ +/* -------------------------------------------------------------------------- */ +/* 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 CLUSTER_XML_H_ +#define CLUSTER_XML_H_ + +#include "ObjectXML.h" + +using namespace std; + +class ClusterXML : public ObjectXML +{ +public: + ClusterXML(const string &xml_doc):ObjectXML(xml_doc) + { + init_attributes(); + }; + + ClusterXML(const xmlNodePtr node):ObjectXML(node) + { + init_attributes(); + }; + + int get_oid() const + { + return oid; + }; + +private: + int oid; + + void init_attributes() + { + oid = atoi(((*this)["/CLUSTER/ID"] )[0].c_str() ); + }; +}; + +#endif /* CLUSTER_XML_H_ */ diff --git a/src/scheduler/include/HostPoolXML.h b/src/scheduler/include/HostPoolXML.h index 78c1c308d8..8a8fceaf3a 100644 --- a/src/scheduler/include/HostPoolXML.h +++ b/src/scheduler/include/HostPoolXML.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -20,6 +20,7 @@ #include "PoolXML.h" #include "HostXML.h" +#include "ClusterPoolXML.h" using namespace std; @@ -45,6 +46,14 @@ public: return static_cast(PoolXML::get(oid)); }; + /** + * For each Host in a cluster, adds the cluster template as a new + * Host xml element + * + * @param clpool Cluster pool + */ + void merge_clusters(ClusterPoolXML * clpool); + protected: int get_suitable_nodes(vector& content) diff --git a/src/scheduler/include/HostXML.h b/src/scheduler/include/HostXML.h index a9171ac146..9576d925f0 100644 --- a/src/scheduler/include/HostXML.h +++ b/src/scheduler/include/HostXML.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -40,6 +40,11 @@ public: return oid; }; + int get_cid() const + { + return cluster_id; + }; + /** * Tests whether a new VM can be hosted by the host or not * @param cpu needed by the VM (percentage) @@ -82,6 +87,7 @@ public: private: int oid; + int cluster_id; // Host share values int disk_usage; /**< Disk allocated to VMs (in Mb). */ diff --git a/src/scheduler/include/PoolXML.h b/src/scheduler/include/PoolXML.h index 7698b7d57e..a25c96212c 100644 --- a/src/scheduler/include/PoolXML.h +++ b/src/scheduler/include/PoolXML.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/scheduler/include/RankPolicy.h b/src/scheduler/include/RankPolicy.h index a86c935111..ca2b2838ca 100644 --- a/src/scheduler/include/RankPolicy.h +++ b/src/scheduler/include/RankPolicy.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/scheduler/include/Scheduler.h b/src/scheduler/include/Scheduler.h index 54add04616..0059aad843 100644 --- a/src/scheduler/include/Scheduler.h +++ b/src/scheduler/include/Scheduler.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -19,6 +19,7 @@ #include "Log.h" #include "HostPoolXML.h" +#include "ClusterPoolXML.h" #include "VirtualMachinePoolXML.h" #include "SchedulerPolicy.h" #include "ActionManager.h" @@ -47,7 +48,9 @@ protected: Scheduler(): hpool(0), + clpool(0), vmpool(0), + vmapool(0), acls(0), timer(0), url(""), @@ -67,11 +70,21 @@ protected: delete hpool; } + if ( clpool != 0) + { + delete clpool; + } + if ( vmpool != 0) { delete vmpool; } + if ( vmapool != 0) + { + delete vmapool; + } + if ( acls != 0) { delete acls; @@ -87,10 +100,13 @@ protected: // Pools // --------------------------------------------------------------- - HostPoolXML * hpool; - VirtualMachinePoolXML * vmpool; + HostPoolXML * hpool; + ClusterPoolXML * clpool; - AclXML * acls; + VirtualMachinePoolXML * vmpool; + VirtualMachineActionsPoolXML* vmapool; + + AclXML * acls; // --------------------------------------------------------------- // Scheduler Policies @@ -116,8 +132,18 @@ protected: virtual int schedule(); + /** + * Retrieves the pools + * + * @return 0 on success + * -1 on error + * -2 if no VMs need to be scheduled + */ virtual int set_up_pools(); + + virtual int do_scheduled_actions(); + private: Scheduler(Scheduler const&){}; @@ -125,7 +151,6 @@ private: friend void * scheduler_action_loop(void *arg); - // --------------------------------------------------------------- // Scheduling Policies // --------------------------------------------------------------- diff --git a/src/scheduler/include/SchedulerPolicy.h b/src/scheduler/include/SchedulerPolicy.h index b62efb3149..a5c2d8c07f 100644 --- a/src/scheduler/include/SchedulerPolicy.h +++ b/src/scheduler/include/SchedulerPolicy.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/scheduler/include/SchedulerTemplate.h b/src/scheduler/include/SchedulerTemplate.h index e20462fde4..354b0683da 100644 --- a/src/scheduler/include/SchedulerTemplate.h +++ b/src/scheduler/include/SchedulerTemplate.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/scheduler/include/VirtualMachinePoolXML.h b/src/scheduler/include/VirtualMachinePoolXML.h index b2b97e169b..257f5b3dc2 100644 --- a/src/scheduler/include/VirtualMachinePoolXML.h +++ b/src/scheduler/include/VirtualMachinePoolXML.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -32,8 +32,15 @@ public: bool _live_resched): PoolXML(client, machines_limit), live_resched(_live_resched){}; - ~VirtualMachinePoolXML(){}; + virtual ~VirtualMachinePoolXML(){}; + /** + * Retrieves the pending and rescheduling VMs + * + * @return 0 on success + * -1 on error + * -2 if no VMs need to be scheduled + */ int set_up(); /** @@ -51,24 +58,94 @@ public: * Dispatch a VM to the given host * @param vid the VM id * @param hid the id of the target host - * @param resched the machine is going to be rescheduled + * @param resched the machine is going to be rescheduled */ int dispatch(int vid, int hid, bool resched) const; + /** + * Update the VM template + * @param vid the VM id + * @param st the template string + * + * @return 0 on success, -1 otherwise + */ + int update(int vid, const string &st) const; + + /** + * Update the VM template + * @param the VM + * + * @return 0 on success, -1 otherwise + */ + int update(VirtualMachineXML * vm) const + { + string xml; + + return update(vm->get_oid(), vm->get_template(xml)); + }; + protected: int get_suitable_nodes(vector& content) { return get_nodes("/VM_POOL/VM[STATE=1 or (LCM_STATE=3 and RESCHED=1)]", content); - }; + } virtual void add_object(xmlNodePtr node); virtual int load_info(xmlrpc_c::value &result); - /* Do live migrations to resched VMs*/ + /** + * Do live migrations to resched VMs + */ bool live_resched; }; +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +class VirtualMachineActionsPoolXML : public VirtualMachinePoolXML +{ +public: + + VirtualMachineActionsPoolXML(Client* client, + unsigned int machines_limit): + VirtualMachinePoolXML(client, machines_limit, false){}; + + virtual ~VirtualMachineActionsPoolXML(){}; + + /** + * Retrieves the VMs with pending actions + * + * @return 0 on success + * -1 on error + * -2 if no VMs with pending actions + */ + int set_up(); + + /** + * Calls one.vm.action + * + * @param vid The VM id + * @param action Action argument (shutdown, hold, release...) + * @param error_msg Error reason, if any + * + * @return 0 on success, -1 otherwise + */ + int action(int vid, const string &action, string &error_msg) const; + +protected: + + int get_suitable_nodes(vector& content) + { + ostringstream oss; + + oss << "/VM_POOL/VM/USER_TEMPLATE/SCHED_ACTION[TIME < " << time(0) + << " and not(DONE > 0)]/../.."; + + return get_nodes(oss.str().c_str(), content); + } +}; + #endif /* VM_POOL_XML_H_ */ diff --git a/src/scheduler/include/VirtualMachineXML.h b/src/scheduler/include/VirtualMachineXML.h index befb264083..29e714e085 100644 --- a/src/scheduler/include/VirtualMachineXML.h +++ b/src/scheduler/include/VirtualMachineXML.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -22,6 +22,7 @@ #include "ObjectXML.h" #include "HostPoolXML.h" +#include "VirtualMachineTemplate.h" using namespace std; @@ -29,12 +30,14 @@ class VirtualMachineXML : public ObjectXML { public: - VirtualMachineXML(const string &xml_doc):ObjectXML(xml_doc) + VirtualMachineXML(const string &xml_doc): + ObjectXML(xml_doc) { init_attributes(); }; - VirtualMachineXML(const xmlNodePtr node):ObjectXML(node) + VirtualMachineXML(const xmlNodePtr node): + ObjectXML(node) { init_attributes(); } @@ -103,22 +106,87 @@ public: return requirements; }; + /** + * Get the user template of the VM + * @return the template as a XML string + */ + string& get_template(string& xml_str) + { + if (vm_template != 0) + { + vm_template->to_xml(xml_str); + } + else + { + xml_str = ""; + } + + return xml_str; + } + + /** + * Removes (but does not delete) the scheduled actions of the VM + * + * @param attributes to hold the VM actions + */ + void get_actions(vector& attributes) const + { + attributes.clear(); + + vm_template->remove("SCHED_ACTION", attributes); + } + + /** + * Sets an attribute in the VM Template, it must be allocated in the heap + * + * @param attributes to hold the VM actions + */ + void set_attribute(Attribute* att) + { + return vm_template->set(att); + } + + /** + * Checks the action to be performed and returns the corresponding XML-RPC + * method name. + * @param action_st, the action to be performed. The XML-RPC name is + * returned here + * @return 0 on success. + */ + static int parse_action_name(string& action_st); + /** * Function to write a Virtual Machine in an output stream */ friend ostream& operator<<(ostream& os, VirtualMachineXML& vm) { + if (vm.hosts.empty()) + { + return os; + } + vector::reverse_iterator i; vector::iterator j; + os << "\t PRI\tHID VM: " << vm.oid << endl + << "\t-----------------------" << endl; + for (i=vm.hosts.rbegin();i!=vm.hosts.rend();i++) { os << "\t" << (*i)->priority << "\t" << (*i)->hid << endl; } + os << endl; + return os; }; + /** + * Adds a message to the VM's USER_TEMPLATE/SCHED_MESSAGE attribute + * @param st Message to set + */ + void log(const string &st); + protected: /** @@ -175,6 +243,10 @@ protected: */ vector hosts; + /** + * The VM user template + */ + VirtualMachineTemplate * vm_template; }; #endif /* VM_XML_H_ */ diff --git a/src/scheduler/src/client/Client.cc b/src/scheduler/src/client/Client.cc index 54cdf61f27..0c3e0327f5 100644 --- a/src/scheduler/src/client/Client.cc +++ b/src/scheduler/src/client/Client.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -15,7 +15,6 @@ /* -------------------------------------------------------------------------- */ #include "Client.h" -#include "SSLTools.h" #include #include diff --git a/src/scheduler/src/client/SConstruct b/src/scheduler/src/client/SConstruct index 06339dedee..bd420479e5 100644 --- a/src/scheduler/src/client/SConstruct +++ b/src/scheduler/src/client/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/pool # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/scheduler/src/pool/AclXML.cc b/src/scheduler/src/pool/AclXML.cc index 66cc5ca273..44ea6d7530 100644 --- a/src/scheduler/src/pool/AclXML.cc +++ b/src/scheduler/src/pool/AclXML.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/scheduler/src/pool/ClusterPoolXML.cc b/src/scheduler/src/pool/ClusterPoolXML.cc new file mode 100644 index 0000000000..aef376d4e2 --- /dev/null +++ b/src/scheduler/src/pool/ClusterPoolXML.cc @@ -0,0 +1,62 @@ +/* -------------------------------------------------------------------------- */ +/* 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 "ClusterPoolXML.h" + +void ClusterPoolXML::add_object(xmlNodePtr node) +{ + if ( node == 0 || node->children == 0 ) + { + NebulaLog::log("CLUSTER",Log::ERROR, + "XML Node does not represent a valid Cluster"); + + return; + } + + ClusterXML* cluster = new ClusterXML( node ); + + objects.insert( pair(cluster->get_oid(), cluster) ); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +int ClusterPoolXML::load_info(xmlrpc_c::value &result) +{ + try + { + client->call( client->get_endpoint(), // serverUrl + "one.clusterpool.info", // methodName + "s", // arguments format + &result, // resultP + client->get_oneauth().c_str() // argument + ); + return 0; + } + catch (exception const& e) + { + ostringstream oss; + oss << "Exception raised: " << e.what(); + + NebulaLog::log("CLUSTER", Log::ERROR, oss); + + return -1; + } +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + diff --git a/src/scheduler/src/pool/HostPoolXML.cc b/src/scheduler/src/pool/HostPoolXML.cc index 316cca5a2d..274edd625b 100644 --- a/src/scheduler/src/pool/HostPoolXML.cc +++ b/src/scheduler/src/pool/HostPoolXML.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -16,7 +16,6 @@ #include "HostPoolXML.h" - int HostPoolXML::set_up() { ostringstream oss; @@ -89,3 +88,42 @@ int HostPoolXML::load_info(xmlrpc_c::value &result) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +void HostPoolXML::merge_clusters(ClusterPoolXML * clpool) +{ + map::iterator it; + + ClusterXML* cluster; + HostXML* host; + + int cluster_id; + vector nodes; + + for (it=objects.begin(); it!=objects.end(); it++) + { + host = static_cast(it->second); + + cluster_id = host->get_cid(); + + if(cluster_id != -1) //ClusterPool::NONE_CLUSTER_ID + { + cluster = clpool->get(cluster_id); + + if(cluster != 0) + { + nodes.clear(); + + cluster->get_nodes("/CLUSTER/TEMPLATE", nodes); + + if (!nodes.empty()) + { + host->add_node("/HOST", nodes[0], "CLUSTER_TEMPLATE"); + } + + cluster->free_nodes(nodes); + } + } + } +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ diff --git a/src/scheduler/src/pool/HostXML.cc b/src/scheduler/src/pool/HostXML.cc index 6ed7a562f4..3e9cebd82e 100644 --- a/src/scheduler/src/pool/HostXML.cc +++ b/src/scheduler/src/pool/HostXML.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -26,6 +26,7 @@ float HostXML::hypervisor_mem; void HostXML::init_attributes() { oid = atoi(((*this)["/HOST/ID"] )[0].c_str() ); + cluster_id = atoi(((*this)["/HOST/CLUSTER_ID"] )[0].c_str() ); disk_usage = atoi(((*this)["/HOST/HOST_SHARE/DISK_USAGE"])[0].c_str()); mem_usage = atoi(((*this)["/HOST/HOST_SHARE/MEM_USAGE"])[0].c_str()); diff --git a/src/scheduler/src/pool/SConstruct b/src/scheduler/src/pool/SConstruct index b8ade4e4f6..687bafdcd6 100644 --- a/src/scheduler/src/pool/SConstruct +++ b/src/scheduler/src/pool/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/pool # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -25,7 +25,8 @@ source_files=[ 'HostPoolXML.cc', 'HostXML.cc', 'VirtualMachinePoolXML.cc', - 'VirtualMachineXML.cc'] + 'VirtualMachineXML.cc', + 'ClusterPoolXML.cc'] # Build library sched_env.StaticLibrary(lib_name, source_files) diff --git a/src/scheduler/src/pool/VirtualMachinePoolXML.cc b/src/scheduler/src/pool/VirtualMachinePoolXML.cc index 1b4852cb69..6479e30456 100644 --- a/src/scheduler/src/pool/VirtualMachinePoolXML.cc +++ b/src/scheduler/src/pool/VirtualMachinePoolXML.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -26,6 +26,11 @@ int VirtualMachinePoolXML::set_up() if ( rc == 0 ) { + if (objects.empty()) + { + return -2; + } + oss.str(""); oss << "Pending and rescheduling VMs:" << endl; @@ -91,7 +96,6 @@ int VirtualMachinePoolXML::load_info(xmlrpc_c::value &result) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ - int VirtualMachinePoolXML::dispatch(int vid, int hid, bool resched) const { ostringstream oss; @@ -103,7 +107,7 @@ int VirtualMachinePoolXML::dispatch(int vid, int hid, bool resched) const } else { - oss << "Dispatching "; + oss << "Dispatching "; } oss << "virtual machine " << vid << " to host " << hid; @@ -112,27 +116,28 @@ int VirtualMachinePoolXML::dispatch(int vid, int hid, bool resched) const try { - //TODO Get live migration from config file if (resched == true) { client->call(client->get_endpoint(), // serverUrl "one.vm.migrate", // methodName - "siib", // arguments format + "siibb", // arguments format &deploy_result, // resultP client->get_oneauth().c_str(), // argument 0 (AUTH) vid, // argument 1 (VM) hid, // argument 2 (HOST) - live_resched); // argument 3 (LIVE) + live_resched, // argument 3 (LIVE) + false); // argument 4 (ENFORCE) } else { client->call(client->get_endpoint(), // serverUrl "one.vm.deploy", // methodName - "sii", // arguments format + "siib", // arguments format &deploy_result, // resultP client->get_oneauth().c_str(), // argument 0 (AUTH) vid, // argument 1 (VM) - hid); // argument 2 (HOST) + hid, // argument 2 (HOST) + false); // argument 3 (ENFORCE) } } catch (exception const& e) @@ -167,3 +172,127 @@ int VirtualMachinePoolXML::dispatch(int vid, int hid, bool resched) const return 0; } + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +int VirtualMachinePoolXML::update(int vid, const string &st) const +{ + xmlrpc_c::value result; + bool success; + + try + { + client->call( client->get_endpoint(), // serverUrl + "one.vm.update", // methodName + "sis", // arguments format + &result, // resultP + client->get_oneauth().c_str(), // argument + vid, // VM ID + st.c_str() // Template + ); + } + catch (exception const& e) + { + return -1; + } + + vector values = + xmlrpc_c::value_array(result).vectorValueValue(); + + success = xmlrpc_c::value_boolean(values[0]); + + if (!success) + { + return -1; + } + + return 0; +} +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +int VirtualMachineActionsPoolXML::set_up() +{ + ostringstream oss; + int rc; + + rc = PoolXML::set_up(); + + if ( rc == 0 ) + { + if (objects.empty()) + { + return -2; + } + + oss.str(""); + oss << "VMs with scheduled actions:" << endl; + + map::iterator it; + + for (it=objects.begin();it!=objects.end();it++) + { + oss << " " << it->first; + } + + NebulaLog::log("VM",Log::DEBUG,oss); + } + + return rc; +} +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +int VirtualMachineActionsPoolXML::action( + int vid, + const string& action, + string& error_msg) const +{ + xmlrpc_c::value result; + bool success; + + try + { + if (action == "snapshot-create") + { + client->call( client->get_endpoint(), // serverUrl + "one.vm.snapshotcreate", // methodName + "sis", // arguments format + &result, // resultP + client->get_oneauth().c_str(), // session + vid, // VM ID + string("").c_str() // snapshot name + ); + } + else + { + client->call( client->get_endpoint(), // serverUrl + "one.vm.action", // methodName + "ssi", // arguments format + &result, // resultP + client->get_oneauth().c_str(), // session + action.c_str(), // action + vid // VM ID + ); + } + } + catch (exception const& e) + { + return -1; + } + + vector values = + xmlrpc_c::value_array(result).vectorValueValue(); + + success = xmlrpc_c::value_boolean(values[0]); + + if (!success) + { + error_msg = xmlrpc_c::value_string( values[1] ); + + return -1; + } + + return 0; +} diff --git a/src/scheduler/src/pool/VirtualMachineXML.cc b/src/scheduler/src/pool/VirtualMachineXML.cc index 6ceed42835..6fe23e47af 100644 --- a/src/scheduler/src/pool/VirtualMachineXML.cc +++ b/src/scheduler/src/pool/VirtualMachineXML.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -17,16 +17,19 @@ #include #include "VirtualMachineXML.h" +#include "NebulaUtil.h" void VirtualMachineXML::init_attributes() { - vector result; + vector result; + vector nodes; oid = atoi(((*this)["/VM/ID"] )[0].c_str()); uid = atoi(((*this)["/VM/UID"])[0].c_str()); gid = atoi(((*this)["/VM/GID"])[0].c_str()); result = ((*this)["/VM/TEMPLATE/MEMORY"]); + if (result.size() > 0) { memory = atoi(result[0].c_str()); @@ -37,6 +40,7 @@ void VirtualMachineXML::init_attributes() } result = ((*this)["/VM/TEMPLATE/CPU"]); + if (result.size() > 0) { istringstream iss; @@ -48,29 +52,55 @@ void VirtualMachineXML::init_attributes() cpu = 0; } - result = ((*this)["/VM/TEMPLATE/RANK"]); + result = ((*this)["/VM/USER_TEMPLATE/SCHED_RANK"]); + if (result.size() > 0) { rank = result[0]; } else { - rank = ""; + // Compatibility with previous versions + result = ((*this)["/VM/USER_TEMPLATE/RANK"]); + + if (result.size() > 0) + { + rank = result[0]; + } + else + { + rank = ""; + } } - result = ((*this)["/VM/TEMPLATE/REQUIREMENTS"]); + result = ((*this)["/VM/TEMPLATE/AUTOMATIC_REQUIREMENTS"]); + if (result.size() > 0) { requirements = result[0]; } - else + + result = ((*this)["/VM/USER_TEMPLATE/SCHED_REQUIREMENTS"]); + + if (result.size() > 0) { - requirements = ""; - } + if ( !requirements.empty() ) + { + ostringstream oss; + + oss << requirements << " & ( " << result[0] << " )"; + + requirements = oss.str(); + } + else + { + requirements = result[0]; + } + } result = ((*this)["/VM/HISTORY_RECORDS/HISTORY/HID"]); - if (result.size() > 0) + if (result.size() > 0) { hid = atoi(result[0].c_str()); } @@ -88,7 +118,20 @@ void VirtualMachineXML::init_attributes() else { resched = 0; - } + } + + if (get_nodes("/VM/USER_TEMPLATE", nodes) > 0) + { + vm_template = new VirtualMachineTemplate; + + vm_template->from_xml_node(nodes[0]); + + free_nodes(nodes); + } + else + { + vm_template = 0; + } } /* -------------------------------------------------------------------------- */ @@ -104,6 +147,11 @@ VirtualMachineXML::~VirtualMachineXML() } hosts.clear(); + + if (vm_template != 0) + { + delete vm_template; + } } /* -------------------------------------------------------------------------- */ @@ -117,7 +165,7 @@ void VirtualMachineXML::add_host(int host_id) ss = new VirtualMachineXML::Host(host_id); - hosts.push_back(ss); + hosts.push_back(ss); } } @@ -222,3 +270,53 @@ void VirtualMachineXML::get_requirements (int& cpu, int& memory, int& disk) memory = this->memory * 1024; //now in Kilobytes disk = 0; } + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void VirtualMachineXML::log(const string &st) +{ + if (vm_template == 0 || st.empty()) + { + return; + } + ostringstream oss; + + oss << one_util::log_time() << " : " << st; + + vm_template->replace("SCHED_MESSAGE", oss.str()); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +int VirtualMachineXML::parse_action_name(string& action_st) +{ + one_util::tolower(action_st); + + // onevm delete command uses the xml-rpc finalize action + if (action_st == "delete") + { + action_st = "finalize"; + } + + if ( action_st != "shutdown" + && action_st != "hold" + && action_st != "release" + && action_st != "stop" + && action_st != "cancel" + && action_st != "suspend" + && action_st != "resume" + && action_st != "restart" + && action_st != "resubmit" + && action_st != "reboot" + && action_st != "reset" + && action_st != "poweroff" + && action_st != "finalize" + && action_st != "snapshot-create") + { + return -1; + } + + return 0; +}; diff --git a/src/scheduler/src/pool/test/HostXMLTest.cc b/src/scheduler/src/pool/test/HostXMLTest.cc index 8fe85f8e4c..c1c6907a29 100644 --- a/src/scheduler/src/pool/test/HostXMLTest.cc +++ b/src/scheduler/src/pool/test/HostXMLTest.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/scheduler/src/pool/test/SConstruct b/src/scheduler/src/pool/test/SConstruct index 13e904116e..f100ae03fa 100644 --- a/src/scheduler/src/pool/test/SConstruct +++ b/src/scheduler/src/pool/test/SConstruct @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/scheduler/src/pool/test/VirtualMachineXMLTest.cc b/src/scheduler/src/pool/test/VirtualMachineXMLTest.cc index 0910c59453..0e8c691c3e 100644 --- a/src/scheduler/src/pool/test/VirtualMachineXMLTest.cc +++ b/src/scheduler/src/pool/test/VirtualMachineXMLTest.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/scheduler/src/sched/SConstruct b/src/scheduler/src/sched/SConstruct index 3d67f79481..1642caeb31 100644 --- a/src/scheduler/src/sched/SConstruct +++ b/src/scheduler/src/sched/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/pool # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/scheduler/src/sched/Scheduler.cc b/src/scheduler/src/sched/Scheduler.cc index 9ed5254d5f..a711899609 100644 --- a/src/scheduler/src/sched/Scheduler.cc +++ b/src/scheduler/src/sched/Scheduler.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -34,6 +34,7 @@ #include "RankPolicy.h" #include "NebulaLog.h" #include "PoolObjectAuth.h" +#include "NebulaUtil.h" using namespace std; @@ -77,46 +78,28 @@ void Scheduler::start() pthread_attr_t pattr; - // ----------------------------------------------------------- - // Log system & Configuration File - // ----------------------------------------------------------- - - try - { - string log_file; - const char * nl = getenv("ONE_LOCATION"); - - if (nl == 0) //OpenNebula installed under root directory - { - log_file = "/var/log/one/sched.log"; - etc_path = "/etc/one/"; - } - else - { - oss << nl << "/var/sched.log"; - - log_file = oss.str(); - - oss.str(""); - oss << nl << "/etc/"; - - etc_path = oss.str(); - } - - NebulaLog::init_log_system(NebulaLog::FILE, - Log::DEBUG, - log_file.c_str()); - - NebulaLog::log("SCHED", Log::INFO, "Init Scheduler Log system"); - } - catch(runtime_error &) - { - throw; - } - // ----------------------------------------------------------- // Configuration File // ----------------------------------------------------------- + string log_file; + const char * nl = getenv("ONE_LOCATION"); + + if (nl == 0) //OpenNebula installed under root directory + { + log_file = "/var/log/one/sched.log"; + etc_path = "/etc/one/"; + } + else + { + oss << nl << "/var/sched.log"; + + log_file = oss.str(); + + oss.str(""); + oss << nl << "/etc/"; + + etc_path = oss.str(); + } SchedulerTemplate conf(etc_path); @@ -128,7 +111,7 @@ void Scheduler::start() conf.get("ONED_PORT", oned_port); oss.str(""); - oss << "http://localhost:" << oned_port << "/RPC2"; + oss << "http://localhost:" << oned_port << "/RPC2"; url = oss.str(); conf.get("SCHED_INTERVAL", timer); @@ -142,9 +125,63 @@ void Scheduler::start() conf.get("LIVE_RESCHEDS", live_rescheds); conf.get("HYPERVISOR_MEM", hypervisor_mem); - + + // ----------------------------------------------------------- + // Log system & Configuration File + // ----------------------------------------------------------- + + try + { + vector logs; + int rc; + + NebulaLog::LogType log_system = NebulaLog::UNDEFINED; + Log::MessageType clevel = Log::ERROR;; + + rc = conf.get("LOG", logs); + + if ( rc != 0 ) + { + string value; + int ilevel; + + const VectorAttribute * log = static_cast + (logs[0]); + value = log->vector_value("SYSTEM"); + log_system = NebulaLog::str_to_type(value); + + value = log->vector_value("DEBUG_LEVEL"); + ilevel = atoi(value.c_str()); + + if (0 <= ilevel && ilevel <= 3 ) + { + clevel = static_cast(ilevel); + } + } + + // Start the log system + if ( log_system != NebulaLog::UNDEFINED ) + { + NebulaLog::init_log_system(log_system, + clevel, + log_file.c_str(), + ios_base::trunc, + "mm_sched"); + } + else + { + throw runtime_error("Unknown LOG_SYSTEM."); + } + + NebulaLog::log("SCHED", Log::INFO, "Init Scheduler Log system"); + } + catch(runtime_error &) + { + throw; + } + oss.str(""); - + oss << "Starting Scheduler Daemon" << endl; oss << "----------------------------------------\n"; oss << " Scheduler Configuration File \n"; @@ -167,7 +204,6 @@ void Scheduler::start() throw; } - xmlInitParser(); // ----------------------------------------------------------- @@ -175,9 +211,12 @@ void Scheduler::start() // ----------------------------------------------------------- hpool = new HostPoolXML(client, hypervisor_mem); - vmpool = new VirtualMachinePoolXML(client, + clpool = new ClusterPoolXML(client); + vmpool = new VirtualMachinePoolXML(client, machines_limit, (live_rescheds == 1)); + vmapool= new VirtualMachineActionsPoolXML(client, machines_limit); + acls = new AclXML(client); // ----------------------------------------------------------- @@ -264,6 +303,17 @@ int Scheduler::set_up_pools() map::const_iterator it; map shares; + //-------------------------------------------------------------------------- + //Cleans the cache and get the pending VMs + //-------------------------------------------------------------------------- + + rc = vmpool->set_up(); + + if ( rc != 0 ) + { + return rc; + } + //-------------------------------------------------------------------------- //Cleans the cache and get the hosts ids //-------------------------------------------------------------------------- @@ -276,16 +326,22 @@ int Scheduler::set_up_pools() } //-------------------------------------------------------------------------- - //Cleans the cache and get the pending VMs + //Cleans the cache and get the cluster information //-------------------------------------------------------------------------- - rc = vmpool->set_up(); + rc = clpool->set_up(); if ( rc != 0 ) { return rc; } + //-------------------------------------------------------------------------- + //Add to each host the corresponding cluster template + //-------------------------------------------------------------------------- + + hpool->merge_clusters(clpool); + //-------------------------------------------------------------------------- //Cleans the cache and get the ACLs //-------------------------------------------------------------------------- @@ -317,8 +373,13 @@ void Scheduler::match() int vm_cpu; int vm_disk; + int oid; int uid; int gid; + int n_hosts; + int n_matched; + int n_auth; + int n_error; string reqs; @@ -340,50 +401,19 @@ void Scheduler::match() reqs = vm->get_requirements(); + oid = vm->get_oid(); uid = vm->get_uid(); gid = vm->get_gid(); + n_hosts = 0; + n_matched = 0; + n_auth = 0; + n_error = 0; + for (h_it=hosts.begin(), matched=false; h_it != hosts.end(); h_it++) { host = static_cast(h_it->second); - // ----------------------------------------------------------------- - // Evaluate VM requirements - // ----------------------------------------------------------------- - - if (reqs != "") - { - rc = host->eval_bool(reqs,matched,&error); - - if ( rc != 0 ) - { - ostringstream oss; - - matched = false; - - oss << "Error evaluating expresion: " << reqs - << ", error: " << error; - NebulaLog::log("SCHED",Log::ERROR,oss); - - free(error); - } - } - else - { - matched = true; - } - - if ( matched == false ) - { - ostringstream oss; - - oss << "Host " << host->get_hid() << - " filtered out. It does not fullfil REQUIREMENTS."; - - NebulaLog::log("SCHED",Log::DEBUG,oss); - continue; - } - // ----------------------------------------------------------------- // Check if user is authorized // ----------------------------------------------------------------- @@ -401,7 +431,7 @@ void Scheduler::match() host_perms.oid = host->get_hid(); host_perms.obj_type = PoolObjectSQL::HOST; - matched = acls->authorize(uid, + matched = acls->authorize(uid, gid, host_perms, AuthRequest::MANAGE); @@ -411,7 +441,7 @@ void Scheduler::match() { ostringstream oss; - oss << "Host " << host->get_hid() + oss << "VM " << oid << ": Host " << host->get_hid() << " filtered out. User is not authorized to " << AuthRequest::operation_to_str(AuthRequest::MANAGE) << " it."; @@ -419,6 +449,56 @@ void Scheduler::match() NebulaLog::log("SCHED",Log::DEBUG,oss); continue; } + + n_auth++; + + // ----------------------------------------------------------------- + // Evaluate VM requirements + // ----------------------------------------------------------------- + + if (reqs != "") + { + rc = host->eval_bool(reqs,matched,&error); + + if ( rc != 0 ) + { + ostringstream oss; + ostringstream error_msg; + + matched = false; + n_error++; + + error_msg << "Error evaluating SCHED_REQUIREMENTS expression: '" + << reqs << "', error: " << error; + + oss << "VM " << oid << ": " << error_msg.str(); + NebulaLog::log("SCHED",Log::ERROR,oss); + + vm->log(error_msg.str()); + + free(error); + + break; + } + } + else + { + matched = true; + } + + if ( matched == false ) + { + ostringstream oss; + + oss << "VM " << oid << ": Host " << host->get_hid() << + " filtered out. It does not fulfill SCHED_REQUIREMENTS."; + + NebulaLog::log("SCHED",Log::DEBUG,oss); + continue; + } + + n_matched++; + // ----------------------------------------------------------------- // Check host capacity // ----------------------------------------------------------------- @@ -427,18 +507,49 @@ void Scheduler::match() if (host->test_capacity(vm_cpu,vm_memory,vm_disk) == true) { - vm->add_host(host->get_hid()); + vm->add_host(host->get_hid()); + + n_hosts++; } else { ostringstream oss; - oss << "Host " << host->get_hid() << " filtered out. " - << "Not enough capacity. " << endl; + oss << "VM " << oid << ": Host " << host->get_hid() + << " filtered out. Not enough capacity."; NebulaLog::log("SCHED",Log::DEBUG,oss); } } + + // --------------------------------------------------------------------- + // Log scheduling errors to VM user if any + // --------------------------------------------------------------------- + + if (n_hosts == 0) //No hosts assigned, let's see why + { + if (n_error == 0) //No syntax error + { + if (hosts.size() == 0) + { + vm->log("No hosts enabled to run VMs"); + } + else if (n_auth == 0) + { + vm->log("User is not authorized to use any host"); + } + else if (n_matched == 0) + { + vm->log("No host meets the SCHED_REQUIREMENTS expression"); + } + else + { + vm->log("No host with enough capacity to deploy the VM"); + } + } + + vmpool->update(vm); + } } } @@ -520,9 +631,7 @@ void Scheduler::dispatch() { vm = static_cast(vm_it->second); - oss << "\t PRI\tHID VM: " << vm->get_oid() << endl - << "\t-----------------------" << endl - << *vm << endl; + oss << *vm; } NebulaLog::log("SCHED",Log::INFO,oss); @@ -552,12 +661,114 @@ void Scheduler::dispatch() /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +int Scheduler::do_scheduled_actions() +{ + VirtualMachineXML* vm; + + const map vms = vmapool->get_objects(); + map::const_iterator vm_it; + + vector attributes; + vector::iterator it; + + VectorAttribute* vatt; + + int action_time; + int done_time; + int has_time; + int has_done; + + string action_st, error_msg; + + time_t the_time = time(0); + string time_str = one_util::log_time(the_time); + + for (vm_it=vms.begin(); vm_it != vms.end(); vm_it++) + { + vm = static_cast(vm_it->second); + + vm->get_actions(attributes); + + // TODO: Sort actions by TIME + for (it=attributes.begin(); it != attributes.end(); it++) + { + vatt = dynamic_cast(*it); + + if (vatt == 0) + { + delete *it; + + continue; + } + + has_time = vatt->vector_value("TIME", action_time); + has_done = vatt->vector_value("DONE", done_time); + action_st = vatt->vector_value("ACTION"); + + if (has_time == 0 && has_done == -1 && action_time < the_time) + { + ostringstream oss; + + int rc = VirtualMachineXML::parse_action_name(action_st); + + oss << "Executing action '" << action_st << "' for VM " + << vm->get_oid() << " : "; + + if ( rc != 0 ) + { + error_msg = "This action is not supported."; + } + else + { + rc = vmapool->action(vm->get_oid(), action_st, error_msg); + } + + if (rc == 0) + { + vatt->remove("MESSAGE"); + vatt->replace("DONE", static_cast(the_time)); + + oss << "Success."; + } + else + { + ostringstream oss_aux; + + oss_aux << time_str << " : " << error_msg; + + vatt->replace("MESSAGE", oss_aux.str()); + + oss << "Failure. " << error_msg; + } + + NebulaLog::log("VM", Log::INFO, oss); + } + + vm->set_attribute(vatt); + } + + vmpool->update(vm); + } + + return 0; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + void Scheduler::do_action(const string &name, void *args) { int rc; if (name == ACTION_TIMER) { + rc = vmapool->set_up(); + + if ( rc == 0 ) + { + do_scheduled_actions(); + } + rc = set_up_pools(); if ( rc != 0 ) diff --git a/src/scheduler/src/sched/SchedulerTemplate.cc b/src/scheduler/src/sched/SchedulerTemplate.cc index 30eb7998ad..79c77ba4c9 100644 --- a/src/scheduler/src/sched/SchedulerTemplate.cc +++ b/src/scheduler/src/sched/SchedulerTemplate.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -29,6 +29,7 @@ void SchedulerTemplate::set_conf_default() SingleAttribute * attribute; VectorAttribute * vattribute; string value; + map vvalue; /* #******************************************************************************* @@ -42,6 +43,7 @@ void SchedulerTemplate::set_conf_default() # DEFAULT_SCHED # LIVE_RESCHEDS # HYPERVISOR_MEM +# LOG #------------------------------------------------------------------------------- */ // ONED_PORT @@ -73,25 +75,33 @@ void SchedulerTemplate::set_conf_default() attribute = new SingleAttribute("MAX_HOST",value); conf_default.insert(make_pair(attribute->name(),attribute)); - + //LIVE_RESCHEDS value = "0"; attribute = new SingleAttribute("LIVE_RESCHEDS",value); conf_default.insert(make_pair(attribute->name(),attribute)); - //DEFAULT_SCHED - map vvalue; + //DEFAULT_SCHED + vvalue.clear(); vvalue.insert(make_pair("POLICY","1")); vattribute = new VectorAttribute("DEFAULT_SCHED",vvalue); - conf_default.insert(make_pair(attribute->name(),vattribute)); + conf_default.insert(make_pair(vattribute->name(),vattribute)); //HYPERVISOR_MEM value = "0.1"; attribute = new SingleAttribute("HYPERVISOR_MEM",value); conf_default.insert(make_pair(attribute->name(),attribute)); + + //LOG CONFIGURATION + vvalue.clear(); + vvalue.insert(make_pair("SYSTEM","file")); + vvalue.insert(make_pair("DEBUG_LEVEL","3")); + + vattribute = new VectorAttribute("LOG",vvalue); + conf_default.insert(make_pair(vattribute->name(),vattribute)); } /* -------------------------------------------------------------------------- */ @@ -105,7 +115,7 @@ string SchedulerTemplate::get_policy() const istringstream iss; vector vsched; - const VectorAttribute * sched; + const VectorAttribute * sched; get("DEFAULT_SCHED", vsched); @@ -123,7 +133,7 @@ string SchedulerTemplate::get_policy() const case 1: //Striping rank = "- RUNNING_VMS"; break; - + case 2: //Load-aware rank = "FREE_CPU"; break; @@ -137,4 +147,4 @@ string SchedulerTemplate::get_policy() const } return rank; -} \ No newline at end of file +} diff --git a/src/scheduler/src/sched/mm_sched.cc b/src/scheduler/src/sched/mm_sched.cc index 014a87ca56..f609786786 100644 --- a/src/scheduler/src/sched/mm_sched.cc +++ b/src/scheduler/src/sched/mm_sched.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sql/MySqlDB.cc b/src/sql/MySqlDB.cc index 0bb621fc2f..5fb1b228bc 100644 --- a/src/sql/MySqlDB.cc +++ b/src/sql/MySqlDB.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sql/SConstruct b/src/sql/SConstruct index 8cd6dd42f7..21f3f61dff 100644 --- a/src/sql/SConstruct +++ b/src/sql/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/pool # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/sql/SqliteDB.cc b/src/sql/SqliteDB.cc index 638751c3a9..11b2f7d7bd 100644 --- a/src/sql/SqliteDB.cc +++ b/src/sql/SqliteDB.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/OpenNebulaVNC.rb b/src/sunstone/OpenNebulaVNC.rb index 784984e68f..9ac0cd4b92 100644 --- a/src/sunstone/OpenNebulaVNC.rb +++ b/src/sunstone/OpenNebulaVNC.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -19,7 +19,7 @@ # require 'json' -require 'OpenNebula' +require 'opennebula' TOKEN_EXPIRE_SECONDS = 4 @@ -27,9 +27,10 @@ class OpenNebulaVNC attr_reader :proxy_port - def initialize(config, logger, opts={ - :json_errors => true, - :token_folder_name => 'sunstone_vnc_tokens'}) + def initialize(config, logger, options = {}) + opts={ :json_errors => true, + :token_folder_name => 'sunstone_vnc_tokens'}.merge(options) + @pipe = nil @token_folder = File.join(VAR_LOCATION, opts[:token_folder_name]) @proxy_path = config[:vnc_proxy_path] @@ -38,6 +39,8 @@ class OpenNebulaVNC @wss = config[:vnc_proxy_support_wss] + @lock_file = config[:lock_file] || '/tmp/novnc.lock' + if (@wss == "yes") || (@wss == "only") || (@wss == true) @enable_wss = true @cert = config[:vnc_proxy_cert] @@ -48,21 +51,24 @@ class OpenNebulaVNC @options = opts @logger = logger - begin - Dir.mkdir(@token_folder) - rescue Exception => e - @logger.error "Cannot create token folder" - @logger.error e.message - end end def start - if @proxy_path == nil || @proxy_path.empty? - @logger.info "VNC proxy not configured" - return + if is_running? + message="VNC server already running" + STDERR.puts message + @logger.info message + return false end + if @proxy_path == nil || @proxy_path.empty? + @logger.error "VNC proxy not configured" + return false + end + + create_token_dir + proxy_options = "--target-config=#{@token_folder} " if @enable_wss @@ -75,16 +81,31 @@ class OpenNebulaVNC begin @logger.info { "Starting VNC proxy: #{cmd}" } - @pipe = IO.popen(cmd,'r') + pid=start_daemon(cmd, 'VNC_LOG') rescue Exception => e @logger.error e.message - return + return false end + + File.write(@lock_file, pid) + + sleep 1 + + if !is_running? + message="Error starting VNC proxy" + STDERR.puts message + @logger.error message + File.delete(@lock_file) if File.exist?(@lock_file) + + return false + end + + true end def proxy(vm_resource) # Check configurations and VM attributes - if !@pipe + if !is_running? return error(400, "VNC Proxy is not running") end @@ -121,12 +142,6 @@ class OpenNebulaVNC :token => random_str, } - # Delete token soon after - Thread.new do - sleep TOKEN_EXPIRE_SECONDS - delete_token(token_file) - end - return [200, info.to_json] end @@ -140,16 +155,40 @@ class OpenNebulaVNC end end - def stop - if !@pipe then return end - @logger.info "Killing VNC proxy" - Process.kill('TERM',@pipe.pid) - @pipe.close - begin - Dir.rmdir(@token_folder) - rescue => e - @logger.error "Error deleting token folder" - @logger.error e.message + def stop(force=false) + pid=get_pid + + if pid + @logger.info "Killing VNC proxy" + + signal=(force ? 'KILL' : 'TERM') + Process.kill(signal ,pid) + + sleep 1 + + if is_running? + message="VNC server is still running" + STDERR.puts message + logger.error message + return false + end + + delete_token_dir + else + message="VNC server is not running" + @logger.info message + STDERR.puts message + end + true + end + + def status + if is_running? + STDOUT.puts "VNC is running" + true + else + STDOUT.puts "VNC is NOT running" + false end end @@ -163,4 +202,56 @@ class OpenNebulaVNC end end + def create_token_dir + delete_token_dir + begin + Dir.mkdir(@token_folder) if !File.exist?(@token_folder) + rescue Exception => e + @logger.error "Cannot create token folder" + @logger.error e.message + end + end + + def delete_token_dir + if File.exist?(@token_folder) + begin + Dir.glob("#{@token_folder}/*").each do |file| + File.delete(file) + end + Dir.rmdir(@token_folder) + rescue => e + @logger.error "Error deleting token folder" + @logger.error e.message + end + end + end + + def is_running? + if File.exist?(@lock_file) + pid=File.read(@lock_file).strip + + if system("ps #{pid} 1> /dev/null") + return pid.to_i + end + + @logger.info "Deleting stale lock file" + File.delete(@lock_file) + end + + false + end + alias_method :get_pid, :is_running? + + def start_daemon(cmd, log) + pid=spawn(*cmd.split(" "), + :pgroup => true, + :in => :close, + [:out, :err] => [log, "a"], + :close_others => true ) + + Process.detach(pid) + + pid + end end + diff --git a/src/sunstone/bin/novnc-server b/src/sunstone/bin/novnc-server new file mode 100755 index 0000000000..e203ff4bf6 --- /dev/null +++ b/src/sunstone/bin/novnc-server @@ -0,0 +1,87 @@ +#!/usr/bin/env ruby +# -*- coding: utf-8 -*- + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +ONE_LOCATION = ENV["ONE_LOCATION"] + +if !ONE_LOCATION + LOG_LOCATION = "/var/log/one" + LOCK_LOCATION = "/var/lock/one" + VAR_LOCATION = "/var/lib/one" + ETC_LOCATION = "/etc/one" + RUBY_LIB_LOCATION = "/usr/lib/one/ruby" +else + VAR_LOCATION = ONE_LOCATION + "/var" + LOCK_LOCATION = ONE_LOCATION + "/var" + LOG_LOCATION = ONE_LOCATION + "/var" + ETC_LOCATION = ONE_LOCATION + "/etc" + RUBY_LIB_LOCATION = ONE_LOCATION+"/lib/ruby" +end + +VNC_LOCK = LOCK_LOCATION + "/novnc.lock" +VNC_LOG = LOG_LOCATION + "/novnc.log" + +CONFIGURATION_FILE = ETC_LOCATION + "/sunstone-server.conf" + +PLUGIN_CONFIGURATION_FILE = ETC_LOCATION + "/sunstone-plugins.yaml" + +SUNSTONE_ROOT_DIR = File.dirname(__FILE__) + +$: << RUBY_LIB_LOCATION +$: << RUBY_LIB_LOCATION+'/cloud' +$: << SUNSTONE_ROOT_DIR +$: << SUNSTONE_ROOT_DIR+'/models' + +require 'logger' +require 'yaml' +require 'OpenNebulaVNC' + +$log=Logger.new(VNC_LOG) + + +begin + conf = YAML.load_file(CONFIGURATION_FILE) +rescue Exception => e + STDERR.puts "Error parsing config file #{CONFIGURATION_FILE}: #{e.message}" + exit 1 +end + +vnc=OpenNebulaVNC.new(conf, $log) + +if ARGV[0] + res=case ARGV[0].downcase.to_sym + when :start + vnc.start + when :stop + vnc.stop(ARGV[1]=='--force') + when :restart + vnc.stop + sleep 1 + vnc.start + when :status + vnc.status + end + + if !res + STDERR.puts "Error, check #{VNC_LOG}" + exit(-1) + end +else + exit(-1) +end + diff --git a/src/sunstone/bin/sunstone-server b/src/sunstone/bin/sunstone-server index 02c413f102..5ad2b8b571 100755 --- a/src/sunstone/bin/sunstone-server +++ b/src/sunstone/bin/sunstone-server @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -24,6 +24,7 @@ if [ -z "$ONE_LOCATION" ]; then SUNSTONE_LOG=/var/log/one/sunstone.log SUNSTONE_LOG_ERROR=/var/log/one/sunstone.error SUNSTONE_CONF=/etc/one/sunstone-server.conf + NOVNC_SERVER=/usr/bin/novnc-server else SUNSTONE_PID=$ONE_LOCATION/var/sunstone.pid SUNSTONE_SERVER=$ONE_LOCATION/lib/sunstone/sunstone-server.rb @@ -31,6 +32,7 @@ else SUNSTONE_LOG=$ONE_LOCATION/var/sunstone.log SUNSTONE_LOG_ERROR=$ONE_LOCATION/var/sunstone.error SUNSTONE_CONF=$ONE_LOCATION/etc/sunstone-server.conf + NOVNC_SERVER=$ONE_LOCATION/bin/novnc-server fi setup() @@ -65,6 +67,13 @@ start() exit 1 fi + # Start novnc server + $NOVNC_SERVER start + + if [ "$?" != "0" ]; then + echo "Could not start novnc server" 1>&2 + fi + # Start the sunstone daemon touch $SUNSTONE_LOCK_FILE ruby $SUNSTONE_SERVER > $SUNSTONE_LOG 2>$SUNSTONE_LOG_ERROR & @@ -95,6 +104,9 @@ start() # stop() { + # Stop novnc server + $NOVNC_SERVER stop + if [ ! -f $SUNSTONE_PID ]; then echo "Couldn't find sunstone-server process pid." exit 1 diff --git a/src/sunstone/config.ru b/src/sunstone/config.ru new file mode 100755 index 0000000000..e74952d454 --- /dev/null +++ b/src/sunstone/config.ru @@ -0,0 +1,12 @@ + +# If you are using self contained installation set this variable to the +# install location +#ENV['ONE_LOCATION']='/path/to/OpenNebula/install' + +WITH_RACKUP=true + +$: << '.' +require 'sunstone-server' + +run Sinatra::Application + diff --git a/src/sunstone/etc/sunstone-server.conf b/src/sunstone/etc/sunstone-server.conf index 46b9750a7f..0104ff5e17 100644 --- a/src/sunstone/etc/sunstone-server.conf +++ b/src/sunstone/etc/sunstone-server.conf @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -31,6 +31,16 @@ :host: 127.0.0.1 :port: 9869 +# Place where to store sessions, this value can be memory or memcache +# Use memcache when starting multiple server processes, for example, +# with passenger +:sessions: memory + +# Memcache configuration +:memcache_host: localhost +:memcache_port: 11211 +:memcache_namespace: opennebula.sunstone + ################################################################################ # Log ################################################################################ diff --git a/src/sunstone/locale/generate_messages_pot.sh b/src/sunstone/locale/generate_messages_pot.sh index b9db23c99a..30546fda10 100755 --- a/src/sunstone/locale/generate_messages_pot.sh +++ b/src/sunstone/locale/generate_messages_pot.sh @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -16,7 +16,7 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -COPYRIGHT_HOLDER="2002-2012, OpenNebula Project Leads (OpenNebula.org)" +COPYRIGHT_HOLDER="2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs" PACKAGE_NAME="OpenNebula" find ../public/js -name \*.js > file_list.txt diff --git a/src/sunstone/locale/languages/SConstruct b/src/sunstone/locale/languages/SConstruct index 7afedf5cd0..604cd15d8d 100644 --- a/src/sunstone/locale/languages/SConstruct +++ b/src/sunstone/locale/languages/SConstruct @@ -1,7 +1,7 @@ # SConstruct for share/man # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/sunstone/locale/languages/ca.po b/src/sunstone/locale/languages/ca.po index 8ca741c7c7..e7985433cc 100644 --- a/src/sunstone/locale/languages/ca.po +++ b/src/sunstone/locale/languages/ca.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/sunstone/locale/languages/cs_CZ.po b/src/sunstone/locale/languages/cs_CZ.po index dcac411a48..015340364b 100644 --- a/src/sunstone/locale/languages/cs_CZ.po +++ b/src/sunstone/locale/languages/cs_CZ.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/sunstone/locale/languages/de.po b/src/sunstone/locale/languages/de.po index e8c243ef9a..e935eefedf 100644 --- a/src/sunstone/locale/languages/de.po +++ b/src/sunstone/locale/languages/de.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/sunstone/locale/languages/el_GR.po b/src/sunstone/locale/languages/el_GR.po index 7078cb23c5..326e487c0e 100644 --- a/src/sunstone/locale/languages/el_GR.po +++ b/src/sunstone/locale/languages/el_GR.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/sunstone/locale/languages/en_US.po b/src/sunstone/locale/languages/en_US.po index eeeca51369..b73b955301 100644 --- a/src/sunstone/locale/languages/en_US.po +++ b/src/sunstone/locale/languages/en_US.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # diff --git a/src/sunstone/locale/languages/es_ES.po b/src/sunstone/locale/languages/es_ES.po index 47f2bd5e85..0df00f3f3d 100644 --- a/src/sunstone/locale/languages/es_ES.po +++ b/src/sunstone/locale/languages/es_ES.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/sunstone/locale/languages/fa_IR.po b/src/sunstone/locale/languages/fa_IR.po index e9dd0d7585..e6e3aaec99 100644 --- a/src/sunstone/locale/languages/fa_IR.po +++ b/src/sunstone/locale/languages/fa_IR.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/sunstone/locale/languages/fr_FR.po b/src/sunstone/locale/languages/fr_FR.po index da214934a0..c4a19f47b2 100644 --- a/src/sunstone/locale/languages/fr_FR.po +++ b/src/sunstone/locale/languages/fr_FR.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/sunstone/locale/languages/it_IT.po b/src/sunstone/locale/languages/it_IT.po index 879aed3272..7cd951bcc9 100644 --- a/src/sunstone/locale/languages/it_IT.po +++ b/src/sunstone/locale/languages/it_IT.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/sunstone/locale/languages/pt_BR.po b/src/sunstone/locale/languages/pt_BR.po index db5e275b15..caf7587c45 100644 --- a/src/sunstone/locale/languages/pt_BR.po +++ b/src/sunstone/locale/languages/pt_BR.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/sunstone/locale/languages/pt_PT.po b/src/sunstone/locale/languages/pt_PT.po index fd419f3126..69c5cf1c7c 100644 --- a/src/sunstone/locale/languages/pt_PT.po +++ b/src/sunstone/locale/languages/pt_PT.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/sunstone/locale/languages/ru_RU.po b/src/sunstone/locale/languages/ru_RU.po index 0a2a559a59..d8c63b4007 100644 --- a/src/sunstone/locale/languages/ru_RU.po +++ b/src/sunstone/locale/languages/ru_RU.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/sunstone/locale/languages/sk_SK.po b/src/sunstone/locale/languages/sk_SK.po index 9f9df9eb36..11dc6c1166 100644 --- a/src/sunstone/locale/languages/sk_SK.po +++ b/src/sunstone/locale/languages/sk_SK.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/sunstone/locale/languages/zh_TW.po b/src/sunstone/locale/languages/zh_TW.po index 27da350e29..fe3e9f5daf 100644 --- a/src/sunstone/locale/languages/zh_TW.po +++ b/src/sunstone/locale/languages/zh_TW.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # # Translators: diff --git a/src/sunstone/locale/messages.pot b/src/sunstone/locale/messages.pot index eeeca51369..b73b955301 100644 --- a/src/sunstone/locale/messages.pot +++ b/src/sunstone/locale/messages.pot @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright (C) YEAR 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # diff --git a/src/sunstone/locale/upgrade_po_translations.sh b/src/sunstone/locale/upgrade_po_translations.sh index 38c0b3a505..2d2a0dd4ea 100755 --- a/src/sunstone/locale/upgrade_po_translations.sh +++ b/src/sunstone/locale/upgrade_po_translations.sh @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/sunstone/models/OpenNebulaJSON.rb b/src/sunstone/models/OpenNebulaJSON.rb index 7055b7a302..d3e6e37d1b 100644 --- a/src/sunstone/models/OpenNebulaJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -14,7 +14,7 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -require 'OpenNebula' +require 'opennebula' include OpenNebula require 'OpenNebulaJSON/GroupJSON' diff --git a/src/sunstone/models/OpenNebulaJSON/AclJSON.rb b/src/sunstone/models/OpenNebulaJSON/AclJSON.rb index 8376df98b6..642ee12160 100644 --- a/src/sunstone/models/OpenNebulaJSON/AclJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/AclJSON.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/sunstone/models/OpenNebulaJSON/ClusterJSON.rb b/src/sunstone/models/OpenNebulaJSON/ClusterJSON.rb index a6cfe414e7..c2d8a09c12 100644 --- a/src/sunstone/models/OpenNebulaJSON/ClusterJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/ClusterJSON.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/sunstone/models/OpenNebulaJSON/DatastoreJSON.rb b/src/sunstone/models/OpenNebulaJSON/DatastoreJSON.rb index 095f30d61a..e7ff02b4ea 100644 --- a/src/sunstone/models/OpenNebulaJSON/DatastoreJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/DatastoreJSON.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/sunstone/models/OpenNebulaJSON/GroupJSON.rb b/src/sunstone/models/OpenNebulaJSON/GroupJSON.rb index 35e01f1403..8d46f4bdc3 100644 --- a/src/sunstone/models/OpenNebulaJSON/GroupJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/GroupJSON.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/sunstone/models/OpenNebulaJSON/HostJSON.rb b/src/sunstone/models/OpenNebulaJSON/HostJSON.rb index 3ca11ecb0b..196010d609 100644 --- a/src/sunstone/models/OpenNebulaJSON/HostJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/HostJSON.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb b/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb index 6224ef063c..3d5dc124cc 100644 --- a/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/sunstone/models/OpenNebulaJSON/JSONUtils.rb b/src/sunstone/models/OpenNebulaJSON/JSONUtils.rb index 8b60fb8e87..a2098d74bc 100644 --- a/src/sunstone/models/OpenNebulaJSON/JSONUtils.rb +++ b/src/sunstone/models/OpenNebulaJSON/JSONUtils.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/sunstone/models/OpenNebulaJSON/PoolJSON.rb b/src/sunstone/models/OpenNebulaJSON/PoolJSON.rb index 791b723645..b3b71ecaed 100644 --- a/src/sunstone/models/OpenNebulaJSON/PoolJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/PoolJSON.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/sunstone/models/OpenNebulaJSON/TemplateJSON.rb b/src/sunstone/models/OpenNebulaJSON/TemplateJSON.rb index ce5e1c0f68..4fe9f74bd2 100644 --- a/src/sunstone/models/OpenNebulaJSON/TemplateJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/TemplateJSON.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/sunstone/models/OpenNebulaJSON/UserJSON.rb b/src/sunstone/models/OpenNebulaJSON/UserJSON.rb index ebf4338802..3bd88c60d0 100644 --- a/src/sunstone/models/OpenNebulaJSON/UserJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/UserJSON.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb b/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb index c44524b2d0..5fcef2fb4f 100644 --- a/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -29,12 +29,6 @@ module OpenNebulaJSON if vm_hash['vm_raw'] template = vm_hash['vm_raw'] - elsif vm_hash['template_id'] - template_id = vm_hash['template_id'] - - template = "TEMPLATE_ID = #{template_id}" - template << "\nNAME = #{vm_hash['vm_name']}" if vm_hash['vm_name'] - else template = template_to_str(vm_hash) end diff --git a/src/sunstone/models/OpenNebulaJSON/VirtualNetworkJSON.rb b/src/sunstone/models/OpenNebulaJSON/VirtualNetworkJSON.rb index 74a67df77f..614f6a4fdc 100644 --- a/src/sunstone/models/OpenNebulaJSON/VirtualNetworkJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/VirtualNetworkJSON.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/sunstone/models/SunstoneMarketplace.rb b/src/sunstone/models/SunstoneMarketplace.rb index c2dcad8217..56f507e284 100644 --- a/src/sunstone/models/SunstoneMarketplace.rb +++ b/src/sunstone/models/SunstoneMarketplace.rb @@ -1,5 +1,5 @@ # ---------------------------------------------------------------------------- # -# Copyright 2010-2012, C12G Labs S.L # +# Copyright 2010-2013, C12G Labs S.L # # # # 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 # diff --git a/src/sunstone/models/SunstonePlugins.rb b/src/sunstone/models/SunstonePlugins.rb index 50ad003d64..ac146b88e9 100644 --- a/src/sunstone/models/SunstonePlugins.rb +++ b/src/sunstone/models/SunstonePlugins.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/sunstone/models/SunstoneServer.rb b/src/sunstone/models/SunstoneServer.rb index e49c6bb79c..8fa4016c74 100644 --- a/src/sunstone/models/SunstoneServer.rb +++ b/src/sunstone/models/SunstoneServer.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -209,7 +209,7 @@ class SunstoneServer < CloudServer return [404, nil] else if !ONE_LOCATION - vm_log_file = LOG_LOCATION + "/vms/#{id}.log" + vm_log_file = LOG_LOCATION + "/#{id}.log" else vm_log_file = LOG_LOCATION + "/vms/#{id}/vm.log" end diff --git a/src/sunstone/public/css/application.css b/src/sunstone/public/css/application.css index 1f995c3d9b..607205ad3f 100644 --- a/src/sunstone/public/css/application.css +++ b/src/sunstone/public/css/application.css @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/css/layout.css b/src/sunstone/public/css/layout.css index 10594db12a..1d2f2e7e37 100644 --- a/src/sunstone/public/css/layout.css +++ b/src/sunstone/public/css/layout.css @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/css/login.css b/src/sunstone/public/css/login.css index 3921199404..833f1b855a 100644 --- a/src/sunstone/public/css/login.css +++ b/src/sunstone/public/css/login.css @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/js/layout.js b/src/sunstone/public/js/layout.js index 049e895644..1fde922a16 100644 --- a/src/sunstone/public/js/layout.js +++ b/src/sunstone/public/js/layout.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/js/locale.js b/src/sunstone/public/js/locale.js index b53137fc6a..7cbbb7f714 100644 --- a/src/sunstone/public/js/locale.js +++ b/src/sunstone/public/js/locale.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/js/login.js b/src/sunstone/public/js/login.js index a1012c14e6..645c6207fe 100644 --- a/src/sunstone/public/js/login.js +++ b/src/sunstone/public/js/login.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/js/monitoring.js b/src/sunstone/public/js/monitoring.js index 98244595e7..2fac4dfb0a 100644 --- a/src/sunstone/public/js/monitoring.js +++ b/src/sunstone/public/js/monitoring.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/js/opennebula.js b/src/sunstone/public/js/opennebula.js index 5c1f5d53c4..1c83d43f38 100644 --- a/src/sunstone/public/js/opennebula.js +++ b/src/sunstone/public/js/opennebula.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -102,14 +102,16 @@ var OpenNebula = { "SHUTDOWN", "CANCEL", "FAILURE", - "CLEANUP", + "CLEANUP_RESUBMIT", "UNKNOWN", "HOTPLUG", "SHUTDOWN_POWEROFF", "BOOT_UNKNOWN", "BOOT_POWEROFF", "BOOT_SUSPENDED", - "BOOT_STOPPED"][value]); + "BOOT_STOPPED", + "CLEANUP_DELETE", + "HOTPLUG_SNAPSHOT"][value]); break; case "IMAGE": case "image": diff --git a/src/sunstone/public/js/plugins/acls-tab.js b/src/sunstone/public/js/plugins/acls-tab.js index 5c749cc7c9..d7a2fd4142 100644 --- a/src/sunstone/public/js/plugins/acls-tab.js +++ b/src/sunstone/public/js/plugins/acls-tab.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/js/plugins/clusters-tab.js b/src/sunstone/public/js/plugins/clusters-tab.js index c276fc02df..da070921b8 100644 --- a/src/sunstone/public/js/plugins/clusters-tab.js +++ b/src/sunstone/public/js/plugins/clusters-tab.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/js/plugins/config-tab.js b/src/sunstone/public/js/plugins/config-tab.js index 418f02ad6e..d0b0e87aa3 100644 --- a/src/sunstone/public/js/plugins/config-tab.js +++ b/src/sunstone/public/js/plugins/config-tab.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/js/plugins/dashboard-tab.js b/src/sunstone/public/js/plugins/dashboard-tab.js index 42cc399ab2..f2cb811e6f 100644 --- a/src/sunstone/public/js/plugins/dashboard-tab.js +++ b/src/sunstone/public/js/plugins/dashboard-tab.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/js/plugins/dashboard-users-tab.js b/src/sunstone/public/js/plugins/dashboard-users-tab.js index 60042ec5d8..18329c0e48 100644 --- a/src/sunstone/public/js/plugins/dashboard-users-tab.js +++ b/src/sunstone/public/js/plugins/dashboard-users-tab.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/js/plugins/datastores-tab.js b/src/sunstone/public/js/plugins/datastores-tab.js index cac0a1aca7..41f4109974 100644 --- a/src/sunstone/public/js/plugins/datastores-tab.js +++ b/src/sunstone/public/js/plugins/datastores-tab.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/js/plugins/groups-tab.js b/src/sunstone/public/js/plugins/groups-tab.js index e54804be81..26fbdec850 100644 --- a/src/sunstone/public/js/plugins/groups-tab.js +++ b/src/sunstone/public/js/plugins/groups-tab.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/js/plugins/hosts-tab.js b/src/sunstone/public/js/plugins/hosts-tab.js index 9d1e2088c2..415afbdecd 100644 --- a/src/sunstone/public/js/plugins/hosts-tab.js +++ b/src/sunstone/public/js/plugins/hosts-tab.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/js/plugins/images-tab.js b/src/sunstone/public/js/plugins/images-tab.js index 829addbf10..34c4a02555 100644 --- a/src/sunstone/public/js/plugins/images-tab.js +++ b/src/sunstone/public/js/plugins/images-tab.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/js/plugins/infra-tab.js b/src/sunstone/public/js/plugins/infra-tab.js index 96f4606ac0..789fd02268 100644 --- a/src/sunstone/public/js/plugins/infra-tab.js +++ b/src/sunstone/public/js/plugins/infra-tab.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/js/plugins/marketplace-tab.js b/src/sunstone/public/js/plugins/marketplace-tab.js index e08f68449a..b4e309e4e4 100644 --- a/src/sunstone/public/js/plugins/marketplace-tab.js +++ b/src/sunstone/public/js/plugins/marketplace-tab.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2010-2012, C12G Labs S.L */ +/* Copyright 2010-2013, C12G Labs S.L */ /* */ /* 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 */ diff --git a/src/sunstone/public/js/plugins/system-tab.js b/src/sunstone/public/js/plugins/system-tab.js index 8dc7e4519a..0374c1b287 100644 --- a/src/sunstone/public/js/plugins/system-tab.js +++ b/src/sunstone/public/js/plugins/system-tab.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/js/plugins/templates-tab.js b/src/sunstone/public/js/plugins/templates-tab.js index 34017aa233..a31a74ee0d 100644 --- a/src/sunstone/public/js/plugins/templates-tab.js +++ b/src/sunstone/public/js/plugins/templates-tab.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/js/plugins/users-tab.js b/src/sunstone/public/js/plugins/users-tab.js index fb3fafc5df..a3b0d7c86a 100644 --- a/src/sunstone/public/js/plugins/users-tab.js +++ b/src/sunstone/public/js/plugins/users-tab.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js index 02a0169059..8610a6a79e 100644 --- a/src/sunstone/public/js/plugins/vms-tab.js +++ b/src/sunstone/public/js/plugins/vms-tab.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -50,7 +50,7 @@ var vm_graphs = [ ]; -var VNCstates=["RUNNING","SHUTDOWN","SHUTDOWN_POWEROFF","UNKNOWN","HOTPLUG","CANCEL","MIGRATE"]; +var VNCstates=["RUNNING","SHUTDOWN","SHUTDOWN_POWEROFF","UNKNOWN","HOTPLUG","CANCEL","MIGRATE", "HOTPLUG_SNAPSHOT"]; //Permanent storage for last value of aggregated network usage //Used to calculate bandwidth @@ -1649,4 +1649,4 @@ $(document).ready(function(){ infoListener(dataTable_vMachines,'VM.showinfo'); $('div#vms_tab div.legend_div').hide(); -}) \ No newline at end of file +}) diff --git a/src/sunstone/public/js/plugins/vnets-tab.js b/src/sunstone/public/js/plugins/vnets-tab.js index f11aa4a365..36a2156694 100644 --- a/src/sunstone/public/js/plugins/vnets-tab.js +++ b/src/sunstone/public/js/plugins/vnets-tab.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/js/plugins/vresources-tab.js b/src/sunstone/public/js/plugins/vresources-tab.js index 0e6d91f84a..3365eea780 100644 --- a/src/sunstone/public/js/plugins/vresources-tab.js +++ b/src/sunstone/public/js/plugins/vresources-tab.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/js/sunstone-util.js b/src/sunstone/public/js/sunstone-util.js index c2bc9fb84b..d54bdf6891 100644 --- a/src/sunstone/public/js/sunstone-util.js +++ b/src/sunstone/public/js/sunstone-util.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/sunstone/public/js/sunstone.js b/src/sunstone/public/js/sunstone.js index 01e5a9f4db..0003aa3b9c 100644 --- a/src/sunstone/public/js/sunstone.js +++ b/src/sunstone/public/js/sunstone.js @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -758,8 +758,15 @@ function popUpConfirmDialog(target_elem){ var value = $(target_elem).val(); var tab_id = $(target_elem).parents('.tab').attr('id'); var button = Sunstone.getButton(tab_id,value); - var tip = button.tip; + + if (button.tip == undefined) + var tip = tr("You have to confrim this action"); + else + var tip = button.tip + $('button#confirm_proceed',dialog).val(value); + + $('div#confirm_tip',dialog).text(tip); dialog.dialog("open"); } @@ -772,7 +779,12 @@ function popUpConfirmWithSelectDialog(target_elem){ var value = $(target_elem).val(); var tab_id = $(target_elem).parents('.tab').attr('id'); var button = Sunstone.getButton(tab_id,value); - var tip = button.tip; + + if (button.tip == undefined) + var tip = tr("You have to confrim this action"); + else + var tip = button.tip + var select_var = button.select(); $('select#confirm_select',dialog).html(select_var); $('div#confirm_with_select_tip',dialog).text(tip); diff --git a/src/sunstone/sunstone-server.rb b/src/sunstone/sunstone-server.rb index 5c260a33fc..35eac27f14 100755 --- a/src/sunstone/sunstone-server.rb +++ b/src/sunstone/sunstone-server.rb @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -80,7 +80,23 @@ set :config, conf set :bind, settings.config[:host] set :port, settings.config[:port] -use Rack::Session::Pool, :key => 'sunstone' +case settings.config[:sessions] +when 'memory' + use Rack::Session::Pool, :key => 'sunstone' +when 'memcache' + memcache_server=settings.config[:memcache_host]+':'<< + settings.config[:memcache_port].to_s + + STDERR.puts memcache_server + + use Rack::Session::Memcache, + :memcache_server => memcache_server, + :namespace => settings.config[:memcache_namespace] + +else + STDERR.puts "Wrong value for :sessions in configuration file" + exit(-1) +end # Enable logger @@ -104,10 +120,6 @@ set :cloud_auth, cloud_auth configure do set :run, false set :vnc, OpenNebulaVNC.new(conf, settings.logger) - settings.vnc.start() - Kernel.at_exit do - settings.vnc.stop - end end ############################################################################## @@ -396,4 +408,5 @@ post '/:resource/:id/action' do request.body.read) end -Sinatra::Application.run! +Sinatra::Application.run! if(!defined?(WITH_RACKUP)) + diff --git a/src/sunstone/test/spec/host_spec.rb b/src/sunstone/test/spec/host_spec.rb index 24a73aac3d..a65529a877 100644 --- a/src/sunstone/test/spec/host_spec.rb +++ b/src/sunstone/test/spec/host_spec.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/sunstone/test/spec/image_spec.rb b/src/sunstone/test/spec/image_spec.rb index 26372b91ff..45f8249d0a 100644 --- a/src/sunstone/test/spec/image_spec.rb +++ b/src/sunstone/test/spec/image_spec.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/sunstone/test/spec/spec_helper.rb b/src/sunstone/test/spec/spec_helper.rb index 94b6bae9ff..060b1d3ec3 100644 --- a/src/sunstone/test/spec/spec_helper.rb +++ b/src/sunstone/test/spec/spec_helper.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/sunstone/test/spec/user_spec.rb b/src/sunstone/test/spec/user_spec.rb index 844c85d5e5..e53b2e0d3d 100644 --- a/src/sunstone/test/spec/user_spec.rb +++ b/src/sunstone/test/spec/user_spec.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/sunstone/test/spec/vm_spec.rb b/src/sunstone/test/spec/vm_spec.rb index 8b58bdccdd..1d04fff8fa 100644 --- a/src/sunstone/test/spec/vm_spec.rb +++ b/src/sunstone/test/spec/vm_spec.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/sunstone/test/spec/vnet_spec.rb b/src/sunstone/test/spec/vnet_spec.rb index 8d30c91d96..f155c9a9be 100644 --- a/src/sunstone/test/spec/vnet_spec.rb +++ b/src/sunstone/test/spec/vnet_spec.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/sunstone/test/test.sh b/src/sunstone/test/test.sh index c266b7ccc6..2029975552 100755 --- a/src/sunstone/test/test.sh +++ b/src/sunstone/test/test.sh @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/template/SConstruct b/src/template/SConstruct index ae42cca414..d424abbdb4 100644 --- a/src/template/SConstruct +++ b/src/template/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/template # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/template/Template.cc b/src/template/Template.cc index 4905639714..05541db4ae 100644 --- a/src/template/Template.cc +++ b/src/template/Template.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -22,6 +22,8 @@ #include #include +#define TO_UPPER(S) transform(S.begin(),S.end(),S.begin(),(int(*)(int))toupper) + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -175,6 +177,11 @@ int Template::parse_str_or_xml(const string &parse_str, string& error_msg) } } + if(rc == 0) + { + trim_name(); + } + return rc; } @@ -473,6 +480,37 @@ bool Template::get( /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +bool Template::get( + const string& name, + bool& value) const +{ + string sval; + + get(name, sval); + + if ( sval == "" ) + { + value = false; + return false; + } + + TO_UPPER(sval); + + if ( sval == "YES" ) + { + value = true; + } + else + { + value = false; + } + + return true; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + string& Template::to_xml(string& xml) const { multimap::const_iterator it; @@ -521,6 +559,24 @@ string& Template::to_str(string& str) const /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +bool Template::trim(const string& name) +{ + string st; + get(name, st); + + if(st.empty()) + { + return false; + } + + replace(name, st.substr( 0, st.find_last_not_of(" \f\n\r\t\v") + 1 ) ); + + return true; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + ostream& operator << (ostream& os, const Template& t) { string str; @@ -635,6 +691,26 @@ int Template::from_xml_node(const xmlNodePtr node) /* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */ +int Template::merge(const Template * from_tmpl, string& error_str) +{ + multimap::const_iterator it; + + for (it = from_tmpl->attributes.begin(); it != from_tmpl->attributes.end(); ++it) + { + this->erase(it->first); + } + + for (it = from_tmpl->attributes.begin(); it != from_tmpl->attributes.end(); ++it) + { + this->set(it->second->clone()); + } + + return 0; +} + +/* ------------------------------------------------------------------------ */ +/* ------------------------------------------------------------------------ */ + void Template::rebuild_attributes(const xmlNode * root_element) { xmlNode * cur_node = 0; diff --git a/src/template/template_parser.c b/src/template/template_parser.c index 61f1818828..2c473ec80d 100644 --- a/src/template/template_parser.c +++ b/src/template/template_parser.c @@ -522,7 +522,7 @@ int template__flex_debug = 0; char *template_text; #line 1 "template_parser.l" /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/template/template_parser.l b/src/template/template_parser.l index bbeba770aa..84b1b16b5b 100644 --- a/src/template/template_parser.l +++ b/src/template/template_parser.l @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/template/template_syntax.cc b/src/template/template_syntax.cc index b8d43da3ae..341db2a4fd 100644 --- a/src/template/template_syntax.cc +++ b/src/template/template_syntax.cc @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.6.5. */ +/* A Bison parser, made by GNU Bison 2.7. */ /* Bison implementation for Yacc-like parsers in C @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.6.5" +#define YYBISON_VERSION "2.7" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -70,7 +70,7 @@ #define yylloc template__lloc /* Copy the first part of user declarations. */ -/* Line 360 of yacc.c */ +/* Line 371 of yacc.c */ #line 17 "template_syntax.y" #include @@ -122,7 +122,7 @@ extern "C" } -/* Line 360 of yacc.c */ +/* Line 371 of yacc.c */ #line 127 "template_syntax.cc" # ifndef YY_NULL @@ -173,14 +173,14 @@ extern int template__debug; #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE { -/* Line 376 of yacc.c */ +/* Line 387 of yacc.c */ #line 74 "template_syntax.y" char * val_str; void * val_attr; -/* Line 376 of yacc.c */ +/* Line 387 of yacc.c */ #line 185 "template_syntax.cc" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 @@ -220,7 +220,7 @@ int template__parse (); /* Copy the second part of user declarations. */ -/* Line 379 of yacc.c */ +/* Line 390 of yacc.c */ #line 225 "template_syntax.cc" #ifdef short @@ -695,14 +695,46 @@ while (YYID (0)) #ifndef YY_LOCATION_PRINT # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - do { \ - fprintf (File, "%d.%d", (Loc).first_line, (Loc).first_column); \ - if ((Loc).first_line < (Loc).last_line) \ - fprintf (File, "-%d.%d", (Loc).last_line, (Loc).last_column - 1); \ - else if ((Loc).first_column < (Loc).last_column - 1) \ - fprintf (File, "-%d", (Loc).last_column - 1); \ - } while (0) + +/* Print *YYLOCP on YYO. Private, do not rely on its existence. */ + +__attribute__((__unused__)) +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static unsigned +yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp) +#else +static unsigned +yy_location_print_ (yyo, yylocp) + FILE *yyo; + YYLTYPE const * const yylocp; +#endif +{ + unsigned res = 0; + int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0; + if (0 <= yylocp->first_line) + { + res += fprintf (yyo, "%d", yylocp->first_line); + if (0 <= yylocp->first_column) + res += fprintf (yyo, ".%d", yylocp->first_column); + } + if (0 <= yylocp->last_line) + { + if (yylocp->first_line < yylocp->last_line) + { + res += fprintf (yyo, "-%d", yylocp->last_line); + if (0 <= end_col) + res += fprintf (yyo, ".%d", end_col); + } + else if (0 <= end_col && yylocp->first_column < end_col) + res += fprintf (yyo, "-%d", end_col); + } + return res; + } + +# define YY_LOCATION_PRINT(File, Loc) \ + yy_location_print_ (File, &(Loc)) + # else # define YY_LOCATION_PRINT(File, Loc) ((void) 0) # endif @@ -780,7 +812,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, mc, tmpl, error_ switch (yytype) { default: - break; + break; } } @@ -1032,7 +1064,6 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, { YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ const char *yyformat = YY_NULL; @@ -1095,11 +1126,13 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, break; } yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; + { + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } } } } @@ -1119,10 +1152,12 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, # undef YYCASE_ } - yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; + { + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } if (*yymsg_alloc < yysize) { @@ -1190,7 +1225,7 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp, mc, tmpl, error_msg) { default: - break; + break; } } @@ -1243,6 +1278,11 @@ int yychar; static YYSTYPE yyval_default; # define YY_INITIAL_VALUE(Value) = Value #endif +static YYLTYPE yyloc_default +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL + = { 1, 1, 1, 1 } +# endif +; #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_END @@ -1255,11 +1295,7 @@ static YYSTYPE yyval_default; YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); /* Location data for the lookahead symbol. */ -YYLTYPE yylloc -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL - = { 1, 1, 1, 1 } -# endif -; +YYLTYPE yylloc = yyloc_default; /* Number of syntax errors so far. */ @@ -1516,7 +1552,7 @@ yyreduce: switch (yyn) { case 6: -/* Line 1778 of yacc.c */ +/* Line 1792 of yacc.c */ #line 103 "template_syntax.y" { Attribute * pattr; @@ -1530,7 +1566,7 @@ yyreduce: break; case 7: -/* Line 1778 of yacc.c */ +/* Line 1792 of yacc.c */ #line 113 "template_syntax.y" { Attribute * pattr; @@ -1547,7 +1583,7 @@ yyreduce: break; case 8: -/* Line 1778 of yacc.c */ +/* Line 1792 of yacc.c */ #line 126 "template_syntax.y" { Attribute * pattr; @@ -1561,7 +1597,7 @@ yyreduce: break; case 9: -/* Line 1778 of yacc.c */ +/* Line 1792 of yacc.c */ #line 138 "template_syntax.y" { map* vattr; @@ -1578,7 +1614,7 @@ yyreduce: break; case 10: -/* Line 1778 of yacc.c */ +/* Line 1792 of yacc.c */ #line 151 "template_syntax.y" { string name((yyvsp[(3) - (5)].val_str)); @@ -1595,8 +1631,8 @@ yyreduce: break; -/* Line 1778 of yacc.c */ -#line 1600 "template_syntax.cc" +/* Line 1792 of yacc.c */ +#line 1636 "template_syntax.cc" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -1834,7 +1870,7 @@ yyreturn: } -/* Line 2041 of yacc.c */ +/* Line 2055 of yacc.c */ #line 164 "template_syntax.y" diff --git a/src/template/template_syntax.h b/src/template/template_syntax.h index 389697a95a..a026114762 100644 --- a/src/template/template_syntax.h +++ b/src/template/template_syntax.h @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.6.5. */ +/* A Bison parser, made by GNU Bison 2.7. */ /* Bison interface for Yacc-like parsers in C @@ -60,14 +60,14 @@ extern int template__debug; #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE { -/* Line 2042 of yacc.c */ +/* Line 2058 of yacc.c */ #line 74 "template_syntax.y" char * val_str; void * val_attr; -/* Line 2042 of yacc.c */ +/* Line 2058 of yacc.c */ #line 72 "template_syntax.hh" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 diff --git a/src/template/template_syntax.y b/src/template/template_syntax.y index 6be981f9d6..4c234e5074 100644 --- a/src/template/template_syntax.y +++ b/src/template/template_syntax.y @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/template/test/SConstruct b/src/template/test/SConstruct index 5c798ef0f5..186e01d6a2 100644 --- a/src/template/test/SConstruct +++ b/src/template/test/SConstruct @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/test/Nebula.cc b/src/test/Nebula.cc index 42563416c3..47603e392a 100644 --- a/src/test/Nebula.cc +++ b/src/test/Nebula.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/test/NebulaTest.cc b/src/test/NebulaTest.cc index 8be19530c8..94e5b620f8 100644 --- a/src/test/NebulaTest.cc +++ b/src/test/NebulaTest.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/test/OneUnitTest.cc b/src/test/OneUnitTest.cc index ad1fae8ce0..46d85c56c6 100644 --- a/src/test/OneUnitTest.cc +++ b/src/test/OneUnitTest.cc @@ -1,6 +1,6 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/test/SConstruct b/src/test/SConstruct index 26f33152d2..7fd2fae818 100644 --- a/src/test/SConstruct +++ b/src/test/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/test # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/tm/SConstruct b/src/tm/SConstruct index d6842df239..1bce1446d8 100644 --- a/src/tm/SConstruct +++ b/src/tm/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/vm # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/tm/TransferManager.cc b/src/tm/TransferManager.cc index 712ded9e8c..73393a8456 100644 --- a/src/tm/TransferManager.cc +++ b/src/tm/TransferManager.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -115,6 +115,10 @@ void TransferManager::trigger(Actions action, int _vid) aname = "EPILOG_DELETE_PREVIOUS"; break; + case EPILOG_DELETE_BOTH: + aname = "EPILOG_DELETE_BOTH"; + break; + case CHECKPOINT: aname = "CHECKPOINT"; break; @@ -183,6 +187,10 @@ void TransferManager::do_action(const string &action, void * arg) { epilog_delete_previous_action(vid); } + else if (action == "EPILOG_DELETE_BOTH") + { + epilog_delete_both_action(vid); + } else if (action == "CHECKPOINT") { checkpoint_action(vid); @@ -937,14 +945,28 @@ void TransferManager::epilog_transfer_command( } else //No saving disk { - //DELETE tm_mad hostname:remote_system_dir/disk.i vmid ds_id - xfr << "DELETE " - << vm->get_tm_mad() << " " - << vm->get_hostname() << ":" - << vm->get_remote_system_dir() << "/disk." << disk_id << " " - << vm->get_oid() << " " - << vm->get_ds_id() - << endl; + if ( isVolatile(disk) == true ) + { + tm_mad = vm->get_tm_mad(); + ds_id = vm->get_ds_id(); + } + else + { + tm_mad = disk->vector_value("TM_MAD"); + ds_id = disk->vector_value("DATASTORE_ID"); + } + + if ( !tm_mad.empty() && !ds_id.empty() ) + { + //DELETE tm_mad hostname:remote_system_dir/disk.i vmid ds_id + xfr << "DELETE " + << tm_mad << " " + << vm->get_hostname() << ":" + << vm->get_remote_system_dir() << "/disk." << disk_id << " " + << vm->get_oid() << " " + << ds_id + << endl; + } } } @@ -1195,61 +1217,74 @@ error_common: return; } + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -void TransferManager::epilog_delete_action(bool local, int vid) +int TransferManager::epilog_delete_commands(VirtualMachine *vm, + ostream& xfr, + bool local, + bool previous) { - ofstream xfr; ostringstream os; - string xfr_name; string vm_tm_mad; string tm_mad; string vm_ds_id; string ds_id; + string host; + string system_dir; + int disk_id; - VirtualMachine * vm; - Nebula& nd = Nebula::instance(); - - const TransferManagerDriver * tm_md; + Nebula& nd = Nebula::instance(); const VectorAttribute * disk; vector attrs; int num; // ------------------------------------------------------------------------ - // Setup & Transfer script + // Setup transfer // ------------------------------------------------------------------------ - vm = vmpool->get(vid,true); - - if (vm == 0) - { - return; - } - if (!vm->hasHistory()) { goto error_history; } - vm_tm_mad = vm->get_tm_mad(); - vm_ds_id = vm->get_ds_id(); - tm_md = get(); - - if ( tm_md == 0 || vm_tm_mad.empty() || vm_ds_id.empty()) + if (local) { - goto error_drivers; + host = nd.get_nebula_hostname(); + system_dir = vm->get_system_dir(); + + vm_tm_mad = vm->get_tm_mad(); + vm_ds_id = vm->get_ds_id(); + } + else if (previous) + { + if (!vm->hasPreviousHistory()) + { + goto error_history; + } + + host = vm->get_previous_hostname(); + system_dir = vm->get_remote_system_dir(); + + vm_tm_mad = vm->get_previous_tm_mad(); + vm_ds_id = vm->get_previous_ds_id(); + } + else + { + host = vm->get_hostname(); + system_dir = vm->get_remote_system_dir(); + + vm_tm_mad = vm->get_tm_mad(); + vm_ds_id = vm->get_ds_id(); } - xfr_name = vm->get_transfer_file() + ".delete"; - xfr.open(xfr_name.c_str(), ios::out | ios::trunc); - - if (xfr.fail() == true) + if ( vm_tm_mad.empty() || vm_ds_id.empty()) { - goto error_file; + goto error_drivers; } // ------------------------------------------------------------------------- @@ -1284,103 +1319,57 @@ void TransferManager::epilog_delete_action(bool local, int vid) } } - if ( local ) - { - //DELETE tm_mad fe:system_dir/disk.i vmid dsid - xfr << "DELETE " - << tm_mad << " " - << nd.get_nebula_hostname() << ":" - << vm->get_system_dir() << "/disk." << disk_id << " " - << vm->get_oid() << " " - << ds_id << endl; - } - else - { - //DELETE tm_mad host:remote_system_dir/disk.i vmid dsid - xfr << "DELETE " - << tm_mad << " " - << vm->get_hostname() << ":" - << vm->get_remote_system_dir() << "/disk." << disk_id << " " - << vm->get_oid() << " " - << ds_id << endl; - } - } - - if ( local ) - { - //DELETE vm_tm_mad fe:system_dir vmid dsid(=0) + //DELETE tm_mad host:remote_system_dir/disk.i vmid dsid + // *local* DELETE tm_mad fe:system_dir/disk.i vmid dsid + // *prev* DELETE tm_mad prev_host:remote_system_dir/disk.i vmid ds_id xfr << "DELETE " - << vm_tm_mad << " " - << nd.get_nebula_hostname() <<":"<< vm->get_system_dir() << " " + << tm_mad << " " + << host << ":" + << system_dir << "/disk." << disk_id << " " << vm->get_oid() << " " - << vm_ds_id; - } - else - { - //DELETE vm_tm_mad hostname:remote_system_dir vmid dsid(=0) - xfr << "DELETE " - << vm_tm_mad << " " - << vm->get_hostname() <<":"<< vm->get_remote_system_dir() << " " - << vm->get_oid() << " " - << vm_ds_id; + << ds_id << endl; } - xfr.close(); + //DELETE vm_tm_mad hostname:remote_system_dir vmid dsid + // *local* DELETE vm_tm_mad fe:system_dir vmid dsid + // *prev* DELTE vm_tm_mad prev_host:remote_system_dir vmid ds_id + xfr << "DELETE " + << vm_tm_mad << " " + << host <<":"<< system_dir << " " + << vm->get_oid() << " " + << vm_ds_id << endl; - tm_md->transfer(vid,xfr_name); - - vm->unlock(); - return; + return 0; error_history: - os.str(""); - os << "epilog_delete, VM " << vid << " has no history"; + os << "epilog_delete, VM " << vm->get_oid() << " missing history record"; goto error_common; error_drivers: - os.str(""); os << "epilog_delete, error getting drivers."; goto error_common; -error_file: - os.str(""); - os << "epilog_delete, could not open file: " << xfr_name; - os << ". You may need to manually clean " << vm->get_hostname() - << ":" << vm->get_remote_system_dir(); - goto error_common; - error_common: vm->log("TM", Log::ERROR, os); - (nd.get_lcm())->trigger(LifeCycleManager::EPILOG_FAILURE,vid); - - vm->unlock(); - return; + return -1; } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -void TransferManager::epilog_delete_previous_action(int vid) +void TransferManager::epilog_delete_action(bool local, int vid) { - ofstream xfr; ostringstream os; - string xfr_name; - string vm_tm_mad; - string tm_mad; - string vm_ds_id; - string ds_id; - - int disk_id; + ofstream xfr; + string xfr_name; VirtualMachine * vm; Nebula& nd = Nebula::instance(); const TransferManagerDriver * tm_md; - const VectorAttribute * disk; - vector attrs; - int num; + int rc; // ------------------------------------------------------------------------ // Setup & Transfer script @@ -1392,18 +1381,84 @@ void TransferManager::epilog_delete_previous_action(int vid) return; } - if (!vm->hasHistory() || !vm->hasPreviousHistory()) + tm_md = get(); + + if ( tm_md == 0 ) { - goto error_history; + goto error_driver; } - vm_tm_mad = vm->get_previous_tm_mad(); - vm_ds_id = vm->get_previous_ds_id(); - tm_md = get(); + xfr_name = vm->get_transfer_file() + ".delete"; + xfr.open(xfr_name.c_str(), ios::out | ios::trunc); - if ( tm_md == 0 || vm_tm_mad.empty() || vm_ds_id.empty() ) + if (xfr.fail() == true) { - goto error_drivers; + goto error_file; + } + + rc = epilog_delete_commands(vm, xfr, local, false); + + if ( rc != 0 ) + { + goto error_common; + } + + xfr.close(); + + tm_md->transfer(vid,xfr_name); + + vm->unlock(); + return; + +error_driver: + os << "epilog_delete, error getting TM driver."; + goto error_common; + +error_file: + os << "epilog_delete, could not open file: " << xfr_name; + os << ". You may need to manually clean the host (current)"; + goto error_common; + +error_common: + vm->log("TM", Log::ERROR, os); + (nd.get_lcm())->trigger(LifeCycleManager::EPILOG_FAILURE, vid); + + vm->unlock(); + return; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void TransferManager::epilog_delete_previous_action(int vid) +{ + ostringstream os; + + ofstream xfr; + string xfr_name; + + VirtualMachine * vm; + Nebula& nd = Nebula::instance(); + + const TransferManagerDriver * tm_md; + + int rc; + + // ------------------------------------------------------------------------ + // Setup & Transfer script + // ------------------------------------------------------------------------ + vm = vmpool->get(vid,true); + + if (vm == 0) + { + return; + } + + tm_md = get(); + + if (tm_md == 0) + { + goto error_driver; } xfr_name = vm->get_transfer_file() + ".delete_prev"; @@ -1414,81 +1469,106 @@ void TransferManager::epilog_delete_previous_action(int vid) goto error_file; } - // ------------------------------------------------------------------------ - // Delete the remote VM Directory - // ------------------------------------------------------------------------ - num = vm->get_template_attribute("DISK",attrs); + rc = epilog_delete_commands(vm, xfr, false, true); - for (int i=0 ; i < num ; i++) + if ( rc != 0 ) { - disk = dynamic_cast(attrs[i]); - - if ( disk == 0 ) - { - continue; - } - - disk->vector_value_str("DISK_ID", disk_id); - - if ( isVolatile(disk) == true ) - { - tm_mad = vm_tm_mad; - ds_id = vm_ds_id; - } - else - { - tm_mad = disk->vector_value("TM_MAD"); - ds_id = disk->vector_value("DATASTORE_ID"); - - if ( tm_mad.empty() || ds_id.empty() ) - { - continue; - } - } - - //DELETE tm_mad prev_host:remote_system_dir/disk.i vmid ds_id - xfr << "DELETE " - << tm_mad << " " - << vm->get_previous_hostname() << ":" - << vm->get_remote_system_dir() << "/disk." << disk_id << " " - << vm->get_oid() << " " - << ds_id << endl; + goto error_common; } - //DELTE vm_tm_mad prev_host:remote_system_dir vmid ds_id(=0) - xfr << "DELETE " - << vm_tm_mad << " " - << vm->get_previous_hostname() <<":"<< vm->get_remote_system_dir() - << " " << vm->get_oid() << " " - << vm_ds_id << endl; - xfr.close(); - tm_md->transfer(vid,xfr_name); + tm_md->transfer(vid, xfr_name); vm->unlock(); return; -error_history: - os.str(""); - os << "epilog_delete_previous, VM " << vid << " has no history"; - goto error_common; - -error_drivers: - os.str(""); - os << "epilog_delete_previous, error getting drivers."; +error_driver: + os << "epilog_delete_previous, error getting TM driver."; goto error_common; error_file: - os.str(""); os << "epilog_delete_previous, could not open file: " << xfr_name; - os << ". You may need to manually clean " << vm->get_previous_hostname() - << ":" << vm->get_remote_system_dir(); + os << ". You may need to manually clean the host (previous)"; goto error_common; error_common: - (nd.get_lcm())->trigger(LifeCycleManager::EPILOG_FAILURE,vid); vm->log("TM", Log::ERROR, os); + (nd.get_lcm())->trigger(LifeCycleManager::EPILOG_FAILURE, vid); + + vm->unlock(); + return; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void TransferManager::epilog_delete_both_action(int vid) +{ + ostringstream os; + + ofstream xfr; + string xfr_name; + + VirtualMachine * vm; + Nebula& nd = Nebula::instance(); + + const TransferManagerDriver * tm_md; + + int rc; + + // ------------------------------------------------------------------------ + // Setup & Transfer script + // ------------------------------------------------------------------------ + vm = vmpool->get(vid,true); + + if (vm == 0) + { + return; + } + + tm_md = get(); + + if (tm_md == 0) + { + goto error_driver; + } + + xfr_name = vm->get_transfer_file() + ".delete_both"; + xfr.open(xfr_name.c_str(),ios::out | ios::trunc); + + if (xfr.fail() == true) + { + goto error_file; + } + + rc = epilog_delete_commands(vm, xfr, false, false); //current + rc = epilog_delete_commands(vm, xfr, false, true); //previous + + if ( rc != 0 ) + { + goto error_common; + } + + xfr.close(); + + tm_md->transfer(vid, xfr_name); + + vm->unlock(); + return; + +error_driver: + os << "epilog_delete_both, error getting TM driver."; + goto error_common; + +error_file: + os << "epilog_delete_both, could not open file: " << xfr_name; + os << ". You may need to manually clean hosts (previous & current)"; + goto error_common; + +error_common: + vm->log("TM", Log::ERROR, os); + (nd.get_lcm())->trigger(LifeCycleManager::EPILOG_FAILURE, vid); vm->unlock(); return; diff --git a/src/tm/TransferManagerDriver.cc b/src/tm/TransferManagerDriver.cc index dbabe4e9da..7f5e85cc79 100644 --- a/src/tm/TransferManagerDriver.cc +++ b/src/tm/TransferManagerDriver.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -127,7 +127,7 @@ void TransferManagerDriver::protocol( case VirtualMachine::EPILOG: case VirtualMachine::EPILOG_STOP: - case VirtualMachine::CLEANUP: + case VirtualMachine::CLEANUP_RESUBMIT: lcm_action = LifeCycleManager::EPILOG_SUCCESS; break; @@ -164,7 +164,7 @@ void TransferManagerDriver::protocol( case VirtualMachine::EPILOG: case VirtualMachine::EPILOG_STOP: - case VirtualMachine::CLEANUP: + case VirtualMachine::CLEANUP_RESUBMIT: lcm_action = LifeCycleManager::EPILOG_FAILURE; break; diff --git a/src/tm_mad/ceph/clone b/src/tm_mad/ceph/clone new file mode 100755 index 0000000000..25a8d96401 --- /dev/null +++ b/src/tm_mad/ceph/clone @@ -0,0 +1,75 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# 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. # +#--------------------------------------------------------------------------- # + +# clone fe:SOURCE host:remote_system_ds/disk.i size +# - fe is the front-end hostname +# - SOURCE is the path of the disk image in the form DS_BASE_PATH/disk +# - host is the target host to deploy the VM +# - remote_system_ds is the path for the system datastore in the host + +SRC=$1 +DST=$2 +VM_ID=$3 +DS_ID=$4 + +if [ -z "${ONE_LOCATION}" ]; then + TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh +else + TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh +fi + +DRIVER_PATH=$(dirname $0) + +source $TMCOMMON +source ${DRIVER_PATH}/../../datastore/ceph/ceph.conf + +#------------------------------------------------------------------------------- +# Get Image information +#------------------------------------------------------------------------------- + +DISK_ID=$(echo "$DST_PATH" | $AWK -F. '{print $NF}') + +XPATH="${DRIVER_PATH}/../../datastore/xpath.rb --stdin" + +unset i XPATH_ELEMENTS + +while IFS= read -r -d '' element; do + XPATH_ELEMENTS[i++]="$element" +done < <(onedatastore show -x $DS_ID | $XPATH \ + /DATASTORE/TEMPLATE/HOST) + +unset i + +CEPH_HOST="${XPATH_ELEMENTS[i++]}" + +#------------------------------------------------------------------------------- +# Compute the destination image name +#------------------------------------------------------------------------------- + +SRC_PATH=`arg_path $SRC` + +DISK_ID=$(echo $DST|awk -F. '{print $NF}') +RBD_DST="${SRC_PATH}-${VM_ID}-${DISK_ID}" + +#------------------------------------------------------------------------------- +# Clone the image +#------------------------------------------------------------------------------- + +ssh_exec_and_log "$CEPH_HOST" "$RBD copy $SRC_PATH $RBD_DST" \ + "Error cloning $SRC_PATH to $RBD_DST in $CEPH_HOST" +exit 0 diff --git a/src/tm_mad/ceph/delete b/src/tm_mad/ceph/delete new file mode 100755 index 0000000000..3adff3d505 --- /dev/null +++ b/src/tm_mad/ceph/delete @@ -0,0 +1,93 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# 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. # +#--------------------------------------------------------------------------- # + +# DELETE +# - host is the target host to deploy the VM +# - remote_system_ds is the path for the system datastore in the host + +DST=$1 +VM_ID=$2 +DS_ID=$3 + +if [ -z "${ONE_LOCATION}" ]; then + TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh +else + TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh +fi + +DRIVER_PATH=$(dirname $0) + +source $TMCOMMON +source ${DRIVER_PATH}/../../datastore/ceph/ceph.conf + +#------------------------------------------------------------------------------- +# Process destination +#------------------------------------------------------------------------------- + +DST_PATH=`arg_path $DST` +DST_HOST=`arg_host $DST` + +#------------------------------------------------------------------------------- +# Delete and exit if directory +#------------------------------------------------------------------------------- + +if [ `is_disk $DST_PATH` -eq 0 ]; then + # Directory + log "Deleting $DST_PATH" + ssh_exec_and_log "$DST_HOST" "rm -rf $DST_PATH" "Error deleting $DST_PATH" + exit 0 +fi + +#------------------------------------------------------------------------------- +# Get Image information +#------------------------------------------------------------------------------- + +DISK_ID=$(echo "$DST_PATH" | $AWK -F. '{print $NF}') + +XPATH="${DRIVER_PATH}/../../datastore/xpath.rb --stdin" + +unset i j XPATH_ELEMENTS + +while IFS= read -r -d '' element; do + XPATH_ELEMENTS[i++]="$element" +done < <(onevm show -x $VM_ID| $XPATH \ + /VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/SOURCE \ + /VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/PERSISTENT) + +SRC="${XPATH_ELEMENTS[j++]}" +PERSISTENT="${XPATH_ELEMENTS[j++]}" + +# Exit if persistent +[ -n "$PERSISTENT" ] && exit 0 + +# non persistent, so the name will be "/one---" +RBD_SRC="${SRC}-${VM_ID}-${DISK_ID}" + +#------------------------------------------------------------------------------- +# Delete the device +#------------------------------------------------------------------------------- + +log "Deleting $DST_PATH" + +# Note that this command, as opposed to the rest of $RBD commands in this set of +# drivers, is executed in the worker node and not in the CEPH frontend. + +ssh_exec_and_log "$DST_HOST" "$RBD rm $RBD_SRC" \ + "Error deleting $RBD_SRC in $DST_HOST" + +exit 0 diff --git a/src/tm_mad/ceph/ln b/src/tm_mad/ceph/ln new file mode 100755 index 0000000000..b9925ea312 --- /dev/null +++ b/src/tm_mad/ceph/ln @@ -0,0 +1,25 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# 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. # +#--------------------------------------------------------------------------- # + +# clone fe:SOURCE host:remote_system_ds/disk.i size +# - fe is the front-end hostname +# - SOURCE is the path of the disk image in the form DS_BASE_PATH/disk +# - host is the target host to deploy the VM +# - remote_system_ds is the path for the system datastore in the host + +exit 0 diff --git a/src/tm_mad/ceph/mv b/src/tm_mad/ceph/mv new file mode 100755 index 0000000000..2c409c7eac --- /dev/null +++ b/src/tm_mad/ceph/mv @@ -0,0 +1,19 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# 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. # +#--------------------------------------------------------------------------- # + +exit 0 diff --git a/src/tm_mad/ceph/mvds b/src/tm_mad/ceph/mvds new file mode 100755 index 0000000000..b777e5d3bb --- /dev/null +++ b/src/tm_mad/ceph/mvds @@ -0,0 +1,82 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# 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. # +#--------------------------------------------------------------------------- # + +# mvds host:remote_system_ds/disk.i fe:SOURCE +# - fe is the front-end hostname +# - SOURCE is the path of the disk image in the form DS_BASE_PATH/disk +# - host is the target host to deploy the VM +# - remote_system_ds is the path for the system datastore in the host + +SRC=$1 +DST=$2 +VM_ID=$3 +DS_ID=$4 + +if [ -z "${ONE_LOCATION}" ]; then + TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh +else + TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh +fi + +DRIVER_PATH=$(dirname $0) + +source $TMCOMMON +source ${DRIVER_PATH}/../../datastore/ceph/ceph.conf + +#------------------------------------------------------------------------------- +# Set dst path and dir +#------------------------------------------------------------------------------- + +SRC_HOST=`arg_host $SRC` +SRC_PATH=`arg_path $SRC` + +#------------------------------------------------------------------------------- +# Get Image information +#------------------------------------------------------------------------------- + +DISK_ID=$(echo "$SRC_PATH" | $AWK -F. '{print $NF}') + +XPATH="${DRIVER_PATH}/../../datastore/xpath.rb --stdin" + +unset i j XPATH_ELEMENTS + +while IFS= read -r -d '' element; do + XPATH_ELEMENTS[i++]="$element" +done < <(onevm show -x $VM_ID| $XPATH \ + /VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/SOURCE \ + /VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/PERSISTENT) + +RBD_SRC="${XPATH_ELEMENTS[j++]}" +PERSISTENT="${XPATH_ELEMENTS[j++]}" + +# Exit if persistent +[ -n "$PERSISTENT" ] && exit 0 + +# non persistent, so the name will be "/one---" +RBD_DST="${RBD_SRC}-${VM_ID}-${DISK_ID}" + +#------------------------------------------------------------------------------- +# Move the image back to the datastore +#------------------------------------------------------------------------------- + +log "Dumping $RBD_DST to $DST" + +ssh_exec_and_log "$SRC_HOST" "$RBD rename $RBD_DST $DST" \ + "Error saving $RBD_DST as $DST in $SRC_HOST" + +exit 0 diff --git a/src/tm_mad/ceph/postmigrate b/src/tm_mad/ceph/postmigrate new file mode 120000 index 0000000000..d580dd8260 --- /dev/null +++ b/src/tm_mad/ceph/postmigrate @@ -0,0 +1 @@ +../common/postmigrate \ No newline at end of file diff --git a/src/tm_mad/ceph/premigrate b/src/tm_mad/ceph/premigrate new file mode 120000 index 0000000000..0e108a8a26 --- /dev/null +++ b/src/tm_mad/ceph/premigrate @@ -0,0 +1 @@ +../common/premigrate \ No newline at end of file diff --git a/src/tm_mad/common/context b/src/tm_mad/common/context index d419cd60fa..c2176c7ff3 100755 --- a/src/tm_mad/common/context +++ b/src/tm_mad/common/context @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/tm_mad/common/delete b/src/tm_mad/common/delete index e2dd4bb636..c997810b38 100755 --- a/src/tm_mad/common/delete +++ b/src/tm_mad/common/delete @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/tm_mad/common/dummy.sh b/src/tm_mad/common/dummy.sh index 6c1cd9257d..e9e0ad4f34 100755 --- a/src/tm_mad/common/dummy.sh +++ b/src/tm_mad/common/dummy.sh @@ -1,7 +1,7 @@ #!/bin/sh # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/tm_mad/common/mkimage b/src/tm_mad/common/mkimage index d393a16486..08263bfd71 100755 --- a/src/tm_mad/common/mkimage +++ b/src/tm_mad/common/mkimage @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/tm_mad/common/mkswap b/src/tm_mad/common/mkswap index 5a42f6d46e..2b0939d90a 100755 --- a/src/tm_mad/common/mkswap +++ b/src/tm_mad/common/mkswap @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/tm_mad/common/postmigrate b/src/tm_mad/common/postmigrate index 9e94890d9b..665b35d7ff 100755 --- a/src/tm_mad/common/postmigrate +++ b/src/tm_mad/common/postmigrate @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/tm_mad/common/premigrate b/src/tm_mad/common/premigrate index bab383dbef..9b5a196c7c 100755 --- a/src/tm_mad/common/premigrate +++ b/src/tm_mad/common/premigrate @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/tm_mad/iscsi/clone b/src/tm_mad/iscsi/clone index ccce7f0df8..9d82307a43 100755 --- a/src/tm_mad/iscsi/clone +++ b/src/tm_mad/iscsi/clone @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -81,14 +81,10 @@ CLONE_CMD=$(cat < ==> persistent + # lv-one--- ==> non-persistent (clone) + + VMID=\$(echo \$LV_NAME|cut -d- -f4) + DISKID=\$(echo \$LV_NAME|cut -d- -f5) + + if [ -n "\$VMID" -a -n "\$DISKID" ]; then + # this is a cloned image + $SUDO $LVREMOVE -f \$DEV + fi EOF ) diff --git a/src/tm_mad/lvm/ln b/src/tm_mad/lvm/ln index a53a50152f..d525c809b5 100755 --- a/src/tm_mad/lvm/ln +++ b/src/tm_mad/lvm/ln @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/tm_mad/lvm/mv b/src/tm_mad/lvm/mv index 8f82a3f4f4..2c409c7eac 100755 --- a/src/tm_mad/lvm/mv +++ b/src/tm_mad/lvm/mv @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/tm_mad/lvm/mvds b/src/tm_mad/lvm/mvds index c4de3cb23b..6a7746e78f 100755 --- a/src/tm_mad/lvm/mvds +++ b/src/tm_mad/lvm/mvds @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -33,7 +33,10 @@ else TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh fi -. $TMCOMMON +DRIVER_PATH=$(dirname $0) + +source $TMCOMMON +source ${DRIVER_PATH}/../../datastore/lvm/lvm.conf #------------------------------------------------------------------------------- # Set dst path and dir @@ -55,14 +58,8 @@ DUMP_CMD=$(cat < /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -435,7 +436,7 @@ string Quota::float_to_str(const float &num) { ostringstream oss; - if ( num - (int)num == 0.0 ) + if ( num == ceil(num) ) { oss.precision(0); } diff --git a/src/um/QuotaDatastore.cc b/src/um/QuotaDatastore.cc index feabd98c00..7fb3935a7f 100644 --- a/src/um/QuotaDatastore.cc +++ b/src/um/QuotaDatastore.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/um/QuotaImage.cc b/src/um/QuotaImage.cc index dd3f1e563a..6465416c0f 100644 --- a/src/um/QuotaImage.cc +++ b/src/um/QuotaImage.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/um/QuotaNetwork.cc b/src/um/QuotaNetwork.cc index b1ca09b45d..a4d02c1dca 100644 --- a/src/um/QuotaNetwork.cc +++ b/src/um/QuotaNetwork.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/um/QuotaVirtualMachine.cc b/src/um/QuotaVirtualMachine.cc index 34378c41dc..1df620dba7 100644 --- a/src/um/QuotaVirtualMachine.cc +++ b/src/um/QuotaVirtualMachine.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -117,3 +117,25 @@ int QuotaVirtualMachine::get_default_quota( /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ + +bool QuotaVirtualMachine::update(Template * tmpl, + Quotas& default_quotas, + string& error) +{ + map vm_request; + + int delta_memory; + float delta_cpu; + + if ( tmpl->get("MEMORY", delta_memory) == true ) + { + vm_request.insert(make_pair("MEMORY", delta_memory)); + } + + if ( tmpl->get("CPU", delta_cpu) == true ) + { + vm_request.insert(make_pair("CPU", delta_cpu)); + } + + return check_quota("", vm_request, default_quotas, error); +} diff --git a/src/um/Quotas.cc b/src/um/Quotas.cc index 325c419e99..90bb22dbb4 100644 --- a/src/um/Quotas.cc +++ b/src/um/Quotas.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -29,7 +29,7 @@ int Quotas::set(Template *tmpl, string& error) { return -1; } - + vquotas.clear(); } @@ -39,7 +39,7 @@ int Quotas::set(Template *tmpl, string& error) { return -1; } - + vquotas.clear(); } @@ -49,7 +49,7 @@ int Quotas::set(Template *tmpl, string& error) { return -1; } - + vquotas.clear(); } @@ -59,7 +59,7 @@ int Quotas::set(Template *tmpl, string& error) { return -1; } - + vquotas.clear(); } @@ -219,6 +219,31 @@ bool Quotas::quota_check(QuotaType type, /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +bool Quotas::quota_update(QuotaType type, + Template *tmpl, + Quotas &default_quotas, + string &error_str) +{ + switch (type) + { + // This is an internal check, should never get in here. + case DATASTORE: + case NETWORK: + case IMAGE: + case VIRTUALMACHINE: + error_str = "Cannot update quota. Not implemented"; + return false; + + case VM: + return vm_quota.update(tmpl, default_quotas, error_str); + } + + return false; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + void Quotas::quota_del(QuotaType type, int uid, int gid, Template * tmpl) { Nebula& nd = Nebula::instance(); @@ -239,7 +264,7 @@ void Quotas::quota_del(QuotaType type, int uid, int gid, Template * tmpl) upool->update(user); user->unlock(); - } + } } if ( gid != GroupPool::ONEADMIN_ID ) @@ -253,6 +278,6 @@ void Quotas::quota_del(QuotaType type, int uid, int gid, Template * tmpl) gpool->update(group); group->unlock(); - } + } } } diff --git a/src/um/SConstruct b/src/um/SConstruct index 122767aff1..c43e7258a9 100644 --- a/src/um/SConstruct +++ b/src/um/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/vm # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/um/User.cc b/src/um/User.cc index 0dfc86cc8f..9c8944f6d1 100644 --- a/src/um/User.cc +++ b/src/um/User.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -197,8 +197,8 @@ int User::from_xml(const string& xml) rc += obj_template->from_xml_node(content[0]); ObjectXML::free_nodes(content); - - rc += quota.from_xml(this); + + rc += quota.from_xml(this); if (rc != 0) { @@ -283,6 +283,30 @@ bool User::pass_is_valid(const string& pass, string& error_str) return true; } + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +int User::get_umask() const +{ + string umask_st; + int umask; + + istringstream iss; + + get_template_attribute("UMASK", umask_st); + + if(umask_st.empty()) + { + Nebula::instance().get_configuration_attribute("DEFAULT_UMASK",umask_st); + } + + iss.str(umask_st); + + iss >> oct >> umask; + + return (umask & 0777); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ diff --git a/src/um/UserPool.cc b/src/um/UserPool.cc index 00dcdda00d..cce59357b9 100644 --- a/src/um/UserPool.cc +++ b/src/um/UserPool.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -22,7 +22,7 @@ #include "NebulaLog.h" #include "Nebula.h" #include "AuthManager.h" -#include "SSLTools.h" +#include "NebulaUtil.h" #include #include @@ -80,8 +80,6 @@ UserPool::UserPool(SqlDB * db, _session_expiration_time = __session_expiration_time; - register_hooks(hook_mads, remotes_location); - User * oneadmin_user = get(0, true); if (oneadmin_user != 0) @@ -89,6 +87,8 @@ UserPool::UserPool(SqlDB * db, oneadmin_name = oneadmin_user->get_name(); oneadmin_user->unlock(); + register_hooks(hook_mads, remotes_location); + return; } @@ -145,7 +145,7 @@ UserPool::UserPool(SqlDB * db, srand(time(0)); sstr << rand(); - random = SSLTools::sha1_digest( sstr.str() ); + random = one_util::sha1_digest(sstr.str()); filenames[0] = nd.get_var_location() + "/.one/sunstone_auth"; filenames[1] = nd.get_var_location() + "/.one/occi_auth"; @@ -188,7 +188,7 @@ UserPool::UserPool(SqlDB * db, GroupPool::ONEADMIN_ID, SERVER_NAME, GroupPool::ONEADMIN_NAME, - SSLTools::sha1_digest(random), + one_util::sha1_digest(random), "server_cipher", true, error_str); @@ -198,6 +198,8 @@ UserPool::UserPool(SqlDB * db, goto error_serveradmin; } + register_hooks(hook_mads, remotes_location); + return; error_no_file: @@ -287,7 +289,7 @@ int UserPool::allocate ( if (auth_driver == UserPool::CORE_AUTH) { - upass = SSLTools::sha1_digest(password); + upass = one_util::sha1_digest(password); } // Build a new User object diff --git a/src/um/test/SConstruct b/src/um/test/SConstruct index 5d0ff663e0..2be90802b2 100644 --- a/src/um/test/SConstruct +++ b/src/um/test/SConstruct @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # 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 diff --git a/src/um/test/UserPoolTest.cc b/src/um/test/UserPoolTest.cc index ec722153d9..b7679e5618 100644 --- a/src/um/test/UserPoolTest.cc +++ b/src/um/test/UserPoolTest.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/vm/History.cc b/src/vm/History.cc index de8ee9ea52..c0abffbde8 100644 --- a/src/vm/History.cc +++ b/src/vm/History.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/vm/SConstruct b/src/vm/SConstruct index 58840389ca..c203d310df 100644 --- a/src/vm/SConstruct +++ b/src/vm/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/vm # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index dcc2e60af2..a0cf21640d 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -43,6 +43,7 @@ VirtualMachine::VirtualMachine(int id, int _gid, const string& _uname, const string& _gname, + int umask, VirtualMachineTemplate * _vm_template): PoolObjectSQL(id,VM,"",_uid,_gid,_uname,_gname,table), last_poll(0), @@ -62,12 +63,19 @@ VirtualMachine::VirtualMachine(int id, { if (_vm_template != 0) { - obj_template = _vm_template; + // This is a VM Template, with the root TEMPLATE. + _vm_template->set_xml_root("USER_TEMPLATE"); + + user_obj_template = _vm_template; } else { - obj_template = new VirtualMachineTemplate; + user_obj_template = new Template(false,'=',"USER_TEMPLATE"); } + + obj_template = new VirtualMachineTemplate; + + set_umask(umask); } VirtualMachine::~VirtualMachine() @@ -77,15 +85,20 @@ VirtualMachine::~VirtualMachine() delete history_records[i]; } - if ( _log != 0 ) + if (_log != 0) { delete _log; } - if ( obj_template != 0 ) + if (obj_template != 0) { delete obj_template; } + + if (user_obj_template != 0) + { + delete user_obj_template; + } } /* ************************************************************************** */ @@ -181,10 +194,31 @@ int VirtualMachine::select(SqlDB * db) //-------------------------------------------------------------------------- try { - Log::MessageType clevel; + Log::MessageType clevel; + NebulaLog::LogType log_system; - clevel = nd.get_debug_level(); - _log = new FileLog(nd.get_vm_log_filename(oid), clevel); + log_system = nd.get_log_system(); + clevel = nd.get_debug_level(); + + switch(log_system) + { + case NebulaLog::FILE_TS: + case NebulaLog::FILE: + _log = new FileLog(nd.get_vm_log_filename(oid), clevel); + break; + + case NebulaLog::SYSLOG: + _log = new SysLogResource(oid, obj_type, clevel); + break; + + case NebulaLog::CERR: + _log = new CerrLog(clevel); + break; + + default: + throw runtime_error("Unknown log system."); + break; + } } catch(exception &e) { @@ -211,10 +245,12 @@ int VirtualMachine::insert(SqlDB * db, string& error_str) { int rc; string name; + string prefix; + + string value; + int ivalue; + float fvalue; - string value; - int ivalue; - float fvalue; ostringstream oss; // ------------------------------------------------------------------------ @@ -224,19 +260,35 @@ int VirtualMachine::insert(SqlDB * db, string& error_str) oss << oid; value = oss.str(); - replace_template_attribute("VMID", value); + user_obj_template->erase("VMID"); + obj_template->add("VMID", value); - get_template_attribute("NAME",name); + user_obj_template->get("TEMPLATE_ID", value); + user_obj_template->erase("TEMPLATE_ID"); - if ( name.empty() == true ) + if (!value.empty()) { - oss.str(""); - oss << "one-" << oid; - name = oss.str(); - - replace_template_attribute("NAME", name); + obj_template->add("TEMPLATE_ID", value); } - else if ( name.length() > 128 ) + + user_obj_template->get("NAME",name); + user_obj_template->erase("NAME"); + + if (name.empty() == true) + { + user_obj_template->get("TEMPLATE_NAME", prefix); + user_obj_template->erase("TEMPLATE_NAME"); + + if (prefix.empty()) + { + prefix = "one"; + } + + oss.str(""); + oss << prefix << "-" << oid; + name = oss.str(); + } + else if (name.length() > 128) { goto error_name_length; } @@ -247,26 +299,35 @@ int VirtualMachine::insert(SqlDB * db, string& error_str) // Check for CPU, VCPU and MEMORY attributes // ------------------------------------------------------------------------ - if ( get_template_attribute("MEMORY", ivalue) == false || ivalue <= 0 ) + if ( user_obj_template->get("MEMORY", ivalue) == false || ivalue <= 0 ) { goto error_memory; } - if ( get_template_attribute("CPU", fvalue) == false || fvalue <= 0 ) + user_obj_template->erase("MEMORY"); + obj_template->add("MEMORY", ivalue); + + if ( user_obj_template->get("CPU", fvalue) == false || fvalue <= 0 ) { goto error_cpu; } + user_obj_template->erase("CPU"); + obj_template->add("CPU", fvalue); + // VCPU is optional, first check if the attribute exists, then check it is // an integer - get_template_attribute("VCPU", value); + user_obj_template->get("VCPU", value); if ( value.empty() == false ) { - if ( get_template_attribute("VCPU", ivalue) == false || ivalue <= 0 ) + if ( user_obj_template->get("VCPU", ivalue) == false || ivalue <= 0 ) { goto error_vcpu; } + + user_obj_template->erase("VCPU"); + obj_template->add("VCPU", ivalue); } // ------------------------------------------------------------------------ @@ -331,6 +392,8 @@ int VirtualMachine::insert(SqlDB * db, string& error_str) parse_graphics(); + parse_well_known_attributes(); + // ------------------------------------------------------------------------ // Insert the VM // ------------------------------------------------------------------------ @@ -492,7 +555,14 @@ int VirtualMachine::parse_os(string& error_str) vector os_attr; VectorAttribute * os; - num = obj_template->get("OS", os_attr); + vector::iterator it; + + num = user_obj_template->remove("OS", os_attr); + + for (it=os_attr.begin(); it != os_attr.end(); it++) + { + obj_template->set(*it); + } if ( num == 0 ) { @@ -684,7 +754,14 @@ void VirtualMachine::parse_graphics() vector array_graphics; VectorAttribute * graphics; - num = obj_template->get("GRAPHICS", array_graphics); + vector::iterator it; + + num = user_obj_template->remove("GRAPHICS", array_graphics); + + for (it=array_graphics.begin(); it != array_graphics.end(); it++) + { + obj_template->set(*it); + } if ( num == 0 ) { @@ -731,7 +808,16 @@ int VirtualMachine::parse_requirements(string& error_str) string parsed; - num = obj_template->remove("REQUIREMENTS", array_reqs); + num = user_obj_template->remove("SCHED_REQUIREMENTS", array_reqs); + + if ( num == 0 ) // Compatibility with old REQUIREMENTS attribute + { + num = user_obj_template->remove("REQUIREMENTS", array_reqs); + } + else + { + user_obj_template->erase("REQUIREMENTS"); + } if ( num == 0 ) { @@ -739,7 +825,7 @@ int VirtualMachine::parse_requirements(string& error_str) } else if ( num > 1 ) { - error_str = "Only one REQUIREMENTS attribute can be defined."; + error_str = "Only one SCHED_REQUIREMENTS attribute can be defined."; goto error_cleanup; } @@ -747,7 +833,7 @@ int VirtualMachine::parse_requirements(string& error_str) if ( reqs == 0 ) { - error_str = "Wrong format for REQUIREMENTS attribute."; + error_str = "Wrong format for SCHED_REQUIREMENTS attribute."; goto error_cleanup; } @@ -757,19 +843,13 @@ int VirtualMachine::parse_requirements(string& error_str) { SingleAttribute * reqs_parsed; - reqs_parsed = new SingleAttribute("REQUIREMENTS",parsed); - obj_template->set(reqs_parsed); + reqs_parsed = new SingleAttribute("SCHED_REQUIREMENTS",parsed); + user_obj_template->set(reqs_parsed); } - /* --- Delete old requirements attributes --- */ + /* --- Delete old requirements attribute --- */ - for (int i = 0; i < num ; i++) - { - if (array_reqs[i] != 0) - { - delete array_reqs[i]; - } - } + delete array_reqs[0]; return rc; @@ -788,6 +868,47 @@ error_cleanup: /* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */ +void VirtualMachine::parse_well_known_attributes() +{ + /* + * List of meaningful attributes, used in other places and expected in + * obj_template: + * + * DISK + * NIC + * VCPU + * MEMORY + * CPU + * CONTEXT + * OS + * GRAPHICS + * + * INPUT + * FEATURES + * RAW + */ + + vector v_attr; + vector::iterator it; + + string names[] = {"INPUT", "FEATURES", "RAW"}; + + for (int i=0; i<3; i++) + { + v_attr.clear(); + + user_obj_template->remove(names[i], v_attr); + + for (it=v_attr.begin(); it != v_attr.end(); it++) + { + obj_template->set(*it); + } + } +} + +/* ------------------------------------------------------------------------ */ +/* ------------------------------------------------------------------------ */ + static int check_and_set_cluster_id(const char * id_name, VectorAttribute * vatt, string& cluster_id) @@ -903,21 +1024,15 @@ int VirtualMachine::automatic_requirements(string& error_str) oss.str(""); oss << "CLUSTER_ID = " << cluster_id; - obj_template->get("REQUIREMENTS", requirements); - - if ( !requirements.empty() ) - { - oss << " & ( " << requirements << " )"; - } - - replace_template_attribute("REQUIREMENTS", oss.str()); + obj_template->add("AUTOMATIC_REQUIREMENTS", oss.str()); } return 0; error_disk: - oss << "Incompatible clusters in DISKs. Datastore for DISK[" - << incomp_id <<"] should be in cluster " << cluster_id << "."; + oss << "Incompatible clusters in DISK. Datastore for DISK "<< incomp_id + << " is not the same as the one used by other VM elements (cluster " + << cluster_id << ")"; goto error_common; error_kernel: @@ -931,8 +1046,9 @@ error_initrd: goto error_common; error_nic: - oss << "Incompatible clusters in NICs. Network for NIC[" << incomp_id <<"]" - << " should be in cluster " << cluster_id << "."; + oss << "Incompatible clusters in NIC. Network for NIC "<< incomp_id + << " is not the same as the one used by other VM elements (cluster " + << cluster_id << ")"; goto error_common; error_common: @@ -1185,14 +1301,11 @@ void VirtualMachine::cp_previous_history() void VirtualMachine::get_requirements (int& cpu, int& memory, int& disk) { - string scpu; istringstream iss; float fcpu; - get_template_attribute("MEMORY",memory); - get_template_attribute("CPU",scpu); - - if ((memory == 0) || (scpu=="")) + if ((get_template_attribute("MEMORY",memory) == false) || + (get_template_attribute("CPU",fcpu) == false)) { cpu = 0; memory = 0; @@ -1201,9 +1314,6 @@ void VirtualMachine::get_requirements (int& cpu, int& memory, int& disk) return; } - iss.str(scpu); - iss >> fcpu; - cpu = (int) (fcpu * 100);//now in 100% memory = memory * 1024; //now in Kilobytes disk = 0; @@ -1214,6 +1324,70 @@ void VirtualMachine::get_requirements (int& cpu, int& memory, int& disk) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +int VirtualMachine::check_resize ( + float cpu, int memory, int vcpu, string& error_str) +{ + if (cpu < 0) + { + error_str = "CPU must be a positive float or integer value."; + return -1; + } + + if (memory < 0) + { + error_str = "MEMORY must be a positive integer value."; + return -1; + } + + if (vcpu < 0) + { + error_str = "VCPU must be a positive integer value."; + return -1; + } + + return 0; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +int VirtualMachine::resize(float cpu, int memory, int vcpu, string& error_str) +{ + ostringstream oss; + + int rc = check_resize(cpu, memory, vcpu, error_str); + + if (rc != 0) + { + return rc; + } + + if (cpu > 0) + { + oss << cpu; + replace_template_attribute("CPU", oss.str()); + oss.str(""); + } + + if (memory > 0) + { + oss << memory; + replace_template_attribute("MEMORY", oss.str()); + oss.str(""); + } + + if (vcpu > 0) + { + oss << vcpu; + replace_template_attribute("VCPU", oss.str()); + } + + return 0; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + static void assign_disk_targets(queue >& _queue, set& used_targets) { @@ -1268,11 +1442,23 @@ int VirtualMachine::get_disk_images(string& error_str) Nebula& nd = Nebula::instance(); ipool = nd.get_ipool(); + vector::iterator it; + // ------------------------------------------------------------------------- // The context is the first of the cdroms // ------------------------------------------------------------------------- - num_context = obj_template->get("CONTEXT", context_disks); - num_disks = obj_template->get("DISK", disks); + num_context = user_obj_template->remove("CONTEXT", context_disks); + num_disks = user_obj_template->remove("DISK", disks); + + for (it=context_disks.begin(); it != context_disks.end(); it++) + { + obj_template->set(*it); + } + + for (it=disks.begin(); it != disks.end(); it++) + { + obj_template->set(*it); + } if ( num_disks > 20 ) { @@ -1387,11 +1573,11 @@ error_duplicated_target: error_common: ImageManager * imagem = nd.get_imagem(); - vector::iterator it; + vector::iterator img_it; - for ( it=acquired_images.begin() ; it < acquired_images.end(); it++ ) + for ( img_it=acquired_images.begin() ; img_it < acquired_images.end(); img_it++ ) { - imagem->release_image(oid, *it, false); + imagem->release_image(oid, *img_it, false); } return -1; @@ -1886,6 +2072,190 @@ void VirtualMachine::release_disk_images() /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +int VirtualMachine::new_snapshot(string& name, int& snap_id) +{ + int num_snaps; + int id; + int max_id = -1; + + vector snaps; + VectorAttribute * snap; + + num_snaps = obj_template->get("SNAPSHOT", snaps); + + for(int i=0; i(snaps[i]); + + if ( snap == 0 ) + { + continue; + } + + snap->vector_value("SNAPSHOT_ID", id); + + if (id > max_id) + { + max_id = id; + } + } + + snap_id = max_id + 1; + + if (name.empty()) + { + ostringstream oss; + + oss << "snapshot-" << snap_id; + + name = oss.str(); + } + + snap = new VectorAttribute("SNAPSHOT"); + snap->replace("SNAPSHOT_ID", snap_id); + snap->replace("NAME", name); + snap->replace("TIME", (int)time(0)); + snap->replace("HYPERVISOR_ID", ""); + + snap->replace("ACTIVE", "YES"); + + obj_template->set(snap); + + return 0; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +int VirtualMachine::set_active_snapshot(int snap_id) +{ + int num_snaps; + int s_id; + + vector snaps; + VectorAttribute * snap; + + num_snaps = obj_template->get("SNAPSHOT", snaps); + + for(int i=0; i(snaps[i]); + + if ( snap == 0 ) + { + continue; + } + + snap->vector_value("SNAPSHOT_ID", s_id); + + if ( s_id == snap_id ) + { + snap->replace("ACTIVE", "YES"); + return 0; + } + } + + return -1; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void VirtualMachine::update_snapshot_id(string& hypervisor_id) +{ + int num_snaps; + vector snaps; + VectorAttribute * snap; + + num_snaps = obj_template->get("SNAPSHOT", snaps); + + for(int i=0; i(snaps[i]); + + if ( snap == 0 ) + { + continue; + } + + if ( snap->vector_value("ACTIVE") == "YES" ) + { + snap->replace("HYPERVISOR_ID", hypervisor_id); + break; + } + } +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void VirtualMachine::clear_active_snapshot() +{ + int num_snaps; + vector snaps; + VectorAttribute * snap; + + num_snaps = obj_template->get("SNAPSHOT", snaps); + + for(int i=0; i(snaps[i]); + + if ( snap == 0 ) + { + continue; + } + + if ( snap->vector_value("ACTIVE") == "YES" ) + { + snap->remove("ACTIVE"); + return; + } + } +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void VirtualMachine::delete_active_snapshot() +{ + vector snaps; + VectorAttribute * snap; + + int num_snaps = obj_template->get("SNAPSHOT", snaps); + + for(int i=0; i(snaps[i]); + + if ( snap == 0 ) + { + continue; + } + + if ( snap->vector_value("ACTIVE") == "YES" ) + { + if (obj_template->remove(snap) != 0) + { + delete snap; + } + + return; + } + } +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void VirtualMachine::delete_snapshots() +{ + obj_template->erase("SNAPSHOT"); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + int VirtualMachine::get_network_leases(string& estr) { int num_nics, rc; @@ -1896,7 +2266,12 @@ int VirtualMachine::get_network_leases(string& estr) Nebula& nd = Nebula::instance(); vnpool = nd.get_vnpool(); - num_nics = obj_template->get("NIC",nics); + num_nics = user_obj_template->remove("NIC",nics); + + for (vector::iterator it=nics.begin(); it != nics.end(); it++) + { + obj_template->set(*it); + } for(int i=0; i" << cpu << "" << "" << net_tx << "" << "" << net_rx << "" - << obj_template->to_xml(template_xml); + << obj_template->to_xml(template_xml) + << user_obj_template->to_xml(user_template_xml); if ( hasHistory() && n_history > 0 ) { @@ -2484,21 +2861,34 @@ int VirtualMachine::from_xml(const string &xml_str) state = static_cast(istate); lcm_state = static_cast(ilcmstate); - // Get associated classes + // Virtual Machine template ObjectXML::get_nodes("/VM/TEMPLATE", content); if (content.empty()) { return -1; } - - // Virtual Machine template rc += obj_template->from_xml_node(content[0]); - // Last history entry ObjectXML::free_nodes(content); content.clear(); + // Virtual Machine user template + + ObjectXML::get_nodes("/VM/USER_TEMPLATE", content); + + if (content.empty()) + { + return -1; + } + + rc += user_obj_template->from_xml_node(content[0]); + + ObjectXML::free_nodes(content); + content.clear(); + + // Last history entry + ObjectXML::get_nodes("/VM/HISTORY_RECORDS/HISTORY", content); if (!content.empty()) @@ -2532,3 +2922,76 @@ string VirtualMachine::get_system_dir() const return oss.str(); }; + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void VirtualMachine::update_info( + const int _memory, + const int _cpu, + const long long _net_tx, + const long long _net_rx, + const map &custom) +{ + map::const_iterator it; + + last_poll = time(0); + + if (_memory != -1) + { + memory = _memory; + } + + if (_cpu != -1) + { + cpu = _cpu; + } + + if (_net_tx != -1) + { + net_tx = _net_tx; + } + + if (_net_rx != -1) + { + net_rx = _net_rx; + } + + for (it = custom.begin(); it != custom.end(); it++) + { + replace_template_attribute(it->first, it->second); + } + + set_vm_info(); + + clear_template_error_message(); +}; + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +int VirtualMachine::replace_template(const string& tmpl_str, string& error) +{ + Template * new_tmpl = new Template(false,'=',"USER_TEMPLATE"); + + if ( new_tmpl == 0 ) + { + error = "Cannot allocate a new template"; + return -1; + } + + if ( new_tmpl->parse_str_or_xml(tmpl_str, error) != 0 ) + { + delete new_tmpl; + return -1; + } + + if (user_obj_template != 0) + { + delete user_obj_template; + } + + user_obj_template = new_tmpl; + + return 0; +} diff --git a/src/vm/VirtualMachineHook.cc b/src/vm/VirtualMachineHook.cc index db65002b1f..1face10cf8 100644 --- a/src/vm/VirtualMachineHook.cc +++ b/src/vm/VirtualMachineHook.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/vm/VirtualMachinePool.cc b/src/vm/VirtualMachinePool.cc index b00c431b80..825d694b1b 100644 --- a/src/vm/VirtualMachinePool.cc +++ b/src/vm/VirtualMachinePool.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -25,6 +25,7 @@ /* -------------------------------------------------------------------------- */ time_t VirtualMachinePool::_monitor_expiration; +bool VirtualMachinePool::_submit_on_hold; /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -35,7 +36,8 @@ VirtualMachinePool::VirtualMachinePool( const string& hook_location, const string& remotes_location, vector& restricted_attrs, - time_t expire_time) + time_t expire_time, + bool on_hold) : PoolSQL(db, VirtualMachine::table, false) { const VectorAttribute * vattr; @@ -44,12 +46,12 @@ VirtualMachinePool::VirtualMachinePool( string on; string cmd; string arg; - string rmt; bool remote; bool state_hook = false; _monitor_expiration = expire_time; + _submit_on_hold = on_hold; if ( _monitor_expiration == 0 ) { @@ -64,7 +66,7 @@ VirtualMachinePool::VirtualMachinePool( on = vattr->vector_value("ON"); cmd = vattr->vector_value("COMMAND"); arg = vattr->vector_value("ARGUMENTS"); - rmt = vattr->vector_value("REMOTE"); + vattr->vector_value("REMOTE", remote); transform (on.begin(),on.end(),on.begin(),(int(*)(int))toupper); @@ -84,18 +86,6 @@ VirtualMachinePool::VirtualMachinePool( name = cmd; } - remote = false; - - if ( !rmt.empty() ) - { - transform(rmt.begin(),rmt.end(),rmt.begin(),(int(*)(int))toupper); - - if ( rmt == "YES" ) - { - remote = true; - } - } - if (cmd[0] != '/') { ostringstream cmd_os; @@ -220,6 +210,7 @@ int VirtualMachinePool::allocate ( int gid, const string& uname, const string& gname, + int umask, VirtualMachineTemplate * vm_template, int * oid, string& error_str, @@ -230,9 +221,9 @@ int VirtualMachinePool::allocate ( // ------------------------------------------------------------------------ // Build a new Virtual Machine object // ------------------------------------------------------------------------ - vm = new VirtualMachine(-1, uid, gid, uname, gname, vm_template); + vm = new VirtualMachine(-1, uid, gid, uname, gname, umask, vm_template); - if (on_hold == true) + if ( _submit_on_hold == true || on_hold ) { vm->state = VirtualMachine::HOLD; } diff --git a/src/vm/VirtualMachineTemplate.cc b/src/vm/VirtualMachineTemplate.cc index 6b6bc73ca3..a404445588 100644 --- a/src/vm/VirtualMachineTemplate.cc +++ b/src/vm/VirtualMachineTemplate.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/vm/test/SConstruct b/src/vm/test/SConstruct index 06f2085cbb..3fa99a15a0 100644 --- a/src/vm/test/SConstruct +++ b/src/vm/test/SConstruct @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # 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 diff --git a/src/vm/test/VirtualMachinePoolTest.cc b/src/vm/test/VirtualMachinePoolTest.cc index 2f67477955..5f5bb15f11 100644 --- a/src/vm/test/VirtualMachinePoolTest.cc +++ b/src/vm/test/VirtualMachinePoolTest.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/vm/vm_file_var_syntax.cc b/src/vm/vm_file_var_syntax.cc index 8eaed65093..a4775069d3 100644 --- a/src/vm/vm_file_var_syntax.cc +++ b/src/vm/vm_file_var_syntax.cc @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.6.5. */ +/* A Bison parser, made by GNU Bison 2.7. */ /* Bison implementation for Yacc-like parsers in C @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.6.5" +#define YYBISON_VERSION "2.7" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -70,7 +70,7 @@ #define yylloc vm_file_var__lloc /* Copy the first part of user declarations. */ -/* Line 360 of yacc.c */ +/* Line 371 of yacc.c */ #line 17 "vm_file_var_syntax.y" #include @@ -217,7 +217,7 @@ int get_image_path(VirtualMachine * vm, /* -------------------------------------------------------------------------- */ -/* Line 360 of yacc.c */ +/* Line 371 of yacc.c */ #line 222 "vm_file_var_syntax.cc" # ifndef YY_NULL @@ -270,7 +270,7 @@ extern int vm_file_var__debug; #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE { -/* Line 376 of yacc.c */ +/* Line 387 of yacc.c */ #line 170 "vm_file_var_syntax.y" char * val_str; @@ -278,7 +278,7 @@ typedef union YYSTYPE char val_char; -/* Line 376 of yacc.c */ +/* Line 387 of yacc.c */ #line 283 "vm_file_var_syntax.cc" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 @@ -318,7 +318,7 @@ int vm_file_var__parse (); /* Copy the second part of user declarations. */ -/* Line 379 of yacc.c */ +/* Line 390 of yacc.c */ #line 323 "vm_file_var_syntax.cc" #ifdef short @@ -789,14 +789,46 @@ while (YYID (0)) #ifndef YY_LOCATION_PRINT # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - do { \ - fprintf (File, "%d.%d", (Loc).first_line, (Loc).first_column); \ - if ((Loc).first_line < (Loc).last_line) \ - fprintf (File, "-%d.%d", (Loc).last_line, (Loc).last_column - 1); \ - else if ((Loc).first_column < (Loc).last_column - 1) \ - fprintf (File, "-%d", (Loc).last_column - 1); \ - } while (0) + +/* Print *YYLOCP on YYO. Private, do not rely on its existence. */ + +__attribute__((__unused__)) +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static unsigned +yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp) +#else +static unsigned +yy_location_print_ (yyo, yylocp) + FILE *yyo; + YYLTYPE const * const yylocp; +#endif +{ + unsigned res = 0; + int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0; + if (0 <= yylocp->first_line) + { + res += fprintf (yyo, "%d", yylocp->first_line); + if (0 <= yylocp->first_column) + res += fprintf (yyo, ".%d", yylocp->first_column); + } + if (0 <= yylocp->last_line) + { + if (yylocp->first_line < yylocp->last_line) + { + res += fprintf (yyo, "-%d", yylocp->last_line); + if (0 <= end_col) + res += fprintf (yyo, ".%d", end_col); + } + else if (0 <= end_col && yylocp->first_column < end_col) + res += fprintf (yyo, "-%d", end_col); + } + return res; + } + +# define YY_LOCATION_PRINT(File, Loc) \ + yy_location_print_ (File, &(Loc)) + # else # define YY_LOCATION_PRINT(File, Loc) ((void) 0) # endif @@ -876,7 +908,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, mc, vm, img_ids, switch (yytype) { default: - break; + break; } } @@ -1130,7 +1162,6 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, { YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ const char *yyformat = YY_NULL; @@ -1193,11 +1224,13 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, break; } yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; + { + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } } } } @@ -1217,10 +1250,12 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, # undef YYCASE_ } - yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; + { + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } if (*yymsg_alloc < yysize) { @@ -1290,7 +1325,7 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp, mc, vm, img_ids, errmsg) { default: - break; + break; } } @@ -1344,6 +1379,11 @@ int yychar; static YYSTYPE yyval_default; # define YY_INITIAL_VALUE(Value) = Value #endif +static YYLTYPE yyloc_default +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL + = { 1, 1, 1, 1 } +# endif +; #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_END @@ -1356,11 +1396,7 @@ static YYSTYPE yyval_default; YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); /* Location data for the lookahead symbol. */ -YYLTYPE yylloc -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL - = { 1, 1, 1, 1 } -# endif -; +YYLTYPE yylloc = yyloc_default; /* Number of syntax errors so far. */ @@ -1617,7 +1653,7 @@ yyreduce: switch (yyn) { case 4: -/* Line 1778 of yacc.c */ +/* Line 1792 of yacc.c */ #line 200 "vm_file_var_syntax.y" { string file((yyvsp[(1) - (7)].val_str)); @@ -1639,7 +1675,7 @@ yyreduce: break; case 5: -/* Line 1778 of yacc.c */ +/* Line 1792 of yacc.c */ #line 218 "vm_file_var_syntax.y" { string file((yyvsp[(1) - (11)].val_str)); @@ -1664,8 +1700,8 @@ yyreduce: break; -/* Line 1778 of yacc.c */ -#line 1669 "vm_file_var_syntax.cc" +/* Line 1792 of yacc.c */ +#line 1705 "vm_file_var_syntax.cc" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -1903,7 +1939,7 @@ yyreturn: } -/* Line 2041 of yacc.c */ +/* Line 2055 of yacc.c */ #line 239 "vm_file_var_syntax.y" diff --git a/src/vm/vm_file_var_syntax.h b/src/vm/vm_file_var_syntax.h index a40d587583..900eaabbb4 100644 --- a/src/vm/vm_file_var_syntax.h +++ b/src/vm/vm_file_var_syntax.h @@ -1,19 +1,19 @@ -/* A Bison parser, made by GNU Bison 2.6.5. */ +/* A Bison parser, made by GNU Bison 2.7. */ /* Bison interface for Yacc-like parsers in C - + Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -26,7 +26,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -62,7 +62,7 @@ extern int vm_file_var__debug; #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE { -/* Line 2042 of yacc.c */ +/* Line 2058 of yacc.c */ #line 170 "vm_file_var_syntax.y" char * val_str; @@ -70,7 +70,7 @@ typedef union YYSTYPE char val_char; -/* Line 2042 of yacc.c */ +/* Line 2058 of yacc.c */ #line 75 "vm_file_var_syntax.hh" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 diff --git a/src/vm/vm_file_var_syntax.y b/src/vm/vm_file_var_syntax.y index 89280c5241..c82c8779d8 100644 --- a/src/vm/vm_file_var_syntax.y +++ b/src/vm/vm_file_var_syntax.y @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/vm/vm_var_parser.c b/src/vm/vm_var_parser.c index 67ab9e7c5f..f3a5f4a8ae 100644 --- a/src/vm/vm_var_parser.c +++ b/src/vm/vm_var_parser.c @@ -505,7 +505,7 @@ int vm_var__flex_debug = 0; char *vm_var_text; #line 1 "vm_var_parser.l" /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/vm/vm_var_parser.l b/src/vm/vm_var_parser.l index d5ac0b12fb..9bcf0e75f7 100644 --- a/src/vm/vm_var_parser.l +++ b/src/vm/vm_var_parser.l @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/vm/vm_var_syntax.cc b/src/vm/vm_var_syntax.cc index baa15c5c3c..b703398188 100644 --- a/src/vm/vm_var_syntax.cc +++ b/src/vm/vm_var_syntax.cc @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.6.5. */ +/* A Bison parser, made by GNU Bison 2.7. */ /* Bison implementation for Yacc-like parsers in C @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.6.5" +#define YYBISON_VERSION "2.7" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -70,7 +70,7 @@ #define yylloc vm_var__lloc /* Copy the first part of user declarations. */ -/* Line 360 of yacc.c */ +/* Line 371 of yacc.c */ #line 17 "vm_var_syntax.y" #include @@ -362,6 +362,11 @@ void insert_single(VirtualMachine * vm, else { vm->get_template_attribute(name.c_str(),value); + + if (value.empty()) + { + vm->get_user_template_attribute(name.c_str(),value); + } } if (!value.empty()) @@ -463,8 +468,8 @@ void insert_vector(VirtualMachine * vm, /* -------------------------------------------------------------------------- */ -/* Line 360 of yacc.c */ -#line 468 "vm_var_syntax.cc" +/* Line 371 of yacc.c */ +#line 473 "vm_var_syntax.cc" # ifndef YY_NULL # if defined __cplusplus && 201103L <= __cplusplus @@ -516,16 +521,16 @@ extern int vm_var__debug; #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE { -/* Line 376 of yacc.c */ -#line 416 "vm_var_syntax.y" +/* Line 387 of yacc.c */ +#line 421 "vm_var_syntax.y" char * val_str; int val_int; char val_char; -/* Line 376 of yacc.c */ -#line 529 "vm_var_syntax.cc" +/* Line 387 of yacc.c */ +#line 534 "vm_var_syntax.cc" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -564,8 +569,8 @@ int vm_var__parse (); /* Copy the second part of user declarations. */ -/* Line 379 of yacc.c */ -#line 569 "vm_var_syntax.cc" +/* Line 390 of yacc.c */ +#line 574 "vm_var_syntax.cc" #ifdef short # undef short @@ -856,7 +861,7 @@ static const yytype_int8 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 440, 440, 441, 444, 448, 461, 476 + 0, 445, 445, 446, 449, 453, 466, 481 }; #endif @@ -1035,14 +1040,46 @@ while (YYID (0)) #ifndef YY_LOCATION_PRINT # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - do { \ - fprintf (File, "%d.%d", (Loc).first_line, (Loc).first_column); \ - if ((Loc).first_line < (Loc).last_line) \ - fprintf (File, "-%d.%d", (Loc).last_line, (Loc).last_column - 1); \ - else if ((Loc).first_column < (Loc).last_column - 1) \ - fprintf (File, "-%d", (Loc).last_column - 1); \ - } while (0) + +/* Print *YYLOCP on YYO. Private, do not rely on its existence. */ + +__attribute__((__unused__)) +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static unsigned +yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp) +#else +static unsigned +yy_location_print_ (yyo, yylocp) + FILE *yyo; + YYLTYPE const * const yylocp; +#endif +{ + unsigned res = 0; + int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0; + if (0 <= yylocp->first_line) + { + res += fprintf (yyo, "%d", yylocp->first_line); + if (0 <= yylocp->first_column) + res += fprintf (yyo, ".%d", yylocp->first_column); + } + if (0 <= yylocp->last_line) + { + if (yylocp->first_line < yylocp->last_line) + { + res += fprintf (yyo, "-%d", yylocp->last_line); + if (0 <= end_col) + res += fprintf (yyo, ".%d", end_col); + } + else if (0 <= end_col && yylocp->first_column < end_col) + res += fprintf (yyo, "-%d", end_col); + } + return res; + } + +# define YY_LOCATION_PRINT(File, Loc) \ + yy_location_print_ (File, &(Loc)) + # else # define YY_LOCATION_PRINT(File, Loc) ((void) 0) # endif @@ -1122,7 +1159,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, mc, vm, parsed, switch (yytype) { default: - break; + break; } } @@ -1376,7 +1413,6 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, { YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ const char *yyformat = YY_NULL; @@ -1439,11 +1475,13 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, break; } yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; + { + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } } } } @@ -1463,10 +1501,12 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, # undef YYCASE_ } - yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; + { + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } if (*yymsg_alloc < yysize) { @@ -1536,7 +1576,7 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp, mc, vm, parsed, errmsg) { default: - break; + break; } } @@ -1590,6 +1630,11 @@ int yychar; static YYSTYPE yyval_default; # define YY_INITIAL_VALUE(Value) = Value #endif +static YYLTYPE yyloc_default +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL + = { 1, 1, 1, 1 } +# endif +; #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_END @@ -1602,11 +1647,7 @@ static YYSTYPE yyval_default; YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); /* Location data for the lookahead symbol. */ -YYLTYPE yylloc -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL - = { 1, 1, 1, 1 } -# endif -; +YYLTYPE yylloc = yyloc_default; /* Number of syntax errors so far. */ @@ -1863,16 +1904,16 @@ yyreduce: switch (yyn) { case 4: -/* Line 1778 of yacc.c */ -#line 445 "vm_var_syntax.y" +/* Line 1792 of yacc.c */ +#line 450 "vm_var_syntax.y" { (*parsed) << (yyvsp[(1) - (1)].val_str); } break; case 5: -/* Line 1778 of yacc.c */ -#line 449 "vm_var_syntax.y" +/* Line 1792 of yacc.c */ +#line 454 "vm_var_syntax.y" { string name((yyvsp[(1) - (2)].val_str)); @@ -1888,8 +1929,8 @@ yyreduce: break; case 6: -/* Line 1778 of yacc.c */ -#line 462 "vm_var_syntax.y" +/* Line 1792 of yacc.c */ +#line 467 "vm_var_syntax.y" { string name((yyvsp[(1) - (5)].val_str)); string vname((yyvsp[(3) - (5)].val_str)); @@ -1907,8 +1948,8 @@ yyreduce: break; case 7: -/* Line 1778 of yacc.c */ -#line 477 "vm_var_syntax.y" +/* Line 1792 of yacc.c */ +#line 482 "vm_var_syntax.y" { string name((yyvsp[(1) - (9)].val_str)); string vname((yyvsp[(3) - (9)].val_str)); @@ -1929,8 +1970,8 @@ yyreduce: break; -/* Line 1778 of yacc.c */ -#line 1934 "vm_var_syntax.cc" +/* Line 1792 of yacc.c */ +#line 1975 "vm_var_syntax.cc" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -2168,8 +2209,8 @@ yyreturn: } -/* Line 2041 of yacc.c */ -#line 495 "vm_var_syntax.y" +/* Line 2055 of yacc.c */ +#line 500 "vm_var_syntax.y" extern "C" void vm_var__error( diff --git a/src/vm/vm_var_syntax.h b/src/vm/vm_var_syntax.h index 0ea16d629e..18e8236991 100644 --- a/src/vm/vm_var_syntax.h +++ b/src/vm/vm_var_syntax.h @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.6.5. */ +/* A Bison parser, made by GNU Bison 2.7. */ /* Bison interface for Yacc-like parsers in C @@ -62,15 +62,15 @@ extern int vm_var__debug; #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE { -/* Line 2042 of yacc.c */ -#line 416 "vm_var_syntax.y" +/* Line 2058 of yacc.c */ +#line 421 "vm_var_syntax.y" char * val_str; int val_int; char val_char; -/* Line 2042 of yacc.c */ +/* Line 2058 of yacc.c */ #line 75 "vm_var_syntax.hh" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 diff --git a/src/vm/vm_var_syntax.y b/src/vm/vm_var_syntax.y index 37e4e94bf9..f3825ea209 100644 --- a/src/vm/vm_var_syntax.y +++ b/src/vm/vm_var_syntax.y @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -304,6 +304,11 @@ void insert_single(VirtualMachine * vm, else { vm->get_template_attribute(name.c_str(),value); + + if (value.empty()) + { + vm->get_user_template_attribute(name.c_str(),value); + } } if (!value.empty()) diff --git a/src/vm_template/SConstruct b/src/vm_template/SConstruct index fed0b89705..bb2e4e18c7 100644 --- a/src/vm_template/SConstruct +++ b/src/vm_template/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/vm # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/vm_template/VMTemplate.cc b/src/vm_template/VMTemplate.cc index 6cbd0b900e..af638437fd 100644 --- a/src/vm_template/VMTemplate.cc +++ b/src/vm_template/VMTemplate.cc @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------ */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -28,6 +28,7 @@ VMTemplate::VMTemplate(int id, int _gid, const string& _uname, const string& _gname, + int umask, VirtualMachineTemplate * _template_contents): PoolObjectSQL(id,TEMPLATE,"",_uid,_gid,_uname,_gname,table), regtime(time(0)) @@ -40,6 +41,8 @@ VMTemplate::VMTemplate(int id, { obj_template = new VirtualMachineTemplate; } + + set_umask(umask); } /* ------------------------------------------------------------------------ */ @@ -73,22 +76,17 @@ const char * VMTemplate::db_bootstrap = int VMTemplate::insert(SqlDB *db, string& error_str) { int rc; - ostringstream oss; // --------------------------------------------------------------------- // Check default attributes // --------------------------------------------------------------------- - // ------------ NAME & TEMPLATE_ID -------------------- - oss << oid; - - replace_template_attribute("TEMPLATE_ID",oss.str()); - get_template_attribute("NAME", name); if ( name.empty() == true ) { - oss.str(""); + ostringstream oss; + oss << "template-" << oid; name = oss.str(); } @@ -204,8 +202,8 @@ string& VMTemplate::to_xml(string& xml) const << "" << oid << "" << "" << uid << "" << "" << gid << "" - << "" << uname << "" - << "" << gname << "" + << "" << uname << "" + << "" << gname << "" << "" << name << "" << perms_to_xml(perm_str) << "" << regtime << "" diff --git a/src/vm_template/VMTemplatePool.cc b/src/vm_template/VMTemplatePool.cc index b88f3aec40..11d7003a24 100644 --- a/src/vm_template/VMTemplatePool.cc +++ b/src/vm_template/VMTemplatePool.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -28,6 +28,7 @@ int VMTemplatePool::allocate ( int gid, const string& uname, const string& gname, + int umask, VirtualMachineTemplate * template_contents, int * oid, string& error_str) @@ -40,7 +41,7 @@ int VMTemplatePool::allocate ( // ------------------------------------------------------------------------ // Build a new VMTemplate object // ------------------------------------------------------------------------ - vm_template = new VMTemplate(-1, uid, gid, uname, gname,template_contents); + vm_template = new VMTemplate(-1, uid, gid, uname, gname, umask, template_contents); // Check name vm_template->get_template_attribute("NAME", name); diff --git a/src/vm_template/test/SConstruct b/src/vm_template/test/SConstruct index ca95f5c3be..26477f64bb 100644 --- a/src/vm_template/test/SConstruct +++ b/src/vm_template/test/SConstruct @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # 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 diff --git a/src/vm_template/test/VMTemplatePoolTest.cc b/src/vm_template/test/VMTemplatePoolTest.cc index 8daeb5ecf0..80023b3e2c 100644 --- a/src/vm_template/test/VMTemplatePoolTest.cc +++ b/src/vm_template/test/VMTemplatePoolTest.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/vmm/LibVirtDriverKVM.cc b/src/vmm/LibVirtDriverKVM.cc index 2cec09ad83..7debfb0af8 100644 --- a/src/vmm/LibVirtDriverKVM.cc +++ b/src/vmm/LibVirtDriverKVM.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -56,9 +56,14 @@ int LibVirtDriver::deployment_description_kvm( string ro = ""; string driver = ""; string cache = ""; + string disk_io = ""; + string source = ""; + string clone = ""; + int disk_id; - string default_driver = ""; - string default_driver_cache = ""; + string default_driver = ""; + string default_driver_cache = ""; + string default_driver_disk_io = ""; bool readonly; const VectorAttribute * nic; @@ -84,8 +89,11 @@ int LibVirtDriver::deployment_description_kvm( const VectorAttribute * features; - string pae = ""; - string acpi = ""; + bool pae = false; + bool acpi = false; + + int pae_found = -1; + int acpi_found = -1; const VectorAttribute * raw; string default_raw; @@ -295,6 +303,7 @@ int LibVirtDriver::deployment_description_kvm( default_driver_cache = "default"; } + get_default("DISK","IO",default_driver_disk_io); // ------------------------------------------------------------------------ num = vm->get_template_attribute("DISK",attrs); @@ -305,7 +314,7 @@ int LibVirtDriver::deployment_description_kvm( if ( disk == 0 ) { - continue; + continue; } type = disk->vector_value("TYPE"); @@ -313,6 +322,10 @@ int LibVirtDriver::deployment_description_kvm( ro = disk->vector_value("READONLY"); driver = disk->vector_value("DRIVER"); cache = disk->vector_value("CACHE"); + disk_io= disk->vector_value("IO"); + source = disk->vector_value("SOURCE"); + clone = disk->vector_value("CLONE"); + disk->vector_value_str("DISK_ID", disk_id); if (target.empty()) @@ -324,7 +337,7 @@ int LibVirtDriver::deployment_description_kvm( if ( !ro.empty() ) { - transform(ro.begin(),ro.end(),ro.begin(),(int(*)(int))toupper); + one_util::toupper(ro); if ( ro == "YES" ) { @@ -334,7 +347,7 @@ int LibVirtDriver::deployment_description_kvm( // ---- Disk type and source for the image ---- - transform(type.begin(),type.end(),type.begin(),(int(*)(int))toupper); + one_util::toupper(type); if ( type == "BLOCK" ) { @@ -342,6 +355,19 @@ int LibVirtDriver::deployment_description_kvm( << "\t\t\t" << endl; } + else if ( type == "RBD" ) + { + file << "\t\t" << endl + << "\t\t\t" << endl; + } else if ( type == "CDROM" ) { file << "\t\t" << endl @@ -387,14 +413,23 @@ int LibVirtDriver::deployment_description_kvm( if ( !cache.empty() ) { - file << cache << "'/>" << endl; + file << cache << "'"; } else { - file << default_driver_cache << "'/>" << endl; + file << default_driver_cache << "'"; } - file << "\t\t" << endl; + if ( !disk_io.empty() ) + { + file << " io='" << disk_io << "'"; + } + else if ( !default_driver_disk_io.empty() ) + { + file << " io='" << default_driver_disk_io << "'"; + } + + file << "/>" << endl << "\t\t" << endl; } attrs.clear(); @@ -471,6 +506,11 @@ int LibVirtDriver::deployment_description_kvm( file << "\t\t\t" << endl; } + if ( vm->get_vnm_mad() == "ovswitch" ) + { + file << "\t\t\t" << endl; + } + if( !mac.empty() ) { file << "\t\t\t" << endl; @@ -545,10 +585,7 @@ int LibVirtDriver::deployment_description_kvm( passwd = graphics->vector_value("PASSWD"); keymap = graphics->vector_value("KEYMAP"); - transform(type.begin(), - type.end(), - type.begin(), - (int(*)(int))tolower); + one_util::tolower(type); if ( type == "vnc" || type == "spice" ) { @@ -629,31 +666,31 @@ int LibVirtDriver::deployment_description_kvm( if ( features != 0 ) { - pae = features->vector_value("PAE"); - acpi = features->vector_value("ACPI"); + pae_found = features->vector_value("PAE", pae); + acpi_found = features->vector_value("ACPI", acpi); } } - if ( pae.empty() ) + if ( pae_found != 0 ) { get_default("FEATURES", "PAE", pae); } - if ( acpi.empty() ) + if ( acpi_found != 0 ) { get_default("FEATURES", "ACPI", acpi); } - if( acpi == "yes" || pae == "yes" ) + if( acpi || pae ) { file << "\t" << endl; - if ( pae == "yes" ) + if ( pae ) { file << "\t\t" << endl; } - if ( acpi == "yes" ) + if ( acpi ) { file << "\t\t" << endl; } @@ -680,7 +717,7 @@ int LibVirtDriver::deployment_description_kvm( type = raw->vector_value("TYPE"); - transform(type.begin(),type.end(),type.begin(),(int(*)(int))toupper); + one_util::toupper(type); if ( type == "KVM" ) { diff --git a/src/vmm/LibVirtDriverVMware.cc b/src/vmm/LibVirtDriverVMware.cc index 483db3f357..b53a580086 100644 --- a/src/vmm/LibVirtDriverVMware.cc +++ b/src/vmm/LibVirtDriverVMware.cc @@ -1,7 +1,7 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -77,6 +77,7 @@ int LibVirtDriver::deployment_description_vmware( const VectorAttribute * raw; string data; string default_raw; + string data_vmx; // ------------------------------------------------------------------------ @@ -447,6 +448,12 @@ int LibVirtDriver::deployment_description_vmware( { data = raw->vector_value("DATA"); file << "\t" << data << endl; + + data_vmx = raw->vector_value("DATA_VMX"); + if ( !data_vmx.empty() ) + { + file << "\t" << data_vmx << "" << endl; + } } } diff --git a/src/vmm/SConstruct b/src/vmm/SConstruct index fdebcd1c3e..419cfb4053 100644 --- a/src/vmm/SConstruct +++ b/src/vmm/SConstruct @@ -1,7 +1,7 @@ # SConstruct for src/vmm # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/vmm/VirtualMachineManager.cc b/src/vmm/VirtualMachineManager.cc index 3838ec5845..5abe46be43 100644 --- a/src/vmm/VirtualMachineManager.cc +++ b/src/vmm/VirtualMachineManager.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -19,6 +19,7 @@ #include "XenDriver.h" #include "XMLDriver.h" #include "LibVirtDriver.h" +#include "NebulaUtil.h" #include "Nebula.h" @@ -146,6 +147,18 @@ void VirtualMachineManager::trigger(Actions action, int _vid) aname = "CANCEL_PREVIOUS"; break; + case CLEANUP: + aname = "CLEANUP"; + break; + + case CLEANUP_BOTH: + aname = "CLEANUP_BOTH"; + break; + + case CLEANUP_PREVIOUS: + aname = "CLEANUP_PREVIOUS"; + break; + case MIGRATE: aname = "MIGRATE"; break; @@ -178,6 +191,18 @@ void VirtualMachineManager::trigger(Actions action, int _vid) aname = "DETACH_NIC"; break; + case SNAPSHOT_CREATE: + aname = "SNAPSHOT_CREATE"; + break; + + case SNAPSHOT_REVERT: + aname = "SNAPSHOT_REVERT"; + break; + + case SNAPSHOT_DELETE: + aname = "SNAPSHOT_DELETE"; + break; + default: delete vid; return; @@ -242,6 +267,18 @@ void VirtualMachineManager::do_action(const string &action, void * arg) { cancel_previous_action(vid); } + else if (action == "CLEANUP") + { + cleanup_action(vid, false); + } + else if (action == "CLEANUP_BOTH") + { + cleanup_action(vid, true); + } + else if (action == "CLEANUP_PREVIOUS") + { + cleanup_previous_action(vid); + } else if (action == "MIGRATE") { migrate_action(vid); @@ -270,6 +307,18 @@ void VirtualMachineManager::do_action(const string &action, void * arg) { detach_nic_action(vid); } + else if (action == "SNAPSHOT_CREATE") + { + snapshot_create_action(vid); + } + else if (action == "SNAPSHOT_REVERT") + { + snapshot_revert_action(vid); + } + else if (action == "SNAPSHOT_DELETE") + { + snapshot_delete_action(vid); + } else if (action == ACTION_TIMER) { timer_action(); @@ -372,7 +421,7 @@ string * VirtualMachineManager::format_message( oss << tmpl << ""; - return SSLTools::base64_encode(oss.str()); + return one_util::base64_encode(oss.str()); } /* -------------------------------------------------------------------------- */ @@ -941,6 +990,183 @@ error_common: /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +void VirtualMachineManager::cleanup_action( + int vid, bool cancel_previous) +{ + int rc; + + VirtualMachine * vm; + ostringstream os; + + string vm_tmpl; + string * drv_msg; + + string m_hostname = ""; + string m_net_drv = ""; + + const VirtualMachineManagerDriver * vmd; + + Nebula& nd = Nebula::instance(); + + // Get the VM from the pool + vm = vmpool->get(vid,true); + + if (vm == 0) + { + return; + } + + if (!vm->hasHistory()) + { + goto error_history; + } + + // Get the driver for this VM + vmd = get(vm->get_vmm_mad()); + + if ( vmd == 0 ) + { + goto error_driver; + } + + if ( cancel_previous && vm->hasPreviousHistory() ) + { + m_hostname = vm->get_previous_hostname(); + m_net_drv = vm->get_previous_vnm_mad(); + } + + rc = nd.get_tm()->epilog_delete_commands(vm, os, false, false); + + if ( rc != 0 ) + { + goto error_common; + } + + // Invoke driver method + drv_msg = format_message( + vm->get_hostname(), + vm->get_vnm_mad(), + m_hostname, + m_net_drv, + vm->get_deploy_id(), + "", + "", + "", + os.str(), + "", + vm->to_xml(vm_tmpl)); + + vmd->cleanup(vid, *drv_msg); + + delete drv_msg; + + vm->unlock(); + + return; + +error_history: + os.str(""); + os << "cleanup_action, VM has no history"; + goto error_common; + +error_driver: + os.str(""); + os << "cleanup_action, error getting driver " << vm->get_vmm_mad(); + +error_common: + (nd.get_lcm())->trigger(LifeCycleManager::CLEANUP_FAILURE, vid); + + vm->unlock(); + return; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void VirtualMachineManager::cleanup_previous_action( + int vid) +{ + int rc; + + VirtualMachine * vm; + ostringstream os; + + string vm_tmpl; + string * drv_msg; + + const VirtualMachineManagerDriver * vmd; + + Nebula& nd = Nebula::instance(); + + // Get the VM from the pool + vm = vmpool->get(vid,true); + + if (vm == 0) + { + return; + } + + if (!vm->hasHistory() || !vm->hasPreviousHistory()) + { + goto error_history; + } + + // Get the driver for this VM + vmd = get(vm->get_vmm_mad()); + + if ( vmd == 0 ) + { + goto error_driver; + } + + rc = nd.get_tm()->epilog_delete_commands(vm, os, false, true); + + if ( rc != 0 ) + { + goto error_common; + } + + // Invoke driver method + drv_msg = format_message( + vm->get_previous_hostname(), + vm->get_previous_vnm_mad(), + "", + "", + vm->get_deploy_id(), + "", + "", + "", + os.str(), + "", + vm->to_xml(vm_tmpl)); + + vmd->cleanup(vid, *drv_msg); + + delete drv_msg; + + vm->unlock(); + + return; + +error_history: + os.str(""); + os << "cleanup_previous_action, VM has no history"; + goto error_common; + +error_driver: + os.str(""); + os << "cleanup_previous_action, error getting driver " << vm->get_vmm_mad(); + +error_common: + (nd.get_lcm())->trigger(LifeCycleManager::CLEANUP_FAILURE, vid); + + vm->unlock(); + return; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + void VirtualMachineManager::migrate_action( int vid) { @@ -1152,8 +1378,6 @@ void VirtualMachineManager::poll_action( "", vm->to_xml(vm_tmpl)); - vm->set_last_poll(time(0)); - vmd->poll(vid, *drv_msg); delete drv_msg; @@ -1235,7 +1459,8 @@ error_common: void VirtualMachineManager::timer_action() { - static int mark = 0; + static int mark = 0; + static int timer_start = time(0); VirtualMachine * vm; vector oids; @@ -1261,6 +1486,13 @@ void VirtualMachineManager::timer_action() // Clear the expired monitoring records vmpool->clean_expired_monitoring(); + // Skip monitoring the first poll_period to allow the Host monitoring to + // gather the VM info + if ( timer_start + poll_period > thetime ) + { + return; + } + // Monitor only VMs that hasn't been monitored for 'poll_period' seconds. rc = vmpool->get_running(oids, vm_limit, thetime - poll_period); @@ -1293,8 +1525,6 @@ void VirtualMachineManager::timer_action() os << "Monitoring VM " << *it << "."; NebulaLog::log("VMM", Log::INFO, os); - vm->set_last_poll(thetime); - vmd = get(vm->get_vmm_mad()); if ( vmd == 0 ) @@ -1320,8 +1550,6 @@ void VirtualMachineManager::timer_action() delete drv_msg; - vmpool->update(vm); - vm->unlock(); } } @@ -1382,7 +1610,7 @@ void VirtualMachineManager::attach_action( vm_tm_mad = vm->get_tm_mad(); opennebula_hostname = nd.get_nebula_hostname(); - rc = Nebula::instance().get_tm()->prolog_transfer_command( + rc = nd.get_tm()->prolog_transfer_command( vm, disk, vm_tm_mad, @@ -1576,6 +1804,237 @@ error_common: /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +void VirtualMachineManager::snapshot_create_action(int vid) +{ + VirtualMachine * vm; + const VirtualMachineManagerDriver * vmd; + + ostringstream os; + + string vm_tmpl; + string* drv_msg; + + // Get the VM from the pool + vm = vmpool->get(vid,true); + + if (vm == 0) + { + return; + } + + if (!vm->hasHistory()) + { + goto error_history; + } + + // Get the driver for this VM + vmd = get(vm->get_vmm_mad()); + + if ( vmd == 0 ) + { + goto error_driver; + } + + drv_msg = format_message( + vm->get_hostname(), + vm->get_vnm_mad(), + "", + "", + vm->get_deploy_id(), + "", + "", + "", + "", + "", + vm->to_xml(vm_tmpl)); + + vmd->snapshot_create(vid, *drv_msg); + + delete drv_msg; + + vm->unlock(); + + return; + +error_history: + os.str(""); + os << "snapshot_create_action, VM has no history"; + goto error_common; + +error_driver: + os.str(""); + os << "snapshot_create_action, error getting driver " << vm->get_vmm_mad(); + goto error_common; + +error_common: + Nebula &ne = Nebula::instance(); + LifeCycleManager * lcm = ne.get_lcm(); + + lcm->trigger(LifeCycleManager::SNAPSHOT_CREATE_FAILURE, vid); + + vm->log("VMM", Log::ERROR, os); + vm->unlock(); + return; + +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void VirtualMachineManager::snapshot_revert_action(int vid) +{ + VirtualMachine * vm; + const VirtualMachineManagerDriver * vmd; + + ostringstream os; + + string vm_tmpl; + string* drv_msg; + + // Get the VM from the pool + vm = vmpool->get(vid,true); + + if (vm == 0) + { + return; + } + + if (!vm->hasHistory()) + { + goto error_history; + } + + // Get the driver for this VM + vmd = get(vm->get_vmm_mad()); + + if ( vmd == 0 ) + { + goto error_driver; + } + + drv_msg = format_message( + vm->get_hostname(), + vm->get_vnm_mad(), + "", + "", + vm->get_deploy_id(), + "", + "", + "", + "", + "", + vm->to_xml(vm_tmpl)); + + vmd->snapshot_revert(vid, *drv_msg); + + delete drv_msg; + + vm->unlock(); + + return; + +error_history: + os.str(""); + os << "snapshot_revert_action, VM has no history"; + goto error_common; + +error_driver: + os.str(""); + os << "snapshot_revert_action, error getting driver " << vm->get_vmm_mad(); + goto error_common; + +error_common: + Nebula &ne = Nebula::instance(); + LifeCycleManager * lcm = ne.get_lcm(); + + lcm->trigger(LifeCycleManager::SNAPSHOT_REVERT_FAILURE, vid); + + vm->log("VMM", Log::ERROR, os); + vm->unlock(); + return; + +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void VirtualMachineManager::snapshot_delete_action(int vid) +{ + VirtualMachine * vm; + const VirtualMachineManagerDriver * vmd; + + ostringstream os; + + string vm_tmpl; + string* drv_msg; + + // Get the VM from the pool + vm = vmpool->get(vid,true); + + if (vm == 0) + { + return; + } + + if (!vm->hasHistory()) + { + goto error_history; + } + + // Get the driver for this VM + vmd = get(vm->get_vmm_mad()); + + if ( vmd == 0 ) + { + goto error_driver; + } + + drv_msg = format_message( + vm->get_hostname(), + vm->get_vnm_mad(), + "", + "", + vm->get_deploy_id(), + "", + "", + "", + "", + "", + vm->to_xml(vm_tmpl)); + + vmd->snapshot_delete(vid, *drv_msg); + + delete drv_msg; + + vm->unlock(); + + return; + +error_history: + os.str(""); + os << "snapshot_delete_action, VM has no history"; + goto error_common; + +error_driver: + os.str(""); + os << "snapshot_delete_action, error getting driver " << vm->get_vmm_mad(); + goto error_common; + +error_common: + Nebula &ne = Nebula::instance(); + LifeCycleManager * lcm = ne.get_lcm(); + + lcm->trigger(LifeCycleManager::SNAPSHOT_DELETE_FAILURE, vid); + + vm->log("VMM", Log::ERROR, os); + vm->unlock(); + return; + +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + void VirtualMachineManager::attach_nic_action( int vid) { diff --git a/src/vmm/VirtualMachineManagerDriver.cc b/src/vmm/VirtualMachineManagerDriver.cc index f343053521..9cd9ea6ce0 100644 --- a/src/vmm/VirtualMachineManagerDriver.cc +++ b/src/vmm/VirtualMachineManagerDriver.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ @@ -19,6 +19,7 @@ #include "LifeCycleManager.h" #include "Nebula.h" +#include "NebulaUtil.h" #include VirtualMachineManagerDriver::VirtualMachineManagerDriver( @@ -98,6 +99,31 @@ void VirtualMachineManagerDriver::get_default( } } +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +bool VirtualMachineManagerDriver::get_default( + const char * name, + const char * vname, + bool& value) const +{ + string st; + + get_default(name, vname, st); + + if ( st == "" ) + { + value = false; + return false; + } + + one_util::toupper(st); + + value = ( st == "YES" ); + + return true; +} + /* ************************************************************************** */ /* MAD Interface */ /* ************************************************************************** */ @@ -106,8 +132,8 @@ void VirtualMachineManagerDriver::get_default( /* Helpers for the protocol function */ /* -------------------------------------------------------------------------- */ -static void log_error(VirtualMachine* vm, - ostringstream& os, +static void log_error(VirtualMachine* vm, + ostringstream& os, istringstream& is, const char * msg) { @@ -186,8 +212,7 @@ void VirtualMachineManagerDriver::protocol( return; } - if ( vm->get_lcm_state() == VirtualMachine::CLEANUP || - vm->get_lcm_state() == VirtualMachine::FAILURE || + if ( vm->get_lcm_state() == VirtualMachine::FAILURE || vm->get_lcm_state() == VirtualMachine::LCM_INIT ) { os.str(""); @@ -207,12 +232,10 @@ void VirtualMachineManagerDriver::protocol( if (result == "SUCCESS") { string deploy_id; - time_t thetime = time(0); is >> deploy_id; vm->update_info(deploy_id); - vm->set_last_poll(thetime); vmpool->update(vm); @@ -237,7 +260,7 @@ void VirtualMachineManagerDriver::protocol( } else { - log_error(vm,os,is,"Error shuting down VM"); + log_error(vm,os,is,"Error shutting down VM"); vmpool->update(vm); lcm->trigger(LifeCycleManager::SHUTDOWN_FAILURE, id); @@ -315,7 +338,7 @@ void VirtualMachineManagerDriver::protocol( { if (result == "SUCCESS") { - vm->log("VMM",Log::ERROR,"VM Successfully rebooted."); + vm->log("VMM",Log::INFO,"VM successfully rebooted."); } else { @@ -327,7 +350,7 @@ void VirtualMachineManagerDriver::protocol( { if (result == "SUCCESS") { - vm->log("VMM",Log::ERROR,"VM Successfully reseted."); + vm->log("VMM",Log::INFO,"VM successfully reset."); } else { @@ -342,7 +365,7 @@ void VirtualMachineManagerDriver::protocol( if ( result == "SUCCESS" ) { - vm->log("VMM", Log::ERROR, "VM Disk Successfully attached."); + vm->log("VMM", Log::INFO, "VM Disk successfully attached."); lcm->trigger(LifeCycleManager::ATTACH_SUCCESS, id); } @@ -361,7 +384,7 @@ void VirtualMachineManagerDriver::protocol( if ( result == "SUCCESS" ) { - vm->log("VMM",Log::ERROR,"VM Disk Successfully detached."); + vm->log("VMM",Log::INFO,"VM Disk successfully detached."); lcm->trigger(LifeCycleManager::DETACH_SUCCESS, id); } @@ -411,165 +434,107 @@ void VirtualMachineManagerDriver::protocol( lcm->trigger(LifeCycleManager::DETACH_NIC_FAILURE, id); } } + else if ( action == "SNAPSHOTCREATE" ) + { + Nebula &ne = Nebula::instance(); + LifeCycleManager *lcm = ne.get_lcm(); + + if ( result == "SUCCESS" ) + { + string hypervisor_id; + + is >> hypervisor_id; + + vm->update_snapshot_id(hypervisor_id); + + vmpool->update(vm); + + vm->log("VMM", Log::INFO, "VM Snapshot successfully created."); + + lcm->trigger(LifeCycleManager::SNAPSHOT_CREATE_SUCCESS, id); + } + else + { + log_error(vm, os, is, "Error creating new VM Snapshot"); + vmpool->update(vm); + + lcm->trigger(LifeCycleManager::SNAPSHOT_CREATE_FAILURE, id); + } + } + else if ( action == "SNAPSHOTREVERT" ) + { + Nebula &ne = Nebula::instance(); + LifeCycleManager *lcm = ne.get_lcm(); + + if ( result == "SUCCESS" ) + { + vm->log("VMM",Log::INFO,"VM Snapshot successfully reverted."); + + lcm->trigger(LifeCycleManager::SNAPSHOT_REVERT_SUCCESS, id); + } + else + { + log_error(vm,os,is,"Error reverting VM Snapshot"); + vmpool->update(vm); + + lcm->trigger(LifeCycleManager::SNAPSHOT_REVERT_FAILURE, id); + } + } + else if ( action == "SNAPSHOTDELETE" ) + { + Nebula &ne = Nebula::instance(); + LifeCycleManager *lcm = ne.get_lcm(); + + if ( result == "SUCCESS" ) + { + vm->log("VMM",Log::INFO,"VM Snapshot successfully deleted."); + + lcm->trigger(LifeCycleManager::SNAPSHOT_DELETE_SUCCESS, id); + } + else + { + log_error(vm,os,is,"Error deleting VM Snapshot"); + vmpool->update(vm); + + lcm->trigger(LifeCycleManager::SNAPSHOT_DELETE_FAILURE, id); + } + } + else if ( action == "CLEANUP" ) + { + Nebula &ne = Nebula::instance(); + LifeCycleManager *lcm = ne.get_lcm(); + + if ( result == "SUCCESS" ) + { + vm->log("VMM", Log::INFO, "Host successfully cleaned."); + + lcm->trigger(LifeCycleManager::CLEANUP_SUCCESS, id); + } + else + { + log_error(vm, os, is, "Error cleaning Host"); + vmpool->update(vm); + + lcm->trigger(LifeCycleManager::CLEANUP_FAILURE, id); + } + } else if ( action == "POLL" ) { if (result == "SUCCESS") { - size_t pos; + string monitor_str; + getline(is, monitor_str); - string tmp; - string var; - ostringstream os; - istringstream tiss; - - int cpu = -1; - int memory = -1; - long long net_tx = -1; - long long net_rx = -1; - char state = '-'; - - string monitor_str = is.str(); - bool parse_error = false; - - while(is.good()) - { - is >> tmp >> ws; - - pos = tmp.find('='); - - if ( pos == string::npos ) - { - parse_error = true; - continue; - } - - tmp.replace(pos,1," "); - - tiss.clear(); - - tiss.str(tmp); - - tiss >> var >> ws; - - if (!tiss.good()) - { - parse_error = true; - continue; - } - - if (var == "USEDMEMORY") - { - tiss >> memory; - } - else if (var == "USEDCPU") - { - tiss >> cpu; - } - else if (var == "NETRX") - { - tiss >> net_rx; - } - else if (var == "NETTX") - { - tiss >> net_tx; - } - else if (var == "STATE") - { - tiss >> state; - } - else if (!var.empty()) - { - string val; - - os.str(""); - os << "Adding custom monitoring attribute: " << tmp; - - vm->log("VMM",Log::WARNING,os); - - tiss >> val; - - vm->replace_template_attribute(var,val); - } - } - - if (parse_error) - { - os.str(""); - os << "Error parsing monitoring str:\"" << monitor_str <<"\""; - - vm->log("VMM",Log::ERROR,os); - - vm->set_template_error_message(os.str()); - vmpool->update(vm); - - vm->unlock(); - return; - } - - vm->update_info(memory,cpu,net_tx,net_rx); - vm->set_vm_info(); - - vmpool->update(vm); - vmpool->update_history(vm); - vmpool->update_monitoring(vm); - - if (state != '-' && - (vm->get_lcm_state() == VirtualMachine::RUNNING || - vm->get_lcm_state() == VirtualMachine::UNKNOWN)) - { - Nebula &ne = Nebula::instance(); - LifeCycleManager * lcm = ne.get_lcm(); - - switch (state) - { - case 'a': // Still active, good! - os.str(""); - os << "Monitor Information:\n" - << "\tCPU : "<< cpu << "\n" - << "\tMemory: "<< memory << "\n" - << "\tNet_TX: "<< net_tx << "\n" - << "\tNet_RX: "<< net_rx; - vm->log("VMM",Log::DEBUG,os); - - if ( vm->get_lcm_state() == VirtualMachine::UNKNOWN) - { - vm->log("VMM",Log::INFO,"VM was now found, new state is" - " RUNNING"); - vm->set_state(VirtualMachine::RUNNING); - vmpool->update(vm); - } - break; - - case 'p': // It's paused - vm->log("VMM",Log::INFO,"VM running but new state " - "from monitor is PAUSED."); - - lcm->trigger(LifeCycleManager::MONITOR_SUSPEND, id); - break; - - case 'e': //Failed - vm->log("VMM",Log::INFO,"VM running but new state " - "from monitor is ERROR."); - - lcm->trigger(LifeCycleManager::MONITOR_FAILURE, id); - break; - - case 'd': //The VM was not found - vm->log("VMM",Log::INFO,"VM running but it was not found." - " Restart and delete actions available or try to" - " recover it manually"); - - lcm->trigger(LifeCycleManager::MONITOR_DONE, id); - break; - } - } + process_poll(vm, monitor_str); } else { - log_error(vm,os,is,"Error monitoring VM"); - vmpool->update(vm); + Nebula &ne = Nebula::instance(); + LifeCycleManager* lcm = ne.get_lcm(); - vm->log("VMM",Log::ERROR,os); + log_error(vm, os, is, "Error monitoring VM"); + + lcm->trigger(LifeCycleManager::MONITOR_DONE, vm->get_oid()); } } else if (action == "LOG") @@ -586,6 +551,223 @@ void VirtualMachineManagerDriver::protocol( /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +void VirtualMachineManagerDriver::process_poll( + int id, + const string &monitor_str) +{ + // Get the VM from the pool + VirtualMachine* vm = Nebula::instance().get_vmpool()->get(id,true); + + if ( vm == 0 ) + { + return; + } + + process_poll(vm, monitor_str); + + vm->unlock(); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void VirtualMachineManagerDriver::process_poll( + VirtualMachine* vm, + const string& monitor_str) +{ + int rc; + + int cpu; + int memory; + long long net_tx; + long long net_rx; + char state; + + map custom; + ostringstream oss; + + Nebula &ne = Nebula::instance(); + + LifeCycleManager* lcm = ne.get_lcm(); + VirtualMachinePool* vmpool = ne.get_vmpool(); + + /* ---------------------------------------------------------------------- */ + /* Parse VM info and update VM */ + /* ---------------------------------------------------------------------- */ + + rc = parse_vm_info(monitor_str, cpu, memory, net_tx, net_rx, state, custom); + + if (rc == -1) + { + oss << "Error parsing monitoring information: " << monitor_str; + NebulaLog::log("VMM", Log::ERROR, oss); + + vm->set_template_error_message(oss.str()); + vm->log("VMM", Log::ERROR, oss); + + vmpool->update(vm); + + lcm->trigger(LifeCycleManager::MONITOR_DONE, vm->get_oid()); + + return; + } + + oss << "VM " << vm->get_oid() << " successfully monitored: " << monitor_str; + NebulaLog::log("VMM", Log::INFO, oss); + + vm->update_info(memory, cpu, net_tx, net_rx, custom); + + vmpool->update(vm); + + vmpool->update_history(vm); + + vmpool->update_monitoring(vm); + + /* ---------------------------------------------------------------------- */ + /* Process the VM state from the monitoring info */ + /* ---------------------------------------------------------------------- */ + + if (state == '-' || ( vm->get_lcm_state() != VirtualMachine::RUNNING && + vm->get_lcm_state() != VirtualMachine::UNKNOWN)) + { + return; + } + + switch (state) + { + case 'a': // Still active, good! + if ( vm->get_lcm_state() == VirtualMachine::UNKNOWN) + { + vm->log("VMM", Log::INFO, "VM found again, state is RUNNING"); + + vm->set_state(VirtualMachine::RUNNING); + vmpool->update(vm); + } + break; + + case 'p': // It's paused + vm->log("VMM",Log::INFO, "VM running but monitor state is PAUSED."); + + lcm->trigger(LifeCycleManager::MONITOR_SUSPEND, vm->get_oid()); + break; + + case 'e': //Failed + vm->log("VMM", Log::INFO, "VM running but monitor state is ERROR."); + + lcm->trigger(LifeCycleManager::MONITOR_FAILURE, vm->get_oid()); + break; + + case 'd': //The VM was not found + vm->log("VMM", Log::INFO, "VM running but it was not found." + " Restart and delete actions available or try to" + " recover it manually"); + + lcm->trigger(LifeCycleManager::MONITOR_DONE, vm->get_oid()); + break; + } +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +int VirtualMachineManagerDriver::parse_vm_info( + const string& monitor_str, + int &cpu, + int &memory, + long long &net_tx, + long long &net_rx, + char &state, + map &custom) +{ + istringstream is; + + int parse_result = 0; + size_t pos; + + string tmp; + string var; + + ostringstream os; + istringstream tiss; + + cpu = -1; + memory = -1; + net_tx = -1; + net_rx = -1; + state = '-'; + + custom.clear(); + + is.str(monitor_str); + + while(parse_result == 0 && is.good()) + { + is >> tmp >> ws; + + pos = tmp.find('='); + + if ( pos == string::npos ) + { + parse_result = -1; + continue; + } + + tmp.replace(pos,1," "); + + tiss.clear(); + + tiss.str(tmp); + + tiss >> var >> ws; + + if (!tiss.good()) + { + parse_result = -1; + continue; + } + + if (var == "USEDMEMORY") + { + tiss >> memory; + } + else if (var == "USEDCPU") + { + tiss >> fixed >> cpu; + } + else if (var == "NETRX") + { + tiss >> net_rx; + } + else if (var == "NETTX") + { + tiss >> net_tx; + } + else if (var == "STATE") + { + tiss >> state; + } + else if (!var.empty()) + { + string val; + + tiss >> val; + + custom.insert(make_pair(var, val)); + } + + if (tiss.fail()) + { + parse_result = -1; + continue; + } + } + + return parse_result; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + void VirtualMachineManagerDriver::recover() { NebulaLog::log("VMM",Log::INFO,"Recovering VMM drivers"); diff --git a/src/vmm/XMLDriver.cc b/src/vmm/XMLDriver.cc index 57d086c3f3..dde76bcbdb 100644 --- a/src/vmm/XMLDriver.cc +++ b/src/vmm/XMLDriver.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/vmm/XenDriver.cc b/src/vmm/XenDriver.cc index 7b89e0ebfb..6a9c19a725 100644 --- a/src/vmm/XenDriver.cc +++ b/src/vmm/XenDriver.cc @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ /* */ /* 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 */ diff --git a/src/vmm_mad/dummy/one_vmm_dummy b/src/vmm_mad/dummy/one_vmm_dummy index d70aabf5df..1101efd057 100755 --- a/src/vmm_mad/dummy/one_vmm_dummy +++ b/src/vmm_mad/dummy/one_vmm_dummy @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/vmm_mad/dummy/one_vmm_dummy.rb b/src/vmm_mad/dummy/one_vmm_dummy.rb index eceb97d040..e01f746d29 100755 --- a/src/vmm_mad/dummy/one_vmm_dummy.rb +++ b/src/vmm_mad/dummy/one_vmm_dummy.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # @@ -140,6 +140,30 @@ class DummyDriver < VirtualMachineDriver send_message(ACTION[:detach_nic],result,id) end + def snapshot_create(id, drv_message) + result = retrieve_result("snapshot_create") + + send_message(ACTION[:snapshot_create], result, id, "dummy-snap") + end + + def snapshot_revert(id, drv_message) + result = retrieve_result("snapshot_revert") + + send_message(ACTION[:snapshot_revert], result, id) + end + + def snapshot_delete(id, drv_message) + result = retrieve_result("snapshot_delete") + + send_message(ACTION[:snapshot_delete], result, id) + end + + def cleanup(id, drv_message) + result = retrieve_result("cleanup") + + send_message(ACTION[:cleanup],result,id) + end + def poll(id, drv_message) result = retrieve_result("poll") @@ -171,13 +195,33 @@ class DummyDriver < VirtualMachineDriver "#{POLL_ATTRIBUTE[:nettx]}=#{prev_nettx+(50*rand(3))} " \ "#{POLL_ATTRIBUTE[:netrx]}=#{prev_netrx+(100*rand(4))} " \ "#{POLL_ATTRIBUTE[:usedmemory]}=#{max_memory * (rand(80)+20)/100} " \ - "#{POLL_ATTRIBUTE[:usedcpu]}=#{max_cpu * (rand(95)+5)/100}" + "#{POLL_ATTRIBUTE[:usedcpu]}=#{max_cpu * (rand(95)+5)/100}" send_message(ACTION[:poll],result,id,monitor_info) end private + # Retrives the result for a given action from the OpenNebula core. Each + # action has a defined set of responses in: + # /tmp/opennebula_dummy_actions/ + # + # Each line of this file represents a response in the form: + # <"sucess|0" | "failure|1" | "-"> [sleep] + # + # - success or 1 returns SUCCESS + # - failure o 0 returns FAILURE + # - "-" returns nothing + # - sleep optional number of seconds to wait before answering + # + # Example: /tmp/opennebula_dummy_actions/deploy + # 0 + # 0 + # 1 120 + # 1 + # - + # 0 + # def retrieve_result(action) begin actions = File.read(DUMMY_ACTIONS_DIR+"/#{action}") @@ -190,20 +234,28 @@ class DummyDriver < VirtualMachineDriver action_id %= actions_array.size if actions_array && actions_array[action_id] - result = actions_array[action_id] - if result == "success" || result == 0 || result == "0" - return RESULT[:success] - else - return RESULT[:failure] - end @actions_counter[action] += 1 + + result = actions_array[action_id].split + + case result[0] + when "success", 1, "1" + sleep result[1].to_i if result[1] + return RESULT[:success] + when "failure", 0, "0" + sleep result[1].to_i if result[1] + return RESULT[:failure] + when "-" + return nil + else + return RESULT[:success] + end else return RESULT[:success] end - end end dd = DummyDriver.new -dd.start_driver \ No newline at end of file +dd.start_driver diff --git a/src/vmm_mad/ec2/one_vmm_ec2 b/src/vmm_mad/ec2/one_vmm_ec2 index 7abe54e0b9..ae1c9896ab 100755 --- a/src/vmm_mad/ec2/one_vmm_ec2 +++ b/src/vmm_mad/ec2/one_vmm_ec2 @@ -1,7 +1,7 @@ #!/bin/bash # -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/vmm_mad/ec2/one_vmm_ec2.rb b/src/vmm_mad/ec2/one_vmm_ec2.rb index 467b9e86f8..f6d223b2ec 100755 --- a/src/vmm_mad/ec2/one_vmm_ec2.rb +++ b/src/vmm_mad/ec2/one_vmm_ec2.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby # ---------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # # # # 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 # diff --git a/src/vmm_mad/ec2/vmm_ec2.conf b/src/vmm_mad/ec2/vmm_ec2.conf index 75052d552b..e80cd87b98 100644 --- a/src/vmm_mad/ec2/vmm_ec2.conf +++ b/src/vmm_mad/ec2/vmm_ec2.conf @@ -1,6 +1,6 @@