Skip to content

Commit

Permalink
swift: add is_ready()
Browse files Browse the repository at this point in the history
  • Loading branch information
naisanzaa committed May 27, 2024
1 parent 65b7a77 commit 21fa504
Showing 1 changed file with 38 additions and 22 deletions.
60 changes: 38 additions & 22 deletions automon/integrations/swift/config.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,64 @@
import os

from automon import log
from automon import environ

logger = log.logging.getLogger(__name__)
logger.setLevel(log.DEBUG)


class SwiftConfig:
OPENSTACK_USERNAME = os.getenv('OPENSTACK_USERNAME') or ''
OPENSTACK_PASSWORD = os.getenv('OPENSTACK_PASSWORD') or ''
OPENSTACK_AUTH_URL = os.getenv('OPENSTACK_AUTH_URL') or ''
OPENSTACK_PROJECT_ID = os.getenv('OPENSTACK_PROJECT_ID') or ''
OPENSTACK_PROJECT_NAME = os.getenv('OPENSTACK_PROJECT_NAME') or ''
OPENSTACK_USER_DOMAIN_NAME = os.getenv('OPENSTACK_USER_DOMAIN_NAME') or ''
OPENSTACK_PROJECT_DOMAIN_ID = os.getenv('OPENSTACK_PROJECT_DOMAIN_ID') or ''
OPENSTACK_REGION_NAME = os.getenv('OPENSTACK_REGION_NAME') or 'RegionOne'
OPENSTACK_INTERFACE = os.getenv('OPENSTACK_INTERFACE') or 'public'
OPENSTACK_IDENTITY_API_VERSION = os.getenv('OPENSTACK_IDENTITY_API_VERSION') or '3'
SWIFTCLIENT_INSECURE = os.getenv('SWIFTCLIENT_INSECURE') or 'True'
OPENSTACK_USERNAME = environ('OPENSTACK_USERNAME', '')
OPENSTACK_PASSWORD = environ('OPENSTACK_PASSWORD', '')
OPENSTACK_AUTH_URL = environ('OPENSTACK_AUTH_URL', '')
OPENSTACK_PROJECT_ID = environ('OPENSTACK_PROJECT_ID', '')
OPENSTACK_PROJECT_NAME = environ('OPENSTACK_PROJECT_NAME', '')
OPENSTACK_USER_DOMAIN_NAME = environ('OPENSTACK_USER_DOMAIN_NAME', '')
OPENSTACK_PROJECT_DOMAIN_ID = environ('OPENSTACK_PROJECT_DOMAIN_ID', '')
OPENSTACK_REGION_NAME = environ('OPENSTACK_REGION_NAME', 'RegionOne')
OPENSTACK_INTERFACE = environ('OPENSTACK_INTERFACE', 'public')
OPENSTACK_IDENTITY_API_VERSION = environ('OPENSTACK_IDENTITY_API_VERSION', 3)
SWIFTCLIENT_INSECURE = environ('SWIFTCLIENT_INSECURE', True)

def __init__(self):
pass

def is_ready(self):
if not self.OPENSTACK_USERNAME:
logger.warning(f'missing OPENSTACK_USERNAME')
logger.error(f'missing OPENSTACK_USERNAME')
return False
if not self.OPENSTACK_PASSWORD:
logger.warning(f'missing OPENSTACK_PASSWORD')
logger.error(f'missing OPENSTACK_PASSWORD')
return False
if not self.OPENSTACK_AUTH_URL:
logger.warning(f'missing OPENSTACK_AUTH_URL')
logger.error(f'missing OPENSTACK_AUTH_URL')
return False
if not self.OPENSTACK_PROJECT_ID:
logger.warning(f'missing OPENSTACK_PROJECT_ID')
logger.error(f'missing OPENSTACK_PROJECT_ID')
return False
if not self.OPENSTACK_PROJECT_NAME:
logger.warning(f'missing OPENSTACK_PROJECT_NAME')
logger.error(f'missing OPENSTACK_PROJECT_NAME')
return False
if not self.OPENSTACK_USER_DOMAIN_NAME:
logger.warning(f'missing OPENSTACK_USER_DOMAIN_NAME')
logger.error(f'missing OPENSTACK_USER_DOMAIN_NAME')
return False
if not self.OPENSTACK_PROJECT_DOMAIN_ID:
logger.warning(f'missing OPENSTACK_PROJECT_DOMAIN_ID')
logger.error(f'missing OPENSTACK_PROJECT_DOMAIN_ID')
return False
if not self.OPENSTACK_REGION_NAME:
logger.warning(f'missing OPENSTACK_REGION_NAME')
logger.error(f'missing OPENSTACK_REGION_NAME')
return False
if not self.OPENSTACK_INTERFACE:
logger.warning(f'missing OPENSTACK_INTERFACE')
logger.error(f'missing OPENSTACK_INTERFACE')
return False
if not self.OPENSTACK_IDENTITY_API_VERSION:
logger.warning(f'missing OPENSTACK_IDENTITY_API_VERSION')
logger.error(f'missing OPENSTACK_IDENTITY_API_VERSION')
return False
if not self.SWIFTCLIENT_INSECURE:
logger.warning(f'missing SWIFTCLIENT_INSECURE')
logger.error(f'missing SWIFTCLIENT_INSECURE')
return False

return True

def __eq__(self, other):
if not isinstance(other, SwiftConfig):
Expand Down

0 comments on commit 21fa504

Please sign in to comment.