Пример #1
0
    def create_configuration(self):
        test_config = config.Config()
        test_config.test_mode = True
        test_config.postgresql_db_name = ':memory:'
        test_config.postgresql_host = ''
        test_config.postgresql_username = ''
        test_config.postgresql_password = ''
        test_config.file_server_root = self.tmpdir
        test_config.file_server_url = 'http://localhost:{0}'.format(
            self.file_server.port)

        test_config.rest_service_log_level = 'DEBUG'
        test_config.rest_service_log_path = self.rest_service_log
        test_config.rest_service_log_file_size_MB = 100,
        test_config.rest_service_log_files_backup_count = 20
        test_config.maintenance_folder = self.maintenance_mode_dir
        test_config.security_hash_salt = 'hash_salt'
        test_config.security_secret_key = 'secret_key'
        test_config.security_encoding_alphabet = \
            'L7SMZ4XebsuIK8F6aVUBYGQtW0P12Rn'
        test_config.security_encoding_block_size = 24
        test_config.security_encoding_min_length = 5
        test_config.authorization_permissions = auth_dict['permissions']
        test_config.security_encryption_key = \
            'f2ytTjQ-R2yKFMzgqDAw6vgQIHGZ9SiJoW-BhktapFQ='
        return test_config
Пример #2
0
    def create_configuration(self):
        test_config = config.Config()
        test_config.test_mode = True
        test_config.postgresql_db_name = ':memory:'
        test_config.postgresql_host = ''
        test_config.postgresql_username = ''
        test_config.postgresql_password = ''
        test_config.file_server_root = self.tmpdir
        test_config.file_server_url = 'http://localhost:{0}'.format(
            self.file_server.port)

        test_config.rest_service_log_level = 'DEBUG'
        test_config.rest_service_log_path = self.rest_service_log
        test_config.rest_service_log_file_size_MB = 100,
        test_config.rest_service_log_files_backup_count = 7
        test_config.maintenance_folder = self.maintenance_mode_dir
        test_config.security_hash_salt = 'hash_salt'
        test_config.security_secret_key = 'secret_key'
        test_config.security_encoding_alphabet = \
            'L7SMZ4XebsuIK8F6aVUBYGQtW0P12Rn'
        test_config.security_encoding_block_size = 24
        test_config.security_encoding_min_length = 5
        test_config.authorization_permissions = auth_dict['permissions']
        test_config.security_encryption_key = (
            'lF88UP5SJKluylJIkPDYrw5UMKOgv9w8TikS0Ds8m2UmM'
            'SzFe0qMRa0EcTgHst6LjmF_tZbq_gi_VArepMsrmw=='
        )
        return test_config
Пример #3
0
    def create_configuration(cls):
        test_config = config.Config()
        test_config.can_load_from_db = False

        test_config.test_mode = True
        test_config.postgresql_host = 'localhost'
        test_config.postgresql_username = '******'
        test_config.postgresql_password = '******'
        test_config.postgresql_connection_options = {'connect_timeout': 2}
        test_config.postgresql_db_name = cls._find_db_name(test_config)
        test_config.file_server_root = cls.tmpdir
        test_config.file_server_url = 'http://localhost:53229'

        test_config.rest_service_log_level = 'INFO'
        test_config.rest_service_log_path = cls.rest_service_log
        test_config.rest_service_log_file_size_MB = 100,
        test_config.rest_service_log_files_backup_count = 7
        test_config.maintenance_folder = cls.maintenance_mode_dir
        test_config.security_hash_salt = 'hash_salt'
        test_config.security_secret_key = 'secret_key'
        test_config.security_encoding_alphabet = \
            'L7SMZ4XebsuIK8F6aVUBYGQtW0P12Rn'
        test_config.security_encoding_block_size = 24
        test_config.security_encoding_min_length = 5
        test_config.authorization_permissions = auth_dict['permissions']
        test_config.security_encryption_key = (
            'lF88UP5SJKluylJIkPDYrw5UMKOgv9w8TikS0Ds8m2UmM'
            'SzFe0qMRa0EcTgHst6LjmF_tZbq_gi_VArepMsrmw==')

        test_config.amqp_host = 'localhost'
        test_config.amqp_username = '******'
        test_config.amqp_password = '******'
        test_config.amqp_ca_path = None
        test_config.amqp_management_host = 'localhost'
        return test_config
Пример #4
0
 def create_configuration(self):
     test_config = config.Config()
     test_config.test_mode = True
     test_config.postgresql_db_name = self.sqlite_db_file
     test_config.postgresql_host = ''
     test_config.postgresql_username = ''
     test_config.postgresql_password = ''
     test_config.file_server_root = self.tmpdir
     test_config.file_server_base_uri = 'http://localhost:{0}'.format(
         FILE_SERVER_PORT)
     test_config.file_server_blueprints_folder = \
         FILE_SERVER_BLUEPRINTS_FOLDER
     test_config.file_server_deployments_folder = \
         FILE_SERVER_DEPLOYMENTS_FOLDER
     test_config.file_server_uploaded_blueprints_folder = \
         FILE_SERVER_UPLOADED_BLUEPRINTS_FOLDER
     test_config.file_server_snapshots_folder = \
         FILE_SERVER_SNAPSHOTS_FOLDER
     test_config.file_server_resources_uri = FILE_SERVER_RESOURCES_URI
     test_config.rest_service_log_level = 'DEBUG'
     test_config.rest_service_log_path = self.rest_service_log
     test_config.rest_service_log_file_size_MB = 100,
     test_config.rest_service_log_files_backup_count = 20
     test_config.maintenance_folder = self.maintenance_mode_dir
     return test_config
def get_storage_manager_instance():
    """Configure and yield a storage_manager instance.
    This is to be used only OUTSIDE of the context of the REST API.
    """
    try:
        with _get_flask_app().app_context():
            sm = get_storage_manager()
            yield sm
    finally:
        config.reset(config.Config())
def _get_storage_manager():
    """Configure and yield a storage_manager instance.
    This is to be used only OUTSIDE of the context of the REST API.
    """
    config.instance.load_from_file(RESTSERVICE_CONFIG_PATH)
    app = server.CloudifyFlaskApp()
    try:
        with app.app_context():
            sm = get_storage_manager()
            yield sm
    finally:
        config.reset(config.Config())
Пример #7
0
def _collect_cloudify_config(data):
    config.instance.load_from_file(RESTSERVICE_CONFIG_PATH)
    app = server.CloudifyFlaskApp()
    try:
        with app.app_context():
            ldap = bool(app.ldap)
        data['cloudify_config'] = {
            'ldap_enabled': ldap,
            'ha_enabled': _is_clustered()
        }
    finally:
        config.reset(config.Config())
def generate_auth_token():
    config.instance.load_from_file(RESTSERVICE_CONFIG_PATH)
    config.instance.rest_service_log_path = '/dev/null'
    app = server.CloudifyFlaskApp()
    try:
        with app.app_context():
            sm = storage.get_storage_manager()

            enc_uid = storage.idencoder.get_encoder().encode(0)

            admin_user = sm.get(storage.models.User, 0)
            token_key = admin_user.api_token_key

            return enc_uid + token_key
    finally:
        config.reset(config.Config())