# Path: cloudify_agent/api/utils.py
# class _Internal(object):
#     CLOUDIFY_DAEMON_STORAGE_DIRECTORY_KEY = 'CLOUDIFY_DAEMON_STORAGE_DIRECTORY'
#     CLOUDIFY_DAEMON_USER_KEY = 'CLOUDIFY_DAEMON_USER'
#     def get_daemon_storage_dir(cls):
#     def get_daemon_user(cls):
#     def get_storage_directory(cls, username=None):
#     def generate_agent_name():
#     def generate_new_agent_name(old_agent_name):
#     def daemon_to_dict(daemon):
#     def get_broker_url(agent):
# def get_agent_registered(name,
#                          celery_client,
#                          timeout=workflows_tasks.INSPECT_TIMEOUT):
# def get_windows_home_dir(username):
# def get_home_dir(username=None):
# def render_template_to_file(template_path, file_path=None, **values):
# def resource_to_tempfile(resource_path, executable=False):
# def get_resource(resource_path):
# def get_absolute_resource_path(resource_path):
# def content_to_file(content, file_path=None, executable=False):
# def env_to_file(env_variables, destination_path=None, posix=True):
# def stringify_values(dictionary):
# def purge_none_values(dictionary):
# def json_load(file_path):
# def json_loads(content):
# def safe_create_dir(path):
# def get_rest_client(rest_host,
#                     rest_port,
#                     rest_token,
#                     rest_tenant,
#                     ssl_cert_path,
#                     bypass_maintenance_mode=False):
# def _parse_comma_separated(ctx, param, value):
# def get_manager_file_server_url(hostname, port, scheme=None):
# def get_agent_version():
# def get_windows_basedir():
# def get_linux_basedir():
# def get_agent_basedir(is_windows=False):
# 
# Path: cloudify_agent/shell/commands/daemons.py
# class _ExpandUserPath(click.Path):
#     def convert(self, value, param, ctx):
# def create(**params):
# def configure(name, user=None):
# def start(name, interval, timeout, no_delete_amqp_queue, user=None):
# def stop(name, interval, timeout):
# def restart(name):
# def delete(name):
# def inspect(name):
# def ls():
# def status(name):
# def _load_daemon(name, user=None):
# def _save_daemon(daemon):
# def _parse_custom_options(options):
# 
# Path: cloudify_agent/shell/commands/configure.py
# @cfy.command()
# @click.option('--disable-requiretty',
#               help='Disables the requiretty directive in the sudoers file.',
#               is_flag=True)
# @click.option('--relocated-env',
#               help='Indication that this virtualenv was relocated. '
#                    'If this option is passed, an auto-correction '
#                    'to the virtualenv shabang entries '
#                    'will be performed',
#               is_flag=True)
# @click.option('--no-sudo',
#               help='Indication whether sudo should be used when applying '
#                    ' disable-requiretty part',
#               is_flag=True)
# @handle_failures
# def configure(disable_requiretty, relocated_env, no_sudo):
# 
#     """
#     Configures global agent properties.
#     """
# 
#     if disable_requiretty:
#         click.echo('Disabling requiretty directive in sudoers file')
#         _disable_requiretty(no_sudo)
#         click.echo('Successfully disabled requiretty for cfy-agent')
# 
# Path: cloudify_agent/shell/commands/cfy.py
# CLICK_CONTEXT_SETTINGS = dict(
#     help_option_names=['-h', '--help'],
#     token_normalize_func=lambda param: param.lower())
# class CommandMixin(object):
# class AgentCommand(CommandMixin, click.Command):
# class AgentGroup(CommandMixin, click.Group):
#     def main(
#         self,
#         args=None,
#         prog_name=None,
#         complete_var=None,
#         standalone_mode=True,
#         **extra
#     ):
#     def set_locale_env():
# def group(name=None):
# def command(*args, **kwargs):


import logging
import click
from cloudify.utils import setup_logger
from cloudify_agent.api.utils import (
    get_agent_version,
    logger as api_utils_logger
)
from cloudify_agent.shell.commands import daemons
from cloudify_agent.shell.commands import configure
from cloudify_agent.shell.commands import cfy

def get_logger():
    return _logger


def show_version(ctx, param, value):
    if not value or ctx.resilient_parsing:
        return
    ver = get_agent_version()
    logger = get_logger()
    logger.info('Cloudify Agent {0}'.format(ver))
    ctx.exit()


@cfy.group()
@click.option('--debug', default=False, is_flag=True)
@click.option('--version', is_flag=True, callback=show_version,
              expose_value=False, is_eager=True, help='Show version and exit')
def main(debug):
    if debug:

        # configure global logger level
        global _logger
        _logger.setLevel(logging.DEBUG)

        # configure api loggers so that there logging level does not rely
        # on imports from the shell modules
        api_utils_logger.setLevel(logging.DEBUG)



