From 99ca81a676006cc5d351bd94e32e284256d00b4a Mon Sep 17 00:00:00 2001 From: Nicolas Vazquez Date: Thu, 7 Jun 2018 02:50:37 -0300 Subject: [PATCH] ui: do not send conserve mode on L2 network offering creation from the UI (#2694) Do not send conserve mode param on L2 network offering creation from the UI. Fix config drive NPE issue on L2 network. --- .../storage/configdrive/ConfigDriveBuilder.java | 2 +- ui/scripts/configuration.js | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/engine/storage/configdrive/src/org/apache/cloudstack/storage/configdrive/ConfigDriveBuilder.java b/engine/storage/configdrive/src/org/apache/cloudstack/storage/configdrive/ConfigDriveBuilder.java index dc6b8893495..55e7979a772 100644 --- a/engine/storage/configdrive/src/org/apache/cloudstack/storage/configdrive/ConfigDriveBuilder.java +++ b/engine/storage/configdrive/src/org/apache/cloudstack/storage/configdrive/ConfigDriveBuilder.java @@ -286,7 +286,7 @@ public class ConfigDriveBuilder { if (!NetworkModel.METATDATA_DIR.equals(dataType)) { return; } - if (StringUtils.isNotBlank(content)) { + if (StringUtils.isEmpty(content)) { return; } //keys are a special case in OpenStack format diff --git a/ui/scripts/configuration.js b/ui/scripts/configuration.js index 2eee7bbeae0..f229d24b19e 100644 --- a/ui/scripts/configuration.js +++ b/ui/scripts/configuration.js @@ -2412,14 +2412,17 @@ if ($useVpcCb.is(':checked')) { //if useVpc is checked, $useVpcCb.removeAttr("checked"); //remove "checked" attribute in useVpc } + $conservemode.css('display', 'inline-block'); } else if ($guestTypeField.val() == 'Isolated') { //Isolated network offering $useVpc.css('display', 'inline-block'); $supportedServices.css('display', 'inline-block'); $userDataL2.hide(); + $conservemode.css('display', 'inline-block'); } else if ($guestTypeField.val() == 'L2') { $useVpc.hide(); $supportedServices.hide(); $userDataL2.css('display', 'inline-block'); + $conservemode.hide(); } var $providers = $useVpcCb.closest('form').find('.dynamic-input select[name!="service.Connectivity.provider"]'); var $optionsOfProviders = $providers.find('option'); @@ -3403,6 +3406,9 @@ } else { delete inputData.serviceProviderList; } + + //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 + delete inputData.conservemode; } if (inputData['forvpc'] == 'on') { @@ -3411,10 +3417,12 @@ 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) } - if (inputData['conservemode'] == 'on') { - 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) - } else { - inputData['conservemode'] = false; + if (inputData['guestIpType'] == "Shared" || inputData['guestIpType'] == "Isolated") { + if (inputData['conservemode'] == 'on') { + 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) + } else { + inputData['conservemode'] = false; + } } // Make service provider map