Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cluster and cluster_info results object and API #228

Merged
merged 6 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions plugins/module_utils/cluster_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2024 Cloudera, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
A common functions for Cloudera Manager cluster management
"""

from ansible_collections.cloudera.cluster.plugins.module_utils.cm_utils import (
_parse_output,
)

from cm_client import ApiCluster


CLUSTER_OUTPUT = [
"name",
"display_name",
# "full_version",
"maintenance_mode",
"maintenance_owners",
# "services",
# "parcels",
"entity_status",
"uuid",
# "data_context_refs",
"cluster_type",
"tags",
]


def parse_cluster_result(cluster: ApiCluster) -> dict:
# Retrieve full_version as version
output = dict(version=cluster.full_version)
output.update(_parse_output(cluster.to_dict(), CLUSTER_OUTPUT))
return output
25 changes: 0 additions & 25 deletions plugins/module_utils/cm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
ApiParcel,
ApiRole,
ApiRoleConfigGroup,
ApiService,
Configuration,
)
from cm_client.rest import ApiException, RESTClientObject
Expand All @@ -49,23 +48,6 @@
__credits__ = ["frisch@cloudera.com"]
__maintainer__ = ["wmudge@cloudera.com"]


SERVICE_OUTPUT = [
"client_config_staleness_status",
# "cluster_ref",
"config_staleness_status",
"display_name",
"health_checks",
"health_summary",
"maintenance_mode",
"maintenance_owners",
"name",
"service_state",
"service_version",
"tags",
"type",
]

ROLE_OUTPUT = [
"commission_state",
"config_staleness_status",
Expand Down Expand Up @@ -114,13 +96,6 @@ def _parse_output(entity: dict, filter: list) -> dict:
return output


def parse_service_result(service: ApiService) -> dict:
# Retrieve only the cluster_name
output = dict(cluster_name=service.cluster_ref.cluster_name)
output.update(_parse_output(service.to_dict(), SERVICE_OUTPUT))
return output


def parse_role_result(role: ApiRole) -> dict:
# Retrieve only the host_id, role_config_group, and service identifiers
output = dict(
Expand Down
46 changes: 46 additions & 0 deletions plugins/module_utils/service_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2024 Cloudera, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
A common functions for Cloudera Manager service management
"""

from ansible_collections.cloudera.cluster.plugins.module_utils.cm_utils import (
_parse_output,
)

from cm_client import ApiService

SERVICE_OUTPUT = [
"client_config_staleness_status",
# "cluster_ref",
"config_staleness_status",
"display_name",
"health_checks",
"health_summary",
"maintenance_mode",
"maintenance_owners",
"name",
"service_state",
"service_version",
"tags",
"type",
]


def parse_service_result(service: ApiService) -> dict:
# Retrieve only the cluster_name
output = dict(cluster_name=service.cluster_ref.cluster_name)
output.update(_parse_output(service.to_dict(), SERVICE_OUTPUT))
return output
Loading
Loading