# Path: cloudify_agent/api/utils.py
# class _Internal(object):
#     CLOUDIFY_DAEMON_STORAGE_DIRECTORY_KEY = 'CLOUDIFY_DAEMON_STORAGE_DIRECTORY'
#     CLOUDIFY_DAEMON_USER_KEY = 'CLOUDIFY_DAEMON_USER'
#     def get_daemon_storage_dir(cls):
#     def get_daemon_user(cls):
#     def get_storage_directory(cls, username=None):
#     def generate_agent_name():
#     def generate_new_agent_name(old_agent_name):
#     def daemon_to_dict(daemon):
#     def get_broker_url(agent):
# def get_agent_registered(name,
#                          celery_client,
#                          timeout=workflows_tasks.INSPECT_TIMEOUT):
# def get_windows_home_dir(username):
# def get_home_dir(username=None):
# def render_template_to_file(template_path, file_path=None, **values):
# def resource_to_tempfile(resource_path, executable=False):
# def get_resource(resource_path):
# def get_absolute_resource_path(resource_path):
# def content_to_file(content, file_path=None, executable=False):
# def env_to_file(env_variables, destination_path=None, posix=True):
# def stringify_values(dictionary):
# def purge_none_values(dictionary):
# def json_load(file_path):
# def json_loads(content):
# def safe_create_dir(path):
# def get_rest_client(rest_host,
#                     rest_port,
#                     rest_token,
#                     rest_tenant,
#                     ssl_cert_path,
#                     bypass_maintenance_mode=False):
# def _parse_comma_separated(ctx, param, value):
# def get_manager_file_server_url(hostname, port, scheme=None):
# def get_agent_version():
# def get_windows_basedir():
# def get_linux_basedir():
# def get_agent_basedir(is_windows=False):
# 
# Path: cloudify_agent/shell/commands/daemons.py
# class _ExpandUserPath(click.Path):
#     def convert(self, value, param, ctx):
# def create(**params):
# def configure(name, user=None):
# def start(name, interval, timeout, no_delete_amqp_queue, user=None):
# def stop(name, interval, timeout):
# def restart(name):
# def delete(name):
# def inspect(name):
# def ls():
# def status(name):
# def _load_daemon(name, user=None):
# def _save_daemon(daemon):
# def _parse_custom_options(options):
# 
# Path: cloudify_agent/shell/commands/configure.py
# @cfy.command()
# @click.option('--disable-requiretty',
#               help='Disables the requiretty directive in the sudoers file.',
#               is_flag=True)
# @click.option('--relocated-env',
#               help='Indication that this virtualenv was relocated. '
#                    'If this option is passed, an auto-correction '
#                    'to the virtualenv shabang entries '
#                    'will be performed',
#               is_flag=True)
# @click.option('--no-sudo',
#               help='Indication whether sudo should be used when applying '
#                    ' disable-requiretty part',
#               is_flag=True)
# @handle_failures
# def configure(disable_requiretty, relocated_env, no_sudo):
# 
#     """
#     Configures global agent properties.
#     """
# 
#     if disable_requiretty:
#         click.echo('Disabling requiretty directive in sudoers file')
#         _disable_requiretty(no_sudo)
#         click.echo('Successfully disabled requiretty for cfy-agent')
# 
# Path: cloudify_agent/shell/commands/cfy.py
# CLICK_CONTEXT_SETTINGS = dict(
#     help_option_names=['-h', '--help'],
#     token_normalize_func=lambda param: param.lower())
# class CommandMixin(object):
# class AgentCommand(CommandMixin, click.Command):
# class AgentGroup(CommandMixin, click.Group):
#     def main(
#         self,
#         args=None,
#         prog_name=None,
#         complete_var=None,
#         standalone_mode=True,
#         **extra
#     ):
#     def set_locale_env():
# def group(name=None):
# def command(*args, **kwargs):


# Path: cloudify_agent/shell/main.py
import logging
import click
from cloudify.utils import setup_logger
from cloudify_agent.api.utils import (
    get_agent_version,
    logger as api_utils_logger
)
from cloudify_agent.shell.commands import daemons
from cloudify_agent.shell.commands import configure
from cloudify_agent.shell.commands import cfy


def get_logger():
    return _logger


def show_version(ctx, param, value):
    if not value or ctx.resilient_parsing:
        return
    ver = get_agent_version()
    logger = get_logger()
    logger.info('Cloudify Agent {0}'.format(ver))
    ctx.exit()


@cfy.group()
@click.option('--debug', default=False, is_flag=True)
@click.option('--version', is_flag=True, callback=show_version,
              expose_value=False, is_eager=True, help='Show version and exit')
def main(debug):
    if debug:

        # configure global logger level
        global _logger
        _logger.setLevel(logging.DEBUG)

        # configure api loggers so that there logging level does not rely
        # on imports from the shell modules
        api_utils_logger.setLevel(logging.DEBUG)



@cfy.group(name='daemons')