Skip to content

Commit

Permalink
Add support for CP4Apps Advanced entitlement (#661)
Browse files Browse the repository at this point in the history
* Add support for CP4Apps Advanced entitlement

Signed-off-by: Leo Christy Jesuraj <leojc@ca.ibm.com>

* Update license metadata

Signed-off-by: Leo Christy Jesuraj <leojc@ca.ibm.com>

* Update unit tests for license ratios

Signed-off-by: Leo Christy Jesuraj <leojc@ca.ibm.com>

* Update the description of license field

Signed-off-by: Leo Christy Jesuraj <leojc@ca.ibm.com>

* Update the description of entitlement source field

Signed-off-by: Leo Christy Jesuraj <leojc@ca.ibm.com>

---------

Signed-off-by: Leo Christy Jesuraj <leojc@ca.ibm.com>
  • Loading branch information
leochr committed Jul 15, 2024
1 parent ff8d97b commit 3c8c999
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 56 deletions.
18 changes: 11 additions & 7 deletions api/v1/webspherelibertyapplication_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
// Defines the desired state of WebSphereLibertyApplication.
type WebSphereLibertyApplicationSpec struct {

// The license must be reviewed and accepted before the application can be deployed.
// +operator-sdk:csv:customresourcedefinitions:order=1,type=spec,displayName="License",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
License License `json:"license"`

Expand Down Expand Up @@ -172,13 +173,12 @@ type WebSphereLibertyApplicationSpec struct {
DisableServiceLinks *bool `json:"disableServiceLinks,omitempty"`
}

// License information is required.
type License struct {
// Product edition. Defaults to IBM WebSphere Application Server. Other options: IBM WebSphere Application Server Liberty Core, IBM WebSphere Application Server Network Deployment
// +operator-sdk:csv:customresourcedefinitions:order=100,type=spec,displayName="Edition"
Edition LicenseEdition `json:"edition,omitempty"`

// Entitlement source for the product. Defaults to Standalone. Other options: IBM Cloud Pak for Applications, IBM WebSphere Application Server Family Edition, IBM WebSphere Hybrid Edition
// Entitlement source for the product. Defaults to Standalone. Other options: IBM Cloud Pak for Applications Advanced, IBM Cloud Pak for Applications Standard, IBM WebSphere Hybrid Edition, IBM WebSphere Application Server Family Edition. Option IBM Cloud Pak for Applications is deprecated. Use option IBM Cloud Pak for Applications Standard instead.
// +operator-sdk:csv:customresourcedefinitions:order=101,type=spec,displayName="Product Entitlement Source"
ProductEntitlementSource LicenseEntitlement `json:"productEntitlementSource,omitempty"`

Expand Down Expand Up @@ -218,18 +218,22 @@ const (
)

// Defines the possible values for product entitlement source
// +kubebuilder:validation:Enum=Standalone;IBM Cloud Pak for Applications;IBM WebSphere Application Server Family Edition;IBM WebSphere Hybrid Edition
// +kubebuilder:validation:Enum=Standalone;IBM Cloud Pak for Applications Advanced;IBM Cloud Pak for Applications Standard;IBM WebSphere Hybrid Edition;IBM WebSphere Application Server Family Edition;IBM Cloud Pak for Applications
type LicenseEntitlement string

const (
// Entitlement source Standalone
LicenseEntitlementStandalone LicenseEntitlement = "Standalone"
// Entitlement source IBM Cloud Pak for Applications
LicenseEntitlementCP4Apps LicenseEntitlement = "IBM Cloud Pak for Applications"
// Entitlement source IBM WebSphere Application Server Family Edition
LicenseEntitlementFamilyEdition LicenseEntitlement = "IBM WebSphere Application Server Family Edition"
// Entitlement source IBM Cloud Pak for Applications Advanced
LicenseEntitlementCP4AppsAdvanced LicenseEntitlement = "IBM Cloud Pak for Applications Advanced"
// Entitlement source IBM Cloud Pak for Applications Standard
LicenseEntitlementCP4AppsStandard LicenseEntitlement = "IBM Cloud Pak for Applications Standard"
// Entitlement source IBM WebSphere Hybrid Edition
LicenseEntitlementWSHE LicenseEntitlement = "IBM WebSphere Hybrid Edition"
// Entitlement source IBM WebSphere Application Server Family Edition
LicenseEntitlementFamilyEdition LicenseEntitlement = "IBM WebSphere Application Server Family Edition"
// Entitlement source IBM Cloud Pak for Applications
LicenseEntitlementCP4Apps LicenseEntitlement = "IBM Cloud Pak for Applications"
)

// Defines the topology spread constraints
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ metadata:
capabilities: Auto Pilot
categories: Application Runtime
containerImage: icr.io/cpopen/websphere-liberty-operator:daily
createdAt: "2024-07-12T19:53:58Z"
createdAt: "2024-07-15T15:45:26Z"
description: Deploy and manage containerized Liberty applications
olm.skipRange: '>=1.0.0 <1.3.3'
operators.openshift.io/infrastructure-features: '["disconnected"]'
Expand Down Expand Up @@ -124,7 +124,9 @@ spec:
path: autoscaling.maxReplicas
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
- displayName: License
- description: The license must be reviewed and accepted before the application
can be deployed.
displayName: License
path: license
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:text
Expand Down Expand Up @@ -561,8 +563,10 @@ spec:
displayName: Edition
path: license.edition
- description: 'Entitlement source for the product. Defaults to Standalone.
Other options: IBM Cloud Pak for Applications, IBM WebSphere Application
Server Family Edition, IBM WebSphere Hybrid Edition'
Other options: IBM Cloud Pak for Applications Advanced, IBM Cloud Pak for
Applications Standard, IBM WebSphere Hybrid Edition, IBM WebSphere Application
Server Family Edition. Option IBM Cloud Pak for Applications is deprecated.
Use option IBM Cloud Pak for Applications Standard instead.'
displayName: Product Entitlement Source
path: license.productEntitlementSource
- description: Deprecated. Charge metric code is now automatically determined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2438,7 +2438,8 @@ spec:
- name
x-kubernetes-list-type: map
license:
description: License information is required.
description: The license must be reviewed and accepted before the
application can be deployed.
properties:
accept:
description: |-
Expand Down Expand Up @@ -2466,14 +2467,18 @@ spec:
type: string
productEntitlementSource:
description: 'Entitlement source for the product. Defaults to
Standalone. Other options: IBM Cloud Pak for Applications, IBM
WebSphere Application Server Family Edition, IBM WebSphere Hybrid
Edition'
Standalone. Other options: IBM Cloud Pak for Applications Advanced,
IBM Cloud Pak for Applications Standard, IBM WebSphere Hybrid
Edition, IBM WebSphere Application Server Family Edition. Option
IBM Cloud Pak for Applications is deprecated. Use option IBM
Cloud Pak for Applications Standard instead.'
enum:
- Standalone
- IBM Cloud Pak for Applications
- IBM WebSphere Application Server Family Edition
- IBM Cloud Pak for Applications Advanced
- IBM Cloud Pak for Applications Standard
- IBM WebSphere Hybrid Edition
- IBM WebSphere Application Server Family Edition
- IBM Cloud Pak for Applications
type: string
required:
- accept
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2434,7 +2434,8 @@ spec:
- name
x-kubernetes-list-type: map
license:
description: License information is required.
description: The license must be reviewed and accepted before the
application can be deployed.
properties:
accept:
description: |-
Expand Down Expand Up @@ -2462,14 +2463,18 @@ spec:
type: string
productEntitlementSource:
description: 'Entitlement source for the product. Defaults to
Standalone. Other options: IBM Cloud Pak for Applications, IBM
WebSphere Application Server Family Edition, IBM WebSphere Hybrid
Edition'
Standalone. Other options: IBM Cloud Pak for Applications Advanced,
IBM Cloud Pak for Applications Standard, IBM WebSphere Hybrid
Edition, IBM WebSphere Application Server Family Edition. Option
IBM Cloud Pak for Applications is deprecated. Use option IBM
Cloud Pak for Applications Standard instead.'
enum:
- Standalone
- IBM Cloud Pak for Applications
- IBM WebSphere Application Server Family Edition
- IBM Cloud Pak for Applications Advanced
- IBM Cloud Pak for Applications Standard
- IBM WebSphere Hybrid Edition
- IBM WebSphere Application Server Family Edition
- IBM Cloud Pak for Applications
type: string
required:
- accept
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ spec:
path: autoscaling.maxReplicas
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
- displayName: License
- description: The license must be reviewed and accepted before the application
can be deployed.
displayName: License
path: license
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:text
Expand Down Expand Up @@ -503,8 +505,10 @@ spec:
displayName: Edition
path: license.edition
- description: 'Entitlement source for the product. Defaults to Standalone.
Other options: IBM Cloud Pak for Applications, IBM WebSphere Application
Server Family Edition, IBM WebSphere Hybrid Edition'
Other options: IBM Cloud Pak for Applications Advanced, IBM Cloud Pak for
Applications Standard, IBM WebSphere Hybrid Edition, IBM WebSphere Application
Server Family Edition. Option IBM Cloud Pak for Applications is deprecated.
Use option IBM Cloud Pak for Applications Standard instead.'
displayName: Product Entitlement Source
path: license.productEntitlementSource
- description: Deprecated. Charge metric code is now automatically determined
Expand Down
17 changes: 11 additions & 6 deletions internal/deploy/kubectl/websphereliberty-app-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2437,7 +2437,8 @@ spec:
- name
x-kubernetes-list-type: map
license:
description: License information is required.
description: The license must be reviewed and accepted before the
application can be deployed.
properties:
accept:
description: |-
Expand Down Expand Up @@ -2465,14 +2466,18 @@ spec:
type: string
productEntitlementSource:
description: 'Entitlement source for the product. Defaults to
Standalone. Other options: IBM Cloud Pak for Applications, IBM
WebSphere Application Server Family Edition, IBM WebSphere Hybrid
Edition'
Standalone. Other options: IBM Cloud Pak for Applications Advanced,
IBM Cloud Pak for Applications Standard, IBM WebSphere Hybrid
Edition, IBM WebSphere Application Server Family Edition. Option
IBM Cloud Pak for Applications is deprecated. Use option IBM
Cloud Pak for Applications Standard instead.'
enum:
- Standalone
- IBM Cloud Pak for Applications
- IBM WebSphere Application Server Family Edition
- IBM Cloud Pak for Applications Advanced
- IBM Cloud Pak for Applications Standard
- IBM WebSphere Hybrid Edition
- IBM WebSphere Application Server Family Edition
- IBM Cloud Pak for Applications
type: string
required:
- accept
Expand Down
17 changes: 11 additions & 6 deletions internal/deploy/kustomize/daily/base/websphere-liberty-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2437,7 +2437,8 @@ spec:
- name
x-kubernetes-list-type: map
license:
description: License information is required.
description: The license must be reviewed and accepted before the
application can be deployed.
properties:
accept:
description: |-
Expand Down Expand Up @@ -2465,14 +2466,18 @@ spec:
type: string
productEntitlementSource:
description: 'Entitlement source for the product. Defaults to
Standalone. Other options: IBM Cloud Pak for Applications, IBM
WebSphere Application Server Family Edition, IBM WebSphere Hybrid
Edition'
Standalone. Other options: IBM Cloud Pak for Applications Advanced,
IBM Cloud Pak for Applications Standard, IBM WebSphere Hybrid
Edition, IBM WebSphere Application Server Family Edition. Option
IBM Cloud Pak for Applications is deprecated. Use option IBM
Cloud Pak for Applications Standard instead.'
enum:
- Standalone
- IBM Cloud Pak for Applications
- IBM WebSphere Application Server Family Edition
- IBM Cloud Pak for Applications Advanced
- IBM Cloud Pak for Applications Standard
- IBM WebSphere Hybrid Edition
- IBM WebSphere Application Server Family Edition
- IBM Cloud Pak for Applications
type: string
required:
- accept
Expand Down
29 changes: 22 additions & 7 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ var editionProductID = map[wlv1.LicenseEdition]string{
}

var entitlementCloudPakID = map[wlv1.LicenseEntitlement]string{
wlv1.LicenseEntitlementCP4Apps: "4df52d2cdc374ba09f631a650ad2b5bf",
wlv1.LicenseEntitlementFamilyEdition: "be8ae84b3dd04d81b90af0d846849182",
wlv1.LicenseEntitlementWSHE: "6358611af04743f99f42dadcd6e39d52",
wlv1.LicenseEntitlementCP4AppsAdvanced: "217562c7767641d982cc6df6bcb5cb87",
wlv1.LicenseEntitlementCP4AppsStandard: "4df52d2cdc374ba09f631a650ad2b5bf",
wlv1.LicenseEntitlementWSHE: "6358611af04743f99f42dadcd6e39d52",
wlv1.LicenseEntitlementFamilyEdition: "be8ae84b3dd04d81b90af0d846849182",
wlv1.LicenseEntitlementCP4Apps: "4df52d2cdc374ba09f631a650ad2b5bf",
}

// Validate if the WebSpherLibertyApplication is valid
Expand Down Expand Up @@ -218,22 +220,35 @@ func CustomizeLicenseAnnotations(pts *corev1.PodTemplateSpec, la *wlv1.WebSphere
entitlement := la.Spec.License.ProductEntitlementSource

metricValue := "PROCESSOR_VALUE_UNIT"
if entitlement == wlv1.LicenseEntitlementWSHE || entitlement == wlv1.LicenseEntitlementCP4Apps {
if entitlement == wlv1.LicenseEntitlementCP4AppsAdvanced || entitlement == wlv1.LicenseEntitlementCP4AppsStandard || entitlement == wlv1.LicenseEntitlementWSHE || entitlement == wlv1.LicenseEntitlementCP4Apps {
metricValue = "VIRTUAL_PROCESSOR_CORE"
}
pts.Annotations[productMetricKey] = metricValue

ratio := ""
switch la.Spec.License.Edition {
case wlv1.LicenseEditionBase:
ratio = "4:1"
if entitlement == wlv1.LicenseEntitlementCP4AppsAdvanced {
ratio = "11:2"
} else {
ratio = "4:1"
}
case wlv1.LicenseEditionCore:
ratio = "8:1"
if entitlement == wlv1.LicenseEntitlementCP4AppsAdvanced {
ratio = "11:1"
} else {
ratio = "8:1"
}
case wlv1.LicenseEditionND:
ratio = "1:1"
if entitlement == wlv1.LicenseEntitlementCP4AppsAdvanced {
ratio = "3:2"
} else {
ratio = "1:1"
}
default:
ratio = "4:1"
}

pts.Annotations[productNameKey] = string(la.Spec.License.Edition)

if entitlement == wlv1.LicenseEntitlementStandalone {
Expand Down
Loading

0 comments on commit 3c8c999

Please sign in to comment.