From 61e1bb6a678cfdb22ca65b5170e83ac189ff26e7 Mon Sep 17 00:00:00 2001 From: Kosta Mushkin Date: Fri, 25 Jul 2025 15:03:39 -0400 Subject: [PATCH] changed logging order --- examples/alerts_example.py | 9 +- examples/datastore_example.py | 15 +- examples/encryption_detection_example.py | 14 +- examples/events_example.py | 13 +- examples/exported_vpg_setting_modifyer.py | 17 ++ examples/license_example.py | 13 +- examples/localsite_example.py | 14 +- examples/peersites_example.py | 14 +- examples/server_date_time_example.py | 14 +- examples/service_profiles_example.py | 13 +- examples/tweaks_example.py | 13 +- examples/update_existing_vpgs_example.py | 4 +- examples/virtualization_sites_example.py | 15 +- examples/vms_example.py | 14 +- examples/volumes_example.py | 12 +- examples/vpg_failover_example.py | 10 +- examples/vpg_setting_export_example.py | 5 +- .../vpg_setting_export_example_enhanced.py | 3 +- examples/vpg_settings_journal_modifier.py | 18 +- examples/vpg_vms_example.py | 5 +- examples/vras_example.py | 15 +- examples/zorgs_example.py | 14 +- zvml/client.py | 7 - zvml/main.py | 2 - zvml/virtualization_sites.py | 249 +++++++++--------- zvml/vpgs.py | 2 +- zvml/zvml.py | 8 - 27 files changed, 269 insertions(+), 263 deletions(-) diff --git a/examples/alerts_example.py b/examples/alerts_example.py index 6c8b35f..5c3689d 100644 --- a/examples/alerts_example.py +++ b/examples/alerts_example.py @@ -35,13 +35,18 @@ Example Usage: --client_secret "your-secret-here" \ --ignore_ssl """ +# Configure logging BEFORE any imports +import logging +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s' +) import sys import os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import argparse -import logging import urllib3 import json from zvml import ZVMLClient @@ -57,8 +62,6 @@ def main(): parser.add_argument("--ignore_ssl", action="store_true", help="Ignore SSL certificate verification") args = parser.parse_args() - logging.basicConfig(level=logging.INFO) - try: # Connect to ZVM client = ZVMLClient( diff --git a/examples/datastore_example.py b/examples/datastore_example.py index 6d1c683..ba57dca 100644 --- a/examples/datastore_example.py +++ b/examples/datastore_example.py @@ -36,12 +36,17 @@ Example Usage: --ignore_ssl """ +# Configure logging BEFORE any imports +import logging +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s' +) + import sys import os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - import argparse -import logging import urllib3 import json from zvml import ZVMLClient @@ -57,12 +62,6 @@ def main(): parser.add_argument("--ignore_ssl", action="store_true", help="Ignore SSL certificate verification") args = parser.parse_args() - # Configure logging - logging.basicConfig( - level=logging.INFO, - format='%(asctime)s - %(levelname)s - %(message)s' - ) - try: # Connect to ZVM logging.info(f"Connecting to ZVM at {args.zvm_address}") diff --git a/examples/encryption_detection_example.py b/examples/encryption_detection_example.py index 802b8fd..609291c 100644 --- a/examples/encryption_detection_example.py +++ b/examples/encryption_detection_example.py @@ -5,12 +5,18 @@ # The author and Zerto further disclaim all implied warranties including, without limitation, # any implied warranties of merchantability or of fitness for a particular purpose. +# Configure logging BEFORE any imports +import logging +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s' +) + import argparse import sys import os import time import paramiko -import logging import urllib3 from zvml.client import Client from zvml.encryptiondetection import EncryptionDetection @@ -77,12 +83,6 @@ def main(): parser.add_argument("--vm_password", required=True, help="Linux VM password") args = parser.parse_args() - # Configure logging - logging.basicConfig( - level=logging.INFO, - format='%(asctime)s - %(levelname)s - %(message)s' - ) - try: # Setup client client = setup_client(args) diff --git a/examples/events_example.py b/examples/events_example.py index b1ea3ed..83a5b65 100644 --- a/examples/events_example.py +++ b/examples/events_example.py @@ -38,13 +38,18 @@ Example Usage: --client_secret \ --ignore_ssl """ +# Configure logging BEFORE any imports +import logging +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s' +) import sys import os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import argparse -import logging import urllib3 import json from zvml import ZVMLClient @@ -61,12 +66,6 @@ def main(): parser.add_argument("--ignore_ssl", action="store_true", help="Ignore SSL certificate verification") args = parser.parse_args() - # Configure logging - logging.basicConfig( - level=logging.INFO, - format='%(asctime)s - %(levelname)s - %(message)s' - ) - try: # Connect to ZVM logging.info(f"Connecting to ZVM at {args.zvm_address}") diff --git a/examples/exported_vpg_setting_modifyer.py b/examples/exported_vpg_setting_modifyer.py index 46051a4..9ae982d 100644 --- a/examples/exported_vpg_setting_modifyer.py +++ b/examples/exported_vpg_setting_modifyer.py @@ -1,3 +1,20 @@ +# Legal Disclaimer +# This script is an example script and is not supported under any Zerto support program or service. +# The author and Zerto further disclaim all implied warranties including, without limitation, +# any implied warranties of merchantability or of fitness for a particular purpose. +# In no event shall Zerto, its authors or anyone else involved in the creation, +# production or delivery of the scripts be liable for any damages whatsoever (including, +# without limitation, damages for loss of business profits, business interruption, loss of business +# information, or other pecuniary loss) arising out of the use of or the inability to use the sample +# scripts or documentation, even if the author or Zerto has been advised of the possibility of such damages. +# The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. + +# Configure logging BEFORE any imports +import logging +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s' +) import json import argparse import sys diff --git a/examples/license_example.py b/examples/license_example.py index e359aa5..c3cc97a 100644 --- a/examples/license_example.py +++ b/examples/license_example.py @@ -38,13 +38,18 @@ Example Usage: --license_key \ --ignore_ssl """ +# Configure logging BEFORE any imports +import logging +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s' +) import sys import os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import argparse -import logging import urllib3 import json from zvml import ZVMLClient @@ -61,12 +66,6 @@ def main(): parser.add_argument("--ignore_ssl", action="store_true", help="Ignore SSL certificate verification") args = parser.parse_args() - # Configure logging - logging.basicConfig( - level=logging.INFO, - format='%(asctime)s - %(levelname)s - %(message)s' - ) - try: # Connect to ZVM logging.info(f"Connecting to ZVM at {args.zvm_address}") diff --git a/examples/localsite_example.py b/examples/localsite_example.py index a1fe9d1..984dcba 100644 --- a/examples/localsite_example.py +++ b/examples/localsite_example.py @@ -40,13 +40,17 @@ Example Usage: --client_secret \ --ignore_ssl """ +# Configure logging BEFORE any imports +import logging +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s' +) import sys import os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - import argparse -import logging import urllib3 import json from zvml import ZVMLClient @@ -62,12 +66,6 @@ def main(): parser.add_argument("--ignore_ssl", action="store_true", help="Ignore SSL certificate verification") args = parser.parse_args() - # Configure logging - logging.basicConfig( - level=logging.INFO, - format='%(asctime)s - %(levelname)s - %(message)s' - ) - try: # Connect to ZVM logging.info(f"Connecting to ZVM at {args.zvm_address}") diff --git a/examples/peersites_example.py b/examples/peersites_example.py index 8fa1c91..30d006e 100644 --- a/examples/peersites_example.py +++ b/examples/peersites_example.py @@ -43,13 +43,17 @@ Example Usage: --site2_client_secret \ --ignore_ssl """ +# Configure logging BEFORE any imports +import logging +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s' +) import sys import os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - import argparse -import logging import urllib3 import json import time @@ -69,12 +73,6 @@ def main(): parser.add_argument("--ignore_ssl", action="store_true", help="Ignore SSL certificate verification") args = parser.parse_args() - # Configure logging - logging.basicConfig( - level=logging.INFO, - format='%(asctime)s - %(levelname)s - %(message)s' - ) - try: # Initialize the site 1 client site1_client = ZVMLClient( diff --git a/examples/server_date_time_example.py b/examples/server_date_time_example.py index 15f13ab..9a04f54 100644 --- a/examples/server_date_time_example.py +++ b/examples/server_date_time_example.py @@ -37,13 +37,17 @@ Example Usage: --client_secret \ --ignore_ssl """ +# Configure logging BEFORE any imports +import logging +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s' +) import sys import os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - import argparse -import logging import urllib3 from zvml import ZVMLClient from zvml.server_date_time import DateTimeFormat @@ -59,12 +63,6 @@ def main(): parser.add_argument("--ignore_ssl", action="store_true", help="Ignore SSL certificate verification") args = parser.parse_args() - # Configure logging - logging.basicConfig( - level=logging.INFO, - format='%(asctime)s - %(levelname)s - %(message)s' - ) - try: # Connect to ZVM logging.info(f"Connecting to ZVM at {args.zvm_address}") diff --git a/examples/service_profiles_example.py b/examples/service_profiles_example.py index a780461..a46d2c4 100644 --- a/examples/service_profiles_example.py +++ b/examples/service_profiles_example.py @@ -42,11 +42,16 @@ Example Usage: --site_identifier \ --ignore_ssl """ +# Configure logging BEFORE any imports +import logging +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s' +) import sys import os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - import argparse import logging import urllib3 @@ -65,12 +70,6 @@ def main(): parser.add_argument("--ignore_ssl", action="store_true", help="Ignore SSL certificate verification") args = parser.parse_args() - # Configure logging - logging.basicConfig( - level=logging.INFO, - format='%(asctime)s - %(levelname)s - %(message)s' - ) - try: # Connect to ZVM logging.info(f"Connecting to ZVM at {args.zvm_address}") diff --git a/examples/tweaks_example.py b/examples/tweaks_example.py index 4804015..a1e5de5 100644 --- a/examples/tweaks_example.py +++ b/examples/tweaks_example.py @@ -40,8 +40,13 @@ Example Usage: --ignore_ssl """ -import argparse +# Configure logging BEFORE any imports import logging +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s' +) +import argparse import urllib3 import json import sys @@ -135,12 +140,6 @@ def main(): parser.add_argument("--ignore_ssl", action="store_true", help="Ignore SSL certificate verification") args = parser.parse_args() - # Configure logging - logging.basicConfig( - level=logging.INFO, - format='%(asctime)s - %(levelname)s - %(message)s' - ) - try: # Setup client client = setup_client(args) diff --git a/examples/update_existing_vpgs_example.py b/examples/update_existing_vpgs_example.py index cfc38c4..49cca96 100644 --- a/examples/update_existing_vpgs_example.py +++ b/examples/update_existing_vpgs_example.py @@ -43,13 +43,13 @@ Example Usage: --client_secret \ --ignore_ssl """ - -import argparse +# Configure logging BEFORE any imports import logging logging.basicConfig( level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s' ) +import argparse import urllib3 import sys import os diff --git a/examples/virtualization_sites_example.py b/examples/virtualization_sites_example.py index 353d0fd..e404492 100644 --- a/examples/virtualization_sites_example.py +++ b/examples/virtualization_sites_example.py @@ -44,13 +44,16 @@ Example Usage: --client_secret \ --ignore_ssl """ - +# Configure logging BEFORE any imports +import logging +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s' +) import sys import os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - import argparse -import logging import urllib3 import json from zvml import ZVMLClient @@ -66,12 +69,6 @@ def main(): parser.add_argument("--ignore_ssl", action="store_true", help="Ignore SSL certificate verification") args = parser.parse_args() - # Configure logging - logging.basicConfig( - level=logging.INFO, - format='%(asctime)s - %(levelname)s - %(message)s' - ) - try: # Initialize the client client = ZVMLClient( diff --git a/examples/vms_example.py b/examples/vms_example.py index 75d097f..1cd4781 100644 --- a/examples/vms_example.py +++ b/examples/vms_example.py @@ -56,13 +56,17 @@ Note: VM restore functionality is commented out in this example as it may return # NOTE # this example assumes that at least one VPG exists on the ZVM and protected VMs exist in the VPG # the vm restore is commnted out as it fails with a 500 - +# Configure logging BEFORE any imports +import logging +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s' +) import sys import os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import argparse -import logging import urllib3 import json from zvml import ZVMLClient @@ -79,12 +83,6 @@ def main(): parser.add_argument("--ignore_ssl", action="store_true", help="Ignore SSL certificate verification") args = parser.parse_args() - # Configure logging - logging.basicConfig( - level=logging.INFO, - format='%(asctime)s - %(levelname)s - %(message)s' - ) - try: # Connect to ZVM logging.info(f"Connecting to ZVM at {args.zvm_address}") diff --git a/examples/volumes_example.py b/examples/volumes_example.py index a1fa7fe..a8e01ae 100644 --- a/examples/volumes_example.py +++ b/examples/volumes_example.py @@ -46,14 +46,17 @@ Example Usage: Note: This script focuses on volume operations and requires only Site 1 credentials since it performs read-only operations on the protected site. """ - +# Configure logging BEFORE any imports +import logging +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s' +) import sys import os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - import urllib3 import argparse -import logging import json from zvml import ZVMLClient @@ -68,9 +71,6 @@ def main(): parser.add_argument("--ignore_ssl", action="store_true", help="Ignore SSL certificate verification") args = parser.parse_args() - # Configure logging - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - try: # Initialize the client client = ZVMLClient(args.zvm_address, args.client_id, args.client_secret, not args.ignore_ssl) diff --git a/examples/vpg_failover_example.py b/examples/vpg_failover_example.py index 3b37e96..5d5515b 100644 --- a/examples/vpg_failover_example.py +++ b/examples/vpg_failover_example.py @@ -69,13 +69,17 @@ Script Flow: 8. Generates test reports 9. Cleans up by deleting both VPGs """ +# Configure logging BEFORE any imports +import logging +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s' +) import sys import os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - import argparse -import logging import urllib3 import json from zvml import ZVMLClient @@ -223,8 +227,6 @@ def main(): parser.add_argument("--ignore_ssl", action="store_true", help="Ignore SSL certificate verification") args = parser.parse_args() - logging.basicConfig(level=logging.DEBUG) - try: vpg_structure = [ { diff --git a/examples/vpg_setting_export_example.py b/examples/vpg_setting_export_example.py index 27ca55d..dc5721a 100644 --- a/examples/vpg_setting_export_example.py +++ b/examples/vpg_setting_export_example.py @@ -71,12 +71,13 @@ Note: This script requires only protected site credentials. It's designed for VP configuration backup and restore scenarios, allowing you to quickly recreate VPGs with identical settings after changes or in disaster recovery situations. """ -import argparse +# Configure logging BEFORE any imports import logging logging.basicConfig( - level=logging.DEBUG, + level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s' ) +import argparse import urllib3 import json import sys diff --git a/examples/vpg_setting_export_example_enhanced.py b/examples/vpg_setting_export_example_enhanced.py index f7d2020..eb33ebc 100644 --- a/examples/vpg_setting_export_example_enhanced.py +++ b/examples/vpg_setting_export_example_enhanced.py @@ -69,12 +69,13 @@ Note: This script requires only protected site credentials. It's designed for VP configuration backup and restore scenarios, allowing you to quickly recreate VPGs with identical settings after changes or in disaster recovery situations. """ -import argparse +# Configure logging BEFORE any imports import logging logging.basicConfig( level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s' ) +import argparse import urllib3 import json import sys diff --git a/examples/vpg_settings_journal_modifier.py b/examples/vpg_settings_journal_modifier.py index d68ea3d..d000d53 100644 --- a/examples/vpg_settings_journal_modifier.py +++ b/examples/vpg_settings_journal_modifier.py @@ -1,5 +1,21 @@ -import argparse +# Legal Disclaimer +# This script is an example script and is not supported under any Zerto support program or service. +# The author and Zerto further disclaim all implied warranties including, without limitation, +# any implied warranties of merchantability or of fitness for a particular purpose. +# In no event shall Zerto, its authors or anyone else involved in the creation, +# production or delivery of the scripts be liable for any damages whatsoever (including, +# without limitation, damages for loss of business profits, business interruption, loss of business +# information, or other pecuniary loss) arising out of the use of or the inability to use the sample +# scripts or documentation, even if the author or Zerto has been advised of the possibility of such damages. +# The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. + +# Configure logging BEFORE any imports import logging +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s' +) +import argparse import urllib3 import json import sys diff --git a/examples/vpg_vms_example.py b/examples/vpg_vms_example.py index 4162991..8b2a7c6 100644 --- a/examples/vpg_vms_example.py +++ b/examples/vpg_vms_example.py @@ -57,13 +57,12 @@ Script Flow: 8. Cleans up by deleting both VPGs """ +# Configure logging BEFORE any imports import logging -# Configure logging before any other imports or code logging.basicConfig( level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s' ) - import argparse import urllib3 import json @@ -106,6 +105,8 @@ def main(): parser.add_argument("--vm2", required=True, help="Name of second VM to protect") args = parser.parse_args() + logging.warning("TEST TEST TEST") + try: # Setup clients and get site identifiers client1 = setup_clients(args) diff --git a/examples/vras_example.py b/examples/vras_example.py index a26a47d..dc30143 100644 --- a/examples/vras_example.py +++ b/examples/vras_example.py @@ -59,10 +59,13 @@ confirmation. It demonstrates proper error handling and logging for VRA manageme operations. """ -#!/usr/bin/python3 -import argparse +# Configure logging BEFORE any imports import logging -# logging.basicConfig(level=logging.DEBUG) +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s' +) +import argparse import urllib3 import json import sys @@ -206,12 +209,6 @@ def main(): parser.add_argument("--ignore_ssl", action="store_true", help="Ignore SSL certificate verification") args = parser.parse_args() - # Configure logging - logging.basicConfig( - level=logging.INFO, - format='%(asctime)s - %(levelname)s - %(message)s' - ) - try: # Setup client client = setup_client(args) diff --git a/examples/zorgs_example.py b/examples/zorgs_example.py index 309c899..a342f85 100644 --- a/examples/zorgs_example.py +++ b/examples/zorgs_example.py @@ -60,13 +60,17 @@ Script Flow: Note: This script demonstrates basic ZORG management capabilities and can be used as a foundation for more complex ZORG operations and automation. """ - +# Configure logging BEFORE any imports +import logging +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s' +) import sys import os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import argparse -import logging import urllib3 import json from zvml import ZVMLClient @@ -83,12 +87,6 @@ def main(): parser.add_argument("--zorg_id", help="Optional: Specific ZORG ID to query") args = parser.parse_args() - # Configure logging - logging.basicConfig( - level=logging.INFO, - format='%(asctime)s - %(levelname)s - %(message)s' - ) - try: # Connect to ZVM logging.info(f"Connecting to ZVM at {args.zvm_address}") diff --git a/zvml/client.py b/zvml/client.py index 7bbbde5..836e6df 100644 --- a/zvml/client.py +++ b/zvml/client.py @@ -13,13 +13,6 @@ import requests import logging import ssl -# Configure logging with timestamp format -logging.basicConfig( - level=logging.INFO, - format='%(asctime)s - %(levelname)s - %(message)s', - datefmt='%Y-%m-%d %H:%M:%S' -) - # Import all necessary classes from .tasks import Tasks from .vpgs import VPGs diff --git a/zvml/main.py b/zvml/main.py index 682f976..d8465cd 100644 --- a/zvml/main.py +++ b/zvml/main.py @@ -20,8 +20,6 @@ def main(): parser.add_argument("--password", required=True, help="Password") args = parser.parse_args() - logging.basicConfig(level=logging.INFO) - try: client = ZVMLClient(zvm_address=args.zvm_address, username=args.username, password=args.password) # Example usage diff --git a/zvml/virtualization_sites.py b/zvml/virtualization_sites.py index 8375a67..5685f29 100644 --- a/zvml/virtualization_sites.py +++ b/zvml/virtualization_sites.py @@ -12,6 +12,9 @@ import requests import logging +# Create module-specific logger +logger = logging.getLogger(__name__) + class VirtualizationSites: def __init__(self, client): self.client = client @@ -34,9 +37,9 @@ class VirtualizationSites: url = f"https://{self.client.zvm_address}/v1/virtualizationsites" if site_identifier: url = f"{url}/{site_identifier}" - logging.info(f"VirtualizationSites.get_virtualization_sites: Fetching site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_sites: Fetching site {site_identifier}...") else: - logging.info("VirtualizationSites.get_virtualization_sites: Fetching all virtualization sites...") + logger.info("VirtualizationSites.get_virtualization_sites: Fetching all virtualization sites...") headers = { 'Content-Type': 'application/json', @@ -49,14 +52,14 @@ class VirtualizationSites: return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_vms(self, site_identifier): @@ -81,21 +84,21 @@ class VirtualizationSites: 'Authorization': f'Bearer {self.client.token}' } - logging.info(f"VirtualizationSites.get_virtualization_site_vms: Fetching VMs for site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_vms: Fetching VMs for site {site_identifier}...") try: response = requests.get(url, headers=headers, verify=self.client.verify_certificate) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_vcd_vapps(self, site_identifier): @@ -120,21 +123,21 @@ class VirtualizationSites: 'Authorization': f'Bearer {self.client.token}' } - logging.info(f"VirtualizationSites.get_virtualization_site_vcd_vapps: Fetching VCD vApps for site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_vcd_vapps: Fetching VCD vApps for site {site_identifier}...") try: response = requests.get(url, headers=headers, verify=self.client.verify_certificate) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_datastores(self, site_identifier): @@ -159,21 +162,21 @@ class VirtualizationSites: 'Authorization': f'Bearer {self.client.token}' } - logging.info(f"VirtualizationSites.get_virtualization_site_datastores: Fetching datastores for site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_datastores: Fetching datastores for site {site_identifier}...") try: response = requests.get(url, headers=headers, verify=self.client.verify_certificate) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_folders(self, site_identifier): @@ -198,21 +201,21 @@ class VirtualizationSites: 'Authorization': f'Bearer {self.client.token}' } - logging.info(f"VirtualizationSites.get_virtualization_site_folders: Fetching folders for site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_folders: Fetching folders for site {site_identifier}...") try: response = requests.get(url, headers=headers, verify=self.client.verify_certificate) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_datastore_clusters(self, site_identifier): @@ -237,21 +240,21 @@ class VirtualizationSites: 'Authorization': f'Bearer {self.client.token}' } - logging.info(f"VirtualizationSites.get_virtualization_site_datastore_clusters: Fetching datastore clusters for site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_datastore_clusters: Fetching datastore clusters for site {site_identifier}...") try: response = requests.get(url, headers=headers, verify=self.client.verify_certificate) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_resource_pools(self, site_identifier): @@ -276,21 +279,21 @@ class VirtualizationSites: 'Authorization': f'Bearer {self.client.token}' } - logging.info(f"VirtualizationSites.get_virtualization_site_resource_pools: Fetching resource pools for site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_resource_pools: Fetching resource pools for site {site_identifier}...") try: response = requests.get(url, headers=headers, verify=self.client.verify_certificate) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_org_vdcs(self, site_identifier): @@ -315,21 +318,21 @@ class VirtualizationSites: 'Authorization': f'Bearer {self.client.token}' } - logging.info(f"VirtualizationSites.get_virtualization_site_org_vdcs: Fetching org VDCs for site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_org_vdcs: Fetching org VDCs for site {site_identifier}...") try: response = requests.get(url, headers=headers, verify=self.client.verify_certificate) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_networks(self, site_identifier): @@ -354,21 +357,21 @@ class VirtualizationSites: 'Authorization': f'Bearer {self.client.token}' } - logging.info(f"VirtualizationSites.get_virtualization_site_networks: Fetching networks for site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_networks: Fetching networks for site {site_identifier}...") try: response = requests.get(url, headers=headers, verify=self.client.verify_certificate) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_hosts(self, site_identifier, host_identifier=None): @@ -393,9 +396,9 @@ class VirtualizationSites: url = f"https://{self.client.zvm_address}/v1/virtualizationsites/{site_identifier}/hosts" if host_identifier: url = f"{url}/{host_identifier}" - logging.info(f"VirtualizationSites.get_virtualization_site_hosts: Fetching host {host_identifier} from site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_hosts: Fetching host {host_identifier} from site {site_identifier}...") else: - logging.info(f"VirtualizationSites.get_virtualization_site_hosts: Fetching all hosts for site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_hosts: Fetching all hosts for site {site_identifier}...") headers = { 'Content-Type': 'application/json', @@ -408,14 +411,14 @@ class VirtualizationSites: return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_repositories(self, site_identifier): @@ -440,21 +443,21 @@ class VirtualizationSites: 'Authorization': f'Bearer {self.client.token}' } - logging.info(f"VirtualizationSites.get_virtualization_site_repositories: Fetching repositories for site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_repositories: Fetching repositories for site {site_identifier}...") try: response = requests.get(url, headers=headers, verify=self.client.verify_certificate) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_host_clusters(self, site_identifier): @@ -479,21 +482,21 @@ class VirtualizationSites: 'Authorization': f'Bearer {self.client.token}' } - logging.info(f"VirtualizationSites.get_virtualization_site_host_clusters: Fetching host clusters for site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_host_clusters: Fetching host clusters for site {site_identifier}...") try: response = requests.get(url, headers=headers, verify=self.client.verify_certificate) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_org_vdc_networks(self, site_identifier, org_vdc_identifier): @@ -519,21 +522,21 @@ class VirtualizationSites: 'Authorization': f'Bearer {self.client.token}' } - logging.info(f"VirtualizationSites.get_virtualization_site_org_vdc_networks: Fetching networks for org VDC {org_vdc_identifier} in site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_org_vdc_networks: Fetching networks for org VDC {org_vdc_identifier} in site {site_identifier}...") try: response = requests.get(url, headers=headers, verify=self.client.verify_certificate) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_org_vdc_storage_policies(self, site_identifier, org_vdc_identifier): @@ -559,21 +562,21 @@ class VirtualizationSites: 'Authorization': f'Bearer {self.client.token}' } - logging.info(f"VirtualizationSites.get_virtualization_site_org_vdc_storage_policies: Fetching storage policies for org VDC {org_vdc_identifier} in site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_org_vdc_storage_policies: Fetching storage policies for org VDC {org_vdc_identifier} in site {site_identifier}...") try: response = requests.get(url, headers=headers, verify=self.client.verify_certificate) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_devices(self, site_identifier, host_identifier=None, device_name=None): @@ -612,21 +615,21 @@ class VirtualizationSites: 'Authorization': f'Bearer {self.client.token}' } - logging.info(f"VirtualizationSites.get_virtualization_site_devices: Fetching devices for site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_devices: Fetching devices for site {site_identifier}...") try: response = requests.get(url, headers=headers, params=params, verify=self.client.verify_certificate) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_public_cloud_networks(self, site_identifier): @@ -651,21 +654,21 @@ class VirtualizationSites: 'Authorization': f'Bearer {self.client.token}' } - logging.info(f"VirtualizationSites.get_virtualization_site_public_cloud_networks: Fetching public cloud virtual networks for site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_public_cloud_networks: Fetching public cloud virtual networks for site {site_identifier}...") try: response = requests.get(url, headers=headers, verify=self.client.verify_certificate) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_public_cloud_subnets(self, site_identifier): @@ -690,21 +693,21 @@ class VirtualizationSites: 'Authorization': f'Bearer {self.client.token}' } - logging.info(f"VirtualizationSites.get_virtualization_site_public_cloud_subnets: Fetching public cloud subnets for site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_public_cloud_subnets: Fetching public cloud subnets for site {site_identifier}...") try: response = requests.get(url, headers=headers, verify=self.client.verify_certificate) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_public_cloud_security_groups(self, site_identifier): @@ -729,21 +732,21 @@ class VirtualizationSites: 'Authorization': f'Bearer {self.client.token}' } - logging.info(f"VirtualizationSites.get_virtualization_site_public_cloud_security_groups: Fetching public cloud security groups for site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_public_cloud_security_groups: Fetching public cloud security groups for site {site_identifier}...") try: response = requests.get(url, headers=headers, verify=self.client.verify_certificate) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_public_cloud_vm_instance_types(self, site_identifier): @@ -768,21 +771,21 @@ class VirtualizationSites: 'Authorization': f'Bearer {self.client.token}' } - logging.info(f"VirtualizationSites.get_virtualization_site_public_cloud_vm_instance_types: Fetching VM instance types for site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_public_cloud_vm_instance_types: Fetching VM instance types for site {site_identifier}...") try: response = requests.get(url, headers=headers, verify=self.client.verify_certificate) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_public_cloud_resource_groups(self, site_identifier): @@ -807,21 +810,21 @@ class VirtualizationSites: 'Authorization': f'Bearer {self.client.token}' } - logging.info(f"VirtualizationSites.get_virtualization_site_public_cloud_resource_groups: Fetching resource groups for site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_public_cloud_resource_groups: Fetching resource groups for site {site_identifier}...") try: response = requests.get(url, headers=headers, verify=self.client.verify_certificate) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_public_cloud_keys_containers(self, site_identifier): @@ -846,21 +849,21 @@ class VirtualizationSites: 'Authorization': f'Bearer {self.client.token}' } - logging.info(f"VirtualizationSites.get_virtualization_site_public_cloud_keys_containers: Fetching keys containers for site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_public_cloud_keys_containers: Fetching keys containers for site {site_identifier}...") try: response = requests.get(url, headers=headers, verify=self.client.verify_certificate) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_public_cloud_encryption_keys(self, site_identifier, encryption_key_id=None): @@ -885,9 +888,9 @@ class VirtualizationSites: url = f"https://{self.client.zvm_address}/v1/virtualizationsites/{site_identifier}/publiccloud/encryptionkeys" if encryption_key_id: url = f"{url}/{encryption_key_id}" - logging.info(f"VirtualizationSites.get_virtualization_site_public_cloud_encryption_keys: Fetching encryption key {encryption_key_id} for site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_public_cloud_encryption_keys: Fetching encryption key {encryption_key_id} for site {site_identifier}...") else: - logging.info(f"VirtualizationSites.get_virtualization_site_public_cloud_encryption_keys: Fetching all encryption keys for site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_public_cloud_encryption_keys: Fetching all encryption keys for site {site_identifier}...") headers = { 'Content-Type': 'application/json', @@ -900,14 +903,14 @@ class VirtualizationSites: return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_public_cloud_managed_identities(self, site_identifier): @@ -932,21 +935,21 @@ class VirtualizationSites: 'Authorization': f'Bearer {self.client.token}' } - logging.info(f"VirtualizationSites.get_virtualization_site_public_cloud_managed_identities: Fetching managed identities for site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_public_cloud_managed_identities: Fetching managed identities for site {site_identifier}...") try: response = requests.get(url, headers=headers, verify=self.client.verify_certificate) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise def get_virtualization_site_public_cloud_disk_encryption_keys(self, site_identifier): @@ -971,19 +974,19 @@ class VirtualizationSites: 'Authorization': f'Bearer {self.client.token}' } - logging.info(f"VirtualizationSites.get_virtualization_site_public_cloud_disk_encryption_keys: Fetching disk encryption keys for site {site_identifier}...") + logger.info(f"VirtualizationSites.get_virtualization_site_public_cloud_disk_encryption_keys: Fetching disk encryption keys for site {site_identifier}...") try: response = requests.get(url, headers=headers, verify=self.client.verify_certificate) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: if e.response is not None: - logging.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") + logger.error(f"HTTPError: {e.response.status_code} - {e.response.reason}") try: error_details = e.response.json() - logging.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") + logger.error(f"Error Message: {error_details.get('Message', 'No detailed error message available')}") except ValueError: - logging.error(f"Response content: {e.response.text}") + logger.error(f"Response content: {e.response.text}") else: - logging.error("HTTPError occurred with no response attached.") + logger.error("HTTPError occurred with no response attached.") raise \ No newline at end of file diff --git a/zvml/vpgs.py b/zvml/vpgs.py index acf0b25..4cc1605 100644 --- a/zvml/vpgs.py +++ b/zvml/vpgs.py @@ -136,7 +136,7 @@ class VPGs: logging.error("HTTPError occurred with no response attached.") raise - def commit_vpg(self, vpg_settings_id, vpg_name, sync=False, expected_status=ZertoVPGStatus.Initializing, timeout=30, interval=5): + def commit_vpg(self, vpg_settings_id, vpg_name, sync=False, expected_status=ZertoVPGStatus.Initializing, timeout=60, interval=5): logging.info(f'VPGs.commit_vpg(zvm_address={self.client.zvm_address}, vpg_settings_id={vpg_settings_id}, vpg_name={vpg_name}, sync={sync})') commit_uri = f"https://{self.client.zvm_address}/v1/vpgSettings/{vpg_settings_id}/commit" headers = { diff --git a/zvml/zvml.py b/zvml/zvml.py index 2455deb..162cb02 100644 --- a/zvml/zvml.py +++ b/zvml/zvml.py @@ -12,14 +12,6 @@ import requests import logging import ssl - -# Configure logging with timestamp format -logging.basicConfig( - level=logging.INFO, - format='%(asctime)s - %(levelname)s - %(message)s', - datefmt='%Y-%m-%d %H:%M:%S' -) - # Import all necessary classes from .tasks import Tasks from .vpgs import VPGs