Revision 9b8862eb src/image/Image.cc

View differences:

src/image/Image.cc
44 44

  
45 45
const char * Image::table = "image_pool";
46 46

  
47
const char * Image::db_names = "(oid, uid, name, type, regtime, " 
47
const char * Image::db_names = "(oid, uid, name, type, public, regtime, " 
48 48
                               "source, state, running_vms)";
49 49

  
50 50
const char * Image::db_bootstrap = "CREATE TABLE IF NOT EXISTS image_pool ("
51 51
    "oid INTEGER PRIMARY KEY, uid INTEGER, name VARCHAR(128), "
52
    "type INTEGER, regtime INTEGER, source TEXT, state INTEGER, "
52
    "type INTEGER, public TEXT, regtime INTEGER, source TEXT, state INTEGER, "
53 53
    "running_vms INTEGER, UNIQUE(name) )";
54 54

  
55 55
/* ------------------------------------------------------------------------ */
......
61 61
        (!values[UID]) ||
62 62
        (!values[NAME]) ||
63 63
        (!values[TYPE]) ||
64
        (!values[PUBLIC]) ||
64 65
        (!values[REGTIME]) ||
65 66
        (!values[SOURCE]) ||
66 67
        (!values[STATE]) ||
......
76 77
    name        = values[NAME];
77 78
    
78 79
    type        = static_cast<ImageType>(atoi(values[TYPE]));
80
    public_img  = values[PUBLIC];
79 81
    regtime     = static_cast<time_t>(atoi(values[REGTIME]));
80 82

  
81 83
    source      = values[SOURCE];
......
194 196
    int    rc;
195 197

  
196 198
    char * sql_name;
199
    char * sql_public;
197 200
    char * sql_source;
198 201

  
199 202
   // Update the Image
......
205 208
        goto error_name;
206 209
    }
207 210

  
211
    sql_public = db->escape_str(public_img.c_str());
212

  
213
    if ( sql_public == 0 )
214
    {
215
        goto error_public;
216
    }
208 217

  
209 218
    sql_source = db->escape_str(source.c_str());
210 219

  
......
228 237
        <<          oid             << ","
229 238
        <<          uid             << ","
230 239
        << "'" <<   sql_name        << "',"
231
        <<          type            << ","       
240
        <<          type            << ","
241
        << "'" <<   sql_public      << "',"
232 242
        <<          regtime         << ","
233 243
        << "'" <<   sql_source      << "',"
234 244
        <<          state           << ","
235
        <<          running_vms     << ")";     
245
        <<          running_vms     << ")";
236 246

  
237 247
    rc = db->exec(oss);
238 248

  
239 249
    db->free_str(sql_name);
250
    db->free_str(sql_public);
240 251
    db->free_str(sql_source);
241 252

  
242 253
    return rc;
243 254

  
244 255
error_source:
256
    db->free_str(sql_public);
257
error_public:
245 258
    db->free_str(sql_name);
246 259
error_name:
247 260
    return -1;
......
256 269
        (!values[UID]) ||
257 270
        (!values[NAME]) ||
258 271
        (!values[TYPE]) ||
272
        (!values[PUBLIC]) ||
259 273
        (!values[REGTIME]) ||
260 274
        (!values[SOURCE]) ||
261 275
        (!values[STATE]) ||
......
271 285
            "<UID>"            << values[UID]         << "</UID>"         <<
272 286
            "<NAME>"           << values[NAME]        << "</NAME>"        <<
273 287
            "<TYPE>"           << values[TYPE]        << "</TYPE>"        <<
288
            "<PUBLIC>"         << values[PUBLIC]      << "</PUBLIC>"      <<
274 289
            "<REGTIME>"        << values[REGTIME]     << "</REGTIME>"     <<
275 290
            "<SOURCE>"         << values[SOURCE]      << "</SOURCE>"      <<
276 291
            "<STATE>"          << values[STATE]       << "</STATE>"       <<
......
333 348
            "<UID>"            << uid         << "</UID>"         <<
334 349
            "<NAME>"           << name        << "</NAME>"        <<
335 350
            "<TYPE>"           << type        << "</TYPE>"        <<
351
            "<PUBLIC>"         << public_img  << "</PUBLIC>"      <<
336 352
            "<REGTIME>"        << regtime     << "</REGTIME>"     <<
337 353
            "<SOURCE>"         << source      << "</SOURCE>"      <<
338 354
            "<STATE>"          << state       << "</STATE>"       <<
......
359 375
        "UID         = "    << uid         << endl <<
360 376
        "NAME        = "    << name        << endl <<
361 377
        "TYPE        = "    << type        << endl <<
378
        "PUBLIC      = "    << public_img  << endl <<
362 379
        "REGTIME     = "    << regtime     << endl <<
363 380
        "SOURCE      = "    << source      << endl <<
364 381
        "STATE       = "    << state       << endl <<

Also available in: Unified diff