Revision 1fc7640d snf-cyclades-app/synnefo/ui/static/snf/js/models.js
b/snf-cyclades-app/synnefo/ui/static/snf/js/models.js | ||
---|---|---|
219 | 219 |
return; |
220 | 220 |
} |
221 | 221 |
} |
222 |
|
|
223 | 222 |
last_ajax = this.fetch(params); |
224 | 223 |
}, this); |
225 | 224 |
handler_options.callback = callback; |
... | ... | |
688 | 687 |
get_connectable_vms: function() { |
689 | 688 |
return storage.vms.filter(function(vm){ |
690 | 689 |
return !vm.in_error_state() && !vm.is_building(); |
691 |
}) |
|
690 |
});
|
|
692 | 691 |
}, |
693 | 692 |
|
694 | 693 |
state_message: function() { |
... | ... | |
1455 | 1454 |
error, 'shutdown', params); |
1456 | 1455 |
break; |
1457 | 1456 |
case 'console': |
1458 |
this.__make_api_call(this.url() + "/action", "create", {'console': {'type':'vnc'}}, function(data) { |
|
1457 |
this.__make_api_call(this.url() + "/action", "create", |
|
1458 |
{'console': {'type':'vnc'}}, |
|
1459 |
function(data) { |
|
1459 | 1460 |
var cons_data = data.console; |
1460 | 1461 |
success.apply(this, [cons_data]); |
1461 | 1462 |
}, undefined, 'console', params) |
... | ... | |
1484 | 1485 |
}, |
1485 | 1486 |
error, 'resize', params); |
1486 | 1487 |
break; |
1488 |
case 'addFloatingIp': |
|
1489 |
this.__make_api_call(this.get_action_url(), // vm actions url |
|
1490 |
"create", // create so that sync later uses POST to make the call |
|
1491 |
{addFloatingIp: {address:params.address}}, // payload |
|
1492 |
function() { |
|
1493 |
self.state('CONNECT'); |
|
1494 |
success.apply(this, arguments); |
|
1495 |
snf.api.trigger("call"); |
|
1496 |
}, |
|
1497 |
error, 'addFloatingIp', params); |
|
1498 |
break; |
|
1499 |
case 'removeFloatingIp': |
|
1500 |
this.__make_api_call(this.get_action_url(), // vm actions url |
|
1501 |
"create", // create so that sync later uses POST to make the call |
|
1502 |
{removeFloatingIp: {address:params.address}}, // payload |
|
1503 |
function() { |
|
1504 |
self.state('DISCONNECT'); |
|
1505 |
success.apply(this, arguments); |
|
1506 |
snf.api.trigger("call"); |
|
1507 |
}, |
|
1508 |
error, 'addFloatingIp', params); |
|
1509 |
break; |
|
1487 | 1510 |
case 'destroy': |
1488 | 1511 |
this.__make_api_call(this.url(), // vm actions url |
1489 | 1512 |
"delete", // create so that sync later uses POST to make the call |
... | ... | |
1502 | 1525 |
} |
1503 | 1526 |
}, |
1504 | 1527 |
|
1505 |
__make_api_call: function(url, method, data, success, error, action, extra_params) { |
|
1528 |
__make_api_call: function(url, method, data, success, error, action, |
|
1529 |
extra_params) { |
|
1506 | 1530 |
var self = this; |
1507 | 1531 |
error = error || function(){}; |
1508 | 1532 |
success = success || function(){}; |
... | ... | |
1510 | 1534 |
var params = { |
1511 | 1535 |
url: url, |
1512 | 1536 |
data: data, |
1513 |
success: function(){ self.handle_action_succeed.apply(self, arguments); success.apply(this, arguments)}, |
|
1537 |
success: function() { |
|
1538 |
self.handle_action_succeed.apply(self, arguments); |
|
1539 |
success.apply(this, arguments) |
|
1540 |
}, |
|
1514 | 1541 |
error: function(){ self.handle_action_fail.apply(self, arguments); error.apply(this, arguments)}, |
1515 | 1542 |
error_params: { ns: "Machines actions", |
1516 | 1543 |
title: "'" + this.get("name") + "'" + " " + action + " failed", |
1517 |
extra_details: { 'Machine ID': this.id, 'URL': url, 'Action': action || "undefined" }, |
|
1544 |
extra_details: {'Machine ID': this.id, |
|
1545 |
'URL': url, |
|
1546 |
'Action': action || "undefined" }, |
|
1518 | 1547 |
allow_reload: false |
1519 | 1548 |
}, |
1520 | 1549 |
display: false, |
1521 | 1550 |
critical: false |
1522 | 1551 |
} |
1523 |
_.extend(params, extra_params) |
|
1552 |
_.extend(params, extra_params);
|
|
1524 | 1553 |
this.sync(method, this, params); |
1525 | 1554 |
}, |
1526 | 1555 |
|
... | ... | |
2244 | 2273 |
_(missing_ids).each(function(imgid){ |
2245 | 2274 |
synnefo.storage.images.update_unknown_id(imgid, check); |
2246 | 2275 |
}); |
2276 |
}, |
|
2277 |
|
|
2278 |
get_connectable: function() { |
|
2279 |
return storage.vms.filter(function(vm){ |
|
2280 |
return !vm.in_error_state() && !vm.is_building(); |
|
2281 |
}); |
|
2247 | 2282 |
} |
2248 | 2283 |
}) |
2249 | 2284 |
|
... | ... | |
2425 | 2460 |
|
2426 | 2461 |
}) |
2427 | 2462 |
|
2463 |
models.PublicIP = models.Model.extend({ |
|
2464 |
path: 'os-floating-ips', |
|
2465 |
has_status: false, |
|
2466 |
|
|
2467 |
initialize: function() { |
|
2468 |
models.PublicIP.__super__.initialize.apply(this, arguments); |
|
2469 |
this.bind('change:instance_id', _.bind(this.handle_status_change, this)); |
|
2470 |
}, |
|
2471 |
|
|
2472 |
handle_status_change: function() { |
|
2473 |
this.set({state: null}); |
|
2474 |
}, |
|
2475 |
|
|
2476 |
get_vm: function() { |
|
2477 |
if (this.get('instance_id')) { |
|
2478 |
return synnefo.storage.vms.get(parseInt(this.get('instance_id'))); |
|
2479 |
} |
|
2480 |
return null; |
|
2481 |
}, |
|
2482 |
|
|
2483 |
connect_to: function(vm) { |
|
2484 |
} |
|
2485 |
}); |
|
2486 |
|
|
2487 |
models.PublicIPs = models.Collection.extend({ |
|
2488 |
model: models.PublicIP, |
|
2489 |
path: 'os-floating-ips', |
|
2490 |
api_type: 'compute', |
|
2491 |
noUpdate: true, |
|
2492 |
|
|
2493 |
parse: function(resp) { |
|
2494 |
resp = _.map(resp.floating_ips, function(ip) { |
|
2495 |
return ip; |
|
2496 |
}); |
|
2497 |
|
|
2498 |
return resp; |
|
2499 |
} |
|
2500 |
}); |
|
2501 |
|
|
2428 | 2502 |
models.PublicKeys = models.Collection.extend({ |
2429 | 2503 |
model: models.PublicKey, |
2430 | 2504 |
details: false, |
... | ... | |
2605 | 2679 |
snf.storage.nics = new models.NICs(); |
2606 | 2680 |
snf.storage.resources = new models.Resources(); |
2607 | 2681 |
snf.storage.quotas = new models.Quotas(); |
2682 |
snf.storage.public_ips = new models.PublicIPs(); |
|
2608 | 2683 |
|
2609 | 2684 |
})(this); |
Also available in: Unified diff