Skip to content

Commit 99ca81a

Browse files
nvazquezrohityadavcloud
authored andcommitted
ui: do not send conserve mode on L2 network offering creation from the UI (apache#2694)
Do not send conserve mode param on L2 network offering creation from the UI. Fix config drive NPE issue on L2 network.
1 parent 3af54ec commit 99ca81a

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

engine/storage/configdrive/src/org/apache/cloudstack/storage/configdrive/ConfigDriveBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ private static void buildOpenStackMetaData(JsonObject metaData, String dataType,
286286
if (!NetworkModel.METATDATA_DIR.equals(dataType)) {
287287
return;
288288
}
289-
if (StringUtils.isNotBlank(content)) {
289+
if (StringUtils.isEmpty(content)) {
290290
return;
291291
}
292292
//keys are a special case in OpenStack format

ui/scripts/configuration.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,14 +2412,17 @@
24122412
if ($useVpcCb.is(':checked')) { //if useVpc is checked,
24132413
$useVpcCb.removeAttr("checked"); //remove "checked" attribute in useVpc
24142414
}
2415+
$conservemode.css('display', 'inline-block');
24152416
} else if ($guestTypeField.val() == 'Isolated') { //Isolated network offering
24162417
$useVpc.css('display', 'inline-block');
24172418
$supportedServices.css('display', 'inline-block');
24182419
$userDataL2.hide();
2420+
$conservemode.css('display', 'inline-block');
24192421
} else if ($guestTypeField.val() == 'L2') {
24202422
$useVpc.hide();
24212423
$supportedServices.hide();
24222424
$userDataL2.css('display', 'inline-block');
2425+
$conservemode.hide();
24232426
}
24242427
var $providers = $useVpcCb.closest('form').find('.dynamic-input select[name!="service.Connectivity.provider"]');
24252428
var $optionsOfProviders = $providers.find('option');
@@ -3403,6 +3406,9 @@
34033406
} else {
34043407
delete inputData.serviceProviderList;
34053408
}
3409+
3410+
//Conserve mode is irrelevant on L2 network offerings as there are no resources to conserve, do not pass it, true by default on server side
3411+
delete inputData.conservemode;
34063412
}
34073413

34083414
if (inputData['forvpc'] == 'on') {
@@ -3411,10 +3417,12 @@
34113417
delete inputData.forvpc; //if forVpc checkbox is unchecked, do not pass forVpc parameter to API call since we need to keep API call's size as small as possible (p.s. forVpc is defaulted as false at server-side)
34123418
}
34133419

3414-
if (inputData['conservemode'] == 'on') {
3415-
delete inputData.conservemode; //if ConserveMode checkbox is checked, do not pass conservemode parameter to API call since we need to keep API call's size as small as possible (p.s. conservemode is defaulted as true at server-side)
3416-
} else {
3417-
inputData['conservemode'] = false;
3420+
if (inputData['guestIpType'] == "Shared" || inputData['guestIpType'] == "Isolated") {
3421+
if (inputData['conservemode'] == 'on') {
3422+
delete inputData.conservemode; //if ConserveMode checkbox is checked, do not pass conservemode parameter to API call since we need to keep API call's size as small as possible (p.s. conservemode is defaulted as true at server-side)
3423+
} else {
3424+
inputData['conservemode'] = false;
3425+
}
34183426
}
34193427

34203428
// Make service provider map

0 commit comments

Comments
 (0)