Skip to content

Commit f1680ef

Browse files
committed
CLOUDSTACK-3268: Support transfer of portable IP
Allow UI to implicitly transfer portable IP, through enabling static NAT on a VM/NIC from another cross-zone network.
1 parent cab72c0 commit f1680ef

1 file changed

Lines changed: 53 additions & 3 deletions

File tree

‎ui/scripts/network.js‎

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,49 @@
3535
return elemData;
3636
};
3737

38-
var instanceSecondaryIPSubselect = function(args) {
38+
var instanceSecondaryIPSubselect = function(args) {
3939
var instance = args.context.instances[0];
4040
var network = args.context.networks[0];
41+
42+
if (args.context.ipAddresses[0].isportable) {
43+
$.ajax({
44+
url: createURL('listNics'),
45+
data: {
46+
virtualmachineid: instance.id
47+
},
48+
success: function(json) {
49+
var nics = json.listnicsresponse.nic;
50+
var ipSelection = [];
51+
52+
$(nics).map(function(index, nic) {
53+
var ips = nic.secondaryip ? nic.secondaryip : [];
54+
var prefix = '[NIC ' + (index + 1) + '] ';
55+
56+
// Add primary IP as default
57+
ipSelection.push({
58+
id: nic.networkid + ',-1',
59+
description: prefix + nic.ipaddress + ' (Primary)'
60+
});
61+
62+
// Add secondary IPs
63+
$(ips).map(function(index, ip) {
64+
ipSelection.push({
65+
id: nic.networkid + ',' + ip.ipaddress,
66+
description: prefix + ip.ipaddress
67+
});
68+
});
69+
});
70+
71+
72+
args.response.success({
73+
data: ipSelection
74+
});
75+
}
76+
});
77+
78+
return;
79+
}
80+
4181
var nic = $.grep(instance.nic, function(nic) {
4282
return nic.networkid == network.id;
4383
})[0];
@@ -2338,7 +2378,7 @@
23382378
networkid: $tierSelect.val(),
23392379
vpcid: args.context.vpc[0].id
23402380
});
2341-
} else if ('networks' in args.context) {
2381+
} else if ('networks' in args.context && !args.context.ipAddresses[0].isportable) {
23422382
$.extend(data, {
23432383
networkid: args.context.networks[0].id
23442384
});
@@ -2382,7 +2422,17 @@
23822422
virtualmachineid: args.context.instances[0].id
23832423
};
23842424

2385-
if (args._subselect && args._subselect != -1) {
2425+
if (args.context.ipAddresses[0].isportable) {
2426+
var subselect = args._subselect.split(',');
2427+
var networkid = subselect[0];
2428+
var vmguestip = subselect[1];
2429+
2430+
data.networkid = subselect[0];
2431+
2432+
if (parseInt(vmguestip) !== -1) {
2433+
data.vmguestip = vmguestip;
2434+
}
2435+
} else if (args._subselect && args._subselect != -1) {
23862436
data.vmguestip = args._subselect;
23872437
}
23882438

0 commit comments

Comments
 (0)