|
13 | 13 | from ocp_resources.catalog_source import CatalogSource
|
14 | 14 | from ocp_resources.cluster_service_version import ClusterServiceVersion
|
15 | 15 | from ocp_resources.config_map import ConfigMap
|
| 16 | +from ocp_resources.data_science_cluster import DataScienceCluster |
16 | 17 | from ocp_resources.deployment import Deployment
|
| 18 | +from ocp_resources.dsc_initialization import DSCInitialization |
17 | 19 | from ocp_resources.exceptions import MissingResourceError
|
18 | 20 | from ocp_resources.inference_service import InferenceService
|
19 | 21 | from ocp_resources.infrastructure import Infrastructure
|
@@ -616,3 +618,59 @@ def get_product_version(admin_client: DynamicClient) -> Version:
|
616 | 618 | raise MissingResourceError("Operator ClusterServiceVersion not found")
|
617 | 619 |
|
618 | 620 | return Version.parse(operator_version)
|
| 621 | + |
| 622 | + |
| 623 | +def get_dsci_applications_namespace(client: DynamicClient, dsci_name: str = "default-dsci") -> str: |
| 624 | + """ |
| 625 | + Get the namespace where DSCI applications are deployed. |
| 626 | +
|
| 627 | + Args: |
| 628 | + client (DynamicClient): DynamicClient object |
| 629 | + dsci_name (str): DSCI name |
| 630 | +
|
| 631 | + Returns: |
| 632 | + str: Namespace where DSCI applications are deployed. |
| 633 | +
|
| 634 | + Raises: |
| 635 | + ValueError: If DSCI applications namespace not found |
| 636 | + MissingResourceError: If DSCI not found |
| 637 | +
|
| 638 | + """ |
| 639 | + dsci = DSCInitialization(client=client, name=dsci_name) |
| 640 | + |
| 641 | + if dsci.exists: |
| 642 | + if app_namespace := dsci.instance.spec.get("applicationsNamespace"): |
| 643 | + return app_namespace |
| 644 | + |
| 645 | + else: |
| 646 | + raise ValueError("DSCI applications namespace not found in {dsci_name}") |
| 647 | + |
| 648 | + raise MissingResourceError(f"DSCI {dsci_name} not found") |
| 649 | + |
| 650 | + |
| 651 | +def get_operator_distribution(client: DynamicClient, dsc_name: str = "default-dsc") -> str: |
| 652 | + """ |
| 653 | + Get the operator distribution. |
| 654 | +
|
| 655 | + Args: |
| 656 | + client (DynamicClient): DynamicClient object |
| 657 | + dsc_name (str): DSC name |
| 658 | +
|
| 659 | + Returns: |
| 660 | + str: Operator distribution. |
| 661 | +
|
| 662 | + Raises: |
| 663 | + ValueError: If DSC release name not found |
| 664 | + MissingResourceError: If DSC not found |
| 665 | +
|
| 666 | + """ |
| 667 | + dsc = DataScienceCluster(client=client, name=dsc_name) |
| 668 | + |
| 669 | + if dsc.exists: |
| 670 | + if dsc_release_name := dsc.instance.status.get("release", {}).get("name"): |
| 671 | + return dsc_release_name |
| 672 | + |
| 673 | + else: |
| 674 | + raise ValueError("DSC release name not found in {dsc_name}") |
| 675 | + |
| 676 | + raise MissingResourceError(f"DSC {dsc_name} not found") |
0 commit comments