# Path: cloudify_agent/api/defaults.py
# START_TIMEOUT = 60
# START_INTERVAL = 1
# STOP_TIMEOUT = 60
# STOP_INTERVAL = 1
# INTERNAL_REST_PORT = 53333
# MIN_WORKERS = 0
# MAX_WORKERS = 5
# BROKER_URL = 'amqp://{username}:{password}@{host}:{port}/{vhost}'
# DELETE_AMQP_QUEUE_BEFORE_START = False
# DAEMON_FORCE_DELETE = False
# CLOUDIFY_AGENT_PREFIX = 'cfy-agent'
# LOG_LEVEL = 'info'
# LOG_FILE_SIZE = 5 * 1024 * 1024
# LOG_BACKUPS = 7
# SSL_CERTS_TARGET_DIR = 'cloudify/ssl'
# AGENT_SSL_CERT_FILENAME = 'cloudify_internal_cert.pem'
# DEFAULT_TENANT_NAME = 'default_tenant'


import uuid
import json
import copy
import tempfile
import os
import errno
import getpass
import pkgutil
import appdirs
import pkg_resources
import cloudify_agent
        import pwd
from jinja2 import Template
from cloudify._compat import urlquote, PY2
from cloudify.cluster import CloudifyClusterClient
from cloudify.workflows import tasks as workflows_tasks
from cloudify.utils import setup_logger, get_exec_tempdir, ipv6_url_compat
from cloudify.constants import (SECURED_PROTOCOL,
                                BROKER_PORT_SSL,
                                BROKER_PORT_NO_SSL)
from cloudify.utils import is_agent_alive  # noqa
from cloudify_agent.api import defaults

        :param daemon: the daemon.
        :type daemon: cloudify_agent.api.pm.base.Daemon
        """

        try:
            getattr(daemon, '__dict__')
        except AttributeError:
            raise ValueError('Cannot save a daemon with '
                             'no __dict__ attribute.')

        # don't use deepcopy here because we this will try to copy
        # the internal non primitive attributes
        original = daemon.__dict__
        result = copy.copy(original)
        for attr in original:
            if attr.startswith('_'):
                result.pop(attr)
        return result

    @staticmethod
    def get_broker_url(agent):
        broker_ip = agent['broker_ip']
        broker_user = agent.get('broker_user', 'guest')
        broker_pass = agent.get('broker_pass', 'guest')
        broker_vhost = agent.get('broker_vhost', '/')
        if agent.get('broker_ssl_enabled'):
            broker_port = BROKER_PORT_SSL
        else:
            broker_port = BROKER_PORT_NO_SSL

# Path: cloudify_agent/api/defaults.py
# START_TIMEOUT = 60
# START_INTERVAL = 1
# STOP_TIMEOUT = 60
# STOP_INTERVAL = 1
# INTERNAL_REST_PORT = 53333
# MIN_WORKERS = 0
# MAX_WORKERS = 5
# BROKER_URL = 'amqp://{username}:{password}@{host}:{port}/{vhost}'
# DELETE_AMQP_QUEUE_BEFORE_START = False
# DAEMON_FORCE_DELETE = False
# CLOUDIFY_AGENT_PREFIX = 'cfy-agent'
# LOG_LEVEL = 'info'
# LOG_FILE_SIZE = 5 * 1024 * 1024
# LOG_BACKUPS = 7
# SSL_CERTS_TARGET_DIR = 'cloudify/ssl'
# AGENT_SSL_CERT_FILENAME = 'cloudify_internal_cert.pem'
# DEFAULT_TENANT_NAME = 'default_tenant'


# Path: cloudify_agent/api/utils.py
import uuid
import json
import copy
import tempfile
import os
import errno
import getpass
import pkgutil
import appdirs
import pkg_resources
import cloudify_agent
        import pwd
from jinja2 import Template
from cloudify._compat import urlquote, PY2
from cloudify.cluster import CloudifyClusterClient
from cloudify.workflows import tasks as workflows_tasks
from cloudify.utils import setup_logger, get_exec_tempdir, ipv6_url_compat
from cloudify.constants import (SECURED_PROTOCOL,
                                BROKER_PORT_SSL,
                                BROKER_PORT_NO_SSL)
from cloudify.utils import is_agent_alive  # noqa
from cloudify_agent.api import defaults


        :param daemon: the daemon.
        :type daemon: cloudify_agent.api.pm.base.Daemon
        """

        try:
            getattr(daemon, '__dict__')
        except AttributeError:
            raise ValueError('Cannot save a daemon with '
                             'no __dict__ attribute.')

        # don't use deepcopy here because we this will try to copy
        # the internal non primitive attributes
        original = daemon.__dict__
        result = copy.copy(original)
        for attr in original:
            if attr.startswith('_'):
                result.pop(attr)
        return result

    @staticmethod
    def get_broker_url(agent):
        broker_ip = agent['broker_ip']
        broker_user = agent.get('broker_user', 'guest')
        broker_pass = agent.get('broker_pass', 'guest')
        broker_vhost = agent.get('broker_vhost', '/')
        if agent.get('broker_ssl_enabled'):
            broker_port = BROKER_PORT_SSL
        else:
            broker_port = BROKER_PORT_NO_SSL

        return defaults.BROKER_URL.format(username=urlquote(broker_user),