Exemple #1
0
 def __init__(self, config_file=None):
     config_file = config_file or Defaults.get_config()
     self.config_data = None
     try:
         with open(config_file, 'r') as config:
             self.config_data = yaml.safe_load(config)
     except Exception as e:
         raise MashConfigException(
             'Failed reading config file: {config}: {error}'.format(
                 config=config_file, error=e
             )
         )
Exemple #2
0
    def get_jwt_secret(self):
        """
        Return JWT secret token from MASH config file.

        Raise exception if secret not in config file.
        """
        secret = self._get_attribute(attribute='jwt_secret')

        if not secret:
            raise MashConfigException('jwt_secret must be in config file.')

        return secret
Exemple #3
0
    def get_cloud_data(self):
        """
        Return the cloud data from config.
        """
        data = self._get_attribute(attribute='cloud')

        if not data:
            raise MashConfigException(
                'cloud data must be provided in config file.'
            )

        return data
Exemple #4
0
    def get_oauth2_redirect_ports(self):
        """
        Return the OAuth2 redirect ports.

        :rtype: int
        """
        redirect_port = self._get_attribute(
            attribute='oauth2_redirect_ports'
        )

        if not redirect_port and 'oauth2' in self.get_auth_methods():
            raise MashConfigException(
                'oauth2_redirect_ports is required in MASH configuration file if OAuth2 login is enabled.'
            )

        return redirect_port
Exemple #5
0
    def get_oauth2_provider_url(self):
        """
        Return the OAuth2 provider URL.

        :rtype: string
        """
        provider_url = self._get_attribute(
            attribute='oauth2_provider_url'
        )

        if not provider_url and 'oauth2' in self.get_auth_methods():
            raise MashConfigException(
                'oauth2_provider_url is required in MASH configuration file if OAuth2 login is enabled.'
            )

        return provider_url
Exemple #6
0
    def get_oauth2_client_secret(self):
        """
        Return the OAuth2 client secret.

        :rtype: string
        """
        client_secret = self._get_attribute(
            attribute='oauth2_client_secret'
        )

        if not client_secret and 'oauth2' in self.get_auth_methods():
            raise MashConfigException(
                'oauth2_secret_id is required in MASH configuration file if OAuth2 login is enabled.'
            )

        return client_secret
Exemple #7
0
    def get_database_uri(self):
        """
        Return the database uri.

        :rtype: string
        """
        database_uri = self._get_attribute(
            attribute='database_uri'
        )

        if not database_uri:
            raise MashConfigException(
                'database_uri is required in MASH configuration file.'
            )

        return database_uri
Exemple #8
0
    def get_smtp_user(self):
        """
        Return the smtp username.

        :rtype: string
        """
        smtp_user = self._get_attribute(
            attribute='smtp_user'
        )

        if not smtp_user:
            raise MashConfigException(
                'smtp_user is required in MASH configuration file.'
            )

        return smtp_user
Exemple #9
0
    def get_ssh_private_key_file(self):
        """
        Return the path to the ssh private key file.

        :rtype: string
        """
        private_key_file = self._get_attribute(
            attribute='ssh_private_key_file'
        )

        if not private_key_file:
            raise MashConfigException(
                'ssh_private_key_file is required in MASH configuration file.'
            )

        return private_key_file