# Path: cloudify/broker_config.py
# DEFAULT_HEARTBEAT = 30
#     BROKER_USE_SSL = {
#         'ca_certs': broker_cert_path,
#         'cert_reqs': ssl.CERT_REQUIRED,
#     }
# URL_TEMPLATE = \
#     'amqp://{username}:{password}@{hostname}:{port}/{vhost}{options}'
#     BROKER_URL = ';'.join(URL_TEMPLATE.format(username=broker_username,
#                                               password=broker_password,
#                                               hostname=node_ip,
#                                               port=broker_port,
#                                               vhost=broker_vhost,
#                                               options=options)
#                           for node_ip in config['cluster'])
#     BROKER_URL = URL_TEMPLATE.format(
#         username=broker_username,
#         password=broker_password,
#         hostname=broker_hostname,
#         port=broker_port,
#         vhost=broker_vhost,
#         options=options
#     )
# CELERY_RESULT_BACKEND = BROKER_URL
# CELERY_TASK_RESULT_EXPIRES = 600
# CELERYD_PREFETCH_MULTIPLIER = 1
# CELERY_ACKS_LATE = False
# 
# Path: cloudify/utils.py
# CFY_EXEC_TEMPDIR_ENVVAR = 'CFY_EXEC_TEMP'
# class ManagerVersion(object):
# class LocalCommandRunner(object):
# class CommandExecutionResponse(object):
# class Internal(object):
#     def __init__(self, raw_version):
#     def greater_than(self, other):
#     def equals(self, other):
#     def __str__(self):
#     def __eq__(self, other):
#     def __gt__(self, other):
#     def __lt__(self, other):
#     def __ge__(self, other):
#     def __le__(self, other):
#     def __ne__(self, other):
# def setup_logger(logger_name,
#                  logger_level=logging.INFO,
#                  handlers=None,
#                  remove_existing_handlers=True,
#                  logger_format=None,
#                  propagate=True):
# def format_exception(e):
# def get_manager_file_server_url():
# def get_manager_file_server_root():
# def get_manager_rest_service_host():
# def get_broker_ssl_cert_path():
# def get_manager_rest_service_port():
# def get_local_rest_certificate():
# def _get_current_context():
# def get_rest_token():
# def get_tenant():
# def get_tenant_name():
# def get_is_bypass_maintenance():
# def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
# def get_exec_tempdir():
# def create_temp_folder():
# def exception_to_error_cause(exception, tb):
#     def __init__(self, logger=None, host='localhost'):
#     def run(self, command,
#             exit_on_failure=True,
#             stdout_pipe=True,
#             stderr_pipe=True,
#             cwd=None,
#             execution_env=None):
#     def __init__(self, command, std_out, std_err, return_code):
# def _shlex_split(command):
#     def get_install_method(properties):
#     def get_broker_ssl_options(ssl_enabled, cert_path):
#     def get_broker_credentials(cloudify_agent):
#     def _get_package_version(plugins_dir, package_name):
#     def plugin_prefix(package_name=None, package_version=None,
#                       deployment_id=None, plugin_name=None, tenant_name=None,
#                       sys_prefix_fallback=True):
#     def _change_tenant(ctx, tenant):
# 
# Path: cloudify/constants.py
# CELERY_TASK_RESULT_EXPIRES = 600
# 
# MGMTWORKER_QUEUE = 'cloudify.management'
# 
# BROKER_PORT_SSL = 5671
# 
# BROKER_PORT_NO_SSL = 5672


from cloudify import broker_config
from cloudify.utils import internal
from cloudify.constants import (CELERY_TASK_RESULT_EXPIRES,
                                MGMTWORKER_QUEUE,
                                BROKER_PORT_SSL,
                                BROKER_PORT_NO_SSL)
    from celery import Celery



def get_celery_app(broker_url=None,
                   broker_ssl_cert_path=None,
                   broker_ssl_enabled=None,
                   max_retries=3,
                   tenant=None,
                   target=None):
    """
    Return a Celery app

    :param broker_url: If supplied, will be used as the broker URL
    :param broker_ssl_cert_path: If not supplied, default is in broker_config
    :param broker_ssl_enabled: Decides whether SSL should be enabled
    :param tenant: If supplied, and if target isn't the mgmtworker queue,
    the broker URL will be derived from the data kept in it
    :param target: The target queue; see `tenant`
    :param max_retries:
    :return: A celery.Celery object
    """
    # celery is imported locally since it's not used by any other method, and
    # we want this utils module to be usable even if celery is not available

    if broker_ssl_enabled is None:
        broker_ssl_enabled = broker_config.broker_ssl_enabled

    broker_url = broker_url or _get_broker_url(tenant,
                                               target,
                                               broker_ssl_enabled)

