1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-25 02:50:08 +03:00

Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Hector Sanjuan 2012-01-24 09:05:02 +01:00
commit 50c646f033
41 changed files with 387 additions and 430 deletions

View File

@ -40,7 +40,8 @@ public:
ImagePool(SqlDB * db,
const string& _default_type,
const string& _default_dev_prefix);
const string& _default_dev_prefix,
vector<const Attribute *>& restricted_attrs);
~ImagePool(){};

View File

@ -30,6 +30,23 @@ 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)
{
return Template::check(rs_attr, restricted_attributes);
};
private:
friend class ImagePool;
static vector<string> restricted_attributes;
static void set_restricted_attributes(vector<const Attribute *>& rattrs);
};
/* -------------------------------------------------------------------------- */

View File

@ -31,7 +31,7 @@ class RequestManagerChmod : public Request
protected:
RequestManagerChmod(const string& method_name,
const string& help,
const string& params = "A:siii")
const string& params = "A:siiiiiiiiii")
:Request(method_name,params,help){};
~RequestManagerChmod(){};
@ -50,7 +50,7 @@ class VirtualMachineChmod : public RequestManagerChmod
public:
VirtualMachineChmod():
RequestManagerChmod("VirtualMachineChmod",
"Changes ownership of a virtual machine")
"Changes permission bits of a virtual machine")
{
Nebula& nd = Nebula::instance();
pool = nd.get_vmpool();
@ -68,7 +68,7 @@ class TemplateChmod : public RequestManagerChmod
public:
TemplateChmod():
RequestManagerChmod("TemplateChmod",
"Changes ownership of a virtual machine template")
"Changes permission bits of a virtual machine template")
{
Nebula& nd = Nebula::instance();
pool = nd.get_tpool();
@ -87,7 +87,7 @@ class VirtualNetworkChmod: public RequestManagerChmod
public:
VirtualNetworkChmod():
RequestManagerChmod("VirtualNetworkChmod",
"Changes ownership of a virtual network")
"Changes permission bits of a virtual network")
{
Nebula& nd = Nebula::instance();
pool = nd.get_vnpool();
@ -106,7 +106,7 @@ class ImageChmod: public RequestManagerChmod
public:
ImageChmod():
RequestManagerChmod("ImageChmod",
"Changes ownership of an image")
"Changes permission bits of an image")
{
Nebula& nd = Nebula::instance();
pool = nd.get_ipool();

View File

@ -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<string> &restricted_attributes);
private:
bool replace_mode;

View File

@ -35,7 +35,8 @@ public:
VirtualMachinePool(SqlDB * db,
vector<const Attribute *> hook_mads,
const string& hook_location,
const string& remotes_location);
const string& remotes_location,
vector<const Attribute *>& restricted_attrs);
~VirtualMachinePool(){};

View File

@ -41,22 +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);
private:
/**
* Number of restricted attributes
*/
const static int RS_ATTRS_LENGTH;
/**
* Restricted template attributes in the form
* 'SINGLE' or 'VECTOR/ATTR'. Restricted attributes are only
* allowed for ONE_ADMIN Group.
*/
const static string RESTRICTED_ATTRIBUTES[];
bool check(string& rs_attr)
{
return Template::check(rs_attr, restricted_attributes);
};
friend class VirtualMachine;
private:
friend class VirtualMachinePool;
static vector<string> restricted_attributes;
static void set_restricted_attributes(vector<const Attribute *>& rattrs);
};
/* -------------------------------------------------------------------------- */

View File

