Skip to content

Commit 4520a01

Browse files
author
Jessica Wang
committed
CLOUDSTACK-4142: listNetworkOfferings API has been changed to not return system-owned network offerings to regular user. conservemode property was just added to listNetworks API response. Change IP Address page to get conservemode from listNetworks API instead of listNetworkOfferings API.
1 parent 3dc8d2f commit 4520a01

1 file changed

Lines changed: 19 additions & 35 deletions

File tree

‎ui/scripts/network.js‎

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -136,24 +136,24 @@
136136
ipAddress: function(args) {
137137
var allowedActions = args.context.actions;
138138
var disallowedActions = [];
139-
var item = args.context.item;
140-
var status = item.state;
139+
var ipObj = args.context.item;
140+
var status = ipObj.state;
141141

142142
if (status == 'Destroyed' ||
143143
status == 'Releasing' ||
144144
status == 'Released' ||
145145
status == 'Creating' ||
146146
status == 'Allocating' ||
147-
item.account == 'system' ||
148-
item.issystem == true) {
147+
ipObj.account == 'system' ||
148+
ipObj.issystem == true) {
149149
return [];
150150
}
151151

152-
if (item.networkOfferingConserveMode == false) {
152+
if (args.context.networks[0].networkofferingconservemode == false) {
153153
/*
154154
(1) If IP is SourceNat, no StaticNat/VPN/PortForwarding/LoadBalancer can be enabled/added.
155155
*/
156-
if (item.issourcenat == true) {
156+
if (ipObj.issourcenat == true) {
157157
disallowedActions.push('enableStaticNAT');
158158
disallowedActions.push('enableVPN');
159159
}
@@ -165,19 +165,19 @@
165165
3. Once a PortForwarding rule is added, hide StaticNat/VPN/LoadBalancer.
166166
4. Once a LoadBalancer rule is added, hide StaticNat/VPN/PortForwarding.
167167
*/
168-
else { //item.issourcenat == false
169-
if (item.isstaticnat) { //1. Once StaticNat is enabled, hide VPN/PortForwarding/LoadBalancer.
168+
else { //ipObj.issourcenat == false
169+
if (ipObj.isstaticnat) { //1. Once StaticNat is enabled, hide VPN/PortForwarding/LoadBalancer.
170170
disallowedActions.push('enableVPN');
171171
}
172-
if (item.vpnenabled) { //2. Once VPN is enabled, hide StaticNat/PortForwarding/LoadBalancer.
172+
if (ipObj.vpnenabled) { //2. Once VPN is enabled, hide StaticNat/PortForwarding/LoadBalancer.
173173
disallowedActions.push('enableStaticNAT');
174174
}
175175

176176
//3. Once a PortForwarding rule is added, hide StaticNat/VPN/LoadBalancer.
177177
$.ajax({
178178
url: createURL('listPortForwardingRules'),
179179
data: {
180-
ipaddressid: item.id,
180+
ipaddressid: ipObj.id,
181181
listAll: true
182182
},
183183
dataType: 'json',
@@ -195,7 +195,7 @@
195195
$.ajax({
196196
url: createURL('listLoadBalancerRules'),
197197
data: {
198-
publicipid: item.id,
198+
publicipid: ipObj.id,
199199
listAll: true
200200
},
201201
dataType: 'json',
@@ -211,24 +211,24 @@
211211
}
212212
}
213213

214-
if (item.isstaticnat) {
214+
if (ipObj.isstaticnat) {
215215
disallowedActions.push('enableStaticNAT');
216216
} else {
217217
disallowedActions.push('disableStaticNAT');
218218
}
219219

220-
if (item.networkOfferingHavingVpnService == true) {
221-
if (item.vpnenabled) {
220+
if (ipObj.networkOfferingHavingVpnService == true) {
221+
if (ipObj.vpnenabled) {
222222
disallowedActions.push('enableVPN');
223223
} else {
224224
disallowedActions.push('disableVPN');
225225
}
226-
} else { //item.networkOfferingHavingVpnService == false
226+
} else { //ipObj.networkOfferingHavingVpnService == false
227227
disallowedActions.push('disableVPN');
228228
disallowedActions.push('enableVPN');
229229
}
230230

231-
if (item.issourcenat) {
231+
if (ipObj.issourcenat) {
232232
disallowedActions.push('enableStaticNAT');
233233
disallowedActions.push('disableStaticNAT');
234234
disallowedActions.push('remove');
@@ -2706,7 +2706,7 @@
27062706
});
27072707
}
27082708
}
2709-
if (args.context.ipAddresses[0].networkOfferingConserveMode == false) {
2709+
if (args.context.networks[0].networkofferingconservemode == false) {
27102710
/*
27112711
(1) If IP is SourceNat, no StaticNat/VPN/PortForwarding/LoadBalancer can be enabled/added.
27122712
*/
@@ -5961,24 +5961,8 @@
59615961
};
59625962
}
59635963
});
5964-
}
5965-
5966-
//get ipObj.networkOfferingConserveMode and ipObj.networkOfferingHavingVpnService from guest network's network offering
5967-
$.ajax({
5968-
url: createURL('listNetworkOfferings'),
5969-
data: {
5970-
id: args.context.networks[0].networkofferingid
5971-
},
5972-
async: false,
5973-
success: function(json) {
5974-
if(json.listnetworkofferingsresponse.networkoffering != null) {
5975-
var networkOfferingObj = json.listnetworkofferingsresponse.networkoffering[0];
5976-
ipObj.networkOfferingConserveMode = networkOfferingObj.conservemode;
5977-
}
5978-
}
5979-
});
5980-
} else { //from VPC section
5981-
ipObj.networkOfferingConserveMode = false; //conserve mode of IP in VPC is always off, so hardcode it as false
5964+
}
5965+
} else { //from VPC section
59825966
ipObj.networkOfferingHavingVpnService = false; //VPN is not supported in IP in VPC, so hardcode it as false
59835967
}
59845968
}

0 commit comments

Comments
 (0)