mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-10 06:24:35 +09:00
Removed unused test files. Listed the test directories in the do_test script to prevent the execution of non-test files
This commit is contained in:
1 parent
bcb7e774de
commit
334223dbca
13 files changed
+16
-1099
No files matched your search
+16
-3
@@ -1,8 +1,23 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# COMMAND LINE PARSING
|
# DEFINE THE TESTS
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
TWD_DIR="../../src"
|
||||||
|
BASE_DIR=$PWD
|
||||||
|
|
||||||
|
TESTS="$TWD_DIR/vnm/test \
|
||||||
|
$TWD_DIR/scheduler/src/xml/test \
|
||||||
|
$TWD_DIR/scheduler/src/pool/test \
|
||||||
|
$TWD_DIR/hm_mad/test \
|
||||||
|
$TWD_DIR/common/test \
|
||||||
|
$TWD_DIR/host/test \
|
||||||
|
$TWD_DIR/template/test \
|
||||||
|
$TWD_DIR/image/test \
|
||||||
|
$TWD_DIR/authm/test \
|
||||||
|
$TWD_DIR/vm/test \
|
||||||
|
$TWD_DIR/um/test \
|
||||||
|
$TWD_DIR/lcm/test \
|
||||||
|
$TWD_DIR/pool/test"
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# COMMAND LINE PARSING
|
# COMMAND LINE PARSING
|
||||||
@@ -38,8 +53,6 @@ LOGS="no"
|
|||||||
CLEAR="no"
|
CLEAR="no"
|
||||||
BUILD="no"
|
BUILD="no"
|
||||||
|
|
||||||
TWD_DIR="../../src"
|
|
||||||
BASE_DIR=$PWD
|
|
||||||
|
|
||||||
while true ; do
|
while true ; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
|||||||
Binary file not shown.
@@ -1,67 +0,0 @@
|
|||||||
#include "ActionManager.h"
|
|
||||||
#include <iostream>
|
|
||||||
#include <cerrno>
|
|
||||||
|
|
||||||
class AMTest : public ActionListener
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AMTest():am()
|
|
||||||
{
|
|
||||||
am.addListener(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
~AMTest(){};
|
|
||||||
|
|
||||||
ActionManager am;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void do_action(const string &action, void * arg);
|
|
||||||
};
|
|
||||||
|
|
||||||
void AMTest::do_action(const string &action, void * arg)
|
|
||||||
{
|
|
||||||
int * i = static_cast<int *>(arg);
|
|
||||||
|
|
||||||
cout<<"Event received: "<<action<<" Argument : "<<*i<<"\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void * startThread(void *arg)
|
|
||||||
{
|
|
||||||
AMTest * MT;
|
|
||||||
int i = 8;
|
|
||||||
string event("ACTION_TEST");
|
|
||||||
|
|
||||||
MT = static_cast<AMTest *> (arg);
|
|
||||||
|
|
||||||
MT->am.trigger(event,&i);
|
|
||||||
|
|
||||||
sleep(4);
|
|
||||||
|
|
||||||
i = 10;
|
|
||||||
|
|
||||||
MT->am.trigger(event,&i);
|
|
||||||
|
|
||||||
i = 23;
|
|
||||||
|
|
||||||
MT->am.trigger(ActionListener::ACTION_FINALIZE,&i);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
pthread_t id;
|
|
||||||
int i = 3;
|
|
||||||
AMTest * MT = new AMTest();
|
|
||||||
|
|
||||||
pthread_create(&id, 0, startThread, MT);
|
|
||||||
|
|
||||||
MT->am.loop(1,&i);
|
|
||||||
|
|
||||||
delete MT;
|
|
||||||
|
|
||||||
pthread_join(id,0);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
@@ -1,252 +0,0 @@
|
|||||||
#include "VirtualMachine.h"
|
|
||||||
#include "VirtualMachineManagerDriver.h"
|
|
||||||
#include "Nebula.h"
|
|
||||||
|
|
||||||
#include "InformationManagerDriver.h"
|
|
||||||
#include "InformationManager.h"
|
|
||||||
#include "Mad.h"
|
|
||||||
|
|
||||||
#include "Host.h"
|
|
||||||
#include "HostPool.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdexcept>
|
|
||||||
|
|
||||||
#include <signal.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#include <climits>
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
extern "C" void *test(void *nothing)
|
|
||||||
{
|
|
||||||
ostringstream os;
|
|
||||||
|
|
||||||
sleep(2);
|
|
||||||
os.str("");
|
|
||||||
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
Nebula & pn = Nebula::instance();
|
|
||||||
|
|
||||||
HostPool * thepool = pn.get_hpool();
|
|
||||||
Host * host;
|
|
||||||
int hid;
|
|
||||||
|
|
||||||
thepool->bootstrap();
|
|
||||||
|
|
||||||
thepool->allocate(&hid,"foo.dacya","mad1","mad2","mad3",true);
|
|
||||||
|
|
||||||
os.str("");
|
|
||||||
os << "Host " << hid << " allocated";
|
|
||||||
Nebula::log("TST", Log::ERROR, os);
|
|
||||||
|
|
||||||
thepool->allocate(&hid,"foo2.dacya","mad1","mad2","mad3",true);
|
|
||||||
|
|
||||||
os.str("");
|
|
||||||
os << "Host " << hid << " allocated";
|
|
||||||
Nebula::log("TST", Log::ERROR, os);
|
|
||||||
|
|
||||||
thepool->allocate(&hid,"foo3.dacya","mad1","mad2","mad3",true);
|
|
||||||
|
|
||||||
os.str("");
|
|
||||||
os << "Host " << hid << " allocated";
|
|
||||||
Nebula::log("TST", Log::ERROR, os);
|
|
||||||
|
|
||||||
host = static_cast<Host *>(thepool->get(3422,false));
|
|
||||||
|
|
||||||
if (host != 0)
|
|
||||||
{
|
|
||||||
os.str("");
|
|
||||||
os << "Test failed. Shouldn't be here.";
|
|
||||||
Nebula::log("TST", Log::ERROR, os);
|
|
||||||
}
|
|
||||||
|
|
||||||
host = static_cast<Host *>(thepool->get(0,true));
|
|
||||||
|
|
||||||
if (host != 0)
|
|
||||||
{
|
|
||||||
os.str("");
|
|
||||||
os << "Going fine. Host " << *host << " retrieved.";
|
|
||||||
Nebula::log("TST", Log::ERROR, os);
|
|
||||||
|
|
||||||
host->unlock();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
os.str("");
|
|
||||||
os << "Test failed!. Not able to retrieve host 0";
|
|
||||||
Nebula::log("TST", Log::ERROR, os);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Host * host2 = static_cast<Host *>(thepool->get(1,false));
|
|
||||||
|
|
||||||
if (host2 != 0)
|
|
||||||
{
|
|
||||||
os.str("");
|
|
||||||
os << "Going fine. Host " << *host2 << " retrieved.";
|
|
||||||
Nebula::log("TST", Log::ERROR, os);
|
|
||||||
}
|
|
||||||
|
|
||||||
Host * host3 = static_cast<Host *>(thepool->get(2,false));
|
|
||||||
|
|
||||||
if (host3 != 0)
|
|
||||||
{
|
|
||||||
os.str("");
|
|
||||||
os << "Going fine. Host " << *host3 << " retrieved.";
|
|
||||||
Nebula::log("TST", Log::ERROR, os);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Host * host4 = static_cast<Host *>(thepool->get(32,false));
|
|
||||||
|
|
||||||
|
|
||||||
if (host4 != 0)
|
|
||||||
{
|
|
||||||
os.str("");
|
|
||||||
os << "Going fine. Host " << *host4 << " retrieved.";
|
|
||||||
Nebula::log("TST", Log::ERROR, os);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
host3->lock();
|
|
||||||
|
|
||||||
string host_info_str("cpuArchitecture=x86_32\nnumberCores=1\ncpuSpeed=2211\ntotalMemory=2046\nfreeMemory=125\nusedMemory=1921\ncpupercentage=50\nnetTX=78516\nnetRX=138612\nnetRX=138612\n");
|
|
||||||
rc = host3->update_info(host_info_str);
|
|
||||||
|
|
||||||
host3->touch();
|
|
||||||
|
|
||||||
|
|
||||||
os.str("");
|
|
||||||
os << "updated host info with RC = " << rc;
|
|
||||||
Nebula::log("TST", Log::ERROR, os);
|
|
||||||
|
|
||||||
rc = thepool->update_host(host3);
|
|
||||||
|
|
||||||
os.str("");
|
|
||||||
os << "updated host into DB with RC = " << rc;
|
|
||||||
Nebula::log("TST", Log::ERROR, os);
|
|
||||||
|
|
||||||
bool result;
|
|
||||||
char * error;
|
|
||||||
|
|
||||||
rc = host3->match("numberCores=1 & cpuArchitecture=\"OTRA ARCH\"",result,&error);
|
|
||||||
|
|
||||||
os.str("");
|
|
||||||
if ( rc == 0)
|
|
||||||
{
|
|
||||||
os << "REQ result = " << result;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
os << "REQ error = " << error;
|
|
||||||
|
|
||||||
free(error);
|
|
||||||
}
|
|
||||||
Nebula::log("TST", Log::ERROR, os);
|
|
||||||
|
|
||||||
int resulti;
|
|
||||||
|
|
||||||
rc = host3->rank("cpuSpeed + numberCores",resulti,&error);
|
|
||||||
|
|
||||||
os.str("");
|
|
||||||
if ( rc == 0)
|
|
||||||
{
|
|
||||||
os << "RANK result = " << resulti;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
os << "RANK error = " << error;
|
|
||||||
|
|
||||||
free(error);
|
|
||||||
}
|
|
||||||
Nebula::log("TST", Log::ERROR, os);
|
|
||||||
|
|
||||||
host3->unlock();
|
|
||||||
|
|
||||||
host3->lock();
|
|
||||||
|
|
||||||
string host_info_str2("cpuArchitecture=\"OTRA ARCH\"\n");
|
|
||||||
|
|
||||||
rc = host3->update_info(host_info_str2);
|
|
||||||
|
|
||||||
host3->touch();
|
|
||||||
|
|
||||||
rc = thepool->update_host(host3);
|
|
||||||
|
|
||||||
host3->unlock();
|
|
||||||
|
|
||||||
|
|
||||||
host2->lock();
|
|
||||||
|
|
||||||
string host_info_str3("cpuArchitecture=x86_32\nnumberCores=8\ncpuSpeed=2211\ntotalMemory=2046\nfreeMemory=125\nusedMemory=1921\ncpupercentage=50\nnetTX=78516\nnetRX=138612\nnetRX=138612\n");
|
|
||||||
|
|
||||||
rc = host2->update_info(host_info_str3);
|
|
||||||
|
|
||||||
host2->touch();
|
|
||||||
|
|
||||||
rc = thepool->update_host(host2);
|
|
||||||
|
|
||||||
host2->unlock();
|
|
||||||
|
|
||||||
map <int, string> test_discover;
|
|
||||||
|
|
||||||
rc = thepool->discover(&test_discover);
|
|
||||||
|
|
||||||
if(rc!=0)
|
|
||||||
{
|
|
||||||
os.str("");
|
|
||||||
os << "Error discovering hosts.";
|
|
||||||
Nebula::log("TST", Log::ERROR, os);
|
|
||||||
}
|
|
||||||
|
|
||||||
os.str("");
|
|
||||||
os << "Discover size:" << test_discover.size();
|
|
||||||
Nebula::log("TST", Log::ERROR, os);
|
|
||||||
|
|
||||||
map <int, string>::iterator it;
|
|
||||||
|
|
||||||
for(it=test_discover.begin();it!=test_discover.end();it++)
|
|
||||||
{
|
|
||||||
os.str("");
|
|
||||||
os << "IM_MAD:" << it->second << " has to monitor " << it->first;
|
|
||||||
Nebula::log("TST", Log::ERROR, os);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
pthread_t test_thread;
|
|
||||||
|
|
||||||
pthread_create(&test_thread,0,test,(void *)0);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Nebula& nd = Nebula::instance();
|
|
||||||
nd.start();
|
|
||||||
}
|
|
||||||
catch (exception &e)
|
|
||||||
{
|
|
||||||
cout << e.what() << endl;
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
/* Copyright 2002-2010, 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 "VirtualMachine.h"
|
|
||||||
#include "VirtualMachineManagerDriver.h"
|
|
||||||
#include "Nebula.h"
|
|
||||||
|
|
||||||
#include "InformationManagerDriver.h"
|
|
||||||
#include "InformationManager.h"
|
|
||||||
#include "Mad.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdexcept>
|
|
||||||
|
|
||||||
#include <signal.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
extern "C" void *test(void *nothing)
|
|
||||||
{
|
|
||||||
sleep(2);
|
|
||||||
|
|
||||||
Nebula& pn = Nebula::instance();
|
|
||||||
|
|
||||||
InformationManager * im = pn.get_im();
|
|
||||||
HostPool * hostp = pn.get_hpool();
|
|
||||||
|
|
||||||
int * oid;
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
sleep(2);
|
|
||||||
|
|
||||||
/* rc = hostp->allocate(oid,"aquila03","im_test","xen_ssh","dummy",true);
|
|
||||||
|
|
||||||
if ( rc != 0 )
|
|
||||||
{
|
|
||||||
Nebula::log("TST",Log::ERROR,"Error allocating host!");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
im->load_mads();
|
|
||||||
|
|
||||||
sleep(600);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
pthread_attr_t pattr;
|
|
||||||
pthread_t test_thread;
|
|
||||||
|
|
||||||
pthread_attr_init (&pattr);
|
|
||||||
pthread_attr_setdetachstate (&pattr, PTHREAD_CREATE_JOINABLE);
|
|
||||||
|
|
||||||
pthread_create(&test_thread,&pattr,test,(void *)0);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Nebula& nd = Nebula::instance();
|
|
||||||
nd.start();
|
|
||||||
}
|
|
||||||
catch (exception &e)
|
|
||||||
{
|
|
||||||
cout << e.what() << endl;
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,188 +0,0 @@
|
|||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "MadManager.h"
|
|
||||||
|
|
||||||
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
|
|
||||||
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
||||||
bool finalized = false;
|
|
||||||
|
|
||||||
class MadEcho : public Mad
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MadEcho(map<string,string> &attrs):Mad(0,attrs,false)
|
|
||||||
{}
|
|
||||||
;
|
|
||||||
|
|
||||||
~MadEcho()
|
|
||||||
{}
|
|
||||||
;
|
|
||||||
|
|
||||||
void protocol(string& message);
|
|
||||||
|
|
||||||
void recover()
|
|
||||||
{
|
|
||||||
cout<<"Recover Function @ MadEcho\n";
|
|
||||||
};
|
|
||||||
|
|
||||||
void test(const char *a1, const char *a2, const char *a3)
|
|
||||||
{
|
|
||||||
ostringstream buf;
|
|
||||||
|
|
||||||
buf << "TEST " << a1 << " " << a2 << " " << a3 << "\n";
|
|
||||||
|
|
||||||
write(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
void first(const char *a1)
|
|
||||||
{
|
|
||||||
ostringstream buf;
|
|
||||||
|
|
||||||
buf << "FIRST " << a1 << "\n";
|
|
||||||
|
|
||||||
write(buf);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void MadEcho::protocol(string& message)
|
|
||||||
{
|
|
||||||
stringbuf sbuf(message);
|
|
||||||
iostream sstr(&sbuf);
|
|
||||||
|
|
||||||
string field[5];
|
|
||||||
|
|
||||||
sstr >> field[0] >> ws;
|
|
||||||
|
|
||||||
if ( field[0] == "INIT" )
|
|
||||||
{
|
|
||||||
getline(sstr,field[1]);
|
|
||||||
|
|
||||||
cout << "Init Result: " << field[1] << "\n";
|
|
||||||
}
|
|
||||||
else if ( field[0] == "FINALIZE" )
|
|
||||||
{
|
|
||||||
getline(sstr,field[1]);
|
|
||||||
|
|
||||||
cout << "Finalize Result: " << field[1] << "\n";
|
|
||||||
}
|
|
||||||
else if ( field[0] == "TEST" )
|
|
||||||
{
|
|
||||||
sstr >> field[1] >> field[2] >> field[3] >> ws;
|
|
||||||
|
|
||||||
getline(sstr,field[4]);
|
|
||||||
|
|
||||||
cout << "Test Result: " << field[1] << "\nArg1: " << field[2]
|
|
||||||
<< "\nArg2: " << field[3] << "\nInfo: " << field[4] << "\n";
|
|
||||||
}
|
|
||||||
else if ( field[0] == "FIRST" )
|
|
||||||
{
|
|
||||||
finalized = true;
|
|
||||||
|
|
||||||
sstr >> field[1] >> ws;
|
|
||||||
getline(sstr,field[2]);
|
|
||||||
|
|
||||||
cout << "First Result: " << field[1] << "\nArg1: " << field[2] << "\n";
|
|
||||||
|
|
||||||
pthread_cond_signal(&cond);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MMadManager : public MadManager
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MMadManager(vector<const Attribute *>& _mads):MadManager(_mads){};
|
|
||||||
~MMadManager(){};
|
|
||||||
|
|
||||||
void load_mads(int uid){};
|
|
||||||
|
|
||||||
int mstart(){
|
|
||||||
return start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void mstop(){
|
|
||||||
stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
int madd(Mad *mad){
|
|
||||||
return add(mad);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
vector<const Attribute *> _mads;
|
|
||||||
MMadManager *mm;
|
|
||||||
MadEcho * mad_echo;
|
|
||||||
map<string,string> attrs;
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
MadManager::mad_manager_system_init();
|
|
||||||
|
|
||||||
mm = new MMadManager(_mads);
|
|
||||||
|
|
||||||
rc = mm->mstart();
|
|
||||||
|
|
||||||
if ( rc != 0 )
|
|
||||||
{
|
|
||||||
goto error_start;
|
|
||||||
}
|
|
||||||
|
|
||||||
attrs.insert(make_pair("NAME","echo_mad"));
|
|
||||||
attrs.insert(make_pair("EXECUTABLE","./mad_echo.sh"));
|
|
||||||
attrs.insert(make_pair("OWNER","foo"));
|
|
||||||
|
|
||||||
mad_echo = new MadEcho(attrs);
|
|
||||||
/*
|
|
||||||
rc = mad_echo->start();
|
|
||||||
|
|
||||||
if ( rc != 0 )
|
|
||||||
{
|
|
||||||
goto error_start_mad;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
rc = mm->madd(mad_echo);
|
|
||||||
|
|
||||||
if ( rc != 0 )
|
|
||||||
{
|
|
||||||
goto error_register;
|
|
||||||
}
|
|
||||||
|
|
||||||
mad_echo->test("argument1","argument2","argument3");
|
|
||||||
|
|
||||||
mad_echo->first("filed1");
|
|
||||||
|
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
|
|
||||||
while ( finalized == false )
|
|
||||||
{
|
|
||||||
pthread_cond_wait(&cond, &mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Mad_Test - OK\n");
|
|
||||||
|
|
||||||
mm->mstop();
|
|
||||||
|
|
||||||
delete mm;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
error_register:
|
|
||||||
cout << "Mad_Test - error register mad\n";
|
|
||||||
mm->mstop();
|
|
||||||
|
|
||||||
delete mm;
|
|
||||||
delete mad_echo;
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
error_start:
|
|
||||||
cout << "Mad_Test - error start manager\n";
|
|
||||||
mm->mstop();
|
|
||||||
|
|
||||||
delete mm;
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
|
||||||
# Copyright 2002-2010, 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.
|
|
||||||
# --------------------------------------------------------------------------
|
|
||||||
|
|
||||||
echo "MAD started" > mad.log
|
|
||||||
|
|
||||||
|
|
||||||
while read COMMAND ARG1 ARG2 ARG3
|
|
||||||
do
|
|
||||||
echo "$COMMAND $ARG1 $ARG2 $ARG3" >> mad.log
|
|
||||||
case $COMMAND in
|
|
||||||
"INIT" | "init")
|
|
||||||
echo "INIT SUCCESS"
|
|
||||||
;;
|
|
||||||
"FINALIZE" | "finalize")
|
|
||||||
echo "FINALIZE SUCCESS"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
"TEST" | "test")
|
|
||||||
echo "TEST SUCCESS $ARG1 $ARG2 $ARG3"
|
|
||||||
;;
|
|
||||||
"FIRST" | "first")
|
|
||||||
echo "FIRST SUCCESS $ARG1"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "$COMMAND - FAILURE Unknown command"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#include "Log.h"
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
Log log("file.log");
|
|
||||||
|
|
||||||
ostringstream message;
|
|
||||||
message << "pepe";
|
|
||||||
|
|
||||||
log.log("module", Log::ERROR, message);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,173 +0,0 @@
|
|||||||
#include "PoolSQL.h"
|
|
||||||
#include <climits>
|
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
class A : public ObjectSQL
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
A(int n,string &t):number(n),text(t){oid=n;};
|
|
||||||
A(int n,const char *t):number(n),text(t){oid=n;};
|
|
||||||
A(int n):number(n){oid=n;};
|
|
||||||
A(){};
|
|
||||||
~A(){};
|
|
||||||
|
|
||||||
int number;
|
|
||||||
string text;
|
|
||||||
|
|
||||||
int insert(sqlite3 *db);
|
|
||||||
int select(sqlite3 *db);
|
|
||||||
int update(sqlite3 *db){return 0;};
|
|
||||||
};
|
|
||||||
|
|
||||||
int A::insert(sqlite3 *db)
|
|
||||||
{
|
|
||||||
const char * sql_cmd;
|
|
||||||
ostringstream buffer;
|
|
||||||
string sql;
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
buffer << "INSERT INTO test (numero,texto) VALUES (" << oid << ",\"" <<
|
|
||||||
text << "\")";
|
|
||||||
|
|
||||||
sql = buffer.str();
|
|
||||||
sql_cmd = sql.c_str();
|
|
||||||
|
|
||||||
rc = sqlite3_exec(db,
|
|
||||||
sql_cmd,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
if ( rc != SQLITE_OK )
|
|
||||||
{
|
|
||||||
cout << "ERROR : "<<sql_cmd<<"\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern "C" int select_cb (
|
|
||||||
void * _this,
|
|
||||||
int num,
|
|
||||||
char ** values,
|
|
||||||
char ** names)
|
|
||||||
{
|
|
||||||
A *aclass;
|
|
||||||
|
|
||||||
aclass = (A *) _this;
|
|
||||||
|
|
||||||
cout << "#" << values[1] << "#\n";
|
|
||||||
|
|
||||||
aclass->text = values[1];
|
|
||||||
|
|
||||||
cout << "-" << aclass->text << "-\n";
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int A::select(sqlite3 *db){
|
|
||||||
|
|
||||||
const char * sql_cmd;
|
|
||||||
ostringstream buffer;
|
|
||||||
string sql;
|
|
||||||
|
|
||||||
buffer << "SELECT * FROM test WHERE numero=" << oid;
|
|
||||||
|
|
||||||
|
|
||||||
sql = buffer.str();
|
|
||||||
sql_cmd = sql.c_str();
|
|
||||||
|
|
||||||
sqlite3_exec(db,
|
|
||||||
sql_cmd,
|
|
||||||
select_cb,
|
|
||||||
this,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Apool : public PoolSQL
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Apool(sqlite3 *db):PoolSQL(db,"test"){};
|
|
||||||
~Apool(){};
|
|
||||||
private:
|
|
||||||
ObjectSQL* create(){ return (new A);};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
sqlite3 * db;
|
|
||||||
|
|
||||||
sqlite3_open("pool.db", &db);
|
|
||||||
|
|
||||||
sqlite3_exec(db,
|
|
||||||
"CREATE TABLE test (numero INTEGER,"
|
|
||||||
"texto TEXT)",
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
|
|
||||||
A *a;
|
|
||||||
Apool apool(db);
|
|
||||||
|
|
||||||
|
|
||||||
a = new A(-1,"prueba");
|
|
||||||
|
|
||||||
apool.allocate(a);
|
|
||||||
|
|
||||||
a = new A(4,"otro");
|
|
||||||
|
|
||||||
apool.allocate(a);
|
|
||||||
|
|
||||||
a = new A(8,"otro mas");
|
|
||||||
|
|
||||||
apool.allocate(a);
|
|
||||||
|
|
||||||
A * aobj = static_cast<A *>(apool.get(1,false));
|
|
||||||
|
|
||||||
cout << aobj->text << "\n";
|
|
||||||
|
|
||||||
delete aobj;
|
|
||||||
|
|
||||||
aobj = static_cast<A *>(apool.get(0,false));
|
|
||||||
|
|
||||||
cout << aobj->text << "\n";
|
|
||||||
|
|
||||||
delete aobj;
|
|
||||||
|
|
||||||
sqlite3_close(db);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
sqlite3 * db;
|
|
||||||
string s("HOLA");
|
|
||||||
A test(8,s);
|
|
||||||
A otro(8);
|
|
||||||
|
|
||||||
sqlite3_open("pool.db", &db);
|
|
||||||
|
|
||||||
sqlite3_exec(db,
|
|
||||||
"CREATE TABLE test (numero INTEGER,"
|
|
||||||
"texto TEXT)",
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
test.insert(db);
|
|
||||||
|
|
||||||
otro.select(db);
|
|
||||||
|
|
||||||
cout << "texto : " << otro.text;
|
|
||||||
|
|
||||||
sqlite3_close(db);
|
|
||||||
}*/
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
#include "VirtualMachineTemplate.h"
|
|
||||||
#include <iostream>
|
|
||||||
#include <sqlite3.h>
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
VirtualMachineTemplate tmp;
|
|
||||||
Template t;
|
|
||||||
|
|
||||||
char *error;
|
|
||||||
string st("MEMORY=345\nCPU=4\nDISK=[FILE=\"img\",TYPE=cd]\nDISK=[FILE=\"../f\"]\n");
|
|
||||||
|
|
||||||
|
|
||||||
ostringstream os;
|
|
||||||
|
|
||||||
if ((tmp.parse("vm.template",&error) != 0 ) &&
|
|
||||||
(error != 0))
|
|
||||||
{
|
|
||||||
cout << "Error parsing file: "<< error << endl;
|
|
||||||
|
|
||||||
free(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
string mrs;
|
|
||||||
|
|
||||||
tmp.marshall(mrs,':');
|
|
||||||
|
|
||||||
cout << "-" << mrs << "-";
|
|
||||||
|
|
||||||
if ((t.parse(st,&error) != 0 ) &&
|
|
||||||
(error != 0))
|
|
||||||
{
|
|
||||||
cout << "Error parsing string: "<< error << endl;
|
|
||||||
|
|
||||||
free(error);
|
|
||||||
}
|
|
||||||
cout << "TEMPLATE" << endl << t << endl;
|
|
||||||
cout << "------" << endl << endl;
|
|
||||||
cout << "TEMPLATE" << endl << tmp << endl;
|
|
||||||
|
|
||||||
string mm("MEMORY");
|
|
||||||
vector<const Attribute*> values;
|
|
||||||
|
|
||||||
tmp.get(mm,values);
|
|
||||||
|
|
||||||
const SingleAttribute *pmemo;
|
|
||||||
|
|
||||||
pmemo = static_cast<const SingleAttribute *>(values[0]);
|
|
||||||
|
|
||||||
cout << "MEM = " << pmemo->value() << "\n";
|
|
||||||
|
|
||||||
cout << "TEMPLATE--" << endl << t << endl;
|
|
||||||
|
|
||||||
// ---- Init template DB ----
|
|
||||||
/*
|
|
||||||
|
|
||||||
sqlite3 * db;
|
|
||||||
sqlite3_open("template.db", &db);
|
|
||||||
|
|
||||||
sqlite3_exec(db,
|
|
||||||
"CREATE TABLE vm_template (id INTEGER,"
|
|
||||||
"name TEXT, value TEXT)",
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
|
|
||||||
cout << tmp.insert(db) << endl;
|
|
||||||
|
|
||||||
VirtualMachineTemplate rtmp(2);
|
|
||||||
|
|
||||||
rtmp.select(db);
|
|
||||||
|
|
||||||
cout << endl << "FROM DB" << endl << rtmp;
|
|
||||||
|
|
||||||
sqlite3_close(db);
|
|
||||||
|
|
||||||
*/
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
TemplateAttribute<string> sa1("ejemplo","valor");
|
|
||||||
TemplateAttribute<string> sa2("sample","value");
|
|
||||||
// Attribute * pa;
|
|
||||||
// Attribute * pa2;
|
|
||||||
|
|
||||||
cout << sa1.name() << ":" << sa1.value() << "\n";
|
|
||||||
cout << sa2.name() << ":" << sa2.value() << "\n";
|
|
||||||
|
|
||||||
|
|
||||||
cout << sa2.name() << ":" << sa2.value() << "\n";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//map<string, Attribute *> mymap;
|
|
||||||
//TemplateAttribute<string> * pta;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//pa = new TemplateAttribute<string>("ejemplo","valor");
|
|
||||||
|
|
||||||
//cout << str_attr.name();
|
|
||||||
//cout << pa->name();
|
|
||||||
|
|
||||||
//pta = static_cast<TemplateAttribute<string> *> (pa);
|
|
||||||
|
|
||||||
//cout << pa->name();
|
|
||||||
|
|
||||||
//mymap.insert(make_pair("cadena",pa));
|
|
||||||
|
|
||||||
//delete pa;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
MEMORY = 512
|
|
||||||
Cpu = 1
|
|
||||||
|
|
||||||
DISK = [ ImaGE="/local/VM/disk.img",device="sda",TYPE="hd" ]
|
|
||||||
DISK = [ image="../debian.iso",DEvice="sdb",TYPE="cdrom" ]
|
|
||||||
|
|
||||||
nic = [ MAC="00:01:02", TYPE="bridged", IP="147.3"]
|
|
||||||
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
#include "VirtualMachinePool.h"
|
|
||||||
#include <climits>
|
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
sqlite3 * db;
|
|
||||||
|
|
||||||
sqlite3_open("pool.db", &db);
|
|
||||||
|
|
||||||
VirtualMachinePool thepool(db);
|
|
||||||
VirtualMachine * vm;
|
|
||||||
int eid;
|
|
||||||
string st("MEMORY=345\nCPU=4\nDISK=[FILE=\"img\",TYPE=cd]\nDISK=[FILE=\"../f\"]\n");
|
|
||||||
|
|
||||||
thepool.bootstrap();
|
|
||||||
|
|
||||||
thepool.allocate(0,st,&eid);
|
|
||||||
cout << eid << endl;
|
|
||||||
|
|
||||||
thepool.allocate(0,st,&eid);
|
|
||||||
cout << eid << endl;
|
|
||||||
|
|
||||||
thepool.allocate(0,st,&eid);
|
|
||||||
cout << eid << endl;
|
|
||||||
|
|
||||||
vm = static_cast<VirtualMachine *>(thepool.get(444,false));
|
|
||||||
|
|
||||||
if (vm != 0)
|
|
||||||
{
|
|
||||||
cout << *vm;
|
|
||||||
}
|
|
||||||
|
|
||||||
vm = static_cast<VirtualMachine *>(thepool.get(1,true));
|
|
||||||
|
|
||||||
string vmm = "xen";
|
|
||||||
string tm = "gridftp";
|
|
||||||
|
|
||||||
//vm->add_history(2,2,vmm,tm);
|
|
||||||
|
|
||||||
//thepool.update_history(vm);
|
|
||||||
|
|
||||||
if (vm != 0)
|
|
||||||
{
|
|
||||||
cout << *vm << endl;
|
|
||||||
|
|
||||||
vm->unlock();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cout << "VM es cero!" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
VirtualMachine * vm2 = static_cast<VirtualMachine *>(thepool.get(2,false));
|
|
||||||
|
|
||||||
if (vm2 != 0)
|
|
||||||
{
|
|
||||||
|
|
||||||
cout << *vm2;
|
|
||||||
}
|
|
||||||
|
|
||||||
VirtualMachine * vm3 = static_cast<VirtualMachine *>(thepool.get(3,true));
|
|
||||||
|
|
||||||
if (vm3 != 0)
|
|
||||||
{
|
|
||||||
cout << *vm3;
|
|
||||||
|
|
||||||
vm3->unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
sqlite3_close(db);
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "Nebula.h"
|
|
||||||
#include <sqlite3.h>
|
|
||||||
#include <exception>
|
|
||||||
#include "VirtualMachine.h"
|
|
||||||
#include "VirtualMachineManagerDriver.h"
|
|
||||||
|
|
||||||
extern "C" void *test(void *nothing)
|
|
||||||
{
|
|
||||||
VirtualMachineManager *vm_manager;
|
|
||||||
InformationManager *im_manager;
|
|
||||||
Nebula& ne = Nebula::instance();
|
|
||||||
string s_template;
|
|
||||||
ostringstream os;
|
|
||||||
|
|
||||||
sleep(20);
|
|
||||||
|
|
||||||
Nebula::log("TST", Log::INFO, "Alive!");
|
|
||||||
|
|
||||||
vm_manager = ne.get_vmm();
|
|
||||||
vm_manager->load_mads(0);
|
|
||||||
|
|
||||||
im_manager = ne.get_im();
|
|
||||||
im_manager->load_mads(0);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
pthread_attr_t pattr;
|
|
||||||
pthread_t test_thread;
|
|
||||||
|
|
||||||
pthread_attr_init (&pattr);
|
|
||||||
pthread_attr_setdetachstate (&pattr, PTHREAD_CREATE_JOINABLE);
|
|
||||||
|
|
||||||
pthread_create(&test_thread,&pattr,test,(void *)0);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Nebula& nd = Nebula::instance();
|
|
||||||
nd.start();
|
|
||||||
}
|
|
||||||
catch (exception &e)
|
|
||||||
{
|
|
||||||
cout << e.what() << endl;
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Reference in new issue
Block a user