Skip to content

Commit f3841b3

Browse files
author
Jessica Wang
committed
cloudstack 3.0 UI - VPC - add LB rule - fix a JS error "args.context.networks is undefined" when configure stickiness.
1 parent 1381fa4 commit f3841b3

1 file changed

Lines changed: 36 additions & 2 deletions

File tree

‎ui/scripts/lbStickyPolicy.js‎

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,53 @@
1414
// KIND, either express or implied. See the License for the
1515
// specific language governing permissions and limitations
1616
// under the License.
17+
1718
(function($, cloudStack) {
1819
cloudStack.lbStickyPolicy = {
1920
dialog: function(args) {
2021
return function(args) {
2122
var success = args.response.success;
2223
var context = args.context;
23-
var network = args.context.networks[0];
24+
25+
var network;
26+
if('vpc' in args.context) { //from VPC section
27+
var data = {
28+
listAll: true,
29+
supportedservices: 'Lb'
30+
};
31+
if(args.context.ipAddresses[0].associatednetworkid == null) {
32+
$.extend(data, {
33+
vpcid: args.context.vpc[0].id
34+
});
35+
}
36+
else {
37+
$.extend(data, {
38+
id: args.context.ipAddresses[0].associatednetworkid
39+
});
40+
}
41+
42+
$.ajax({
43+
url: createURL("listNetworks"), //check whether the VPC has a network including Lb service
44+
data: data,
45+
async: false,
46+
success: function(json) {
47+
var items = json.listnetworksresponse.network;
48+
if(items != null && items.length > 0) {
49+
network = items[0];
50+
}
51+
}
52+
});
53+
}
54+
else { //from Guest Network section
55+
network = args.context.networks[0];
56+
}
57+
2458
var $item = args.$item;
2559

2660
var lbService = $.grep(network.service, function(service) {
2761
return service.name == 'Lb';
2862
})[0];
29-
63+
3064
var stickinessCapabilities = JSON.parse($.grep(
3165
lbService.capability,
3266
function(capability) {

0 commit comments

Comments
 (0)