diff --git a/src/Common/CustomerPortalClient.cs b/src/Common/CustomerPortalClient.cs index 6e51fbf..93fa003 100644 --- a/src/Common/CustomerPortalClient.cs +++ b/src/Common/CustomerPortalClient.cs @@ -392,7 +392,7 @@ public async Task CheckCustomerEnvironmentConnectionStatus(long? definitio } /// - public async Task CreateOrUpdateAppInstallation(long customerEnvironmentId, string appName, string appVersion, string parameters, string customerLicenseName) + public async Task CreateOrUpdateAppInstallation(long customerEnvironmentId, string appName, string appVersion, string parameters, string softwareLicenseName) { return (await new CreateOrUpdateAppInstallationInput() { @@ -400,7 +400,7 @@ public async Task CreateOrUpdateAppInstal ApplicationPackageName = appName, AppVersion = appVersion, Parameters = parameters, - CustomerLicenseName = customerLicenseName + SoftwareLicenseName = softwareLicenseName }.CreateOrUpdateAppInstallationAsync(true)).CustomerEnvironmentApplicationPackage; } diff --git a/src/Common/Handlers/NewEnvironmentHandler.cs b/src/Common/Handlers/NewEnvironmentHandler.cs index 37e7710..f61f55b 100644 --- a/src/Common/Handlers/NewEnvironmentHandler.cs +++ b/src/Common/Handlers/NewEnvironmentHandler.cs @@ -1,8 +1,10 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Threading.Tasks; using Cmf.CustomerPortal.BusinessObjects; +using Cmf.CustomerPortal.Common.Deployment; using Cmf.CustomerPortal.Orchestration.CustomerEnvironmentManagement.InputObjects; using Cmf.CustomerPortal.Sdk.Common.Services; using Cmf.Foundation.BusinessObjects; @@ -10,8 +12,6 @@ using Cmf.Foundation.BusinessOrchestration.GenericServiceManagement.InputObjects; using Cmf.Foundation.Common.Licenses.Enums; using Cmf.LightBusinessObjects.Infrastructure.Errors; -using System.Linq; -using Cmf.CustomerPortal.Common.Deployment; namespace Cmf.CustomerPortal.Sdk.Common.Handlers { @@ -93,7 +93,7 @@ bool terminateOtherVersionsRemoveVolumes } environment.DeploymentPackage = isInfrastructureAgent || string.IsNullOrWhiteSpace(deploymentPackageName) ? environment.DeploymentPackage : await _customerPortalClient.GetObjectByName(deploymentPackageName); - environment.CustomerLicense = isInfrastructureAgent || string.IsNullOrWhiteSpace(licenseName) ? environment.CustomerLicense : await _customerPortalClient.GetObjectByName(licenseName); + environment.SoftwareLicense = isInfrastructureAgent || string.IsNullOrWhiteSpace(licenseName) ? environment.SoftwareLicense : await Utils.GetLicenseByUniqueName(licenseName); environment.DeploymentTarget = _newEnvironmentUtilities.GetDeploymentTargetValue(target); environment.ChangeSet = null; @@ -193,7 +193,7 @@ bool terminateOtherVersionsRemoveVolumes DeploymentPackage = isInfrastructureAgent ? null : await _customerPortalClient.GetObjectByName(deploymentPackageName), DeploymentTarget = _newEnvironmentUtilities.GetDeploymentTargetValue(target), Site = environmentSite, - CustomerLicense = isInfrastructureAgent ? null : await _customerPortalClient.GetObjectByName(licenseName) + SoftwareLicense = isInfrastructureAgent ? null : await Utils.GetLicenseByUniqueName(licenseName) }; // check environment connection @@ -219,7 +219,7 @@ bool terminateOtherVersionsRemoveVolumes Site = isInfrastructureAgent ? null : await _customerPortalClient.GetObjectByName(siteName), Name = name, DeploymentPackage = isInfrastructureAgent ? null : await _customerPortalClient.GetObjectByName(deploymentPackageName), - CustomerLicense = isInfrastructureAgent ? null : await _customerPortalClient.GetObjectByName(licenseName), + SoftwareLicense = isInfrastructureAgent ? null : await Utils.GetLicenseByUniqueName(licenseName), DeploymentTarget = _newEnvironmentUtilities.GetDeploymentTargetValue(target), Parameters = rawParameters }; diff --git a/src/Common/ICustomerPortalClient.cs b/src/Common/ICustomerPortalClient.cs index ace1f8c..7d01ed6 100644 --- a/src/Common/ICustomerPortalClient.cs +++ b/src/Common/ICustomerPortalClient.cs @@ -92,9 +92,9 @@ public interface ICustomerPortalClient /// Name of the ApplicationPackage. /// Version of the ApplicationPackage. /// Deployment parameters for the CustomerEnvironmentApplicationPackage. - /// Name of a CustomerLicense. + /// Name of a SoftwareLicense. /// The CustomerEnvironmentApplicationPackage relation. - Task CreateOrUpdateAppInstallation(long customerEnvironmentId, string appName, string appVersion, string parameters, string customerLicenseName); + Task CreateOrUpdateAppInstallation(long customerEnvironmentId, string appName, string appVersion, string parameters, string softwareLicenseName); /// /// Check the Deployment connection to verify if the deployment of an environment/app can occur. diff --git a/src/Common/Utils.cs b/src/Common/Utils.cs index e2c2601..4ce2280 100644 --- a/src/Common/Utils.cs +++ b/src/Common/Utils.cs @@ -1,7 +1,12 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; +using Cmf.CustomerPortal.BusinessObjects; +using Cmf.Foundation.BusinessObjects.QueryObject; +using Cmf.Foundation.BusinessOrchestration.GenericServiceManagement.InputObjects; +using Cmf.Foundation.Common; namespace Cmf.CustomerPortal.Sdk.Common { @@ -85,5 +90,33 @@ private static async Task> ConfigureTokens(ISession _ return tokens; }); } + + /// + /// Name of SoftwareLicense is not unique, since it is a versioned entity + /// To load a license by name, we need to get it by the LicenseUniqueName + /// + /// + /// + public static async Task GetLicenseByUniqueName(string licenseUniqueName) + { + FilterCollection fcCollection = new FilterCollection() + { + new Filter() + { + Name = "LicenseUniqueName", + LogicalOperator = LogicalOperator.AND, + Operator = FieldOperator.IsEqualTo, + Value = licenseUniqueName + } + }; + + GetObjectsByFilterInput gobfiInput = new GetObjectsByFilterInput + { + Filter = fcCollection, + Type = Activator.CreateInstance() + }; + + return (CPSoftwareLicense)gobfiInput.GetObjectsByFilterSync().Instance[0]; + } } } diff --git a/src/Common/libs/Cmf.LightBusinessObjects.dll b/src/Common/libs/Cmf.LightBusinessObjects.dll index ac513c9..e93b1b2 100644 Binary files a/src/Common/libs/Cmf.LightBusinessObjects.dll and b/src/Common/libs/Cmf.LightBusinessObjects.dll differ diff --git a/src/Common/libs/Cmf.LoadBalancing.dll b/src/Common/libs/Cmf.LoadBalancing.dll index 731bd1b..b81a2ec 100644 Binary files a/src/Common/libs/Cmf.LoadBalancing.dll and b/src/Common/libs/Cmf.LoadBalancing.dll differ diff --git a/src/Common/libs/Cmf.MessageBus.Client.dll b/src/Common/libs/Cmf.MessageBus.Client.dll index 2ba53e3..0313668 100644 Binary files a/src/Common/libs/Cmf.MessageBus.Client.dll and b/src/Common/libs/Cmf.MessageBus.Client.dll differ