Revision 6329d8b3 src/cluster/ClusterPool.cc

View differences:

src/cluster/ClusterPool.cc
21 21
#include <stdexcept>
22 22

  
23 23
const string ClusterPool::DEFAULT_CLUSTER_NAME = "default";
24
const int    ClusterPool::DEFAULT_CLUSTER_ID   = 0;
24 25

  
25 26
/* -------------------------------------------------------------------------- */
26 27
/* -------------------------------------------------------------------------- */
......
35 36
        string      error_str;
36 37

  
37 38
        // Build a new Cluster object
38
        cluster = new Cluster(0, ClusterPool::DEFAULT_CLUSTER_NAME);
39
        cluster = new Cluster(DEFAULT_CLUSTER_ID, DEFAULT_CLUSTER_NAME);
39 40

  
40 41
        // Insert the Object in the pool
41 42
        rc = PoolSQL::allocate(cluster, error_str);
......
110 111
    Nebula&     nd = Nebula::instance();
111 112
    HostPool *  hpool = nd.get_hpool();
112 113

  
113
    string      cluster_name = cluster->get_name();
114
    string      where = "cluster = '" + cluster_name + "'";
114
    int         cluster_id = cluster->get_oid();
115

  
116
    ostringstream where;
117
    where << "cid = " << cluster_id;
115 118

  
116 119
    // Return error if cluster is 'default'
117
    if( cluster->get_oid() == 0 )
120
    if( cluster->get_oid() == DEFAULT_CLUSTER_ID )
118 121
    {
119 122
        NebulaLog::log("CLUSTER",Log::WARNING,
120 123
                       "Default cluster cannot be deleted.");
......
127 130
    // Move the hosts assigned to the deleted cluster to the default one
128 131
    if( rc == 0 )
129 132
    {
130
        hpool->search(hids, where);
133
        hpool->search(hids, where.str());
131 134

  
132 135
        for ( hid_it=hids.begin() ; hid_it < hids.end(); hid_it++ )
133 136
        {

Also available in: Unified diff