diff --git a/include/ImageTemplate.h b/include/ImageTemplate.h index df7661e96a..7bd1b867ed 100644 --- a/include/ImageTemplate.h +++ b/include/ImageTemplate.h @@ -30,6 +30,20 @@ public: ImageTemplate() : Template(true,'=',"TEMPLATE"){}; ~ImageTemplate(){}; + + /** + * Checks the template for RESTRICTED ATTRIBUTES + * @param rs_attr the first restricted attribute found if any + * @return true if a restricted attribute is found in the template + */ + bool check(string& rs_attr) + { + vector restricted_attributes; + + restricted_attributes.push_back("SOURCE"); + + return Template::check(rs_attr, restricted_attributes); + }; }; /* -------------------------------------------------------------------------- */ diff --git a/include/Template.h b/include/Template.h index 79d2ec45bb..8a1dbe8b9a 100644 --- a/include/Template.h +++ b/include/Template.h @@ -221,6 +221,13 @@ protected: */ Attribute* vector_xml_att(const xmlNode * node); + /** + * Checks the template for RESTRICTED ATTRIBUTES + * @param rs_attr the first restricted attribute found if any + * @return true if a restricted attribute is found in the template + */ + bool check(string& rs_attr, const vector &restricted_attributes); + private: bool replace_mode; diff --git a/include/VirtualMachineTemplate.h b/include/VirtualMachineTemplate.h index 394de28d7f..f60cbca9a1 100644 --- a/include/VirtualMachineTemplate.h +++ b/include/VirtualMachineTemplate.h @@ -41,20 +41,18 @@ public: * @param rs_attr the first restricted attribute found if any * @return true if a restricted attribute is found in the template */ - bool check(string& rs_attr); + bool check(string& rs_attr) + { + vector restricted_attributes; -private: - /** - * Number of restricted attributes - */ - const static int RS_ATTRS_LENGTH; + restricted_attributes.push_back("CONTEXT/FILES"); + restricted_attributes.push_back("DISK/SOURCE"); + restricted_attributes.push_back("NIC/MAC"); + restricted_attributes.push_back("NIC/VLAN_ID"); + restricted_attributes.push_back("RANK"); - /** - * Restricted template attributes in the form - * 'SINGLE' or 'VECTOR/ATTR'. Restricted attributes are only - * allowed for ONE_ADMIN Group. - */ - const static string RESTRICTED_ATTRIBUTES[]; + return Template::check(rs_attr, restricted_attributes); + }; friend class VirtualMachine; }; diff --git a/src/authm/AuthManager.cc b/src/authm/AuthManager.cc index cbfb2741fc..348782c68a 100644 --- a/src/authm/AuthManager.cc +++ b/src/authm/AuthManager.cc @@ -88,7 +88,7 @@ void AuthRequest::add_auth(Operation op, if ( auth == false ) { - ostringstream oss; + oss.str(""); oss << message; diff --git a/src/authm/test/AuthManagerTest.cc b/src/authm/test/AuthManagerTest.cc index d0a82b8f86..38635216ff 100644 --- a/src/authm/test/AuthManagerTest.cc +++ b/src/authm/test/AuthManagerTest.cc @@ -180,10 +180,11 @@ public: //OBJECT:OBJECT_ID:ACTION:OWNER:PUBLIC:CORE_RESULT - string astr = "VM:VGhpcyBpcyBhIHRlbXBsYXRlCg==:CREATE:-1:0:0 " - "IMAGE:2:USE:3:0:0 " - "NET:4:MANAGE:5:1:0 " - "HOST:6:MANAGE:7:1:0 0"; + string astr = "VM:VGhpcyBpcyBhIHRlbXBsYXRlCg==:CREATE:2:0 " + "IMAGE:2:USE:3:0 " + "NET:4:MANAGE:5:0 " + "HOST:6:MANAGE:7:0 " + "0"; PoolObjectAuth perm; @@ -230,7 +231,7 @@ public: AuthRequest ar1(2, 2); - string astr1= "VM:VGhpcyBpcyBhIHRlbXBsYXRlCg==:CREATE:-1:0:0 0"; + string astr1= "VM:VGhpcyBpcyBhIHRlbXBsYXRlCg==:CREATE:2:0 0"; ar1.add_create_auth(PoolObjectSQL::VM, "This is a template\n"); @@ -259,15 +260,15 @@ public: am->trigger(AuthManager::AUTHORIZE,&ar2); ar2.wait(); //* - if ( ar1.result != false ) + if ( ar2.result != false ) { - cout << endl << "ar.result: " << ar1.result << endl; + cout << endl << "ar2.result: " << ar2.result << endl; } - if ( ar1.message != astr1 ) + if ( ar2.message != astr2 ) { - cout << endl << "ar.message: " << ar1.message; - cout << endl << "expected: " << astr1 << endl; + cout << endl << "ar2.message: " << ar2.message; + cout << endl << "expected: " << astr2 << endl; } //*/ CPPUNIT_ASSERT(ar2.result==false); diff --git a/src/host/test/HostPoolTest.cc b/src/host/test/HostPoolTest.cc index 1e87ecbde0..044d154d63 100644 --- a/src/host/test/HostPoolTest.cc +++ b/src/host/test/HostPoolTest.cc @@ -181,7 +181,7 @@ protected: host->to_xml(xml_str); // A little help for debugging -/* +//* if( xml_str != xmls[index] ) { cout << endl << xml_str << endl << "========" @@ -284,7 +284,7 @@ public: string result = oss.str(); // A little help for debugging -/* +//* if( result != xml_dump ) { cout << endl << result << endl << "========" @@ -311,14 +311,14 @@ public: ostringstream oss; - rc = ((HostPool*)pool)->dump(oss, "name LIKE 'a%' ORDER BY oid"); + rc = ((HostPool*)pool)->dump(oss, "name LIKE 'a%'"); CPPUNIT_ASSERT(rc == 0); string result = oss.str(); // A little help for debugging -/* +//* if( result != xml_dump_like_a ) { cout << endl << result << endl << "========" diff --git a/src/image/Image.cc b/src/image/Image.cc index dca65bf838..181300ce56 100644 --- a/src/image/Image.cc +++ b/src/image/Image.cc @@ -93,6 +93,23 @@ int Image::insert(SqlDB *db, string& error_str) string persistent_attr; string dev_prefix; string source_attr; + string aname; + + ostringstream oss; + + // ------------------------------------------------------------------------ + // Check template for restricted attributes + // ------------------------------------------------------------------------ + + if ( uid != 0 && gid != GroupPool::ONEADMIN_ID ) + { + ImageTemplate *img_template = static_cast(obj_template); + + if (img_template->check(aname)) + { + goto error_restricted; + } + } // --------------------------------------------------------------------- // Check default image attributes @@ -204,6 +221,11 @@ error_path_and_source: error_str = "Template malformed, PATH and SOURCE are mutually exclusive."; goto error_common; +error_restricted: + oss << "Template includes a restricted attribute " << aname << "."; + error_str = oss.str(); + goto error_common; + error_common: NebulaLog::log("IMG", Log::ERROR, error_str); return -1; diff --git a/src/image/test/ImagePoolTest.cc b/src/image/test/ImagePoolTest.cc index c127433492..feb835aea9 100644 --- a/src/image/test/ImagePoolTest.cc +++ b/src/image/test/ImagePoolTest.cc @@ -40,7 +40,6 @@ const string templates[] = "NAME = \"Second Image\"\n" "PATH = /tmp/image_second_test\n" - "PUBLIC = YES\n" "DESCRIPTION = \"This is a rather short description.\"\n", "NAME = \"The third image\"\n" @@ -52,20 +51,20 @@ const string templates[] = const string xmls[] = { -"001oneoneadminImage one0010000000000/tmp/image_test040", +"001oneoneadminImage one110000000010000000000/tmp/image_test040", -"111twooneadminSecond Image0100000000000/tmp/image_second_test040", +"111twooneadminSecond Image110000000000000000000/tmp/image_second_test040", -"021threeusersThe third image0000000000000/tmp/image_test040", +"021threeusersThe third image110000000000000000000/tmp/image_test040", }; // This xml dump result has the STIMEs modified to 0000000000 const string xml_dump = -"001oneoneadminImage one0010000000000/tmp/image_test040111twooneadminSecond Image0100000000000/tmp/image_second_test040221threeusersThe third image0000000000000/tmp/image_test040"; +"001oneoneadminImage one110000000010000000000/tmp/image_test040111twooneadminSecond Image110000000000000000000/tmp/image_second_test040221threeusersThe third image110000000000000000000/tmp/image_test040"; const string xml_dump_where = -"001oneoneadminImage one0010000000000/tmp/image_test040111twooneadminSecond Image0100000000000/tmp/image_second_test040"; +"001oneoneadminImage one110000000010000000000/tmp/image_test040111twooneadminSecond Image110000000000000000000/tmp/image_second_test040"; /* ************************************************************************* */ /* ************************************************************************* */ @@ -190,7 +189,7 @@ protected: ((Image*)obj)->to_xml(xml_str); fix_regtimes(xml_str); -/* +//* if( xml_str != xmls[index] ) { cout << endl << xml_str << endl << xmls[index] << endl; @@ -860,7 +859,7 @@ public: string result = oss.str(); fix_regtimes(result); -/* +//* if( result != xml_dump ) { cout << endl << result << endl << xml_dump << endl; @@ -893,7 +892,7 @@ public: string result = oss.str(); fix_regtimes(result); -/* +//* if( result != xml_dump_where ) { cout << endl << result << endl << xml_dump_where << endl; diff --git a/src/template/Template.cc b/src/template/Template.cc index bc4fe03011..71ea6b0539 100644 --- a/src/template/Template.cc +++ b/src/template/Template.cc @@ -533,3 +533,57 @@ void Template::rebuild_attributes(const xmlNode * root_element) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +bool Template::check(string& rs_attr, const vector &restricted_attributes) +{ + size_t pos; + string avector, vattr; + vector values; + + for (uint i=0; i < restricted_attributes.size(); i++) + { + pos = restricted_attributes[i].find("/"); + + if (pos != string::npos) //Vector Attribute + { + int num; + + avector = restricted_attributes[i].substr(0,pos); + vattr = restricted_attributes[i].substr(pos+1); + + if ((num = get(avector,values)) > 0 ) //Template contains the attr + { + const VectorAttribute * attr; + + for (int j=0; j(values[j]); + + if (attr == 0) + { + continue; + } + + if ( !attr->vector_value(vattr.c_str()).empty() ) + { + rs_attr = restricted_attributes[i]; + return true; + } + } + } + } + else //Single Attribute + { + if (get(avector,values) > 0 ) + { + rs_attr = restricted_attributes[i]; + return true; + } + } + } + + return false; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + diff --git a/src/um/test/UserPoolTest.cc b/src/um/test/UserPoolTest.cc index 8e37a4d080..9ae1b6f78b 100644 --- a/src/um/test/UserPoolTest.cc +++ b/src/um/test/UserPoolTest.cc @@ -362,7 +362,7 @@ public: // by" is a dirty fix (SQL injection, actually) because MySQL orders the // results by user_name ostringstream oss; - ((UserPool*)pool)->dump(oss, "name LIKE 'a%' ORDER BY oid"); + ((UserPool*)pool)->dump(oss, "name LIKE 'a%'"); //* if( oss.str() != dump_where_result ) diff --git a/src/vm/SConstruct b/src/vm/SConstruct index bc041d804e..b69822ff24 100644 --- a/src/vm/SConstruct +++ b/src/vm/SConstruct @@ -40,8 +40,7 @@ source_files=[ 'vm_var_parser.c', 'vm_var_syntax.cc', 'VirtualMachinePool.cc', - 'VirtualMachineHook.cc', - 'VirtualMachineTemplate.cc' + 'VirtualMachineHook.cc' ] # Build library diff --git a/src/vm/VirtualMachineTemplate.cc b/src/vm/VirtualMachineTemplate.cc deleted file mode 100644 index 1f9686e294..0000000000 --- a/src/vm/VirtualMachineTemplate.cc +++ /dev/null @@ -1,86 +0,0 @@ -/* -------------------------------------------------------------------------- */ -/* 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 "VirtualMachineTemplate.h" -#include - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -const string VirtualMachineTemplate::RESTRICTED_ATTRIBUTES[] = { - "CONTEXT/FILES", - "DISK/SOURCE", - "NIC/MAC", - "NIC/VLAN_ID", - "RANK" -}; - -const int VirtualMachineTemplate::RS_ATTRS_LENGTH = 5; - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -bool VirtualMachineTemplate::check(string& rs_attr) -{ - size_t pos; - string avector, vattr; - vector values; - - for (int i=0; i < RS_ATTRS_LENGTH ;i++) - { - pos = RESTRICTED_ATTRIBUTES[i].find("/"); - - if (pos != string::npos) //Vector Attribute - { - int num; - - avector = RESTRICTED_ATTRIBUTES[i].substr(0,pos); - vattr = RESTRICTED_ATTRIBUTES[i].substr(pos+1); - - if ((num = get(avector,values)) > 0 ) //Template contains the attr - { - const VectorAttribute * attr; - - for (int j=0; j(values[j]); - - if (attr == 0) - { - continue; - } - - if ( !attr->vector_value(vattr.c_str()).empty() ) - { - rs_attr = RESTRICTED_ATTRIBUTES[i]; - return true; - } - } - - } - } - else //Single Attribute - { - if (get(avector,values) > 0 ) - { - rs_attr = RESTRICTED_ATTRIBUTES[i]; - return true; - } - } - } - - return false; -} diff --git a/src/vm/test/VirtualMachinePoolTest.cc b/src/vm/test/VirtualMachinePoolTest.cc index 75e93edd45..ae6ecd8b1d 100644 --- a/src/vm/test/VirtualMachinePoolTest.cc +++ b/src/vm/test/VirtualMachinePoolTest.cc @@ -46,19 +46,9 @@ const string templates[] = const string xmls[] = { - "01231the_userusersVM one010000000000000000", + "01231the_userusersVM one110000000010000000000000000", - "12611the_userusersSecond VM0" - "1000000000000<" - "/ETIME>0000", + "12611the_userusersSecond VM110000000010000000000000000", "01231the_userusersVM one01000000000000011the_userusersVM one010000000000000000121the_userusersSecond VM020000000000000000"; + "011the_userusersVM one110000000010000000000000000121the_userusersSecond VM110000000020000000000000000"; const string xml_dump_where = - "011the_userusersVM one010000000000000000"; + "011the_userusersVM one110000000010000000000000000"; const string xml_history_dump = - "001the_userusersVM one010000000000000000101the_userusersSecond VM0200000000000000000A_hostnameA_vm_dir000A_vmm_madA_vnm_madA_tm_mad0000000201the_userusersVM one0200000000000000001C_hostnameC_vm_dir200C_vmm_madC_vnm_madC_tm_mad0000000311the_userusersVM one060000000000000000"; + "001the_userusersVM one110000000010000000000000000101the_userusersSecond VM1100000000200000000000000000A_hostnameA_vm_dir000A_vmm_madA_vnm_madA_tm_mad0000000201the_userusersVM one1100000000200000000000000001C_hostnameC_vm_dir200C_vmm_madC_vnm_madC_tm_mad0000000311the_userusersVM one110000000060000000000000000"; /* ************************************************************************* */ /* ************************************************************************* */ @@ -169,7 +159,7 @@ protected: ((VirtualMachine*)obj)->to_xml(xml_str); fix_stimes(xml_str); -/* +//* if( xml_str != xmls[index] ) { cout << endl << xml_str << endl << "========" @@ -260,13 +250,11 @@ public: string result = oss.str(); fix_stimes(result); -/* if( result != xml_dump ) { cout << endl << result << endl << "========" << endl << xml_dump << endl << "--------"; } -*/ CPPUNIT_ASSERT( result == xml_dump ); } @@ -290,6 +278,12 @@ public: string result = oss.str(); fix_stimes(result); + if( result != xml_dump_where ) + { + cout << endl << result << endl << "========" + << endl << xml_dump_where << endl << "--------"; + } + CPPUNIT_ASSERT( result == xml_dump_where ); } diff --git a/src/vm_template/test/VMTemplatePoolTest.cc b/src/vm_template/test/VMTemplatePoolTest.cc index 142d6f7a8f..5e5c074b9d 100644 --- a/src/vm_template/test/VMTemplatePoolTest.cc +++ b/src/vm_template/test/VMTemplatePoolTest.cc @@ -45,9 +45,9 @@ const string templates[] = const string xmls[] = { - "000the_useroneadminTemplate one00000000000", + "000the_useroneadminTemplate one1100000000000000000", - "110the_useroneadminSecond Template00000000000", + "110the_useroneadminSecond Template1100000000000000000", "220the_useroneadminThird Template00000000000" }; @@ -55,9 +55,9 @@ const string xmls[] = // This xml dump result has the STIMEs modified to 0000000000 const string xml_dump = - "000the_useroneadminTemplate one00000000000110the_useroneadminSecond Template00000000000220the_useroneadminThird Template00000000000"; + "000the_useroneadminTemplate one1100000000000000000110the_useroneadminSecond Template1100000000000000000220the_useroneadminThird Template1100000000000000000"; const string xml_dump_where = - "000the_useroneadminTemplate one00000000000110the_useroneadminSecond Template00000000000"; + "000the_useroneadminTemplate one1100000000000000000110the_useroneadminSecond Template1100000000000000000"; class VMTemplatePoolFriend : public VMTemplatePool { @@ -108,7 +108,6 @@ class VMTemplatePoolTest : public PoolTest CPPUNIT_TEST ( get_using_name ); CPPUNIT_TEST ( wrong_get_name ); CPPUNIT_TEST ( duplicates ); -// CPPUNIT_TEST ( public_attribute ); CPPUNIT_TEST ( dump ); CPPUNIT_TEST ( dump_where ); @@ -146,7 +145,7 @@ protected: ((VMTemplate*)obj)->to_xml(xml_str); fix_regtimes( xml_str ); -/* +//* if( xml_str != xmls[index] ) { cout << endl << xml_str << endl << xmls[index] << endl; @@ -384,90 +383,6 @@ public: CPPUNIT_ASSERT( oid == rc ); } -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ -/* - void public_attribute() - { - int oid; - VMTemplatePoolFriend * tpool = static_cast(pool); - VMTemplate * temp; - - string templates[] = - { - // false - "NAME = \"name A\"\n", - - // true - "NAME = \"name B\"\n" - "PUBLIC = YES", - - // false - "NAME = \"name C\"\n" - "PUBLIC = NO", - - // false - "NAME = \"name D\"\n" - "PUBLIC = 1", - - // true - "NAME = \"name E\"\n" - "PUBLIC = Yes", - - // false - "NAME = \"name F\"\n" - "PUBLIC = TRUE", - - // true - "NAME = \"name G\"\n" - "PUBLIC = yes", - - // false - "NAME = \"name H\"\n" - "PUBLIC = 'YES'", - - // true - "NAME = \"name I\"\n" - "PUBLIC = \"YES\"", - - "END" - }; - - bool results[] = { false, true, false, false, - true, false, true, false, true }; - - int i = 0; - while( templates[i] != "END" ) - { - - tpool->allocate(0, templates[i], &oid); - - CPPUNIT_ASSERT( oid >= 0 ); - - temp = tpool->get( oid, false ); - CPPUNIT_ASSERT( temp != 0 ); -//cout << endl << i << " : exp. " << results[i] << " got " << temp->is_public(); - - CPPUNIT_ASSERT( temp->isPublic() == results[i] ); - - i++; - } - - int success; - - // temp 0 is not public. - temp = tpool->get( 0, false ); - CPPUNIT_ASSERT( temp != 0 ); - - success = temp->publish(false); - CPPUNIT_ASSERT( success == 0 ); - CPPUNIT_ASSERT( temp->isPublic() == false ); - - success = temp->publish(true); - CPPUNIT_ASSERT( success == 0 ); - CPPUNIT_ASSERT( temp->isPublic() == true ); - } -*/ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -489,7 +404,7 @@ public: string result = oss.str(); fix_regtimes(result); -/* +//* if( result != xml_dump ) { cout << endl << result << endl << xml_dump << endl; @@ -522,7 +437,7 @@ public: string result = oss.str(); fix_regtimes(result); -/* +//* if( result != xml_dump_where ) { cout << endl << result << endl << xml_dump_where << endl; diff --git a/src/vmm_mad/remotes/poll_ganglia.rb b/src/vmm_mad/remotes/poll_ganglia.rb index c9eaa91180..94a74cb946 100755 --- a/src/vmm_mad/remotes/poll_ganglia.rb +++ b/src/vmm_mad/remotes/poll_ganglia.rb @@ -50,9 +50,8 @@ GANGLIA_PORT=8649 domain=ARGV[0] -dom_id=ARGV[1] -host=ARGV[2] - +dom_id=ARGV[2] +host=ARGV[1] # Gets monitoring data from ganglia or file begin @@ -69,6 +68,12 @@ end doms_info=ganglia.get_vms_information dom_id=domain.split('-').last +# Unknown state when the VM is not found +if !doms_info || !(doms_info[domain] || doms_info[dom_id]) + puts "STATE=d" + exit(0) +end + # Get key one- or key from the hash dom_info=doms_info[domain] dom_info=doms_info[dom_id] if !dom_info diff --git a/src/vnm/test/VirtualNetworkPoolTest.cc b/src/vnm/test/VirtualNetworkPoolTest.cc index d63cf50dcd..a88378a321 100644 --- a/src/vnm/test/VirtualNetworkPoolTest.cc +++ b/src/vnm/test/VirtualNetworkPoolTest.cc @@ -43,8 +43,7 @@ const string templates[] = "TYPE = RANGED\n" "BRIDGE = br0\n" "NETWORK_SIZE = C\n" - "NETWORK_ADDRESS = 192.168.0.0\n" - "PUBLIC = YES", + "NETWORK_ADDRESS = 192.168.0.0", "NAME = \"Net number two\"\n" "TYPE = fixed\n" @@ -71,18 +70,18 @@ const string templates[] = const string xmls[] = { - "01230the_useroneadminNet number one1br1000130.10.0.150:20:20:20:20:200-1", + "01230the_useroneadminNet number one1100000001br100130.10.0.150:20:20:20:20:200-1", - "12610the_useroneadminA virtual network0br00192.168.0.1192.168.0.25410", + "12610the_useroneadminA virtual network1100000000br00192.168.0.1192.168.0.2540", - "01330the_useroneadminNet number two1br1000130.10.2.150:20:20:20:20:200-1", + "01330the_useroneadminNet number two1100000001br100130.10.2.150:20:20:20:20:200-1", }; const string xml_dump = - "010the_useroneadminNet number one1br1000120the_useroneadminA virtual network0br00192.168.0.1192.168.0.25410"; + "010the_useroneadminNet number one1100000001br100120the_useroneadminA virtual network1100000000br00192.168.0.1192.168.0.2540"; const string xml_dump_where = - "120the_useroneadminA virtual network0br00192.168.0.1192.168.0.25410"; + "120the_useroneadminA virtual network1100000000br00192.168.0.1192.168.0.2540"; /* ************************************************************************* */ /* ************************************************************************* */ @@ -165,7 +164,6 @@ class VirtualNetworkPoolTest : public PoolTest CPPUNIT_TEST (overlapping_leases_rf); CPPUNIT_TEST (overlapping_leases_rr); CPPUNIT_TEST (drop_leases); -// CPPUNIT_TEST (public_attribute); CPPUNIT_TEST (vnpool_nic_attribute); CPPUNIT_TEST (add_lease_fixed); @@ -213,7 +211,7 @@ protected: ((VirtualNetwork*)obj)->to_xml_extended(xml_str); -/* +//* if( xml_str != xmls[index] ) { cout << endl << xml_str << endl << "========" @@ -312,8 +310,8 @@ public: }; string phydev_xml[] = { - "000the_useroneadminBRIDGE and PHYDEV1br00eth000130.10.0.150:20:20:20:20:200-1", - "100the_useroneadminNo BRIDGE only PHYDEV1onebr10eth000130.10.0.150:20:20:20:20:200-1" + "000the_useroneadminBRIDGE and PHYDEV1100000001br01eth00130.10.0.150:20:20:20:20:200-1", + "100the_useroneadminNo BRIDGE only PHYDEV1100000001onebr11eth00130.10.0.150:20:20:20:20:200-1" }; // test vm with bridge and phydev @@ -325,6 +323,14 @@ public: ((VirtualNetwork*)vn)->to_xml_extended(xml_str); +//* + if( xml_str != phydev_xml[0] ) + { + cout << endl << xml_str << endl << "========" + << endl << phydev_xml[0] << endl << "--------"; + } +//*/ + CPPUNIT_ASSERT( xml_str == phydev_xml[0] ); // test vm with phydev only @@ -337,6 +343,15 @@ public: CPPUNIT_ASSERT( vn != 0 ); ((VirtualNetwork*)vn)->to_xml_extended(xml_str); + +//* + if( xml_str != phydev_xml[1] ) + { + cout << endl << xml_str << endl << "========" + << endl << phydev_xml[1] << endl << "--------"; + } +//*/ + CPPUNIT_ASSERT( xml_str == phydev_xml[1] ); } @@ -522,7 +537,7 @@ public: string result = oss.str(); -/* +//* if( result != xml_dump ) { cout << endl << result << endl << "========" @@ -553,7 +568,7 @@ public: string result = oss.str(); -/* +//* if( result != xml_dump_where ) { cout << endl << result << endl << "========" @@ -1039,103 +1054,6 @@ public: CPPUNIT_ASSERT(results.size() == 0); } -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ -/* - void public_attribute() - { - int oid; - VirtualNetworkPoolFriend * vnp = - static_cast(pool); - VirtualNetwork * vn; - - string templates[] = - { - // false - "NAME = \"name A\"\n" - "TYPE = FIXED\n" - "BRIDGE = br1\n" - "LEASES = [IP=130.10.0.1, MAC=50:20:20:20:20:20]\n", - - // true - "NAME = \"name B\"\n" - "TYPE = FIXED\n" - "BRIDGE = br1\n" - "LEASES = [IP=130.10.0.1, MAC=50:20:20:20:20:20]\n" - "PUBLIC = YES", - - // false - "NAME = \"name C\"\n" - "TYPE = FIXED\n" - "BRIDGE = br1\n" - "LEASES = [IP=130.10.0.1, MAC=50:20:20:20:20:20]\n" - "PUBLIC = NO", - - // false - "NAME = \"name D\"\n" - "TYPE = FIXED\n" - "BRIDGE = br1\n" - "LEASES = [IP=130.10.0.1, MAC=50:20:20:20:20:20]\n" - "PUBLIC = 1", - - // true - "NAME = \"name E\"\n" - "TYPE = FIXED\n" - "BRIDGE = br1\n" - "LEASES = [IP=130.10.0.1, MAC=50:20:20:20:20:20]\n" - "PUBLIC = Yes", - - // false - "NAME = \"name F\"\n" - "TYPE = FIXED\n" - "BRIDGE = br1\n" - "LEASES = [IP=130.10.0.1, MAC=50:20:20:20:20:20]\n" - "PUBLIC = TRUE", - - // true - "NAME = \"name G\"\n" - "TYPE = FIXED\n" - "BRIDGE = br1\n" - "LEASES = [IP=130.10.0.1, MAC=50:20:20:20:20:20]\n" - "PUBLIC = yes", - - // false - "NAME = \"name H\"\n" - "TYPE = FIXED\n" - "BRIDGE = br1\n" - "LEASES = [IP=130.10.0.1, MAC=50:20:20:20:20:20]\n" - "PUBLIC = 'YES'", - - // true - "NAME = \"name I\"\n" - "TYPE = FIXED\n" - "BRIDGE = br1\n" - "LEASES = [IP=130.10.0.1, MAC=50:20:20:20:20:20]\n" - "PUBLIC = \"YES\"", - - "END" - }; - - bool results[] = { false, true, false, false, - true, false, true, false, true }; - - int i = 0; - while( templates[i] != "END" ) - { - - vnp->allocate(0, templates[i], &oid); - - CPPUNIT_ASSERT( oid >= 0 ); - - vn = vnp->get( oid, false ); - CPPUNIT_ASSERT( vn != 0 ); - -//cout << endl << i << ":expected " << results[i] << " got " << vn->is_public(); - CPPUNIT_ASSERT( vn->isPublic() == results[i] ); - i++; - } - } -*/ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */