Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,10 @@ public interface MorpheusAdminService {
* @return an instance of the implementation of the {@link MorpheusApplianceService}
*/
MorpheusApplianceService getAppliance();

/**
* Returns the Appliance License Service for querying and managing the appliance license asynchronously (reactive).
* @return an instance of the implementation of the {@link MorpheusApplianceLicenseService}
*/
MorpheusApplianceLicenseService getLicense();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2024 Morpheus Data, LLC.
*
* Licensed under the PLUGIN CORE SOURCE LICENSE (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://raw.githubusercontent.com/gomorpheus/morpheus-plugin-core/v1.0.x/LICENSE
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.morpheusdata.core.admin;

import com.morpheusdata.model.license.ApplianceLicenseInfo;
import com.morpheusdata.response.ServiceResponse;
import io.reactivex.rxjava3.core.Single;

/**
* Provides async (reactive) access to appliance license data and operations.
* Mirrors the functionality of the {@code /api/license} REST endpoints.
*
* <p>Example usage:
* <pre>
* morpheusContext.async.admin.license.getLicense().subscribe { info ->
* log.info("Product tier: ${info.license?.productTier}")
* }
* </pre>
*
* @since 1.4.0
* @author Morpheus Data
*/
public interface MorpheusApplianceLicenseService {

/**
* Returns the current appliance license information including usage counts and limit checks.
* @return a {@link Single} emitting the current {@link ApplianceLicenseInfo}
*/
Single<ApplianceLicenseInfo> getLicense();

/**
* Applies a license key to the appliance. By default the new license replaces any existing licenses.
* Pass {@code stackLicense=true} to add on top of existing licenses instead.
* @param licenseKey the license key string to apply
* @param stackLicense if true, stacks on top of existing licenses; if false, replaces them
* @return a {@link Single} emitting a {@link ServiceResponse} containing the updated {@link ApplianceLicenseInfo} on success
*/
Single<ServiceResponse<ApplianceLicenseInfo>> applyLicense(String licenseKey, boolean stackLicense);

/**
* Removes an installed license from the appliance.
* @param keyId the key ID (first 8 characters of the license content) of the license to remove, or null to remove all
* @return a {@link Single} emitting a {@link ServiceResponse} containing the updated {@link ApplianceLicenseInfo} on success
*/
Single<ServiceResponse<ApplianceLicenseInfo>> removeLicense(String keyId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ public interface MorpheusSynchronousAdminService {
MorpheusSynchronousUserService getUser();

MorpheusSynchronousApplianceService getAppliance();

/**
* Returns the Appliance License Service for querying and managing the appliance license synchronously.
* @return an instance of the implementation of the {@link MorpheusSynchronousApplianceLicenseService}
*/
MorpheusSynchronousApplianceLicenseService getLicense();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2024 Morpheus Data, LLC.
*
* Licensed under the PLUGIN CORE SOURCE LICENSE (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://raw.githubusercontent.com/gomorpheus/morpheus-plugin-core/v1.0.x/LICENSE
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.morpheusdata.core.synchronous.admin;

import com.morpheusdata.model.license.ApplianceLicenseInfo;
import com.morpheusdata.response.ServiceResponse;

/**
* Provides synchronous (blocking) access to appliance license data and operations.
* Mirrors the functionality of the {@code /api/license} REST endpoints.
*
* <p>Example usage:
* <pre>
* ApplianceLicenseInfo info = morpheusContext.services.admin.license.getLicense()
* log.info("Product tier: ${info.license?.productTier}")
* </pre>
*
* @since 1.4.0
* @author Morpheus Data
*/
public interface MorpheusSynchronousApplianceLicenseService {

/**
* Returns the current appliance license information including usage counts and limit checks.
* @return the current {@link ApplianceLicenseInfo}
*/
ApplianceLicenseInfo getLicense();

/**
* Applies a license key to the appliance.
* @param licenseKey the license key string to apply
* @param stackLicense if true, stacks on top of existing licenses; if false, replaces them
* @return a {@link ServiceResponse} containing the updated {@link ApplianceLicenseInfo} on success
*/
ServiceResponse<ApplianceLicenseInfo> applyLicense(String licenseKey, boolean stackLicense);

/**
* Removes an installed license from the appliance.
* @param keyId the key ID of the license to remove, or null to remove all
* @return a {@link ServiceResponse} containing the updated {@link ApplianceLicenseInfo} on success
*/
ServiceResponse<ApplianceLicenseInfo> removeLicense(String keyId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright 2024 Morpheus Data, LLC.
*
* Licensed under the PLUGIN CORE SOURCE LICENSE (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://raw.githubusercontent.com/gomorpheus/morpheus-plugin-core/v1.0.x/LICENSE
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.morpheusdata.model.license;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
* Represents a single appliance license configuration, either the currently merged/active license
* or one of the individually installed licenses.
*/
public class ApplianceLicenseData {
public Long id;
public String keyId;
public String hash;
public Integer licenseVersion;
public String productTier;
public Date startDate;
public Date endDate;

// workload limitType limits
public Long maxInstances;
public Long maxMemory;
public Long maxStorage;

// limit type
public String limitType;

// standard limitType limits
public Long maxManagedServers;
public Long maxDiscoveredServers;
public Long maxHosts;
/** @deprecated use maxMvmSockets */
@Deprecated
public Long maxMvm;
public Long maxMvmSockets;
public Long maxSockets;
public Long maxIac;
public Long maxXaas;
public Long maxExecutions;
public Long maxDistributedWorkers;
public Long maxDiscoveredObjects;

public Boolean hardLimit;
public Boolean multiTenant;
public Boolean whiteLabel;
public Boolean reportStatus;
public String supportLevel;
public String accountName;

/** Arbitrary key/value config embedded in the license */
public Map<String, Object> config;
public List<String> amazonProductCodes;

/** Map of feature name → enabled flag */
public Map<String, Boolean> features;
public List<String> zoneTypes;
public List<String> zoneTypesExcluded;
public List<String> taskTypes;
public List<String> taskTypesExcluded;

public Date lastUpdated;
public Date dateCreated;
/** Date when license limits should be recalculated (e.g. after a stacked license expires) */
public Date recalculationDate;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2024 Morpheus Data, LLC.
*
* Licensed under the PLUGIN CORE SOURCE LICENSE (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://raw.githubusercontent.com/gomorpheus/morpheus-plugin-core/v1.0.x/LICENSE
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.morpheusdata.model.license;

import java.util.ArrayList;
import java.util.List;

/**
* Root model returned by the Appliance License DataService. Contains the current merged license config,
* the list of individually installed licenses, current usage counts, per-metric limit checks, and a
* convenience flag indicating whether any limit has been reached.
*/
public class ApplianceLicenseInfo {
public ApplianceLicenseData license;
public List<ApplianceLicenseData> installedLicenses = new ArrayList<>();
public ApplianceLicenseUsage currentUsage;
public List<ApplianceLicenseLimit> licenseLimits = new ArrayList<>();
public Boolean limitReached;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2024 Morpheus Data, LLC.
*
* Licensed under the PLUGIN CORE SOURCE LICENSE (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://raw.githubusercontent.com/gomorpheus/morpheus-plugin-core/v1.0.x/LICENSE
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.morpheusdata.model.license;

/**
* Represents the limit check result for a single license metric (e.g. maxManagedServers, maxSockets).
*/
public class ApplianceLicenseLimit {
/** Metric code, e.g. "maxManagedServers", "maxSockets", "maxMemory" */
public String code;
/** Maximum allowed value. Null means unlimited. */
public Long max;
public Long used;
public Double percentUsed;
/** True when usage is ≥ 85% of max */
public Boolean warning;
/** True when usage is ≥ 100% of max */
public Boolean limitReached;
/** Optional unit, e.g. "bytes" for memory/storage limits */
public String unit;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2024 Morpheus Data, LLC.
*
* Licensed under the PLUGIN CORE SOURCE LICENSE (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://raw.githubusercontent.com/gomorpheus/morpheus-plugin-core/v1.0.x/LICENSE
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.morpheusdata.model.license;

/**
* Current appliance usage counts used for license limit checking.
*/
public class ApplianceLicenseUsage {
// standard limitType metrics
public Long managedServers;
public Long discoveredServers;
public Long hosts;
/** @deprecated use mvmSockets */
@Deprecated
public Long mvm;
public Long mvmSockets;
public Long mvmVirtualMachines;
public Long sockets;
public Long hypervisorSocketCount;
public Long publicVirtualMachineCount;
public Long publicVirtualMachineSocketCount;
public Long iac;
public Long xaas;
public Long executions;
public Long distributedWorkers;
public Long discoveredObjects;

// workload / capacity limitType metrics
public Long workloads;
/** Memory in bytes */
public Long memory;
/** Storage in bytes */
public Long storage;
}
Loading
Loading