mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-22 13:33:52 +03:00
This commit is contained in:
parent
d8cc0fea13
commit
beae0776c3
@ -21,6 +21,7 @@
|
||||
#include "HostPool.h"
|
||||
#include "VirtualMachinePool.h"
|
||||
#include "VirtualRouterPool.h"
|
||||
#include "ClusterPool.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -82,7 +83,7 @@ class DispatchManager : public ActionListener
|
||||
public:
|
||||
|
||||
DispatchManager():
|
||||
hpool(0), vmpool(0), vrouterpool(0), tm(0), vmm(0), lcm(0), imagem(0)
|
||||
hpool(0), vmpool(0), clpool(0), vrouterpool(0), tm(0), vmm(0), lcm(0), imagem(0)
|
||||
{
|
||||
am.addListener(this);
|
||||
};
|
||||
@ -497,7 +498,12 @@ private:
|
||||
VirtualMachinePool * vmpool;
|
||||
|
||||
/**
|
||||
* Pointer to the Virtual Machine Pool, to access hosts
|
||||
* Pointer to the Cluster Pool
|
||||
*/
|
||||
ClusterPool * clpool;
|
||||
|
||||
/**
|
||||
* Pointer to the Virtual Router Pool
|
||||
*/
|
||||
VirtualRouterPool * vrouterpool;
|
||||
|
||||
|
@ -109,6 +109,7 @@ void DispatchManager::init_managers()
|
||||
|
||||
hpool = nd.get_hpool();
|
||||
vmpool = nd.get_vmpool();
|
||||
clpool = nd.get_clpool();
|
||||
vrouterpool = nd.get_vrouterpool();
|
||||
}
|
||||
|
||||
|
@ -214,19 +214,33 @@ void DispatchManager::free_vm_resources(VirtualMachine * vm)
|
||||
Template* tmpl;
|
||||
vector<Template *> ds_quotas;
|
||||
|
||||
int vmid;
|
||||
int uid;
|
||||
int gid;
|
||||
string deploy_id;
|
||||
int vrid = -1;
|
||||
int vmid;
|
||||
unsigned int port;
|
||||
|
||||
vm->release_network_leases();
|
||||
|
||||
vm->release_vmgroup();
|
||||
|
||||
vm->release_disk_images(ds_quotas);
|
||||
|
||||
vm->set_state(VirtualMachine::DONE);
|
||||
|
||||
vm->set_state(VirtualMachine::LCM_INIT);
|
||||
|
||||
vm->set_exit_time(time(0));
|
||||
|
||||
vm->set_state(VirtualMachine::LCM_INIT);
|
||||
vm->set_state(VirtualMachine::DONE);
|
||||
VectorAttribute * graphics = vm->get_template_attribute("GRAPHICS");
|
||||
|
||||
if ( graphics != 0 && (graphics->vector_value("PORT", port) == 0))
|
||||
{
|
||||
graphics->remove("PORT");
|
||||
clpool->release_vnc_port(vm->get_cid(), port);
|
||||
}
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
vmid = vm->get_oid();
|
||||
@ -234,6 +248,11 @@ void DispatchManager::free_vm_resources(VirtualMachine * vm)
|
||||
gid = vm->get_gid();
|
||||
tmpl = vm->clone_template();
|
||||
|
||||
if (vm->is_imported())
|
||||
{
|
||||
deploy_id = vm->get_deploy_id();
|
||||
}
|
||||
|
||||
if (vm->is_vrouter())
|
||||
{
|
||||
vrid = vm->get_vrouter_id();
|
||||
@ -250,6 +269,11 @@ void DispatchManager::free_vm_resources(VirtualMachine * vm)
|
||||
Quotas::ds_del(uid, gid, ds_quotas);
|
||||
}
|
||||
|
||||
if (!deploy_id.empty())
|
||||
{
|
||||
vmpool->drop_index(deploy_id);
|
||||
}
|
||||
|
||||
if (vrid != -1)
|
||||
{
|
||||
VirtualRouter* vr = vrouterpool->get(vrid, true);
|
||||
|
@ -202,14 +202,6 @@ void DispatchManager::poweroff_success_action(int vid)
|
||||
void DispatchManager::done_action(int vid)
|
||||
{
|
||||
VirtualMachine * vm;
|
||||
Template * tmpl;
|
||||
|
||||
vector<Template *> ds_quotas;
|
||||
|
||||
int uid;
|
||||
int gid;
|
||||
string deploy_id;
|
||||
int vrid = -1;
|
||||
|
||||
VirtualMachine::LcmState lcm_state;
|
||||
VirtualMachine::VmState dm_state;
|
||||
@ -228,63 +220,7 @@ void DispatchManager::done_action(int vid)
|
||||
(lcm_state == VirtualMachine::EPILOG ||
|
||||
lcm_state == VirtualMachine::CLEANUP_DELETE))
|
||||
{
|
||||
vm->release_network_leases();
|
||||
|
||||
vm->release_vmgroup();
|
||||
|
||||
vm->release_disk_images(ds_quotas);
|
||||
|
||||
vm->set_state(VirtualMachine::DONE);
|
||||
|
||||
vm->set_state(VirtualMachine::LCM_INIT);
|
||||
|
||||
vm->set_exit_time(time(0));
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
uid = vm->get_uid();
|
||||
gid = vm->get_gid();
|
||||
tmpl = vm->clone_template();
|
||||
|
||||
if (vm->is_imported())
|
||||
{
|
||||
deploy_id = vm->get_deploy_id();
|
||||
}
|
||||
|
||||
if (vm->is_vrouter())
|
||||
{
|
||||
vrid = vm->get_vrouter_id();
|
||||
}
|
||||
|
||||
vm->unlock();
|
||||
|
||||
Quotas::vm_del(uid, gid, tmpl);
|
||||
|
||||
delete tmpl;
|
||||
|
||||
if ( !ds_quotas.empty() )
|
||||
{
|
||||
Quotas::ds_del(uid, gid, ds_quotas);
|
||||
}
|
||||
|
||||
if (!deploy_id.empty())
|
||||
{
|
||||
vmpool->drop_index(deploy_id);
|
||||
}
|
||||
|
||||
if (vrid != -1)
|
||||
{
|
||||
VirtualRouter* vr = vrouterpool->get(vrid, true);
|
||||
|
||||
if (vr != 0)
|
||||
{
|
||||
vr->del_vmid(vid);
|
||||
|
||||
vrouterpool->update(vr);
|
||||
|
||||
vr->unlock();
|
||||
}
|
||||
}
|
||||
free_vm_resources(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user