Metadata-Version: 2.4
Name: mas-devops
Version: 9.18.0
Summary: Python for Maximo Application Suite Dev/Ops
Home-page: https://github.com/ibm-mas/python-devops
Author: David Parker
Author-email: parkerda@uk.ibm.com
License: Eclipse Public License - v1.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Communications
Classifier: Topic :: Internet
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pyyaml
Requires-Dist: openshift
Requires-Dist: kubernetes<36
Requires-Dist: kubeconfig
Requires-Dist: setuptools
Requires-Dist: jinja2
Requires-Dist: jinja2-base64-filters
Requires-Dist: semver
Requires-Dist: boto3
Requires-Dist: slack_sdk
Requires-Dist: packaging
Provides-Extra: dev
Requires-Dist: build; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-mock; extra == "dev"
Requires-Dist: requests-mock; extra == "dev"
Provides-Extra: docs
Requires-Dist: mkdocs; extra == "docs"
Requires-Dist: mkdocs-material; extra == "docs"
Requires-Dist: mkdocstrings[python]; extra == "docs"
Requires-Dist: pymdown-extensions; extra == "docs"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: summary

mas.devops
===============================================================================
[![Code style: PEP8](https://img.shields.io/badge/code%20style-PEP--8-blue.svg)](https://peps.python.org/pep-0008/)
[![Flake8: checked](https://img.shields.io/badge/flake8-checked-blueviolet)](https://flake8.pycqa.org/en/latest/)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/ibm-mas/python-devops/python-release.yml)
[![PyPI - Version](https://img.shields.io/pypi/v/mas.devops)](https://pypi.org/project/mas-devops)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mas.devops)
![PyPI - Downloads](https://img.shields.io/pypi/dm/mas.devops)


Example
-------------------------------------------------------------------------------
```python
from openshift import dynamic
from kubernetes import config
from kubernetes.client import api_client

from mas.devops.ocp import createNamespace
from mas.devops.tekton import installOpenShiftPipelines, updateTektonDefinitions, launchUpgradePipeline

instanceId = "mymas"
pipelinesNamespace = f"mas-{instanceId}-pipelines"

# Create an OpenShift client
dynClient = dynamic.DynamicClient(
    api_client.ApiClient(configuration=config.load_kube_config())
)

# Install OpenShift Pipelines Operator
installOpenShiftPipelines(dynamicClient)

# Create the pipelines namespace and install the MAS tekton definitions
createNamespace(dynamicClient, pipelinesNamespace)
updateTektonDefinitions(pipelinesNamespace, "/mascli/templates/ibm-mas-tekton.yaml")

# Launch the upgrade pipeline and print the URL to view the pipeline run
pipelineURL = launchUpgradePipeline(self.dynamicClient, instanceId)
print(pipelineURL)
```

mas-devops-create-initial-users
---------------------------------------------


Add to /etc/hosts
```
127.0.0.1               tgk01-masdev.mas-tgk01-manage.svc.cluster.local
127.0.0.1               coreapi.mas-tgk01-core.svc.cluster.local
127.0.0.1               admin-dashboard.mas-tgk01-core.svc.cluster.local
```

```bash
SM_AWS_REGION=""
SM_AWS_ACCESS_KEY_ID=""
SM_AWS_SECRET_ACCESS_KEY=""

aws configure set default.region ${SM_AWS_REGION}
aws configure set aws_access_key_id ${SM_AWS_ACCESS_KEY_ID}
aws configure set aws_secret_access_key ${SM_AWS_SECRET_ACCESS_KEY}


oc login --token=sha256~xxx --server=https://xxx:6443

oc port-forward service/admin-dashboard 8445:443 -n mas-tgk01-core
oc port-forward service/coreapi 8444:443 -n mas-tgk01-core
oc port-forward service/tgk01-masdev 8443:443 -n mas-tgk01-manage

mas-devops-create-initial-users-for-saas \
    --mas-instance-id tgk01 \
    --mas-workspace-id masdev \
    --log-level INFO \
    --initial-users-secret-name "aws-dev/noble4/tgk01/initial_users" \
    --manage-api-port 8443 \
    --coreapi-port 8444 \
    --admin-dashboard-port 8445
    

mas-devops-create-initial-users-for-saas \
    --mas-instance-id tgk01 \
    --mas-workspace-id masdev \
    --log-level INFO \
    --initial-users-yaml-file /home/tom/workspaces/notes/mascore3423/example-users-single.yaml \
    --manage-api-port 8443 \
    --coreapi-port 8444 \
    --admin-dashboard-port 8445
```

Example of initial_users secret:
```json
{"john.smith1@example.com":"primary,john1,smith1","john.smith2@example.com":"primary,john2,smith2","john.smith3@example.com":"secondary,john3,smith3"}
```