# Path: cloudify/broker_config.py
# DEFAULT_HEARTBEAT = 30
#     BROKER_USE_SSL = {
#         'ca_certs': broker_cert_path,
#         'cert_reqs': ssl.CERT_REQUIRED,
#     }
# URL_TEMPLATE = \
#     'amqp://{username}:{password}@{hostname}:{port}/{vhost}{options}'
#     BROKER_URL = ';'.join(URL_TEMPLATE.format(username=broker_username,
#                                               password=broker_password,
#                                               hostname=node_ip,
#                                               port=broker_port,
#                                               vhost=broker_vhost,
#                                               options=options)
#                           for node_ip in config['cluster'])
#     BROKER_URL = URL_TEMPLATE.format(
#         username=broker_username,
#         password=broker_password,
#         hostname=broker_hostname,
#         port=broker_port,
#         vhost=broker_vhost,
#         options=options
#     )
# CELERY_RESULT_BACKEND = BROKER_URL
# CELERY_TASK_RESULT_EXPIRES = 600
# CELERYD_PREFETCH_MULTIPLIER = 1
# CELERY_ACKS_LATE = False
# 
# Path: cloudify/utils.py
# CFY_EXEC_TEMPDIR_ENVVAR = 'CFY_EXEC_TEMP'
# class ManagerVersion(object):
# class LocalCommandRunner(object):
# class CommandExecutionResponse(object):
# class Internal(object):
#     def __init__(self, raw_version):
#     def greater_than(self, other):
#     def equals(self, other):
#     def __str__(self):
#     def __eq__(self, other):
#     def __gt__(self, other):
#     def __lt__(self, other):
#     def __ge__(self, other):
#     def __le__(self, other):
#     def __ne__(self, other):
# def setup_logger(logger_name,
#                  logger_level=logging.INFO,
#                  handlers=None,
#                  remove_existing_handlers=True,
#                  logger_format=None,
#                  propagate=True):
# def format_exception(e):
# def get_manager_file_server_url():
# def get_manager_file_server_root():
# def get_manager_rest_service_host():
# def get_broker_ssl_cert_path():
# def get_manager_rest_service_port():
# def get_local_rest_certificate():
# def _get_current_context():
# def get_rest_token():
# def get_tenant():
# def get_tenant_name():
# def get_is_bypass_maintenance():
# def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
# def get_exec_tempdir():
# def create_temp_folder():
# def exception_to_error_cause(exception, tb):
#     def __init__(self, logger=None, host='localhost'):
#     def run(self, command,
#             exit_on_failure=True,
#             stdout_pipe=True,
#             stderr_pipe=True,
#             cwd=None,
#             execution_env=None):
#     def __init__(self, command, std_out, std_err, return_code):
# def _shlex_split(command):
#     def get_install_method(properties):
#     def get_broker_ssl_options(ssl_enabled, cert_path):
#     def get_broker_credentials(cloudify_agent):
#     def _get_package_version(plugins_dir, package_name):
#     def plugin_prefix(package_name=None, package_version=None,
#                       deployment_id=None, plugin_name=None, tenant_name=None,
#                       sys_prefix_fallback=True):
#     def _change_tenant(ctx, tenant):
# 
# Path: cloudify/constants.py
# CELERY_TASK_RESULT_EXPIRES = 600
# 
# MGMTWORKER_QUEUE = 'cloudify.management'
# 
# BROKER_PORT_SSL = 5671
# 
# BROKER_PORT_NO_SSL = 5672


# Path: cloudify/celery/app.py
from cloudify import broker_config
from cloudify.utils import internal
from cloudify.constants import (CELERY_TASK_RESULT_EXPIRES,
                                MGMTWORKER_QUEUE,
                                BROKER_PORT_SSL,
                                BROKER_PORT_NO_SSL)
    from celery import Celery




def get_celery_app(broker_url=None,
                   broker_ssl_cert_path=None,
                   broker_ssl_enabled=None,
                   max_retries=3,
                   tenant=None,
                   target=None):
    """
    Return a Celery app

    :param broker_url: If supplied, will be used as the broker URL
    :param broker_ssl_cert_path: If not supplied, default is in broker_config
    :param broker_ssl_enabled: Decides whether SSL should be enabled
    :param tenant: If supplied, and if target isn't the mgmtworker queue,
    the broker URL will be derived from the data kept in it
    :param target: The target queue; see `tenant`
    :param max_retries:
    :return: A celery.Celery object
    """
    # celery is imported locally since it's not used by any other method, and
    # we want this utils module to be usable even if celery is not available

    if broker_ssl_enabled is None:
        broker_ssl_enabled = broker_config.broker_ssl_enabled

    broker_url = broker_url or _get_broker_url(tenant,
                                               target,
                                               broker_ssl_enabled)

    broker_ssl_options = internal.get_broker_ssl_options(