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

feature #1678: Drop logic moved to Information Manager. Always drop the host

This commit is contained in:
Ruben S. Montero 2013-10-25 21:11:20 +02:00
parent beb266a3bb
commit c6748b2816
4 changed files with 39 additions and 40 deletions

View File

@ -235,10 +235,8 @@ error_common:
int HostPool::drop(int hid, string& error_msg)
{
Nebula& nd = Nebula::instance();
Host * host;
ClusterPool * clpool;
host = get(hid,true);
@ -250,8 +248,6 @@ int HostPool::drop(int hid, string& error_msg)
return -1;
}
clpool = nd.get_clpool();
int cluster_id = host->get_cluster_id();
int rc = drop(host, error_msg);
@ -260,7 +256,10 @@ int HostPool::drop(int hid, string& error_msg)
if ( cluster_id != ClusterPool::NONE_CLUSTER_ID && rc == 0 )
{
Cluster * cluster = clpool->get(cluster_id, true);
Nebula& nd = Nebula::instance();
ClusterPool * clpool = nd.get_clpool();
Cluster * cluster = clpool->get(cluster_id, true);
if( cluster != 0 )
{
@ -281,7 +280,6 @@ int HostPool::drop(int hid, string& error_msg)
return rc;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -133,6 +133,7 @@ void InformationManager::trigger(Actions action, int _hid)
break;
default:
delete hid;
return;
}
@ -183,11 +184,8 @@ void InformationManager::stop_monitor(int hid)
host = hpool->get(hid,true);
if (host == 0)
if (host == 0) //Already deleted silently return
{
oss.str("");
oss << "Could get host " << hid;
NebulaLog::log("InM",Log::ERROR,oss);
return;
}
@ -203,8 +201,12 @@ void InformationManager::stop_monitor(int hid)
return;
}
host->disable();
imd->stop_monitor(hid, host->get_name());
hpool->update(host);
host->unlock();
}

View File

@ -292,32 +292,40 @@ void InformationManagerDriver::protocol(const string& message) const
}
else if (action == "STOPMONITOR")
{
int rc;
string error;
host = hpool->get(id,true);
if ( host == 0 )
{
goto error_host;
}
if (result != "SUCCESS")
{
host = hpool->get(id,true);
ostringstream oss;
string info;
if ( host == 0 )
{
goto error_host;
}
getline (is, info);
host->set_error();
hpool->update(host);
host->unlock();
oss << "Could not stop monitor on host " << id << " " << info;
NebulaLog::log("InM", Log::ERROR, oss.str());
}
else
{
string error_message;
int rc = hpool->drop(id, error_message);
if (rc != 0)
{
ostringstream oss;
oss << "Could not delete host " << id << " " << error_message;
NebulaLog::log("InM",Log::ERROR,oss.str());
}
rc = hpool->drop(id, error);
host->unlock();
if (rc != 0)
{
ostringstream oss;
oss << "Could not delete host " << id << " " << error;
NebulaLog::log("InM",Log::ERROR,oss.str());
}
}
return;
error_host:

View File

@ -146,19 +146,10 @@ int RequestManagerDelete::drop(
int HostDelete::drop(int oid, PoolObjectSQL * object, string& error_msg)
{
Nebula& nd = Nebula::instance();
Nebula& nd = Nebula::instance();
InformationManager * im = nd.get_im();
InformationManager * im = nd.get_im();
HostPool * hpool = nd.get_hpool();
Host * host = static_cast<Host *>(object);
host->disable();
hpool->update(host);
host->unlock();
im->trigger(InformationManager::STOPMONITOR,oid);
im->trigger(InformationManager::STOPMONITOR, oid);
return 0;
}