You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bf...@apache.org on 2013/02/25 20:37:34 UTC
git commit: refs/heads/ui-multiple-nics - UI: Update IP address
server calls to support per-NIC IPs
Updated Branches:
refs/heads/ui-multiple-nics b652d2e4b -> 6c8182b6f
UI: Update IP address server calls to support per-NIC IPs
Update the following actions on IP address section to support per-NIC IP
addresses:
- List IPs -> listNics
- Add IP -> addIpToNic
- Remove IP -> removeIpFromNic
These API calls will be conditionally invoked in place of the existing
calls if a NIC is selected -- i.e., args.context.nics is present
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/6c8182b6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/6c8182b6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/6c8182b6
Branch: refs/heads/ui-multiple-nics
Commit: 6c8182b6f4740a98a613dc440a84c6a080b43d95
Parents: b652d2e
Author: Brian Federle <br...@citrix.com>
Authored: Mon Feb 25 11:35:41 2013 -0800
Committer: Brian Federle <br...@citrix.com>
Committed: Mon Feb 25 11:35:41 2013 -0800
----------------------------------------------------------------------
ui/scripts/network.js | 194 +++++++++++++++++++++++++++-----------------
1 files changed, 120 insertions(+), 74 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6c8182b6/ui/scripts/network.js
----------------------------------------------------------------------
diff --git a/ui/scripts/network.js b/ui/scripts/network.js
index 84cc067..cca0e6c 100755
--- a/ui/scripts/network.js
+++ b/ui/scripts/network.js
@@ -1585,30 +1585,47 @@
});
}
}
- $.ajax({
- url: createURL('associateIpAddress'),
- data: dataObj,
- success: function(data) {
- args.response.success({
- _custom: {
- jobId: data.associateipaddressresponse.jobid,
- getUpdatedItem: function(data) {
- var newIP = data.queryasyncjobresultresponse.jobresult.ipaddress;
- return $.extend(newIP, {
- state: 'Allocated'
- });
- },
- getActionFilter: function() {
- return actionFilters.ipAddress;
+
+ if (args.context.nics) {
+ $.ajax({
+ url: createURL('addIpToNic'),
+ data: {
+ nicId: args.context.nics[0].id
+ },
+ success: function(json) {
+ args.response.success({
+ _custom: {
+ jobId: json.addiptonicresponse.jobid
}
- }
- });
- },
+ });
+ }
+ });
+ } else {
+ $.ajax({
+ url: createURL('associateIpAddress'),
+ data: dataObj,
+ success: function(data) {
+ args.response.success({
+ _custom: {
+ jobId: data.associateipaddressresponse.jobid,
+ getUpdatedItem: function(data) {
+ var newIP = data.queryasyncjobresultresponse.jobresult.ipaddress;
+ return $.extend(newIP, {
+ state: 'Allocated'
+ });
+ },
+ getActionFilter: function() {
+ return actionFilters.ipAddress;
+ }
+ }
+ });
+ },
- error: function(json) {
- args.response.error(parseXMLHttpResponse(json));
- }
- });
+ error: function(json) {
+ args.response.error(parseXMLHttpResponse(json));
+ }
+ });
+ }
},
notification: {
@@ -1643,27 +1660,42 @@
});
}
- $.ajax({
- url: createURL('listPublicIpAddresses'),
- data: data,
- dataType: "json",
- async: true,
- success: function(json) {
- var items = json.listpublicipaddressesresponse.publicipaddress;
-
- $(items).each(function() {
- getExtaPropertiesForIpObj(this, args);
- });
-
- args.response.success({
- actionFilter: actionFilters.ipAddress,
- data: items
- });
- },
- error: function(data) {
- args.response.error(parseXMLHttpResponse(data));
- }
- });
+ if (args.context.nics) {
+ $.ajax({
+ url: createURL('listNics'),
+ data: {
+ nicId: args.context.nics[0].id,
+ vmId: args.context.instances[0].id
+ },
+ success: function(json) {
+ args.response.success({
+ data: json.listnicsresponse.nic[0].ipAddresses
+ });
+ }
+ });
+ } else {
+ $.ajax({
+ url: createURL('listPublicIpAddresses'),
+ data: data,
+ dataType: "json",
+ async: true,
+ success: function(json) {
+ var items = json.listpublicipaddressesresponse.publicipaddress;
+
+ $(items).each(function() {
+ getExtaPropertiesForIpObj(this, args);
+ });
+
+ args.response.success({
+ actionFilter: actionFilters.ipAddress,
+ data: items
+ });
+ },
+ error: function(data) {
+ args.response.error(parseXMLHttpResponse(data));
+ }
+ });
+ }
},
// Detail view
@@ -2017,39 +2049,53 @@
remove: {
label: 'label.action.release.ip',
action: function(args) {
- $.ajax({
- url: createURL('disassociateIpAddress'),
- data: {
- id: args.context.ipAddresses[0].id
- },
- dataType: 'json',
- async: true,
- success: function(data) {
- args.response.success({
- _custom: {
- jobId: data.disassociateipaddressresponse.jobid,
- getActionFilter: function() {
- return function(args) {
- var allowedActions = ['enableStaticNAT'];
+ if (args.context.nics) {
+ $.ajax({
+ url: createURL('removeIpFromNic'),
+ data: {
+ id: args.context.ipAddresses[0].id
+ },
+ success: function(json) {
+ args.response.success({
+ _custom: { jobId: json.removeipfromnicresponse.jobid }
+ });
+ }
+ });
+ } else {
+ $.ajax({
+ url: createURL('disassociateIpAddress'),
+ data: {
+ id: args.context.ipAddresses[0].id
+ },
+ dataType: 'json',
+ async: true,
+ success: function(data) {
+ args.response.success({
+ _custom: {
+ jobId: data.disassociateipaddressresponse.jobid,
+ getActionFilter: function() {
+ return function(args) {
+ var allowedActions = ['enableStaticNAT'];
- return allowedActions;
- };
- },
- getUpdatedItem: function(args) {
- return {
- state: 'Released'
- };
- },
- onComplete: function() {
- $(window).trigger('cloudStack.fullRefresh');
+ return allowedActions;
+ };
+ },
+ getUpdatedItem: function(args) {
+ return {
+ state: 'Released'
+ };
+ },
+ onComplete: function() {
+ $(window).trigger('cloudStack.fullRefresh');
+ }
}
- }
- });
- },
- error: function(data) {
- args.response.error(parseXMLHttpResponse(data));
- }
- });
+ });
+ },
+ error: function(data) {
+ args.response.error(parseXMLHttpResponse(data));
+ }
+ });
+ }
},
messages: {
confirm: function(args) {