@ -471,4 +471,19 @@ AUTH_MAD = [
SESSION_EXPIRATION_TIME = 900
#ENABLE_OTHER_PERMISSIONS = "YES"
#ENABLE_OTHER_PERMISSIONS = "YES"
#*******************************************************************************
# Restricted Attributes Configuration
#*******************************************************************************
# The following attributes are restricted to users outside the oneadmin group
#*******************************************************************************
VM_RESTRICTED_ATTR = "CONTEXT/FILES"
VM_RESTRICTED_ATTR = "DISK/SOURCE"
VM_RESTRICTED_ATTR = "NIC/MAC"
VM_RESTRICTED_ATTR = "NIC/VLAN_ID"
VM_RESTRICTED_ATTR = "RANK"
IMAGE_RESTRICTED_ATTR = "SOURCE"

View File

@ -93,29 +93,30 @@ module OneWatch
last_register = vm_sql.registers.last
seq = last_register ? last_register.seq : 0
if hr = vm['HISTORY_RECORDS']
unless hr['HISTORY'].instance_of?(Array)
if hr['HISTORY']['SEQ'] == seq
# The VM has not moved from the Host
insert_register(vm_sql, last_register, hr['HISTORY'])
return
else
hr = vm['HISTORY_RECORDS']
if hr and !hr.empty?
if hr['HISTORY']['SEQ'] == seq
# The VM has not moved from the Host
insert_register(vm_sql, last_register, hr['HISTORY'])
return
else
unless hr['HISTORY'].instance_of?(Array)
# Get the full HISTORY
vm = OpenNebula::VirtualMachine.new_with_id(vm['ID'], @client)
vm.info
vm_hash = vm.to_hash['VM']
hr = vm_hash['HISTORY_RECORDS']
# Insert a new entry for each new history record
[hr['HISTORY']].flatten.each { |history|
if history['SEQ'].to_i < seq
next
else
insert_register(vm_sql, last_register, history)
end
}
end
# Insert a new entry for each new history record
[hr['HISTORY']].flatten.each { |history|
if history['SEQ'].to_i < seq
next
else
insert_register(vm_sql, last_register, history)
end
}
end
end
end

View File

@ -88,7 +88,7 @@ void AuthRequest::add_auth(Operation op,
if ( auth == false )
{
ostringstream oss;
oss.str("");
oss << message;

View File

@ -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);

View File

@ -82,7 +82,7 @@ class Quota
if template['TYPE'] == 'DATABLOCK'
template['SIZE'].to_i
elsif template['PATH']
(File.size(template['PATH']).to_f / 2**20).round(2)
(File.size(template['PATH']).to_f / 2**20).round
elsif template['SAVED_VM_ID']
vm_id = template['SAVED_VM_ID'].to_i
disk_id = template['SAVED_DISK_ID'].to_i

View File

@ -22,7 +22,8 @@ class ImageOCCI < Image
OCCI_IMAGE = %q{
<STORAGE href="<%= base_url %>/storage/<%= self.id.to_s %>">
<ID><%= self.id.to_s %></ID>
<NAME><%= self.name %></NAME>
<NAME><%= self.name %></NAME
<STATE><%= self.state_str %></STATE>
<% if self['TYPE'] != nil %>
<TYPE><%= self.type_str %></TYPE>
<% end %>

View File

@ -324,7 +324,7 @@ post '/config' do
end
get '/ui/login' do
File.read(File.dirname(__FILE__)+'/ui/templates/login.html')
redirect to('ui')
end
post '/ui/login' do

View File

@ -1101,7 +1101,7 @@ $(document).ready(function(){
tableCheckboxesListener(dataTable_vMachines);
vMachineInfoListener();
$('#li_vms_tab a').click(function(){
$('#li_vms_tab').click(function(){
popUpVMDashboard();
});

View File

@ -55,7 +55,7 @@ $(document).ready(function(){
setLang($(this).val());
});
$('#li_config_tab a').click(function(){
$('#li_config_tab').click(function(){
hideDialog();
});

View File

@ -169,7 +169,7 @@ $(document).ready(function(){
quickstart_setup();
$('#li_dashboard_tab a').click(function(){
$('#li_dashboard_tab').click(function(){
hideDialog();
});

View File

@ -445,7 +445,7 @@ $(document).ready(function(){
tableCheckboxesListener(dataTable_vNetworks);
vNetworkInfoListener();
$('#li_vnets_tab a').click(function(){
$('#li_vnets_tab').click(function(){
popUpVNetDashboard();
//return false;
});

View File

@ -631,7 +631,7 @@ $(document).ready(function(){
tableCheckboxesListener(dataTable_images);
imageInfoListener();
$('#li_images_tab a').click(function(){
$('#li_images_tab').click(function(){
popUpImageDashboard();
//return false;
});

View File

@ -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 << "========"

View File

@ -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<ImageTemplate *>(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;

View File

@ -33,7 +33,8 @@ string ImagePool::_default_dev_prefix;
ImagePool::ImagePool(SqlDB * db,
const string& __default_type,
const string& __default_dev_prefix):
const string& __default_dev_prefix,
vector<const Attribute *>& restricted_attrs):
PoolSQL(db,Image::table)
{
ostringstream sql;
@ -50,6 +51,9 @@ ImagePool::ImagePool(SqlDB * db,
NebulaLog::log("IMG", Log::ERROR, "Bad default for type, setting OS");
_default_type = "OS";
}
// Set restricted attributes
ImageTemplate::set_restricted_attributes(restricted_attrs);
}
/* -------------------------------------------------------------------------- */

View File

@ -0,0 +1,44 @@
/* -------------------------------------------------------------------------- */
/* 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 "ImageTemplate.h"
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
vector<string> ImageTemplate::restricted_attributes;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void ImageTemplate::set_restricted_attributes(vector<const Attribute *>& rattrs)
{
const SingleAttribute * sattr;
string attr;
for (unsigned int i = 0 ; i < rattrs.size() ; i++ )
{
sattr = static_cast<const SingleAttribute *>(rattrs[i]);
attr = sattr->value();
transform (attr.begin(),attr.end(),attr.begin(),(int(*)(int))toupper);
restricted_attributes.push_back(attr);
}
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -26,7 +26,8 @@ source_files=[
'ImagePool.cc',
'ImageManagerDriver.cc',
'ImageManager.cc',
'ImageManagerActions.cc'
'ImageManagerActions.cc',
'ImageTemplate.cc'
]
# Build library

View File

@ -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[] =
{
"<IMAGE><ID>0</ID><UID>0</UID><GID>1</GID><UNAME>one</UNAME><GNAME>oneadmin</GNAME><NAME>Image one</NAME><TYPE>0</TYPE><PUBLIC>0</PUBLIC><PERSISTENT>1</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE></SOURCE><PATH>/tmp/image_test</PATH><FSTYPE></FSTYPE><SIZE>0</SIZE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a very long description of an image, and to achieve the longness I will copy this over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over.This is a very long description of an image, and to achieve the longness I will copy this over.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX></TEMPLATE></IMAGE>",
"<IMAGE><ID>0</ID><UID>0</UID><GID>1</GID><UNAME>one</UNAME><GNAME>oneadmin</GNAME><NAME>Image one</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><TYPE>0</TYPE><PERSISTENT>1</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE></SOURCE><PATH>/tmp/image_test</PATH><FSTYPE></FSTYPE><SIZE>0</SIZE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a very long description of an image, and to achieve the longness I will copy this over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over.This is a very long description of an image, and to achieve the longness I will copy this over.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX></TEMPLATE></IMAGE>",
"<IMAGE><ID>1</ID><UID>1</UID><GID>1</GID><UNAME>two</UNAME><GNAME>oneadmin</GNAME><NAME>Second Image</NAME><TYPE>0</TYPE><PUBLIC>1</PUBLIC><PERSISTENT>0</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE></SOURCE><PATH>/tmp/image_second_test</PATH><FSTYPE></FSTYPE><SIZE>0</SIZE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a rather short description.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX></TEMPLATE></IMAGE>",
"<IMAGE><ID>1</ID><UID>1</UID><GID>1</GID><UNAME>two</UNAME><GNAME>oneadmin</GNAME><NAME>Second Image</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><TYPE>0</TYPE><PERSISTENT>0</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE></SOURCE><PATH>/tmp/image_second_test</PATH><FSTYPE></FSTYPE><SIZE>0</SIZE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a rather short description.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX></TEMPLATE></IMAGE>",
"<IMAGE><ID>0</ID><UID>2</UID><GID>1</GID><UNAME>three</UNAME><GNAME>users</GNAME><NAME>The third image</NAME><TYPE>0</TYPE><PUBLIC>0</PUBLIC><PERSISTENT>0</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE></SOURCE><PATH>/tmp/image_test</PATH><FSTYPE></FSTYPE><SIZE>0</SIZE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><BUS><![CDATA[SCSI]]></BUS><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX><PROFILE><![CDATA[STUDENT]]></PROFILE></TEMPLATE></IMAGE>",
"<IMAGE><ID>0</ID><UID>2</UID><GID>1</GID><UNAME>three</UNAME><GNAME>users</GNAME><NAME>The third image</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><TYPE>0</TYPE><PERSISTENT>0</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE></SOURCE><PATH>/tmp/image_test</PATH><FSTYPE></FSTYPE><SIZE>0</SIZE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><BUS><![CDATA[SCSI]]></BUS><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX><PROFILE><![CDATA[STUDENT]]></PROFILE></TEMPLATE></IMAGE>",
};
// This xml dump result has the STIMEs modified to 0000000000
const string xml_dump =
"<IMAGE_POOL><IMAGE><ID>0</ID><UID>0</UID><GID>1</GID><UNAME>one</UNAME><GNAME>oneadmin</GNAME><NAME>Image one</NAME><TYPE>0</TYPE><PUBLIC>0</PUBLIC><PERSISTENT>1</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE></SOURCE><PATH>/tmp/image_test</PATH><FSTYPE></FSTYPE><SIZE>0</SIZE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a very long description of an image, and to achieve the longness I will copy this over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over.This is a very long description of an image, and to achieve the longness I will copy this over.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX></TEMPLATE></IMAGE><IMAGE><ID>1</ID><UID>1</UID><GID>1</GID><UNAME>two</UNAME><GNAME>oneadmin</GNAME><NAME>Second Image</NAME><TYPE>0</TYPE><PUBLIC>1</PUBLIC><PERSISTENT>0</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE></SOURCE><PATH>/tmp/image_second_test</PATH><FSTYPE></FSTYPE><SIZE>0</SIZE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a rather short description.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX></TEMPLATE></IMAGE><IMAGE><ID>2</ID><UID>2</UID><GID>1</GID><UNAME>three</UNAME><GNAME>users</GNAME><NAME>The third image</NAME><TYPE>0</TYPE><PUBLIC>0</PUBLIC><PERSISTENT>0</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE></SOURCE><PATH>/tmp/image_test</PATH><FSTYPE></FSTYPE><SIZE>0</SIZE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><BUS><![CDATA[SCSI]]></BUS><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX><PROFILE><![CDATA[STUDENT]]></PROFILE></TEMPLATE></IMAGE></IMAGE_POOL>";
"<IMAGE_POOL><IMAGE><ID>0</ID><UID>0</UID><GID>1</GID><UNAME>one</UNAME><GNAME>oneadmin</GNAME><NAME>Image one</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><TYPE>0</TYPE><PERSISTENT>1</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE></SOURCE><PATH>/tmp/image_test</PATH><FSTYPE></FSTYPE><SIZE>0</SIZE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a very long description of an image, and to achieve the longness I will copy this over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over.This is a very long description of an image, and to achieve the longness I will copy this over.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX></TEMPLATE></IMAGE><IMAGE><ID>1</ID><UID>1</UID><GID>1</GID><UNAME>two</UNAME><GNAME>oneadmin</GNAME><NAME>Second Image</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><TYPE>0</TYPE><PERSISTENT>0</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE></SOURCE><PATH>/tmp/image_second_test</PATH><FSTYPE></FSTYPE><SIZE>0</SIZE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a rather short description.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX></TEMPLATE></IMAGE><IMAGE><ID>2</ID><UID>2</UID><GID>1</GID><UNAME>three</UNAME><GNAME>users</GNAME><NAME>The third image</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><TYPE>0</TYPE><PERSISTENT>0</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE></SOURCE><PATH>/tmp/image_test</PATH><FSTYPE></FSTYPE><SIZE>0</SIZE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><BUS><![CDATA[SCSI]]></BUS><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX><PROFILE><![CDATA[STUDENT]]></PROFILE></TEMPLATE></IMAGE></IMAGE_POOL>";
const string xml_dump_where =
"<IMAGE_POOL><IMAGE><ID>0</ID><UID>0</UID><GID>1</GID><UNAME>one</UNAME><GNAME>oneadmin</GNAME><NAME>Image one</NAME><TYPE>0</TYPE><PUBLIC>0</PUBLIC><PERSISTENT>1</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE></SOURCE><PATH>/tmp/image_test</PATH><FSTYPE></FSTYPE><SIZE>0</SIZE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a very long description of an image, and to achieve the longness I will copy this over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over.This is a very long description of an image, and to achieve the longness I will copy this over.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX></TEMPLATE></IMAGE><IMAGE><ID>1</ID><UID>1</UID><GID>1</GID><UNAME>two</UNAME><GNAME>oneadmin</GNAME><NAME>Second Image</NAME><TYPE>0</TYPE><PUBLIC>1</PUBLIC><PERSISTENT>0</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE></SOURCE><PATH>/tmp/image_second_test</PATH><FSTYPE></FSTYPE><SIZE>0</SIZE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a rather short description.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX></TEMPLATE></IMAGE></IMAGE_POOL>";
"<IMAGE_POOL><IMAGE><ID>0</ID><UID>0</UID><GID>1</GID><UNAME>one</UNAME><GNAME>oneadmin</GNAME><NAME>Image one</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><TYPE>0</TYPE><PERSISTENT>1</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE></SOURCE><PATH>/tmp/image_test</PATH><FSTYPE></FSTYPE><SIZE>0</SIZE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a very long description of an image, and to achieve the longness I will copy this over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over.This is a very long description of an image, and to achieve the longness I will copy this over.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX></TEMPLATE></IMAGE><IMAGE><ID>1</ID><UID>1</UID><GID>1</GID><UNAME>two</UNAME><GNAME>oneadmin</GNAME><NAME>Second Image</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><TYPE>0</TYPE><PERSISTENT>0</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE></SOURCE><PATH>/tmp/image_second_test</PATH><FSTYPE></FSTYPE><SIZE>0</SIZE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a rather short description.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX></TEMPLATE></IMAGE></IMAGE_POOL>";
/* ************************************************************************* */
/* ************************************************************************* */
@ -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;

View File

@ -193,6 +193,10 @@ class SshStreamCommand < RemotesCommand
return self
end
def close
@stream.close
end
end

View File

@ -276,14 +276,20 @@ void Nebula::start()
vector<const Attribute *> vm_hooks;
vector<const Attribute *> host_hooks;
vector<const Attribute *> vm_restricted_attrs;
vector<const Attribute *> img_restricted_attrs;
nebula_configuration->get("VM_HOOK", vm_hooks);
nebula_configuration->get("HOST_HOOK", host_hooks);
nebula_configuration->get("VM_RESTRICTED_ATTR", vm_restricted_attrs);
nebula_configuration->get("IMAGE_RESTRICTED_ATTR", img_restricted_attrs);
vmpool = new VirtualMachinePool(db,
vm_hooks,
hook_location,
remotes_location);
remotes_location,
vm_restricted_attrs);
hpool = new HostPool(db, host_hooks, hook_location, remotes_location);
nebula_configuration->get("MAC_PREFIX", mac_prefix);
@ -301,7 +307,8 @@ void Nebula::start()
ipool = new ImagePool(db,
default_image_type,
default_device_prefix);
default_device_prefix,
img_restricted_attrs);
tpool = new VMTemplatePool(db);
}

View File

@ -70,15 +70,15 @@ function updateVMsList(req,list,tag,zone_id,zone_name){
state,
vm.CPU,
humanize_size(vm.MEMORY),
vm.HISTORY_RECORDS ? vm.HISTORY_RECORDS.HISTORY.HOSTNAME : "--",
hostname,
pretty_time(vm.STIME)
]);
};
});
updateView(vms_array,vmsDataTable);
}
vmsDataTable.fnAddData(vms_array);
vmsDataTable.fnDraw(false);
};
function updateVNsList(req,list,tag,zone_id,zone_name){
var vnDataTable = $(tag).dataTable();
@ -103,7 +103,6 @@ function updateVNsList(req,list,tag,zone_id,zone_name){
network.NAME,
parseInt(network.TYPE) ? "FIXED" : "RANGED",
network.BRIDGE,
parseInt(network.PUBLIC) ? "yes" : "no",
total_leases
]);
} else {
@ -114,14 +113,14 @@ function updateVNsList(req,list,tag,zone_id,zone_name){
network.NAME,
parseInt(network.TYPE) ? "FIXED" : "RANGED",
network.BRIDGE,
parseInt(network.PUBLIC) ? "yes" : "no",
total_leases
]);
}
});
updateView(vn_array,vnDataTable);
}
vnDataTable.fnAddData(vn_array);
vnDataTable.fnDraw(false);
};
function updateTemplatesList(req,list,tag,zone_id,zone_name){
var templateDataTable = $(tag).dataTable();
@ -138,7 +137,6 @@ function updateTemplatesList(req,list,tag,zone_id,zone_name){
template.GNAME,
template.NAME,
pretty_time(template.REGTIME),
parseInt(template.PUBLIC) ? "yes" : "no"
]);
} else {
template_array.push([
@ -147,11 +145,11 @@ function updateTemplatesList(req,list,tag,zone_id,zone_name){
template.GNAME,
template.NAME,
pretty_time(template.REGTIME),
parseInt(template.PUBLIC) ? "yes" : "no"
]);
};
});
updateView(template_array,templateDataTable);
templateDataTable.fnAddData(template_array);
templateDataTable.fnDraw(false);
}
function updateUsersList(req,list,tag, zone_id,zone_name){
@ -186,8 +184,9 @@ function updateUsersList(req,list,tag, zone_id,zone_name){
}
});
updateView(user_array,userDataTable);
}
userDataTable.fnAddData(user_array);
userDataTable.fnDraw(false);
};
function updateImagesList(req,list,tag,zone_id,zone_name){
var imageDataTable = $(tag).dataTable();
@ -206,7 +205,6 @@ function updateImagesList(req,list,tag,zone_id,zone_name){
image.NAME,
oZones.Helper.image_type(image.TYPE),
pretty_time(image.REGTIME),
parseInt(image.PUBLIC) ? "yes" : "no",
parseInt(image.PERSISTENT) ? "yes" : "no",
oZones.Helper.resource_state("image",image.STATE),
image.RUNNING_VMS
@ -219,15 +217,15 @@ function updateImagesList(req,list,tag,zone_id,zone_name){
image.NAME,
oZones.Helper.image_type(image.TYPE),
pretty_time(image.REGTIME),
parseInt(image.PUBLIC) ? "yes" : "no",
parseInt(image.PERSISTENT) ? "yes" : "no",
oZones.Helper.resource_state("image",image.STATE),
image.RUNNING_VMS
]);
};
});
updateView(image_array,imageDataTable);
}
imageDataTable.fnAddData(image_array);
imageDataTable.fnDraw(false);
};
function hostElementArray(host,zone_id,zone_name){

View File

@ -70,7 +70,6 @@ var aggregated_vns_tab_content =
<th>Name</th>\
<th>Type</th>\
<th>Bridge</th>\
<th>Public?</th>\
<th>Total Leases</th>\
</tr>\
</thead>\
@ -91,7 +90,6 @@ var aggregated_images_tab_content =
<th>Name</th>\
<th>Type</th>\
<th>Registration time</th>\
<th>Public</th>\
<th>Persistent</th>\
<th>State</th>\
<th>#VMS</th>\
@ -129,7 +127,6 @@ var aggregated_templates_tab_content =
<th>Group</th>\
<th>Name</th>\
<th>Registration time</th>\
<th>Public</th>\
</tr>\
</thead>\
<tbody>\
@ -410,80 +407,98 @@ Sunstone.addMainTab("agg_templates_tab",templates_tab);
function hostsListCB(req,list){
dataTable_agg_hosts.fnClearTable();
var total_hosts = [];
$.each(list,function(){
if (this.ZONE.error){
notifyError(this.ZONE.error.message);
return;
};
var host_json = oZones.Helper.pool("HOST",this.ZONE);
total_hosts = total_hosts.concat(host_json);
updateHostsList(req, host_json,'#datatable_agg_hosts',this.ZONE.ID,this.ZONE.NAME);
updateZonesDashboard("hosts",host_json);
});
updateZonesDashboard("hosts",total_hosts);
}
function vmsListCB(req,list){
dataTable_agg_vms.fnClearTable();
var total_vms = [];
$.each(list,function(){
if (this.ZONE.error){
notifyError(this.ZONE.error.message);
return;
};
var vms_json = oZones.Helper.pool("VM",this.ZONE);
total_vms = total_vms.concat(vms_json);
updateVMsList(req, vms_json,'#datatable_agg_vms',this.ZONE.ID,this.ZONE.NAME);
updateZonesDashboard("vms",vms_json);
});
updateZonesDashboard("vms",total_vms);
}
function vnsListCB(req,list){
dataTable_agg_vns.fnClearTable();
var total_vns = [];
$.each(list,function(){
if (this.ZONE.error){
notifyError(this.ZONE.error.message);
return;
};
var vn_json = oZones.Helper.pool("VNET",this.ZONE);
total_vns = total_vns.concat(vn_json);
updateVNsList(req, vn_json,'#datatable_agg_vnets',this.ZONE.ID,this.ZONE.NAME);
updateZonesDashboard("vnets",vn_json);
});
updateZonesDashboard("vnets",total_vns);
}
function imagesListCB(req,list){
dataTable_agg_images.fnClearTable();
total_images = [];
$.each(list,function(){
if (this.ZONE.error){
notifyError(this.ZONE.error.message);
return;
};
var image_json = oZones.Helper.pool("IMAGE",this.ZONE);
total_images = total_images.concat(image_json);
updateImagesList(req,image_json,'#datatable_agg_images',this.ZONE.ID,this.ZONE.NAME);
updateZonesDashboard("images",image_json);
});
updateZonesDashboard("images",total_images);
}
function usersListCB(req,list){
dataTable_agg_users.fnClearTable();
var total_users = [];
$.each(list,function(){
if (this.ZONE.error){
notifyError(this.ZONE.error.message);
return;
};
var user_json = oZones.Helper.pool("USER",this.ZONE);
total_users = total_users.concat(user_json);
updateUsersList(req,user_json,'#datatable_agg_users',this.ZONE.ID,this.ZONE.NAME);
updateZonesDashboard("users",user_json);
});
updateZonesDashboard("users",total_users);
}
function templatesListCB(req,list){
dataTable_agg_templates.fnClearTable();
var total_templates = [];
$.each(list,function(){
if (this.ZONE.error){
notifyError(this.ZONE.error.message);
return;
};
var template_json = oZones.Helper.pool("VMTEMPLATE",this.ZONE);
total_templates = total_templates.concat(template_json);
updateTemplatesList(req,template_json,'#datatable_agg_templates',this.ZONE.ID,this.ZONE.NAME);
updateZonesDashboard("templates",template_json);
});
updateZonesDashboard("templates",total_templates);
}
function setAutorefreshes(){
@ -566,7 +581,7 @@ $(document).ready(function(){
"bAutoWidth":false,
"sPaginationType": "full_numbers",
"aoColumnDefs": [
{ "sWidth": "60px", "aTargets": [6,7,8,9] },
{ "sWidth": "60px", "aTargets": [6,7,8] },
{ "sWidth": "35px", "aTargets": [0,2] },
{ "sWidth": "100px", "aTargets": [1,3,4] }
]
@ -578,8 +593,8 @@ $(document).ready(function(){
"bAutoWidth":false,
"sPaginationType": "full_numbers",
"aoColumnDefs": [
{ "sWidth": "60px", "aTargets": [10] },
{ "sWidth": "35px", "aTargets": [0,2,8,9,11] },
{ "sWidth": "60px", "aTargets": [9] },
{ "sWidth": "35px", "aTargets": [0,2,8,10] },
{ "sWidth": "100px", "aTargets": [1,3,4,6,7] }
]
});
@ -590,7 +605,7 @@ $(document).ready(function(){
"bAutoWidth":false,
"sPaginationType": "full_numbers",
"aoColumnDefs": [
{ "sWidth": "35px", "aTargets": [0,2,7] },
{ "sWidth": "35px", "aTargets": [0,2] },
{ "sWidth": "100px", "aTargets": [1,3,4,6] }
]
});

View File

@ -81,10 +81,6 @@ var dashboard_tab_content =
<td class="key_td">Total</td>\
<td class="value_td"><span id="total_templates"></span></td>\
</tr>\
<tr>\
<td class="key_td">Public</td>\
<td class="value_td"><span id="public_templates"></span></td>\
</tr>\
</table>\
</div>\
</div>\
@ -124,10 +120,6 @@ var dashboard_tab_content =
<td class="key_td">Total</td>\
<td class="value_td"><span id="total_vnets"></span></td>\
</tr>\
<tr>\
<td class="key_td">Public</td>\
<td class="value_td"><span id="public_vnets"></span></td>\
</tr>\
</table>\
</div>\
</div>\
@ -146,10 +138,6 @@ var dashboard_tab_content =
<td class="key_td">Total</td>\
<td class="value_td"><span id="total_images"></span></td>\
</tr>\
<tr>\
<td class="key_td">Public</td>\
<td class="value_td"><span id="public_images"></span></td>\
</tr>\
</table>\
</div>\
</div>\
@ -180,7 +168,6 @@ var dashboard_tab = {
Sunstone.addMainTab('dashboard_tab',dashboard_tab);
$(document).ready(function(){
//Dashboard link listener
$("#dashboard_table h3 a").live("click", function (){
var tab = $(this).attr('href');
showTab(tab);
@ -220,15 +207,7 @@ function updateZonesDashboard(what,json_info){
break;
case "templates":
var total_templates=json_info.length;
var public_templates=0;
$.each(json_info,function(){
if (parseInt(this.VMTEMPLATE.PUBLIC)){
public_templates++;
};
});
$('#total_templates',db).html(total_templates);
$('#public_templates',db).html(public_templates);
break;
case "vms":
var total_vms=json_info.length;
@ -248,14 +227,8 @@ function updateZonesDashboard(what,json_info){
$('#failed_vms',db).html(failed_vms);
break;
case "vnets":
var public_vnets=0;
var total_vnets=json_info.length;
$.each(json_info,function(){
if (parseInt(this.VNET.PUBLIC)){
public_vnets++;}
});
$('#total_vnets',db).html(total_vnets);
$('#public_vnets',db).html(public_vnets);
break;
case "users":
var total_users=json_info.length;
@ -263,13 +236,7 @@ function updateZonesDashboard(what,json_info){
break;
case "images":
var total_images=json_info.length;
var public_images=0;
$.each(json_info,function(){
if (parseInt(this.IMAGE.PUBLIC)){
public_images++;}
});
$('#total_images',db).html(total_images);
$('#public_images',db).html(public_images);
break;
}
}

View File

@ -352,7 +352,6 @@ function updateZoneInfo(req,zone_json){
<th>Group</th>\
<th>Name</th>\
<th>Registration time</th>\
<th>Public</th>\
</tr>\
</thead>\
<tbody>\
@ -396,7 +395,6 @@ function updateZoneInfo(req,zone_json){
<th>Name</th>\
<th>Type</th>\
<th>Bridge</th>\
<th>Public?</th>\
<th>Total Leases</th>\
</tr>\
</thead>\
@ -418,7 +416,6 @@ function updateZoneInfo(req,zone_json){
<th>Name</th>\
<th>Type</th>\
<th>Registration time</th>\
<th>Public</th>\
<th>Persistent</th>\
<th>State</th>\
<th>#VMS</th>\
@ -490,7 +487,7 @@ function updateZoneInfo(req,zone_json){
"bAutoWidth":false,
"sPaginationType": "full_numbers",
"aoColumnDefs": [
{ "sWidth": "60px", "aTargets": [4,5,6,7] },
{ "sWidth": "60px", "aTargets": [4,5,6] },
{ "sWidth": "35px", "aTargets": [0] },
{ "sWidth": "100px", "aTargets": [1,2] }
]
@ -502,8 +499,8 @@ function updateZoneInfo(req,zone_json){
"bAutoWidth":false,
"sPaginationType": "full_numbers",
"aoColumnDefs": [
{ "sWidth": "60px", "aTargets": [8] },
{ "sWidth": "35px", "aTargets": [0,6,7,9] },
{ "sWidth": "60px", "aTargets": [7] },
{ "sWidth": "35px", "aTargets": [0,6,8] },
{ "sWidth": "100px", "aTargets": [1,2,4,5] }
]
});
@ -514,7 +511,7 @@ function updateZoneInfo(req,zone_json){
"bAutoWidth":false,
"sPaginationType": "full_numbers",
"aoColumnDefs": [
{ "sWidth": "35px", "aTargets": [0,5] },
{ "sWidth": "35px", "aTargets": [0] },
{ "sWidth": "100px", "aTargets": [1,2,4] }
]
});

View File

@ -326,7 +326,14 @@ function onError(request,error_json) {
//redirect to login if unauthenticated
if (error_json.error.http_status=="401") {
window.location.href = "login";
switch (whichUI()){
case "selfservice":
window.location.href = "ui";
break;
default:
window.location.href = "login";
};
onError.disabled=false;
return false;
};

View File

@ -403,7 +403,7 @@ function setLogin(){
case "ozones":
username = cookie["ozones-user"];
break;
case "occi":
case "selfservice":
username = cookie["occi-user"];
break;
};
@ -420,7 +420,7 @@ function setLogin(){
case "ozones":
oZones.Auth.logout({success:redirect});
break;
case "occi":
case "selfservice":
OCCI.Auth.logout({success:function(){window.location.href = "ui";}});
break;
}
@ -436,7 +436,7 @@ function whichUI(){
if (typeof(oZones)!="undefined")
return "ozones";
if (typeof(OCCI)!="undefined")
return "occi";
return "selfservice";
};
//Inserts all main tabs in the DOM

View File

@ -533,3 +533,57 @@ void Template::rebuild_attributes(const xmlNode * root_element)
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
bool Template::check(string& rs_attr, const vector<string> &restricted_attributes)
{
size_t pos;
string avector, vattr;
vector<const Attribute *> values;
for (unsigned int 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<num ; j++ )
{
attr = dynamic_cast<const VectorAttribute *>(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(restricted_attributes[i],values) > 0 )
{
rs_attr = restricted_attributes[i];
return true;
}
}
}
return false;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -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 )

View File

@ -27,7 +27,8 @@
VirtualMachinePool::VirtualMachinePool(SqlDB * db,
vector<const Attribute *> hook_mads,
const string& hook_location,
const string& remotes_location)
const string& remotes_location,
vector<const Attribute *>& restricted_attrs)
: PoolSQL(db,VirtualMachine::table)
{
const VectorAttribute * vattr;
@ -182,6 +183,9 @@ VirtualMachinePool::VirtualMachinePool(SqlDB * db,
add_hook(hook);
}
// Set restricted attributes
VirtualMachineTemplate::set_restricted_attributes(restricted_attrs);
}
/* -------------------------------------------------------------------------- */

View File

@ -15,72 +15,31 @@
/* -------------------------------------------------------------------------- */
#include "VirtualMachineTemplate.h"
#include <vector>
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
const string VirtualMachineTemplate::RESTRICTED_ATTRIBUTES[] = {
"CONTEXT/FILES",
"DISK/SOURCE",
"NIC/MAC",
"NIC/VLAN_ID",
"RANK"
};
vector<string> VirtualMachineTemplate::restricted_attributes;
const int VirtualMachineTemplate::RS_ATTRS_LENGTH = 3;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
bool VirtualMachineTemplate::check(string& rs_attr)
void VirtualMachineTemplate::set_restricted_attributes(
vector<const Attribute *>& rattrs)
{
size_t pos;
string avector, vattr;
vector<const Attribute *> values;
const SingleAttribute * sattr;
string attr;
for (int i=0; i < RS_ATTRS_LENGTH ;i++)
{
pos = RESTRICTED_ATTRIBUTES[i].find("/");
for (unsigned int i = 0 ; i < rattrs.size() ; i++ )
{
sattr = static_cast<const SingleAttribute *>(rattrs[i]);
if (pos != string::npos) //Vector Attribute
{
int num;
attr = sattr->value();
transform (attr.begin(),attr.end(),attr.begin(),(int(*)(int))toupper);
avector = RESTRICTED_ATTRIBUTES[i].substr(0,pos);
vattr = RESTRICTED_ATTRIBUTES[i].substr(pos+1);
restricted_attributes.push_back(attr);
}
}
if ((num = get(avector,values)) > 0 ) //Template contains the attr
{
const VectorAttribute * attr;
for (int j=0; j<num ; j++ )
{
attr = dynamic_cast<const VectorAttribute *>(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;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -46,19 +46,9 @@ const string templates[] =
const string xmls[] =
{
"<VM><ID>0</ID><UID>123</UID><GID>1</GID><UNAME>the_user</UNAME><GNAME>users</GNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><ST"
"ATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ET"
"IME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX"
"><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]"
"]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[0]]></VMID>"
"</TEMPLATE><HISTORY_RECORDS/></VM>",
"<VM><ID>0</ID><UID>123</UID><GID>1</GID><UNAME>the_user</UNAME><GNAME>users</GNAME><NAME>VM one</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[0]]></VMID></TEMPLATE><HISTORY_RECORDS/></VM>",
"<VM><ID>1</ID><UID>261</UID><GID>1</GID><UNAME>the_user</UNAME><GNAME>users</GNAME><NAME>Second VM</NAME><LAST_POLL>0</LAST_POLL>"
"<STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0<"
"/ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET"
"_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY>"
"<![CDATA[256]]></MEMORY><NAME><![CDATA[Second VM]]></NAME><VMID>"
"<![CDATA[1]]></VMID></TEMPLATE><HISTORY_RECORDS/></VM>",
"<VM><ID>1</ID><UID>261</UID><GID>1</GID><UNAME>the_user</UNAME><GNAME>users</GNAME><NAME>Second VM</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second VM]]></NAME><VMID><![CDATA[1]]></VMID></TEMPLATE><HISTORY_RECORDS/></VM>",
"<VM><ID>0</ID><UID>123</UID><GID>1</GID><UNAME>the_user</UNAME><GNAME>users</GNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><ST"
"ATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ET"
@ -70,13 +60,13 @@ const string xmls[] =
// This xml dump result has the STIMEs modified to 0000000000
const string xml_dump =
"<VM_POOL><VM><ID>0</ID><UID>1</UID><GID>1</GID><UNAME>the_user</UNAME><GNAME>users</GNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[0]]></VMID></TEMPLATE><HISTORY_RECORDS/></VM><VM><ID>1</ID><UID>2</UID><GID>1</GID><UNAME>the_user</UNAME><GNAME>users</GNAME><NAME>Second VM</NAME><LAST_POLL>0</LAST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second VM]]></NAME><VMID><![CDATA[1]]></VMID></TEMPLATE><HISTORY_RECORDS/></VM></VM_POOL>";
"<VM_POOL><VM><ID>0</ID><UID>1</UID><GID>1</GID><UNAME>the_user</UNAME><GNAME>users</GNAME><NAME>VM one</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[0]]></VMID></TEMPLATE><HISTORY_RECORDS/></VM><VM><ID>1</ID><UID>2</UID><GID>1</GID><UNAME>the_user</UNAME><GNAME>users</GNAME><NAME>Second VM</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><LAST_POLL>0</LAST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second VM]]></NAME><VMID><![CDATA[1]]></VMID></TEMPLATE><HISTORY_RECORDS/></VM></VM_POOL>";
const string xml_dump_where =
"<VM_POOL><VM><ID>0</ID><UID>1</UID><GID>1</GID><UNAME>the_user</UNAME><GNAME>users</GNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[0]]></VMID></TEMPLATE><HISTORY_RECORDS/></VM></VM_POOL>";
"<VM_POOL><VM><ID>0</ID><UID>1</UID><GID>1</GID><UNAME>the_user</UNAME><GNAME>users</GNAME><NAME>VM one</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[0]]></VMID></TEMPLATE><HISTORY_RECORDS/></VM></VM_POOL>";
const string xml_history_dump =
"<VM_POOL><VM><ID>0</ID><UID>0</UID><GID>1</GID><UNAME>the_user</UNAME><GNAME>users</GNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[0]]></VMID></TEMPLATE><HISTORY_RECORDS/></VM><VM><ID>1</ID><UID>0</UID><GID>1</GID><UNAME>the_user</UNAME><GNAME>users</GNAME><NAME>Second VM</NAME><LAST_POLL>0</LAST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second VM]]></NAME><VMID><![CDATA[1]]></VMID></TEMPLATE><HISTORY_RECORDS><HISTORY><SEQ>0</SEQ><HOSTNAME>A_hostname</HOSTNAME><VM_DIR>A_vm_dir</VM_DIR><HID>0</HID><STIME>0</STIME><ETIME>0</ETIME><VMMMAD>A_vmm_mad</VMMMAD><VNMMAD>A_vnm_mad</VNMMAD><TMMAD>A_tm_mad</TMMAD><PSTIME>0</PSTIME><PETIME>0</PETIME><RSTIME>0</RSTIME><RETIME>0</RETIME><ESTIME>0</ESTIME><EETIME>0</EETIME><REASON>0</REASON></HISTORY></HISTORY_RECORDS></VM><VM><ID>2</ID><UID>0</UID><GID>1</GID><UNAME>the_user</UNAME><GNAME>users</GNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[1024]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[2]]></VMID></TEMPLATE><HISTORY_RECORDS><HISTORY><SEQ>1</SEQ><HOSTNAME>C_hostname</HOSTNAME><VM_DIR>C_vm_dir</VM_DIR><HID>2</HID><STIME>0</STIME><ETIME>0</ETIME><VMMMAD>C_vmm_mad</VMMMAD><VNMMAD>C_vnm_mad</VNMMAD><TMMAD>C_tm_mad</TMMAD><PSTIME>0</PSTIME><PETIME>0</PETIME><RSTIME>0</RSTIME><RETIME>0</RETIME><ESTIME>0</ESTIME><EETIME>0</EETIME><REASON>0</REASON></HISTORY></HISTORY_RECORDS></VM><VM><ID>3</ID><UID>1</UID><GID>1</GID><UNAME>the_user</UNAME><GNAME>users</GNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>6</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[3]]></VMID></TEMPLATE><HISTORY_RECORDS/></VM></VM_POOL>";
"<VM_POOL><VM><ID>0</ID><UID>0</UID><GID>1</GID><UNAME>the_user</UNAME><GNAME>users</GNAME><NAME>VM one</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[0]]></VMID></TEMPLATE><HISTORY_RECORDS/></VM><VM><ID>1</ID><UID>0</UID><GID>1</GID><UNAME>the_user</UNAME><GNAME>users</GNAME><NAME>Second VM</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><LAST_POLL>0</LAST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second VM]]></NAME><VMID><![CDATA[1]]></VMID></TEMPLATE><HISTORY_RECORDS><HISTORY><SEQ>0</SEQ><HOSTNAME>A_hostname</HOSTNAME><VM_DIR>A_vm_dir</VM_DIR><HID>0</HID><STIME>0</STIME><ETIME>0</ETIME><VMMMAD>A_vmm_mad</VMMMAD><VNMMAD>A_vnm_mad</VNMMAD><TMMAD>A_tm_mad</TMMAD><PSTIME>0</PSTIME><PETIME>0</PETIME><RSTIME>0</RSTIME><RETIME>0</RETIME><ESTIME>0</ESTIME><EETIME>0</EETIME><REASON>0</REASON></HISTORY></HISTORY_RECORDS></VM><VM><ID>2</ID><UID>0</UID><GID>1</GID><UNAME>the_user</UNAME><GNAME>users</GNAME><NAME>VM one</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><LAST_POLL>0</LAST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[1024]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[2]]></VMID></TEMPLATE><HISTORY_RECORDS><HISTORY><SEQ>1</SEQ><HOSTNAME>C_hostname</HOSTNAME><VM_DIR>C_vm_dir</VM_DIR><HID>2</HID><STIME>0</STIME><ETIME>0</ETIME><VMMMAD>C_vmm_mad</VMMMAD><VNMMAD>C_vnm_mad</VNMMAD><TMMAD>C_tm_mad</TMMAD><PSTIME>0</PSTIME><PETIME>0</PETIME><RSTIME>0</RSTIME><RETIME>0</RETIME><ESTIME>0</ESTIME><EETIME>0</EETIME><REASON>0</REASON></HISTORY></HISTORY_RECORDS></VM><VM><ID>3</ID><UID>1</UID><GID>1</GID><UNAME>the_user</UNAME><GNAME>users</GNAME><NAME>VM one</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><LAST_POLL>0</LAST_POLL><STATE>6</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[3]]></VMID></TEMPLATE><HISTORY_RECORDS/></VM></VM_POOL>";
/* ************************************************************************* */
/* ************************************************************************* */
@ -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 );
}

View File

@ -45,9 +45,9 @@ const string templates[] =
const string xmls[] =
{
"<VMTEMPLATE><ID>0</ID><UID>0</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>Template one</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[Template one]]></NAME><TEMPLATE_ID><![CDATA[0]]></TEMPLATE_ID></TEMPLATE></VMTEMPLATE>",
"<VMTEMPLATE><ID>0</ID><UID>0</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>Template one</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[Template one]]></NAME><TEMPLATE_ID><![CDATA[0]]></TEMPLATE_ID></TEMPLATE></VMTEMPLATE>",
"<VMTEMPLATE><ID>1</ID><UID>1</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>Second Template</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second Template]]></NAME><TEMPLATE_ID><![CDATA[1]]></TEMPLATE_ID></TEMPLATE></VMTEMPLATE>",
"<VMTEMPLATE><ID>1</ID><UID>1</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>Second Template</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second Template]]></NAME><TEMPLATE_ID><![CDATA[1]]></TEMPLATE_ID></TEMPLATE></VMTEMPLATE>",
"<VMTEMPLATE><ID>2</ID><UID>2</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>Third Template</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[3]]></CPU><MEMORY><![CDATA[1024]]></MEMORY><NAME><![CDATA[Third Template]]></NAME><TEMPLATE_ID><![CDATA[2]]></TEMPLATE_ID></TEMPLATE></VMTEMPLATE>"
};
@ -55,9 +55,9 @@ const string xmls[] =
// This xml dump result has the STIMEs modified to 0000000000
const string xml_dump =
"<VMTEMPLATE_POOL><VMTEMPLATE><ID>0</ID><UID>0</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>Template one</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[Template one]]></NAME><TEMPLATE_ID><![CDATA[0]]></TEMPLATE_ID></TEMPLATE></VMTEMPLATE><VMTEMPLATE><ID>1</ID><UID>1</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>Second Template</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second Template]]></NAME><TEMPLATE_ID><![CDATA[1]]></TEMPLATE_ID></TEMPLATE></VMTEMPLATE><VMTEMPLATE><ID>2</ID><UID>2</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>Third Template</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[3]]></CPU><MEMORY><![CDATA[1024]]></MEMORY><NAME><![CDATA[Third Template]]></NAME><TEMPLATE_ID><![CDATA[2]]></TEMPLATE_ID></TEMPLATE></VMTEMPLATE></VMTEMPLATE_POOL>";
"<VMTEMPLATE_POOL><VMTEMPLATE><ID>0</ID><UID>0</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>Template one</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[Template one]]></NAME><TEMPLATE_ID><![CDATA[0]]></TEMPLATE_ID></TEMPLATE></VMTEMPLATE><VMTEMPLATE><ID>1</ID><UID>1</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>Second Template</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second Template]]></NAME><TEMPLATE_ID><![CDATA[1]]></TEMPLATE_ID></TEMPLATE></VMTEMPLATE><VMTEMPLATE><ID>2</ID><UID>2</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>Third Template</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[3]]></CPU><MEMORY><![CDATA[1024]]></MEMORY><NAME><![CDATA[Third Template]]></NAME><TEMPLATE_ID><![CDATA[2]]></TEMPLATE_ID></TEMPLATE></VMTEMPLATE></VMTEMPLATE_POOL>";
const string xml_dump_where =
"<VMTEMPLATE_POOL><VMTEMPLATE><ID>0</ID><UID>0</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>Template one</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[Template one]]></NAME><TEMPLATE_ID><![CDATA[0]]></TEMPLATE_ID></TEMPLATE></VMTEMPLATE><VMTEMPLATE><ID>1</ID><UID>1</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>Second Template</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second Template]]></NAME><TEMPLATE_ID><![CDATA[1]]></TEMPLATE_ID></TEMPLATE></VMTEMPLATE></VMTEMPLATE_POOL>";
"<VMTEMPLATE_POOL><VMTEMPLATE><ID>0</ID><UID>0</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>Template one</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[Template one]]></NAME><TEMPLATE_ID><![CDATA[0]]></TEMPLATE_ID></TEMPLATE></VMTEMPLATE><VMTEMPLATE><ID>1</ID><UID>1</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>Second Template</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second Template]]></NAME><TEMPLATE_ID><![CDATA[1]]></TEMPLATE_ID></TEMPLATE></VMTEMPLATE></VMTEMPLATE_POOL>";
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<VMTemplatePoolFriend *>(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;

View File

@ -94,6 +94,9 @@ class VmmAction
def run(steps, info_on_success = nil)
result = execute_steps(steps)
@ssh_src.close if @ssh_src
@ssh_dst.close if @ssh_dst
#Prepare the info for the OpenNebula core
if DriverExecHelper.failed?(result)
info = @data[:failed_info]

View File

@ -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-<vmid> or <vmid> key from the hash
dom_info=doms_info[domain]
dom_info=doms_info[dom_id] if !dom_info

View File

@ -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[] =
{
"<VNET><ID>0</ID><UID>123</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>Net number one</NAME><TYPE>1</TYPE><BRIDGE>br1</BRIDGE><VLAN>0</VLAN><PHYDEV/><VLAN_ID/><PUBLIC>0</PUBLIC><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE></TEMPLATE><LEASES><LEASE><IP>130.10.0.1</IP><MAC>50:20:20:20:20:20</MAC><USED>0</USED><VID>-1</VID></LEASE></LEASES></VNET>",
"<VNET><ID>0</ID><UID>123</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>Net number one</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><TYPE>1</TYPE><BRIDGE>br1</BRIDGE><VLAN>0</VLAN><PHYDEV/><VLAN_ID/><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE></TEMPLATE><LEASES><LEASE><IP>130.10.0.1</IP><MAC>50:20:20:20:20:20</MAC><USED>0</USED><VID>-1</VID></LEASE></LEASES></VNET>",
"<VNET><ID>1</ID><UID>261</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>A virtual network</NAME><TYPE>0</TYPE><BRIDGE>br0</BRIDGE><VLAN>0</VLAN><PHYDEV/><VLAN_ID/><RANGE><IP_START>192.168.0.1</IP_START><IP_END>192.168.0.254</IP_END></RANGE><PUBLIC>1</PUBLIC><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE><NETWORK_MASK><![CDATA[255.255.255.0]]></NETWORK_MASK></TEMPLATE><LEASES></LEASES></VNET>",
"<VNET><ID>1</ID><UID>261</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>A virtual network</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><TYPE>0</TYPE><BRIDGE>br0</BRIDGE><VLAN>0</VLAN><PHYDEV/><VLAN_ID/><RANGE><IP_START>192.168.0.1</IP_START><IP_END>192.168.0.254</IP_END></RANGE><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE><NETWORK_MASK><![CDATA[255.255.255.0]]></NETWORK_MASK></TEMPLATE><LEASES></LEASES></VNET>",
"<VNET><ID>0</ID><UID>133</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>Net number two</NAME><TYPE>1</TYPE><BRIDGE>br1</BRIDGE><VLAN>0</VLAN><PHYDEV/><VLAN_ID/><PUBLIC>0</PUBLIC><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE></TEMPLATE><LEASES><LEASE><IP>130.10.2.1</IP><MAC>50:20:20:20:20:20</MAC><USED>0</USED><VID>-1</VID></LEASE></LEASES></VNET>",
"<VNET><ID>0</ID><UID>133</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>Net number two</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><TYPE>1</TYPE><BRIDGE>br1</BRIDGE><VLAN>0</VLAN><PHYDEV/><VLAN_ID/><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE></TEMPLATE><LEASES><LEASE><IP>130.10.2.1</IP><MAC>50:20:20:20:20:20</MAC><USED>0</USED><VID>-1</VID></LEASE></LEASES></VNET>",
};
const string xml_dump =
"<VNET_POOL><VNET><ID>0</ID><UID>1</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>Net number one</NAME><TYPE>1</TYPE><BRIDGE>br1</BRIDGE><VLAN>0</VLAN><PHYDEV/><VLAN_ID/><PUBLIC>0</PUBLIC><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE></TEMPLATE></VNET><VNET><ID>1</ID><UID>2</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>A virtual network</NAME><TYPE>0</TYPE><BRIDGE>br0</BRIDGE><VLAN>0</VLAN><PHYDEV/><VLAN_ID/><RANGE><IP_START>192.168.0.1</IP_START><IP_END>192.168.0.254</IP_END></RANGE><PUBLIC>1</PUBLIC><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE><NETWORK_MASK><![CDATA[255.255.255.0]]></NETWORK_MASK></TEMPLATE></VNET></VNET_POOL>";
"<VNET_POOL><VNET><ID>0</ID><UID>1</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>Net number one</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><TYPE>1</TYPE><BRIDGE>br1</BRIDGE><VLAN>0</VLAN><PHYDEV/><VLAN_ID/><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE></TEMPLATE></VNET><VNET><ID>1</ID><UID>2</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>A virtual network</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><TYPE>0</TYPE><BRIDGE>br0</BRIDGE><VLAN>0</VLAN><PHYDEV/><VLAN_ID/><RANGE><IP_START>192.168.0.1</IP_START><IP_END>192.168.0.254</IP_END></RANGE><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE><NETWORK_MASK><![CDATA[255.255.255.0]]></NETWORK_MASK></TEMPLATE></VNET></VNET_POOL>";
const string xml_dump_where =
"<VNET_POOL><VNET><ID>1</ID><UID>2</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>A virtual network</NAME><TYPE>0</TYPE><BRIDGE>br0</BRIDGE><VLAN>0</VLAN><PHYDEV/><VLAN_ID/><RANGE><IP_START>192.168.0.1</IP_START><IP_END>192.168.0.254</IP_END></RANGE><PUBLIC>1</PUBLIC><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE><NETWORK_MASK><![CDATA[255.255.255.0]]></NETWORK_MASK></TEMPLATE></VNET></VNET_POOL>";
"<VNET_POOL><VNET><ID>1</ID><UID>2</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>A virtual network</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><TYPE>0</TYPE><BRIDGE>br0</BRIDGE><VLAN>0</VLAN><PHYDEV/><VLAN_ID/><RANGE><IP_START>192.168.0.1</IP_START><IP_END>192.168.0.254</IP_END></RANGE><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE><NETWORK_MASK><![CDATA[255.255.255.0]]></NETWORK_MASK></TEMPLATE></VNET></VNET_POOL>";
/* ************************************************************************* */
/* ************************************************************************* */
@ -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[] = {
"<VNET><ID>0</ID><UID>0</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>BRIDGE and PHYDEV</NAME><TYPE>1</TYPE><BRIDGE>br0</BRIDGE><VLAN>0</VLAN><PHYDEV>eth0</PHYDEV><VLAN_ID/><PUBLIC>0</PUBLIC><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE></TEMPLATE><LEASES><LEASE><IP>130.10.0.1</IP><MAC>50:20:20:20:20:20</MAC><USED>0</USED><VID>-1</VID></LEASE></LEASES></VNET>",
"<VNET><ID>1</ID><UID>0</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>No BRIDGE only PHYDEV</NAME><TYPE>1</TYPE><BRIDGE>onebr1</BRIDGE><VLAN>0</VLAN><PHYDEV>eth0</PHYDEV><VLAN_ID/><PUBLIC>0</PUBLIC><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE></TEMPLATE><LEASES><LEASE><IP>130.10.0.1</IP><MAC>50:20:20:20:20:20</MAC><USED>0</USED><VID>-1</VID></LEASE></LEASES></VNET>"
"<VNET><ID>0</ID><UID>0</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>BRIDGE and PHYDEV</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><TYPE>1</TYPE><BRIDGE>br0</BRIDGE><VLAN>1</VLAN><PHYDEV>eth0</PHYDEV><VLAN_ID/><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE></TEMPLATE><LEASES><LEASE><IP>130.10.0.1</IP><MAC>50:20:20:20:20:20</MAC><USED>0</USED><VID>-1</VID></LEASE></LEASES></VNET>",
"<VNET><ID>1</ID><UID>0</UID><GID>0</GID><UNAME>the_user</UNAME><GNAME>oneadmin</GNAME><NAME>No BRIDGE only PHYDEV</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><TYPE>1</TYPE><BRIDGE>onebr1</BRIDGE><VLAN>1</VLAN><PHYDEV>eth0</PHYDEV><VLAN_ID/><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE></TEMPLATE><LEASES><LEASE><IP>130.10.0.1</IP><MAC>50:20:20:20:20:20</MAC><USED>0</USED><VID>-1</VID></LEASE></LEASES></VNET>"
};
// 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<VirtualNetworkPoolFriend*>(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++;
}
}
*/
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */