Revision 6329d8b3 src/host/Host.cc

View differences:

src/host/Host.cc
29 29

  
30 30
Host::Host(
31 31
    int     id,
32
    int     cluster_id,
32 33
    const string& _hostname,
33 34
    const string& _im_mad_name,
34 35
    const string& _vmm_mad_name,
35
    const string& _tm_mad_name,
36
    const string& _cluster):
37
        PoolObjectSQL(id,_hostname,-1,-1,table),
36
    const string& _tm_mad_name):
37
        PoolObjectSQL(id,_hostname,-1,cluster_id,table),
38 38
        state(INIT),
39 39
        im_mad_name(_im_mad_name),
40 40
        vmm_mad_name(_vmm_mad_name),
41 41
        tm_mad_name(_tm_mad_name),
42
        last_monitored(0),
43
        cluster(_cluster)
42
        last_monitored(0)
44 43
{
45 44
    obj_template = new HostTemplate;        
46 45
}
......
59 58

  
60 59
const char * Host::table = "host_pool";
61 60

  
62
const char * Host::db_names = "oid, name, body, state, last_mon_time, cluster";
61
const char * Host::db_names = "oid, name, body, state, last_mon_time, cid";
63 62

  
64 63
const char * Host::db_bootstrap = "CREATE TABLE IF NOT EXISTS host_pool ("
65 64
    "oid INTEGER PRIMARY KEY, name VARCHAR(256), body TEXT, state INTEGER, "
66
    "last_mon_time INTEGER, cluster VARCHAR(128), UNIQUE(name))";
65
    "last_mon_time INTEGER, cid INTEGER, UNIQUE(name))";
67 66

  
68 67
/* ------------------------------------------------------------------------ */
69 68
/* ------------------------------------------------------------------------ */
......
105 104
    string xml_body;
106 105

  
107 106
    char * sql_hostname;
108
    char * sql_cluster;
109 107
    char * sql_xml;
110 108

  
111 109
   // Update the Host
......
117 115
        goto error_hostname;
118 116
    }
119 117

  
120
    sql_cluster = db->escape_str(cluster.c_str());
121

  
122
    if ( sql_cluster == 0 )
123
    {
124
        goto error_cluster;
125
    }
126

  
127 118
    sql_xml = db->escape_str(to_xml(xml_body).c_str());
128 119

  
129 120
    if ( sql_xml == 0 )
......
148 139
        << "'" <<   sql_xml             << "',"
149 140
        <<          state               << ","
150 141
        <<          last_monitored      << ","
151
        << "'" <<   sql_cluster         << "')";
142
        <<          gid                 << ")";
152 143

  
153 144
    rc = db->exec(oss);
154 145

  
155 146
    db->free_str(sql_hostname);
156
    db->free_str(sql_cluster);
157 147
    db->free_str(sql_xml);
158 148

  
159 149
    return rc;
160 150

  
161 151
error_body:
162
    db->free_str(sql_cluster);
163
error_cluster:
164 152
    db->free_str(sql_hostname);
165 153
error_hostname:
166 154
    return -1;
......
227 215
       "<VM_MAD>"        << vmm_mad_name   << "</VM_MAD>"        <<
228 216
       "<TM_MAD>"        << tm_mad_name    << "</TM_MAD>"        <<
229 217
       "<LAST_MON_TIME>" << last_monitored << "</LAST_MON_TIME>" <<
230
       "<CLUSTER>"       << cluster        << "</CLUSTER>"       <<
218
       "<CID>"           << gid            << "</CID>"       <<
231 219
       host_share.to_xml(share_xml)  <<
232 220
       obj_template->to_xml(template_xml) <<
233 221
    "</HOST>";
......
260 248
    rc += xpath(tm_mad_name, "/HOST/TM_MAD", "not_found");
261 249

  
262 250
    rc += xpath(last_monitored, "/HOST/LAST_MON_TIME", 0);
263
    rc += xpath(cluster, "/HOST/CLUSTER", "not_found");
251
    rc += xpath(gid, "/HOST/CID", 0);
264 252

  
265 253
    state = static_cast<HostState>( int_state );
266 254

  

Also available in: Unified diff