ChinmayHegde24 commented on code in PR #583: URL: https://github.com/apache/ranger/pull/583#discussion_r2136293433
########## dev-support/ranger-docker/scripts/ranger-plugin-status.py: ########## @@ -0,0 +1,142 @@ +#!/usr/bin/env python3 + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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 +# +# http://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. + +import os +import requests +import time +import json +from dotenv import load_dotenv + +# Load environment variables from .env +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) + +# Path to the .env file in the parent directory +ENV_PATH = os.path.join(SCRIPT_DIR, "..", ".env") + +# Load it +load_dotenv(dotenv_path=ENV_PATH) + +RANGER_HOST = "http://localhost:6080" +ENDPOINT = f"{RANGER_HOST}/service/public/v2/api/plugins/info" +KNOX_ENDPOINT = "https://localhost:8443/gateway/sandbox/webhdfs/v1/?op=LISTSTATUS" + +RANGER_ADMIN_USER = os.getenv("RANGER_ADMIN_USER") +RANGER_ADMIN_PASS = os.getenv("RANGER_ADMIN_PASS") +KNOX_USER = os.getenv("KNOX_USER") +KNOX_PASS = os.getenv("KNOX_PASS") + +expected_services = ["hdfs", "hbase", "kms", "yarn", "kafka", "ozone", "knox", "hive"] + + +def trigger_knox_activity(): + print("\nTriggering Knox activity to ensure plugin status is updated...") + try: + response = requests.get( + KNOX_ENDPOINT, + auth=(KNOX_USER,KNOX_PASS), + verify=False, + timeout=10 + ) + print("Knox activity triggered.") + except requests.RequestException as e: + print(f"Failed to trigger Knox activity: {e}") + +def fetch_plugin_info(): + print(f"\nFetching plugin info from {ENDPOINT} ...") + try: + response = requests.get( Review Comment: Yes I've made these changes please check once -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@ranger.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org