logging
This commit is contained in:
		| @@ -571,6 +571,10 @@ class CertPusher: | |||||||
|              |              | ||||||
|             source_key_path = self.get_key_path(section, source_cert_path) |             source_key_path = self.get_key_path(section, source_cert_path) | ||||||
|              |              | ||||||
|  |             # Show which certificate we're using | ||||||
|  |             logger.info(f"Source certificate: {source_cert_path}") | ||||||
|  |             logger.info(f"Source key: {source_key_path}") | ||||||
|  |              | ||||||
|             if not os.path.exists(source_key_path): |             if not os.path.exists(source_key_path): | ||||||
|                 logger.error(f"Private key not found: {source_key_path}") |                 logger.error(f"Private key not found: {source_key_path}") | ||||||
|                 return False |                 return False | ||||||
| @@ -578,12 +582,25 @@ class CertPusher: | |||||||
|             # Load source certificate for comparison |             # Load source certificate for comparison | ||||||
|             source_cert = self.cert_manager.get_cert_from_file(source_cert_path) |             source_cert = self.cert_manager.get_cert_from_file(source_cert_path) | ||||||
|              |              | ||||||
|  |             if source_cert: | ||||||
|  |                 # Show source cert details | ||||||
|  |                 source_serial = format(source_cert.serial_number, 'X').upper() | ||||||
|  |                 logger.info(f"Source cert serial: {source_serial}") | ||||||
|  |                 logger.info(f"Source cert expires: {source_cert.not_valid_after_utc}") | ||||||
|  |             else: | ||||||
|  |                 logger.error("Failed to load source certificate") | ||||||
|  |                 return False | ||||||
|  |              | ||||||
|             # Get check URL if available |             # Get check URL if available | ||||||
|             check_url = self.config.get(section, 'check_url', fallback=None) |             check_url = self.config.get(section, 'check_url', fallback=None) | ||||||
|              |              | ||||||
|             # Check if we should verify before upload |             # Check if we should verify before upload | ||||||
|             check_first = self.config.getboolean(section, 'check_before_upload', fallback=True) |             check_first = self.config.getboolean(section, 'check_before_upload', fallback=True) | ||||||
|              |              | ||||||
|  |             logger.info(f"Check before upload: {check_first}") | ||||||
|  |             if check_url: | ||||||
|  |                 logger.info(f"Check URL: {check_url}") | ||||||
|  |              | ||||||
|             proxmox = ProxmoxManager(hostname, port, username, ssh_key) |             proxmox = ProxmoxManager(hostname, port, username, ssh_key) | ||||||
|              |              | ||||||
|             if not proxmox.connect(): |             if not proxmox.connect(): | ||||||
| @@ -591,19 +608,25 @@ class CertPusher: | |||||||
|                 return False |                 return False | ||||||
|              |              | ||||||
|             # Upload with optional checking |             # Upload with optional checking | ||||||
|             if not proxmox.upload_certificate(source_cert_path, source_key_path,  |             result = proxmox.upload_certificate(source_cert_path, source_key_path,  | ||||||
|                                             check_first, source_cert, check_url): |                                             check_first, source_cert, check_url) | ||||||
|                 proxmox.disconnect() |  | ||||||
|                 self.stats['failed'] += 1 |  | ||||||
|                 return False |  | ||||||
|              |              | ||||||
|             proxmox.disconnect() |             proxmox.disconnect() | ||||||
|  |              | ||||||
|  |             if result: | ||||||
|  |                 # Check if it was actually uploaded or skipped | ||||||
|  |                 # This is a bit tricky - we need to track this in upload_certificate | ||||||
|                 self.stats['uploaded'] += 1 |                 self.stats['uploaded'] += 1 | ||||||
|                 logger.info(f"✓ Proxmox processed successfully") |                 logger.info(f"✓ Proxmox processed successfully") | ||||||
|                 return True |                 return True | ||||||
|  |             else: | ||||||
|  |                 self.stats['failed'] += 1 | ||||||
|  |                 return False | ||||||
|              |              | ||||||
|         except Exception as e: |         except Exception as e: | ||||||
|             logger.error(f"Proxmox processing failed: {e}") |             logger.error(f"Proxmox processing failed: {e}") | ||||||
|  |             import traceback | ||||||
|  |             logger.debug(traceback.format_exc()) | ||||||
|             self.stats['failed'] += 1 |             self.stats['failed'] += 1 | ||||||
|             return False |             return False | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Mateusz Gruszczyński
					Mateusz Gruszczyński