diff --git a/src/image/test/ImagePoolTest.cc b/src/image/test/ImagePoolTest.cc index 6ec2480186..1b61ff193a 100644 --- a/src/image/test/ImagePoolTest.cc +++ b/src/image/test/ImagePoolTest.cc @@ -589,7 +589,7 @@ public: Image * img; VectorAttribute * disk; - int oid_0, oid_1, index; + int oid_0, oid_1, index, img_id; string value; Image::ImageType img_type; @@ -625,7 +625,7 @@ public: disk = new VectorAttribute("DISK"); disk->replace("IMAGE_ID", "0"); - ((ImagePool*)imp)->disk_attribute(disk, 0, &index, &img_type,0); + ((ImagePool*)imp)->disk_attribute(disk, 0, &index, &img_type,0, img_id); value = ""; value = disk->vector_value("TARGET"); @@ -639,7 +639,7 @@ public: disk = new VectorAttribute("DISK"); disk->replace("IMAGE_ID", "1"); - ((ImagePool*)imp)->disk_attribute(disk, 0, &index, &img_type,0); + ((ImagePool*)imp)->disk_attribute(disk, 0, &index, &img_type,0, img_id); value = ""; value = disk->vector_value("TARGET"); diff --git a/src/onedb/2.0_to_2.9.80.rb b/src/onedb/2.0_to_2.9.80.rb index 20d47aeb62..a3e9afe400 100644 --- a/src/onedb/2.0_to_2.9.80.rb +++ b/src/onedb/2.0_to_2.9.80.rb @@ -257,8 +257,8 @@ module Migrator public = row[:public] total_leases = 0 - @db.fetch("SELECT COUNT (ip) FROM old_leases WHERE (oid=#{oid} AND used=1)") do |r| - total_leases = r[:"COUNT (ip)"] + @db.fetch("SELECT COUNT(ip) FROM old_leases WHERE (oid=#{oid} AND used=1)") do |r| + total_leases = r[:"COUNT(ip)"] end diff --git a/src/onedb/onedb_backend.rb b/src/onedb/onedb_backend.rb index cfe079052d..71cbda3324 100644 --- a/src/onedb/onedb_backend.rb +++ b/src/onedb/onedb_backend.rb @@ -177,7 +177,7 @@ class BackEndMySQL < OneDBBacKEnd end create_cmd = mysql_cmd+"-e 'CREATE DATABASE IF NOT EXISTS #{@db_name};'" - rc = system(create_cnd) + rc = system(create_cmd) if !rc raise "Error creating MySQL DB #{@db_name} at #{@server}." end diff --git a/src/onedb/test/2.2/mysqldb.sql b/src/onedb/test/2.2/mysqldb.sql new file mode 100644 index 0000000000..16fb92e86c --- /dev/null +++ b/src/onedb/test/2.2/mysqldb.sql @@ -0,0 +1,314 @@ +-- MySQL dump 10.13 Distrib 5.1.41, for debian-linux-gnu (i486) +-- +-- Host: localhost Database: onedb_test +-- ------------------------------------------------------ +-- Server version 5.1.41-3ubuntu12.10 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `cluster_pool` +-- + +DROP TABLE IF EXISTS `cluster_pool`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `cluster_pool` ( + `oid` int(11) NOT NULL, + `cluster_name` varchar(128) DEFAULT NULL, + PRIMARY KEY (`oid`), + UNIQUE KEY `cluster_name` (`cluster_name`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `cluster_pool` +-- + +LOCK TABLES `cluster_pool` WRITE; +/*!40000 ALTER TABLE `cluster_pool` DISABLE KEYS */; +INSERT INTO `cluster_pool` VALUES (0,'default'); +/*!40000 ALTER TABLE `cluster_pool` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `history` +-- + +DROP TABLE IF EXISTS `history`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `history` ( + `vid` int(11) NOT NULL DEFAULT '0', + `seq` int(11) NOT NULL DEFAULT '0', + `host_name` text, + `vm_dir` text, + `hid` int(11) DEFAULT NULL, + `vm_mad` text, + `tm_mad` text, + `stime` int(11) DEFAULT NULL, + `etime` int(11) DEFAULT NULL, + `pstime` int(11) DEFAULT NULL, + `petime` int(11) DEFAULT NULL, + `rstime` int(11) DEFAULT NULL, + `retime` int(11) DEFAULT NULL, + `estime` int(11) DEFAULT NULL, + `eetime` int(11) DEFAULT NULL, + `reason` int(11) DEFAULT NULL, + PRIMARY KEY (`vid`,`seq`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `history` +-- + +LOCK TABLES `history` WRITE; +/*!40000 ALTER TABLE `history` DISABLE KEYS */; +INSERT INTO `history` VALUES (0,0,'host_0','/home/cmartin/trabajo/opennebula/install/var/',0,'vmm_dummy','tm_dummy',1316187929,1316187934,1316187929,1316187929,1316187929,1316187934,0,0,3),(1,0,'host_1','/home/cmartin/trabajo/opennebula/install/var/',1,'vmm_dummy','tm_dummy',1316187929,1316187935,1316187929,1316187929,1316187929,1316187935,0,0,3),(2,0,'host_2','/home/cmartin/trabajo/opennebula/install/var/',2,'vmm_dummy','tm_dummy',1316187930,1316187940,1316187930,1316187930,1316187930,1316187940,1316187940,1316187940,0),(3,0,'host_3','/home/cmartin/trabajo/opennebula/install/var/',3,'vmm_dummy','tm_dummy',1316187930,1316187941,1316187930,1316187930,1316187930,1316187941,0,0,3),(0,1,'host_1','/home/cmartin/trabajo/opennebula/install/var/',1,'vmm_dummy','tm_dummy',1316187934,0,1316187934,1316187934,1316187934,0,0,0,0),(1,1,'host_2','/home/cmartin/trabajo/opennebula/install/var/',2,'vmm_dummy','tm_dummy',1316187935,1316187936,0,0,1316187935,1316187936,1316187936,1316187936,2),(1,2,'host_0','/home/cmartin/trabajo/opennebula/install/var/',0,'vmm_dummy','tm_dummy',1316187937,1316187938,1316187937,1316187937,1316187937,1316187938,0,0,3),(1,3,'host_3','/home/cmartin/trabajo/opennebula/install/var/',3,'vmm_dummy','tm_dummy',1316187938,1316187939,1316187938,1316187938,1316187938,1316187939,1316187939,1316187939,0); +/*!40000 ALTER TABLE `history` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `host_pool` +-- + +DROP TABLE IF EXISTS `host_pool`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `host_pool` ( + `oid` int(11) NOT NULL, + `host_name` varchar(256) DEFAULT NULL, + `state` int(11) DEFAULT NULL, + `im_mad` varchar(128) DEFAULT NULL, + `vm_mad` varchar(128) DEFAULT NULL, + `tm_mad` varchar(128) DEFAULT NULL, + `last_mon_time` int(11) DEFAULT NULL, + `cluster` varchar(128) DEFAULT NULL, + `template` text, + PRIMARY KEY (`oid`), + UNIQUE KEY `host_name` (`host_name`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `host_pool` +-- + +LOCK TABLES `host_pool` WRITE; +/*!40000 ALTER TABLE `host_pool` DISABLE KEYS */; +INSERT INTO `host_pool` VALUES (1,'host_1',2,'im_dummy','vmm_dummy','tm_dummy',1316187946,'default',''),(3,'host_3',4,'im_dummy','vmm_dummy','tm_dummy',1316187931,'default',''),(4,'host_4',2,'im_dummy','vmm_dummy','tm_dummy',1316187946,'default',''),(0,'host_0',2,'im_dummy','vmm_dummy','tm_dummy',1316187946,'default',''),(2,'host_2',2,'im_dummy','vmm_dummy','tm_dummy',1316187946,'default',''); +/*!40000 ALTER TABLE `host_pool` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `host_shares` +-- + +DROP TABLE IF EXISTS `host_shares`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `host_shares` ( + `hid` int(11) NOT NULL, + `disk_usage` int(11) DEFAULT NULL, + `mem_usage` int(11) DEFAULT NULL, + `cpu_usage` int(11) DEFAULT NULL, + `max_disk` int(11) DEFAULT NULL, + `max_mem` int(11) DEFAULT NULL, + `max_cpu` int(11) DEFAULT NULL, + `free_disk` int(11) DEFAULT NULL, + `free_mem` int(11) DEFAULT NULL, + `free_cpu` int(11) DEFAULT NULL, + `used_disk` int(11) DEFAULT NULL, + `used_mem` int(11) DEFAULT NULL, + `used_cpu` int(11) DEFAULT NULL, + `running_vms` int(11) DEFAULT NULL, + PRIMARY KEY (`hid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `host_shares` +-- + +LOCK TABLES `host_shares` WRITE; +/*!40000 ALTER TABLE `host_shares` DISABLE KEYS */; +INSERT INTO `host_shares` VALUES (0,0,0,0,0,16777216,800,0,16777216,800,0,0,0,0),(1,0,524288,0,0,16777216,800,0,16777216,800,0,0,0,1),(2,0,0,0,0,16777216,800,0,16777216,800,0,0,0,0),(3,0,0,0,0,16777216,800,0,16777216,800,0,0,0,0),(4,0,0,0,0,16777216,800,0,16777216,800,0,0,0,0); +/*!40000 ALTER TABLE `host_shares` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `image_pool` +-- + +DROP TABLE IF EXISTS `image_pool`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `image_pool` ( + `oid` int(11) NOT NULL, + `uid` int(11) DEFAULT NULL, + `name` varchar(128) DEFAULT NULL, + `type` int(11) DEFAULT NULL, + `public` int(11) DEFAULT NULL, + `persistent` int(11) DEFAULT NULL, + `regtime` int(11) DEFAULT NULL, + `source` text, + `state` int(11) DEFAULT NULL, + `running_vms` int(11) DEFAULT NULL, + `template` text, + PRIMARY KEY (`oid`), + UNIQUE KEY `name` (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `image_pool` +-- + +LOCK TABLES `image_pool` WRITE; +/*!40000 ALTER TABLE `image_pool` DISABLE KEYS */; +INSERT INTO `image_pool` VALUES (0,1,'image_0',2,0,0,1316187925,'/home/cmartin/trabajo/opennebula/install/var//images/f4f08f2ad6fcb19432db9da3161d144aa2d5e730',2,1,''),(3,4,'image_3',2,0,1,1316187926,'/home/cmartin/trabajo/opennebula/install/var//images/01a1e990037cabc5419076c78e21f96b8c889dbf',1,0,''),(4,5,'image_4',2,0,0,1316187926,'/home/cmartin/trabajo/opennebula/install/var//images/df76114f6749fb9ef6674649c809f28054c0d125',2,1,''),(1,2,'image_1',2,0,0,1316187925,'/home/cmartin/trabajo/opennebula/install/var//images/1dbcefd204efa3c32280d2c56a2d499f89790bae',1,0,''),(2,3,'image_2',2,0,0,1316187925,'/home/cmartin/trabajo/opennebula/install/var//images/a42e387dcd957218a4f5c86f1b586631ab769c17',1,0,''); +/*!40000 ALTER TABLE `image_pool` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `leases` +-- + +DROP TABLE IF EXISTS `leases`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `leases` ( + `oid` int(11) NOT NULL DEFAULT '0', + `ip` bigint(20) NOT NULL DEFAULT '0', + `mac_prefix` bigint(20) DEFAULT NULL, + `mac_suffix` bigint(20) DEFAULT NULL, + `vid` int(11) DEFAULT NULL, + `used` int(11) DEFAULT NULL, + PRIMARY KEY (`oid`,`ip`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `leases` +-- + +LOCK TABLES `leases` WRITE; +/*!40000 ALTER TABLE `leases` DISABLE KEYS */; +INSERT INTO `leases` VALUES (0,3232235521,512,3232235521,0,1),(0,3232235522,512,3232235522,-1,0),(0,3232235523,512,3232235523,-1,0),(0,3232235524,512,3232235524,-1,0),(0,3232235525,512,3232235525,-1,0),(1,3232235777,512,3232235777,-1,0),(1,3232235778,512,3232235778,-1,0),(1,3232235779,512,3232235779,-1,0),(1,3232235780,512,3232235780,-1,0),(1,3232235781,512,3232235781,-1,0),(2,3232236033,512,3232236033,-1,0),(2,3232236034,512,3232236034,-1,0),(2,3232236035,512,3232236035,-1,0),(2,3232236036,512,3232236036,-1,0),(2,3232236037,512,3232236037,-1,0),(4,3232236545,512,3232236545,4,1); +/*!40000 ALTER TABLE `leases` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `network_pool` +-- + +DROP TABLE IF EXISTS `network_pool`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `network_pool` ( + `oid` int(11) NOT NULL, + `uid` int(11) DEFAULT NULL, + `name` varchar(256) DEFAULT NULL, + `type` int(11) DEFAULT NULL, + `bridge` text, + `public` int(11) DEFAULT NULL, + `template` text, + PRIMARY KEY (`oid`), + UNIQUE KEY `name` (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `network_pool` +-- + +LOCK TABLES `network_pool` WRITE; +/*!40000 ALTER TABLE `network_pool` DISABLE KEYS */; +INSERT INTO `network_pool` VALUES (0,1,'vnet_fixed_0',1,'vbr1',0,''),(1,2,'vnet_fixed_1',1,'vbr1',0,''),(2,3,'vnet_fixed_2',1,'vbr1',1,''),(3,4,'vnet_ranged_3',0,'vbr0',0,''),(4,5,'vnet_ranged_4',0,'vbr0',1,''); +/*!40000 ALTER TABLE `network_pool` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `user_pool` +-- + +DROP TABLE IF EXISTS `user_pool`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `user_pool` ( + `oid` int(11) NOT NULL, + `user_name` varchar(256) DEFAULT NULL, + `password` text, + `enabled` int(11) DEFAULT NULL, + PRIMARY KEY (`oid`), + UNIQUE KEY `user_name` (`user_name`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `user_pool` +-- + +LOCK TABLES `user_pool` WRITE; +/*!40000 ALTER TABLE `user_pool` DISABLE KEYS */; +INSERT INTO `user_pool` VALUES (0,'oneadmin','7bc8559a8fe509e680562b85c337f170956fcb06',1),(1,'user_0','90e3707afc67a2038d1088761fea5cd50bbd08bb',1),(2,'user_1','681aae69de00c2df72381c3e5f9d77e70e7e384c',1),(3,'user_2','a195b95bf777854dfe566d1ffef1b76a34dc15a1',1),(4,'user_3','05bf903dc5ff0f2f69f630d9a59bc0b6df8c1cff',1),(5,'user_4','1a6f9b4e378ab45beee6cde9396df5c6ea9863b8',1); +/*!40000 ALTER TABLE `user_pool` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `vm_pool` +-- + +DROP TABLE IF EXISTS `vm_pool`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `vm_pool` ( + `oid` int(11) NOT NULL, + `uid` int(11) DEFAULT NULL, + `name` text, + `last_poll` int(11) DEFAULT NULL, + `state` int(11) DEFAULT NULL, + `lcm_state` int(11) DEFAULT NULL, + `stime` int(11) DEFAULT NULL, + `etime` int(11) DEFAULT NULL, + `deploy_id` text, + `memory` int(11) DEFAULT NULL, + `cpu` int(11) DEFAULT NULL, + `net_tx` int(11) DEFAULT NULL, + `net_rx` int(11) DEFAULT NULL, + `last_seq` int(11) DEFAULT NULL, + `template` text, + PRIMARY KEY (`oid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `vm_pool` +-- + +LOCK TABLES `vm_pool` WRITE; +/*!40000 ALTER TABLE `vm_pool` DISABLE KEYS */; +INSERT INTO `vm_pool` VALUES (0,1,'one-0',1316187945,3,3,1316187927,0,'dummy',0,0,12345,0,1,''),(1,2,'one-1',1316187930,6,0,1316187927,1316187939,'dummy',0,0,0,0,3,''),(2,3,'one-2',1316187930,6,0,1316187928,1316187940,'dummy',0,0,0,0,0,''),(3,4,'one-3',1316187930,6,0,1316187928,1316187941,'dummy',0,0,0,0,0,''),(4,5,'one-4',0,1,0,1316187928,0,'',0,0,0,0,-1,''); +/*!40000 ALTER TABLE `vm_pool` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2011-09-16 8:45:58 diff --git a/src/onedb/test/oned_mysql.conf b/src/onedb/test/oned_mysql.conf new file mode 100644 index 0000000000..164abeaf5d --- /dev/null +++ b/src/onedb/test/oned_mysql.conf @@ -0,0 +1,433 @@ +#******************************************************************************* +# OpenNebula Configuration file +#******************************************************************************* + +#******************************************************************************* +# Daemon configuration attributes +#------------------------------------------------------------------------------- +# MANAGER_TIMER: Time in seconds the core uses to evaluate periodical functions. +# HOST_MONITORING_INTERVAL and VM_POLLING_INTERVAL can not have smaller values +# than MANAGER_TIMER. +# +# HOST_MONITORING_INTERVAL: Time in seconds between host monitorization. +# +# VM_POLLING_INTERVAL: Time in seconds between virtual machine monitorization. +# (use 0 to disable VM monitoring). +# +# VM_DIR: Remote path to store the VM images, it should be shared between all +# the cluster nodes to perform live migrations. This variable is the default +# for all the hosts in the cluster. VM_DIR IS ONLY FOR THE NODES AND *NOT* THE +# FRONT-END +# +# SCRIPTS_REMOTE_DIR: Remote path to store the monitoring and VM management +# scripts. +# +# PORT: Port where oned will listen for xmlrpc calls. +# +# DB: Configuration attributes for the database backend +# backend : can be sqlite or mysql (default is sqlite) +# server : (mysql) host name or an IP address for the MySQL server +# port : (mysql) port for the connection to the server. +# If set to 0, the default port is used. +# user : (mysql) user's MySQL login ID +# passwd : (mysql) the password for user +# db_name : (mysql) the database name +# +# VNC_BASE_PORT: VNC ports for VMs can be automatically set to VNC_BASE_PORT + +# VMID +# +# DEBUG_LEVEL: 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG +#******************************************************************************* + +#MANAGER_TIMER=30 + +HOST_MONITORING_INTERVAL = 1 + +VM_POLLING_INTERVAL = 1 + +#VM_DIR=/srv/cloud/one/var + +SCRIPTS_REMOTE_DIR=/var/tmp/one + +PORT=2889 + +#DB = [ backend = "sqlite" ] + +# Sample configuration for MySQL +DB = [ backend = "mysql", + server = "localhost", + port = 0, + user = "oneadmin", + passwd = "oneadmin", + db_name = "onedb_test" ] + +VNC_BASE_PORT = 5900 + +DEBUG_LEVEL=3 + +#******************************************************************************* +# Physical Networks configuration +#******************************************************************************* +# NETWORK_SIZE: Here you can define the default size for the virtual networks +# +# MAC_PREFIX: Default MAC prefix to be used to create the auto-generated MAC +# addresses is defined here (this can be overrided by the Virtual Network +# template) +#******************************************************************************* + +NETWORK_SIZE = 254 + +MAC_PREFIX = "02:00" + +#******************************************************************************* +# Image Repository Configuration +#******************************************************************************* +# DEFAULT_IMAGE_TYPE: This can take values +# OS Image file holding an operating system +# CDROM Image file holding a CDROM +# DATABLOCK Image file holding a datablock, +# always created as an empty block +# DEFAULT_DEVICE_PREFIX: This can be set to +# hd IDE prefix +# sd SCSI +# xvd XEN Virtual Disk +# vd KVM virtual disk +#******************************************************************************* +DEFAULT_IMAGE_TYPE = "OS" +DEFAULT_DEVICE_PREFIX = "hd" + +#******************************************************************************* +# Information Driver Configuration +#******************************************************************************* +# You can add more information managers with different configurations but make +# sure it has different names. +# +# name : name for this information manager +# +# executable: path of the information driver executable, can be an +# absolute path or relative to $ONE_LOCATION/lib/mads (or +# /usr/lib/one/mads/ if OpenNebula was installed in /) +# +# arguments : for the driver executable, usually a probe configuration file, +# can be an absolute path or relative to $ONE_LOCATION/etc (or +# /etc/one/ if OpenNebula was installed in /) +#******************************************************************************* + +#------------------------------------------------------------------------------- +# KVM Information Driver Manager Configuration +# -r number of retries when monitoring a host +# -t number of threads, i.e. number of hosts monitored at the same time +#------------------------------------------------------------------------------- +#IM_MAD = [ +# name = "im_kvm", +# executable = "one_im_ssh", +# arguments = "-r 0 -t 15 kvm" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# XEN Information Driver Manager Configuration +# -r number of retries when monitoring a host +# -t number of threads, i.e. number of hosts monitored at the same time +#------------------------------------------------------------------------------- +#IM_MAD = [ +# name = "im_xen", +# executable = "one_im_ssh", +# arguments = "xen" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# EC2 Information Driver Manager Configuration +#------------------------------------------------------------------------------- +#IM_MAD = [ +# name = "im_ec2", +# executable = "one_im_ec2", +# arguments = "im_ec2/im_ec2.conf" ] +#------------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# Ganglia Information Driver Manager Configuration +#----------------------------------------------------------------------------- +#IM_MAD = [ +# name = "im_ganglia", +# executable = "one_im_sh", +# arguments = "ganglia" ] +#----------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# Dummy Information Driver Manager Configuration +#------------------------------------------------------------------------------- +IM_MAD = [ name="im_dummy", executable="one_im_dummy"] +#------------------------------------------------------------------------------- + +#******************************************************************************* +# Virtualization Driver Configuration +#******************************************************************************* +# You can add more virtualization managers with different configurations but +# make sure it has different names. +# +# name : name of the virtual machine manager driver +# +# executable: path of the virtualization driver executable, can be an +# absolute path or relative to $ONE_LOCATION/lib/mads (or +# /usr/lib/one/mads/ if OpenNebula was installed in /) +# +# arguments : for the driver executable +# +# default : default values and configuration parameters for the driver, can +# be an absolute path or relative to $ONE_LOCATION/etc (or +# /etc/one/ if OpenNebula was installed in /) +# +# type : driver type, supported drivers: xen, kvm, xml +#******************************************************************************* + +#------------------------------------------------------------------------------- +# KVM Virtualization Driver Manager Configuration +# -r number of retries when monitoring a host +# -t number of threads, i.e. number of hosts monitored at the same time +# -p name of the poll probe (executed locally) +#------------------------------------------------------------------------------- +#VM_MAD = [ +# name = "vmm_kvm", +# executable = "one_vmm_ssh", +# arguments = "-t 15 -r 0 kvm", +# default = "vmm_ssh/vmm_ssh_kvm.conf", +# type = "kvm" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# XEN Virtualization Driver Manager Configuration +# -r number of retries when monitoring a host +# -t number of threads, i.e. number of hosts monitored at the same time +# -l do not perform the VM polling in the node +# -p name of the poll probe (executed locally) +#------------------------------------------------------------------------------- +#VM_MAD = [ +# name = "vmm_xen", +# executable = "one_vmm_ssh", +# arguments = "xen", +# default = "vmm_ssh/vmm_ssh_xen.conf", +# type = "xen" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# EC2 Virtualization Driver Manager Configuration +# arguments: default values for the EC2 driver, can be an absolute path or +# relative to $ONE_LOCATION/etc (or /etc/one/ if OpenNebula was +# installed in /). +#------------------------------------------------------------------------------- +#VM_MAD = [ +# name = "vmm_ec2", +# executable = "one_vmm_ec2", +# arguments = "vmm_ec2/vmm_ec2.conf", +# type = "xml" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# Dummy Virtualization Driver Configuration +#------------------------------------------------------------------------------- +VM_MAD = [ name="vmm_dummy", executable="one_vmm_dummy", type="xml" ] +#------------------------------------------------------------------------------- + +#******************************************************************************* +# Transfer Manager Driver Configuration +#******************************************************************************* +# You can add more transfer managers with different configurations but make +# sure it has different names. +# name : name for this transfer driver +# +# executable: path of the transfer driver executable, can be an +# absolute path or relative to $ONE_LOCATION/lib/mads (or +# /usr/lib/one/mads/ if OpenNebula was installed in /) +# +# arguments : for the driver executable, usually a commands configuration file +# , can be an absolute path or relative to $ONE_LOCATION/etc (or +# /etc/one/ if OpenNebula was installed in /) +#******************************************************************************* + +#------------------------------------------------------------------------------- +# SHARED Transfer Manager Driver Configuration +#------------------------------------------------------------------------------- +#TM_MAD = [ +# name = "tm_shared", +# executable = "one_tm", +# arguments = "tm_shared/tm_shared.conf" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# SSH Transfer Manager Driver Configuration +#------------------------------------------------------------------------------- +#TM_MAD = [ +# name = "tm_ssh", +# executable = "one_tm", +# arguments = "tm_ssh/tm_ssh.conf" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# Dummy Transfer Manager Driver Configuration +#------------------------------------------------------------------------------- +TM_MAD = [ + name = "tm_dummy", + executable = "one_tm", + arguments = "tm_dummy/tm_dummy.conf" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# LVM Transfer Manager Driver Configuration +#------------------------------------------------------------------------------- +#TM_MAD = [ +# name = "tm_lvm", +# executable = "one_tm", +# arguments = "tm_lvm/tm_lvm.conf" ] +#------------------------------------------------------------------------------- + +#******************************************************************************* +# Image Manager Driver Configuration +#******************************************************************************* +# Drivers to manage the image repository, specialized for the storage backend +# executable: path of the transfer driver executable, can be an +# absolute path or relative to $ONE_LOCATION/lib/mads (or +# /usr/lib/one/mads/ if OpenNebula was installed in /) +# +# arguments : for the driver executable +#******************************************************************************* +#------------------------------------------------------------------------------- +# FS based Image Manager Driver Configuration +# -t number of threads, i.e. number of repo operations at the same time +#------------------------------------------------------------------------------- +IMAGE_MAD = [ + executable = "one_image", + arguments = "fs -t 15" ] +#------------------------------------------------------------------------------- + +#******************************************************************************* +# Hook Manager Configuration +#******************************************************************************* +# The Driver (HM_MAD), used to execute the Hooks +# executable: path of the hook driver executable, can be an +# absolute path or relative to $ONE_LOCATION/lib/mads (or +# /usr/lib/one/mads/ if OpenNebula was installed in /) +# +# arguments : for the driver executable, can be an absolute path or relative +# to $ONE_LOCATION/etc (or /etc/one/ if OpenNebula was installed +# in /) +# +# Virtual Machine Hooks (VM_HOOK) defined by: +# name : for the hook, useful to track the hook (OPTIONAL) +# on : when the hook should be executed, +# - CREATE, when the VM is created (onevm create) +# - RUNNING, after the VM is successfully booted +# - SHUTDOWN, after the VM is shutdown +# - STOP, after the VM is stopped (including VM image transfers) +# - DONE, after the VM is deleted or shutdown +# - FAILED, when the VM enters the failed state +# command : path can be absolute or relative to $ONE_LOCATION/share/hooks +# case of self-contained installation or relative to +# /usr/share/one/hooks in case of system-wide installation +# arguments : for the hook. You can access to VM information with $ +# - $VMID, the ID of the virtual machine +# - $TEMPLATE, the VM template in xml and base64 encoded +# remote : values, +# - YES, The hook is executed in the host where the VM was +# allocated +# - NO, The hook is executed in the OpenNebula server (default) +# +# +# Host Hooks (HOST_HOOK) defined by: +# name : for the hook, useful to track the hook (OPTIONAL) +# on : when the hook should be executed, +# - CREATE, when the Host is created (onehost create) +# - ERROR, when the Host enters the error state +# - DISABLE, when the Host is disabled +# command : path can be absolute or relative to $ONE_LOCATION/share/hooks +# case of self-contained installation or relative to +# /usr/share/one/hooks in case of system-wide installation +# arguments : for the hook. You can use the following Host information: +# - $HID, the ID of the host +# - $TEMPLATE, the Host template in xml and base64 encoded +# remote : values, +# - YES, The hook is executed in the host +# - NO, The hook is executed in the OpenNebula server (default) +#------------------------------------------------------------------------------- + +HM_MAD = [ + executable = "one_hm" ] + +#------------------------------------------------------------------------------- + +#------------------------------ Fault Tolerance Hooks -------------------------- +# This hook is used to perform recovery actions when a host fails. The VMs +# running in the host can be deleted (use -d option) or resubmitted (-r) in +# other host +# Last argument (force) can be "y", so suspended VMs in the host will be +# resubmitted/deleted, or "n", so suspended VMs in the host will be ignored +# +#HOST_HOOK = [ +# name = "error", +# on = "ERROR", +# command = "host_error.rb", +# arguments = "$HID -r n", +# remote = "no" ] +#------------------------------------------------------------------------------- +# This two hooks can be used to automatically delete or resubmit VMs that reach +# the "failed" state. This way, the administrator doesn't have to interact +# manually to release its resources or retry the deployment. +# +# Only one of them should be uncommented. +#------------------------------------------------------------------------------- +# +#VM_HOOK = [ +# name = "on_failure_delete", +# on = "FAILED", +# command = "/usr/bin/env onevm delete", +# arguments = "$VMID" ] +# +#VM_HOOK = [ +# name = "on_failure_resubmit", +# on = "FAILED", +# command = "/usr/bin/env onevm resubmit", +# arguments = "$VMID" ] +#------------------------------------------------------------------------------- + +#-------------------------------- ebtables Hook--------------------------------- +# You can use these two hooks to isolate networks at the ethernet level so the +# traffic generated in different virtual networks can not be seen in others. +# +# All the network configuration will be done in the cluster nodes, these are the +# additional requisites: +# - ebtables package installed +# - sudoers configured so oneadmin can execute ebtables without password +# +# NOTE: Change the first command for ebtables-xen if you are using Xen +# +#VM_HOOK = [ +# name = "ebtables-start", +# on = "running", +# command = "ebtables-kvm", # or ebtables-xen +# arguments = "one-$VMID", +# remote = "yes" ] +# +#VM_HOOK = [ +# name = "ebtables-flush", +# on = "done", +# command = "ebtables-flush", +# arguments = "", +# remote = "yes" ] +#------------------------------------------------------------------------------- + +#******************************************************************************* +# Auth Manager Configuration +#******************************************************************************* +# The Driver (AUTHM_MAD) that will be used to authenticate and authorize +# OpenNebula requests. If not defined OpenNebula will use the built-in auth +# policies +# executable: path of the auth driver executable, can be an +# absolute path or relative to $ONE_LOCATION/lib/mads (or +# /usr/lib/one/mads/ if OpenNebula was installed in /) +# +# arguments : for the driver executable, can be an absolute path or relative +# to $ONE_LOCATION/etc (or /etc/one/ if OpenNebula was installed +# in /) +#------------------------------------------------------------------------------- + +#AUTH_MAD = [ +# executable = "one_auth_mad" ] diff --git a/src/onedb/test/oned.conf b/src/onedb/test/oned_sqlite.conf similarity index 100% rename from src/onedb/test/oned.conf rename to src/onedb/test/oned_sqlite.conf diff --git a/src/onedb/test/test_mysql.sh b/src/onedb/test/test_mysql.sh new file mode 100755 index 0000000000..ac973b72ac --- /dev/null +++ b/src/onedb/test/test_mysql.sh @@ -0,0 +1,173 @@ +#!/bin/bash + +################################################################################ +# Initialization +################################################################################ + +if [ -z $ONE_LOCATION ]; then + echo "ONE_LOCATION not defined." + exit -1 +fi + +ONEDCONF_LOCATION="$ONE_LOCATION/etc/oned.conf" + +if [ -f $ONEDCONF_LOCATION ]; then + echo "$ONEDCONF_LOCATION has to be overwritten, move it to a safe place." + exit -1 +fi + +VAR_LOCATION="$ONE_LOCATION/var" + + +# Clean DB +mysql -u oneadmin -poneadmin -h localhost -P 0 -e "DROP DATABASE IF EXISTS onedb_test;" + +cp oned_mysql.conf $ONEDCONF_LOCATION + + +echo "oneadmin:oneadmin" > oneadmin_auth +export ONE_XMLRPC=http://localhost:2889/RPC2 +export PATH=$ONE_LOCATION/bin:$PATH +export ONE_AUTH="`pwd`/oneadmin_auth" + + +PID=$$ + +mkdir results + +################################################################################ +# Start OpenNebula and populate a DB +################################################################################ + +echo "Starting oned, some resources will be created" + +oned -f & +sleep 2s; + +./create.sh + +pkill -P $PID oned +sleep 2s; +pkill -9 -P $PID oned + +################################################################################ +# Upgrade the 2.2 sample DB, and compare schemas +################################################################################ + +echo "All resources created, now 2.2 DB will be upgraded." + +# dump current DB and schema +onedb backup results/mysqldb.3.0 +mysqldump -u oneadmin -poneadmin -h localhost -P 0 --no-data onedb_test > results/mysqldb.3.0.tmpschema + +# restore 2.2 +onedb restore -f 2.2/mysqldb.sql +# upgrade +onedb upgrade -v --backup results/mysqldb.backup +# dump upgraded DB schema +mysqldump -u oneadmin -poneadmin -h localhost -P 0 --no-data onedb_test > results/mysqldb.upgraded.tmpschema + +echo "Done. Upgraded DB and the one just created will be compared." + +# Sort the files contents, to avoid false diff errors +sort results/mysqldb.upgraded.tmpschema > results/mysqldb.upgraded.schema +sort results/mysqldb.3.0.tmpschema > results/mysqldb.3.0.schema + +rm results/mysqldb.upgraded.tmpschema +rm results/mysqldb.3.0.tmpschema + + + +# Perform a diff +FILE=results/schema.diff +diff <(grep -v -e "Dump completed on" results/mysqldb.upgraded.schema) <(grep -v -e "Dump completed on" results/mysqldb.3.0.schema) > $FILE + + +if [[ -s $FILE ]] ; then + echo "Error: Schemas do not match. Check file $FILE" + exit -1 +fi + + +################################################################################ +# Start oned using the upgraded DB and compare objects XMLs +################################################################################ + +echo "Schemas match. OpenNebula 3.0 will be started with the upgraded 2.2 DB." + +oned -f & +sleep 2s; + +for obj in host vnet image vm user; do + for i in 0 1 2 3 4; do + one$obj show -x $i > results/xml_files/$obj-$i-upgraded.xml + done +done + +for obj in host vnet image vm acl group user; do + one$obj list a -x > results/xml_files/$obj-pool-upgraded.xml +done + + +pkill -P $PID oned +sleep 2s; +pkill -9 -P $PID oned + +echo "XML output collected. A diff will be performed." + +mkdir results/diff_files + +diff <(grep -v -e "" -e "" -e "NAME>" results/xml_files/host-pool.xml) <(grep -v -e "" -e "" -e "NAME>" results/xml_files/host-pool-upgraded.xml) > results/diff_files/host-pool.diff + +# TODO: fix +# The image-pool.xml files are the same, but for some reason the Images are +# returned in different order. +#diff <(grep -v -e "" -e "" -e "" results/xml_files/image-pool.xml) <(grep -v -e "" -e "" -e "" results/xml_files/image-pool-upgraded.xml) > results/diff_files/image-pool.diff + +diff <(grep -v -e "" -e "TIME>" -e "" -e "" -e "" results/xml_files/vm-pool.xml) <(grep -v -e "" -e "TIME>" -e "" -e "" -e "" results/xml_files/vm-pool-upgraded.xml) > results/diff_files/vm-pool.diff + +for obj in vnet acl group user; do + diff <(cat results/xml_files/$obj-pool.xml) <(cat results/xml_files/$obj-pool-upgraded.xml) > results/diff_files/$obj-pool.diff +done + +for i in 0 1 2 3 4; do + diff <(grep -v -e "" -e "" -e "NAME>" results/xml_files/host-$i.xml) <(grep -v -e "" -e "" -e "NAME>" results/xml_files/host-$i-upgraded.xml) > results/diff_files/host-$i.diff + + diff <(cat results/xml_files/vnet-$i.xml) <(cat results/xml_files/vnet-$i-upgraded.xml) > results/diff_files/vnet-$i.diff + + diff <(grep -v -e "" -e "" -e "" results/xml_files/image-$i.xml) <(grep -v -e "" -e "" -e "" results/xml_files/image-$i-upgraded.xml) > results/diff_files/image-$i.diff + + diff <(grep -v -e "" -e "TIME>" -e "" -e "" -e "" -e "" results/xml_files/vm-$i.xml) <(grep -v -e "" -e "TIME>" -e "" -e "" -e "" -e "" results/xml_files/vm-$i-upgraded.xml) > results/diff_files/vm-$i.diff + + diff <(cat results/xml_files/user-$i.xml) <(cat results/xml_files/user-$i-upgraded.xml) > results/diff_files/user-$i.diff +done + + +CODE=0 + +for obj in host vnet image vm user; do + for i in 0 1 2 3 4; do + FILE=results/diff_files/$obj-$i.diff + if [[ -s $FILE ]] ; then + echo "Error: diff file $FILE is not empty." + CODE=-1 + fi + done +done + +for obj in host vnet image vm acl group user; do + FILE=results/diff_files/$obj-pool.diff + if [[ -s $FILE ]] ; then + echo "Error: diff file $FILE is not empty." + CODE=-1 + fi +done + + +if [ $CODE -eq 0 ]; then + echo "Done, all tests passed." +fi + +rm oneadmin_auth + +exit $CODE diff --git a/src/onedb/test/test.sh b/src/onedb/test/test_sqlite.sh similarity index 99% rename from src/onedb/test/test.sh rename to src/onedb/test/test_sqlite.sh index 5253b93cee..c0ff4d0d0a 100755 --- a/src/onedb/test/test.sh +++ b/src/onedb/test/test_sqlite.sh @@ -24,7 +24,7 @@ if [ -f $VAR_LOCATION/one.db ]; then fi -cp oned.conf $ONEDCONF_LOCATION +cp oned_sqlite.conf $ONEDCONF_LOCATION echo "oneadmin:oneadmin" > oneadmin_auth