CLOUDSTACK-114 UI - VPC related Network Offerings should not be provided as options to create a guest network for the Account before a VPC is actually present with the Account

This commit is contained in:
Mice Xia 2012-09-18 11:02:14 +08:00
parent cf5d7f879f
commit 11b42481e1
1 changed files with 30 additions and 15 deletions

View File

@ -282,25 +282,40 @@
label: 'label.network.offering',
validation: { required: true },
dependsOn: 'zoneId',
select: function(args) {
select: function(args) {
$.ajax({
url: createURL('listNetworkOfferings&zoneid=' + args.zoneId),
url: createURL('listVPCs'),
data: {
guestiptype: 'Isolated',
supportedServices: 'SourceNat',
specifyvlan: false,
state: 'Enabled'
listAll: true
},
success: function(json) {
networkOfferingObjs = json.listnetworkofferingsresponse.networkoffering;
args.response.success({
data: $.map(networkOfferingObjs, function(zone) {
return {
id: zone.id,
description: zone.name
};
})
});
var items = json.listvpcsresponse.vpc;
var baseUrl = 'listNetworkOfferings&zoneid=' + args.zoneId;
var listUrl;
if(items != null && items.length > 0)
listUrl = baseUrl;
else
listUrl = baseUrl + '&forVpc=false';
$.ajax({
url: createURL(listUrl),
data: {
guestiptype: 'Isolated',
supportedServices: 'SourceNat',
specifyvlan: false,
state: 'Enabled'
},
success: function(json) {
networkOfferingObjs = json.listnetworkofferingsresponse.networkoffering;
args.response.success({
data: $.map(networkOfferingObjs, function(zone) {
return {
id: zone.id,
description: zone.name
};
})
});
}
});
}
});
}