|
10 | 10 |
|
11 | 11 | from osism import settings, utils |
12 | 12 | from osism.tasks import Config, run_command |
13 | | -from osism.tasks.conductor.utils import get_vault |
| 13 | +from osism.tasks.conductor.utils import load_yaml_file |
14 | 14 |
|
15 | 15 | app = Celery("openstack") |
16 | 16 | app.config_from_object(Config) |
@@ -432,51 +432,9 @@ def get_cloud_password(cloud): |
432 | 432 | logger.warning(f"Secrets file not found: {secrets_path}") |
433 | 433 | return None |
434 | 434 |
|
435 | | - # Get vault instance for decryption |
436 | | - vault = get_vault() |
437 | | - |
438 | | - # Load the secrets file |
439 | | - with open(secrets_path, "rb") as f: |
440 | | - file_data = f.read() |
441 | | - |
442 | | - decrypted_secrets = None |
443 | | - |
444 | | - # Try to decrypt the file if it's vault encrypted |
445 | | - try: |
446 | | - if vault.is_encrypted(file_data): |
447 | | - # File is encrypted, decrypt it |
448 | | - decrypted_data = vault.decrypt(file_data).decode() |
449 | | - logger.debug(f"Successfully decrypted secrets file: {secrets_path}") |
450 | | - else: |
451 | | - # File is not encrypted, use as-is |
452 | | - decrypted_data = file_data.decode() |
453 | | - logger.debug( |
454 | | - f"Secrets file is not encrypted (development mode): {secrets_path}" |
455 | | - ) |
456 | | - |
457 | | - # Parse the YAML content safely |
458 | | - try: |
459 | | - decrypted_secrets = yaml.safe_load(decrypted_data) |
460 | | - except yaml.YAMLError as yaml_exc: |
461 | | - logger.error( |
462 | | - f"Failed to parse YAML content from secrets file: {yaml_exc}" |
463 | | - ) |
464 | | - return None |
465 | | - |
466 | | - except Exception as decrypt_exc: |
467 | | - # If decryption fails, try reading as plain YAML (development fallback) |
468 | | - logger.warning( |
469 | | - f"Failed to decrypt secrets file, attempting to read as plain YAML: {decrypt_exc}" |
470 | | - ) |
471 | | - try: |
472 | | - with open(secrets_path, "r") as f: |
473 | | - decrypted_secrets = yaml.safe_load(f) |
474 | | - logger.debug( |
475 | | - f"Successfully loaded unencrypted secrets file (development mode): {secrets_path}" |
476 | | - ) |
477 | | - except Exception as plain_exc: |
478 | | - logger.error(f"Failed to read secrets file as plain YAML: {plain_exc}") |
479 | | - return None |
| 435 | + decrypted_secrets = load_yaml_file(secrets_path) |
| 436 | + if decrypted_secrets is None: |
| 437 | + return None |
480 | 438 |
|
481 | 439 | if not decrypted_secrets or not isinstance(decrypted_secrets, dict): |
482 | 440 | logger.warning( |
|
0 commit comments