|
136 | 136 | ipAddress: function(args) { |
137 | 137 | var allowedActions = args.context.actions; |
138 | 138 | var disallowedActions = []; |
139 | | - var item = args.context.item; |
140 | | - var status = item.state; |
| 139 | + var ipObj = args.context.item; |
| 140 | + var status = ipObj.state; |
141 | 141 |
|
142 | 142 | if (status == 'Destroyed' || |
143 | 143 | status == 'Releasing' || |
144 | 144 | status == 'Released' || |
145 | 145 | status == 'Creating' || |
146 | 146 | status == 'Allocating' || |
147 | | - item.account == 'system' || |
148 | | - item.issystem == true) { |
| 147 | + ipObj.account == 'system' || |
| 148 | + ipObj.issystem == true) { |
149 | 149 | return []; |
150 | 150 | } |
151 | 151 |
|
152 | | - if (item.networkOfferingConserveMode == false) { |
| 152 | + if (args.context.networks[0].networkofferingconservemode == false) { |
153 | 153 | /* |
154 | 154 | (1) If IP is SourceNat, no StaticNat/VPN/PortForwarding/LoadBalancer can be enabled/added. |
155 | 155 | */ |
156 | | - if (item.issourcenat == true) { |
| 156 | + if (ipObj.issourcenat == true) { |
157 | 157 | disallowedActions.push('enableStaticNAT'); |
158 | 158 | disallowedActions.push('enableVPN'); |
159 | 159 | } |
|
165 | 165 | 3. Once a PortForwarding rule is added, hide StaticNat/VPN/LoadBalancer. |
166 | 166 | 4. Once a LoadBalancer rule is added, hide StaticNat/VPN/PortForwarding. |
167 | 167 | */ |
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. |
170 | 170 | disallowedActions.push('enableVPN'); |
171 | 171 | } |
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. |
173 | 173 | disallowedActions.push('enableStaticNAT'); |
174 | 174 | } |
175 | 175 |
|
176 | 176 | //3. Once a PortForwarding rule is added, hide StaticNat/VPN/LoadBalancer. |
177 | 177 | $.ajax({ |
178 | 178 | url: createURL('listPortForwardingRules'), |
179 | 179 | data: { |
180 | | - ipaddressid: item.id, |
| 180 | + ipaddressid: ipObj.id, |
181 | 181 | listAll: true |
182 | 182 | }, |
183 | 183 | dataType: 'json', |
|
195 | 195 | $.ajax({ |
196 | 196 | url: createURL('listLoadBalancerRules'), |
197 | 197 | data: { |
198 | | - publicipid: item.id, |
| 198 | + publicipid: ipObj.id, |
199 | 199 | listAll: true |
200 | 200 | }, |
201 | 201 | dataType: 'json', |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 |
|
214 | | - if (item.isstaticnat) { |
| 214 | + if (ipObj.isstaticnat) { |
215 | 215 | disallowedActions.push('enableStaticNAT'); |
216 | 216 | } else { |
217 | 217 | disallowedActions.push('disableStaticNAT'); |
218 | 218 | } |
219 | 219 |
|
220 | | - if (item.networkOfferingHavingVpnService == true) { |
221 | | - if (item.vpnenabled) { |
| 220 | + if (ipObj.networkOfferingHavingVpnService == true) { |
| 221 | + if (ipObj.vpnenabled) { |
222 | 222 | disallowedActions.push('enableVPN'); |
223 | 223 | } else { |
224 | 224 | disallowedActions.push('disableVPN'); |
225 | 225 | } |
226 | | - } else { //item.networkOfferingHavingVpnService == false |
| 226 | + } else { //ipObj.networkOfferingHavingVpnService == false |
227 | 227 | disallowedActions.push('disableVPN'); |
228 | 228 | disallowedActions.push('enableVPN'); |
229 | 229 | } |
230 | 230 |
|
231 | | - if (item.issourcenat) { |
| 231 | + if (ipObj.issourcenat) { |
232 | 232 | disallowedActions.push('enableStaticNAT'); |
233 | 233 | disallowedActions.push('disableStaticNAT'); |
234 | 234 | disallowedActions.push('remove'); |
|
2706 | 2706 | }); |
2707 | 2707 | } |
2708 | 2708 | } |
2709 | | - if (args.context.ipAddresses[0].networkOfferingConserveMode == false) { |
| 2709 | + if (args.context.networks[0].networkofferingconservemode == false) { |
2710 | 2710 | /* |
2711 | 2711 | (1) If IP is SourceNat, no StaticNat/VPN/PortForwarding/LoadBalancer can be enabled/added. |
2712 | 2712 | */ |
|
5961 | 5961 | }; |
5962 | 5962 | } |
5963 | 5963 | }); |
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 |
5982 | 5966 | ipObj.networkOfferingHavingVpnService = false; //VPN is not supported in IP in VPC, so hardcode it as false |
5983 | 5967 | } |
5984 | 5968 | } |
|
0 commit comments