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', installPlanApproval=None, startingCSV=None)
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.
When installPlanApproval is set to "Manual" and a startingCSV is specified, this function will automatically approve the InstallPlan for the first-time installation to move to that startingCSV. Subsequent upgrades will still require manual approval.
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'
|
installPlanApproval
|
str
|
Install plan approval mode ("Automatic" or "Manual"). Defaults to None. |
None
|
startingCSV
|
str
|
The specific CSV version to install. When combined with Manual approval, the first InstallPlan to this CSV will be automatically approved. Required when installPlanApproval is "Manual". Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Subscription |
The created or updated subscription resource |
Raises:
| Type | Description |
|---|---|
OLMException
|
If the package is not available in any catalog, or if installPlanApproval is "Manual" without a startingCSV |
NotFoundError
|
If resources cannot be created |
Source code in src/mas/devops/olm.py
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 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | |