OLM Module
The olm module provides functions for managing Operator Lifecycle Manager (OLM) operations.
olm
Functions
getPackageManifest(dynClient, packageName, catalogSourceNamespace='openshift-marketplace')
Get the PackageManifest for an operator package.
Retrieves package information including available channels and catalog source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynClient
|
DynamicClient
|
OpenShift Dynamic Client |
required |
packageName
|
str
|
Name of the operator package (e.g., "ibm-mas-operator") |
required |
catalogSourceNamespace
|
str
|
Namespace containing the catalog source. Defaults to "openshift-marketplace". |
'openshift-marketplace'
|
Returns:
| Name | Type | Description |
|---|---|---|
PackageManifest |
The package manifest resource, or None if not found |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If the package manifest is not found (caught and returns None) |
Source code in src/mas/devops/olm.py
ensureOperatorGroupExists(dynClient, env, namespace, installMode='OwnNamespace')
Ensure an OperatorGroup exists in the specified namespace.
Creates a new OperatorGroup if one doesn't already exist in the namespace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynClient
|
DynamicClient
|
OpenShift Dynamic Client |
required |
env
|
Environment
|
Jinja2 environment for template rendering |
required |
namespace
|
str
|
The namespace to check/create the OperatorGroup in |
required |
installMode
|
str
|
The install mode for the OperatorGroup. Defaults to "OwnNamespace". |
'OwnNamespace'
|
Returns:
| Type | Description |
|---|---|
|
None |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If resources cannot be accessed |
Source code in src/mas/devops/olm.py
getSubscription(dynClient, namespace, packageName)
Get the Subscription for an operator package in a namespace.
Searches for subscriptions using label selector based on package name and namespace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynClient
|
DynamicClient
|
OpenShift Dynamic Client |
required |
namespace
|
str
|
The namespace to search in |
required |
packageName
|
str
|
Name of the operator package |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Subscription |
The subscription resource, or None if not found |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If no subscription is found (returns None) |
Source code in src/mas/devops/olm.py
applySubscription(dynClient, namespace, packageName, packageChannel=None, catalogSource=None, catalogSourceNamespace='openshift-marketplace', config=None, installMode='OwnNamespace')
Create or update an operator subscription in a namespace.
Automatically detects default channel and catalog source from PackageManifest if not provided. Ensures an OperatorGroup exists before creating the subscription.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynClient
|
DynamicClient
|
OpenShift Dynamic Client |
required |
namespace
|
str
|
The namespace to create the subscription in |
required |
packageName
|
str
|
Name of the operator package (e.g., "ibm-mas-operator") |
required |
packageChannel
|
str
|
Subscription channel. Auto-detected if None. Defaults to None. |
None
|
catalogSource
|
str
|
Catalog source name. Auto-detected if None. Defaults to None. |
None
|
catalogSourceNamespace
|
str
|
Namespace of the catalog source. Defaults to "openshift-marketplace". |
'openshift-marketplace'
|
config
|
dict
|
Additional subscription configuration. Defaults to None. |
None
|
installMode
|
str
|
Install mode for the OperatorGroup. Defaults to "OwnNamespace". |
'OwnNamespace'
|
Returns:
| Name | Type | Description |
|---|---|---|
Subscription |
The created or updated subscription resource |
Raises:
| Type | Description |
|---|---|
OLMException
|
If the package is not available in any catalog |
NotFoundError
|
If resources cannot be created |
Source code in src/mas/devops/olm.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |