Revision 7e45ddef

b/api/util.py
103 103
    """Returns data sent by the client as a python dict."""
104 104
    
105 105
    data = request.raw_post_data
106
    if request.META.get('CONTENT_TYPE') == 'application/json':
106
    if request.META.get('CONTENT_TYPE').startswith('application/json'):
107 107
        try:
108 108
            return json.loads(data)
109 109
        except ValueError:
b/ui/static/synnefo.js
248 248
			
249 249
			if (jqXHR.status == 200 || jqXHR.status == 203) {
250 250
				try {
251
					servers = data.servers;
251
					servers = data.servers.values;
252 252
				} catch(err) { ajax_error('400', undefined, 'Update VMs', jqXHR.responseText);}
253 253
				update_machines_view(data);
254 254
			} else if (jqXHR.status != 304){
......
470 470
            }
471 471
        }
472 472
    };
473

  
473
	var uri = API_URL + '/servers';
474 474

  
475 475
    $.ajax({
476
    url: API_URL + '/servers',
476
    url: uri,
477 477
    type: "POST",
478
	contentType: "application/json",
478 479
    dataType: "json",    
479 480
    data: JSON.stringify(payload),
480 481
    timeout: TIMEOUT,
......
505 506
	
506 507
	$.ajax({
507 508
		url: API_URL + '/servers/' + serverID + '/action',
508
		type: "POST",        
509
		type: "POST",
510
		contentType: "application/json",
509 511
		dataType: "json",
510 512
		data: JSON.stringify(payload),
511 513
		timeout: TIMEOUT,
......
545 547
    $.ajax({
546 548
	    url: API_URL + '/servers/' + serverID + '/action',
547 549
	    type: "POST",
550
		contentType: "application/json",
548 551
	    dataType: "json",
549 552
        data: JSON.stringify(payload),
550 553
        timeout: TIMEOUT,
......
582 585
    $.ajax({
583 586
	    url: API_URL + '/servers/' + serverID,
584 587
	    type: "DELETE",
588
		contentType: "application/json",
585 589
	    dataType: "json",
586 590
        data: JSON.stringify(payload),
587 591
        timeout: TIMEOUT,
......
621 625
    $.ajax({
622 626
        url: API_URL + '/servers/' + serverID + '/action',
623 627
        type: "POST",
628
		contentType: "application/json",
624 629
        dataType: "json",
625 630
        data: JSON.stringify(payload),
626 631
        timeout: TIMEOUT,
b/ui/templates/list.html
174 174
    new ones to the list
175 175
    */
176 176
	tableData = vmTable.fnGetData();
177
    $.each(data.servers, function(i,server){        
177
    $.each(data.servers.values, function(i,server){        
178 178
        current = -1;
179 179
        // check server status to select the appropriate OS icon
180 180
        osTag = image_tags[server.imageRef]
......
211 211
					imgStr = "<img class=list-logo src=" + imgSrc + " title=" + osTag + " height=16 width=16 />";
212 212
					tableData[current][1] = "<span class=imagetag>" + osTag + "</span>" + imgStr;
213 213
					tableData[current][2] = "<a class=name><span class=name>" + server.name + "</span></a>";
214
					tableData[current][3] = "<a class=ip><span class=public>"+ server.addresses.public.ip.addr + "</span></a>";
214
					tableData[current][3] = "<a class=ip><span class=public>"+ server.addresses.values[0].values[0].addr + "</span></a>";
215 215
					//tableData[current][4] = "group"; //TODO
216 216
					tableData[current][5] = "<span class=status>" + STATUS_MESSAGES[server.status] + "</span>";
217 217
					vmTable.fnUpdate(tableData[current],current);
......
232 232
                "<span class=imagetag>" + osTag + "</span><img class=list-logo src=static/os_logos/" + osIcon +
233 233
                    " title=" + osTag + " height=16 width=16>",
234 234
                "<a class=name><span class=name>" + server.name + "</span></a>",
235
                "<a class=ip><span class=public>"+ server.addresses.public.ip.addr + "</span></a>",
235
                "<a class=ip><span class=public>"+ server.addresses.values[0].values[0].addr + "</span></a>",
236 236
                "group",
237 237
                "<span class=status>" + STATUS_MESSAGES[server.status] + "</span>"
238 238
            ]);
b/ui/templates/standard.html
162 162
    Go through the servers in the input data. Update existing entries, add
163 163
    new ones to the list
164 164
    */    
165
    $.each(data.servers, function(i,server){
166
        
165
    $.each(data.servers.values, function(i,server){
167 166
        existing = $('#' + server.id);
168 167
        
169 168
        // if multiple machines exist in the DOM, delete all but one
......
210 209
                            
211 210
            }
212 211
            existing.find("a.name span.name").text(server.name);
213
            existing.find("a.ip span.public").text(String(server.addresses.public.ip.addr).replace(',',' '));
212
            existing.find("a.ip span.public").text(String(server.addresses.values[0].values[0].addr).replace(',',' '));
214 213
        } else if (server.status != 'DELETED') {
215 214
            // If it does not exist and it's not deleted, we should create it
216 215
            var machine = $("#machine-template").clone().attr("id", server.id).fadeIn("slow");
217 216
            machine.find("a.name span.name").text(server.name);
218 217
            machine.find("img.logo").attr("src","static/machines/"+image_tags[server.imageRef]+'.png');
219 218
            machine.find("span.imagetag").text(image_tags[server.imageRef]);
220
            machine.find("a.ip span.public").text(String(server.addresses.public.ip.addr).replace(',',' '));            
219
            machine.find("a.ip span.public").text(String(server.addresses.values[0].values[0].addr).replace(',',' '));            
221 220
            machine.find(".status").text(STATUS_MESSAGES[server.status]);
222 221
            if (['BUILD', 'ACTIVE', 'REBOOT'].indexOf(server.status) >= 0){
223 222
                machine.appendTo(".running");

Also available in: Unified diff