Revision 621a1869 src/cluster/Cluster.cc

View differences:

src/cluster/Cluster.cc
34 34
    "gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER, "
35 35
    "UNIQUE(name))";
36 36

  
37
const char * Cluster::host_table = "cluster_host_relation";
38
const char * Cluster::host_db_names = "cid, oid";
39
const char * Cluster::host_db_bootstrap =
40
    "CREATE TABLE IF NOT EXISTS cluster_host_relation ("
41
    "cid INTEGER, oid INTEGER, PRIMARY KEY(cid, oid))";
42

  
43
const char * Cluster::datastore_table = "cluster_datastore_relation";
44
const char * Cluster::datastore_db_names = "cid, oid";
45
const char * Cluster::datastore_db_bootstrap =
46
    "CREATE TABLE IF NOT EXISTS cluster_datastore_relation ("
47
    "cid INTEGER, oid INTEGER, PRIMARY KEY(cid, oid))";
48

  
49
const char * Cluster::network_table = "cluster_network_relation";
50
const char * Cluster::network_db_names = "cid, oid";
51
const char * Cluster::network_db_bootstrap =
52
    "CREATE TABLE IF NOT EXISTS cluster_network_relation ("
53
    "cid INTEGER, oid INTEGER, PRIMARY KEY(cid, oid))";
54

  
37 55
/* ************************************************************************** */
38 56
/* Cluster :: Constructor/Destructor                                          */
39 57
/* ************************************************************************** */
......
247 265
    db->free_str(sql_name);
248 266
    db->free_str(sql_xml);
249 267

  
268
    if (rc == 0)
269
    {
270
        oss.str("");
271
        oss << "BEGIN TRANSACTION; "
272
            << "DELETE FROM " << host_table     << " WHERE cid = " << oid << "; "
273
            << "DELETE FROM " << network_table  << " WHERE cid = " << oid << "; "
274
            << "DELETE FROM " << datastore_table<< " WHERE cid = " << oid << "; ";
275

  
276
        // TODO
277
        //if (db->multiple_values_support())
278
        if (false)
279
        {
280
        }
281
        else
282
        {
283
            set<int>::iterator i;
284

  
285
            set<int> host_set = hosts.get_collection();
286

  
287
            for(i = host_set.begin(); i != host_set.end(); i++)
288
            {
289
                oss << "INSERT INTO " << host_table
290
                    << " (" << host_db_names << ") VALUES ("
291
                    << oid  << ","
292
                    << *i   << "); ";
293
            }
294

  
295
            set<int> datastore_set = datastores.get_collection();
296

  
297
            for(i = datastore_set.begin(); i != datastore_set.end(); i++)
298
            {
299
                oss << "INSERT INTO " << datastore_table
300
                    << " (" << datastore_db_names << ") VALUES ("
301
                    << oid  << ","
302
                    << *i   << "); ";
303
            }
304

  
305
            set<int> vnet_set = vnets.get_collection();
306

  
307
            for(i = vnet_set.begin(); i != vnet_set.end(); i++)
308
            {
309
                oss << "INSERT INTO " << network_table
310
                    << " (" << network_db_names << ") VALUES ("
311
                    << oid  << ","
312
                    << *i   << "); ";
313
            }
314
        }
315

  
316
        oss << "COMMIT";
317

  
318
        rc = db->exec(oss);
319
    }
320

  
250 321
    return rc;
251 322

  
252 323
error_xml:

Also available in: Unified diff