You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by je...@apache.org on 2013/04/18 21:25:32 UTC
git commit: updated refs/heads/ui-vm-affinity to 3390f01
Updated Branches:
refs/heads/ui-vm-affinity 935b08b21 -> 3390f0114
CLOUDSTACK-2074: cloudstack UI - Affinity - Affinity Group page - add new tab "instances" that displays all vm instances under this affinity group.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/3390f011
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/3390f011
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/3390f011
Branch: refs/heads/ui-vm-affinity
Commit: 3390f0114b2a6f52802fb6cb1f0e8321e3da4a71
Parents: 935b08b
Author: Jessica Wang <je...@citrix.com>
Authored: Thu Apr 18 12:24:44 2013 -0700
Committer: Jessica Wang <je...@citrix.com>
Committed: Thu Apr 18 12:24:44 2013 -0700
----------------------------------------------------------------------
ui/scripts/affinity.js | 62 ++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 61 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3390f011/ui/scripts/affinity.js
----------------------------------------------------------------------
diff --git a/ui/scripts/affinity.js b/ui/scripts/affinity.js
index 0bb08cc..daa8fb7 100644
--- a/ui/scripts/affinity.js
+++ b/ui/scripts/affinity.js
@@ -166,7 +166,67 @@
}
});
}
- }
+ },
+
+ /**
+ * VMs tab
+ */
+ vms: {
+ title: 'label.instances',
+ multiple: true,
+ fields: [
+ {
+ id: { label: 'ID' },
+ displayname: { label: 'label.display.name' },
+ state: { label: 'label.state' }
+ }
+ ],
+ dataProvider: function(args) {
+ var vmIds = args.context.affinityGroups[0].virtualmachineIds;
+ if(vmIds == null || vmIds.length == 0) {
+ args.response.success({data: null});
+ return;
+ }
+
+ $.ajax({
+ url: createURL('listVirtualMachines'),
+ success: function(json) {
+ var firstPageVms = json.listvirtualmachinesresponse.virtualmachine;
+ var items = [];
+ if(vmIds != null) {
+ for(var i = 0; i < vmIds.length; i++) {
+ var item = {id: vmIds[i]};
+ var matchFound = false;
+ if(firstPageVms != null) {
+ for(var k = 0; k < firstPageVms.length; k++) {
+ if(firstPageVms[k].id == vmIds[i]) {
+ matchFound = true;
+ item.displayname = firstPageVms[k].displayname;
+ item.state = firstPageVms[k].state;
+ break; //break for looup
+ }
+ }
+ }
+ if(matchFound == false) { //the VM is not in API response of "listVirtualMachines&page=1&pagesize=500"
+ $.ajax({
+ url: createURL('listVirtualMachines'),
+ async: false,
+ data: {id: vmIds[i]},
+ success: function(json) {
+ var vmObj = json.listvirtualmachinesresponse.virtualmachine[0];
+ item.displayname = vmObj.displayname;
+ item.state = vmObj.state;
+ }
+ });
+ }
+ items.push(item);
+ }
+ }
+ args.response.success({data: items});
+ }
+ });
+ }
+ }
}
}
}