Ejemplo n.º 1
0
    def _create_agent_env(self):

        execution_env = {

            # mandatory values calculated before the agent
            # is actually created
            env.CLOUDIFY_MANAGER_IP: self.cloudify_agent['manager_ip'],
            env.CLOUDIFY_DAEMON_QUEUE: self.cloudify_agent['queue'],
            env.CLOUDIFY_DAEMON_NAME: self.cloudify_agent['name'],

            # these are variables that have default values that will be set
            # by the agent on the remote host if not set here
            env.CLOUDIFY_DAEMON_USER: self.cloudify_agent.get('user'),
            env.CLOUDIFY_BROKER_IP: self.cloudify_agent.get('broker_ip'),
            env.CLOUDIFY_BROKER_PORT: self.cloudify_agent.get('broker_port'),
            env.CLOUDIFY_MANAGER_PORT: self.cloudify_agent.get('manager_port'),
            env.CLOUDIFY_DAEMON_MAX_WORKERS: self.cloudify_agent.get(
                'max_workers'),
            env.CLOUDIFY_DAEMON_MIN_WORKERS: self.cloudify_agent.get(
                'min_workers'),
            env.CLOUDIFY_DAEMON_PROCESS_MANAGEMENT:
            self.cloudify_agent['process_management']['name'],
            env.CLOUDIFY_DAEMON_WORKDIR: self.cloudify_agent['workdir'],
            env.CLOUDIFY_DAEMON_EXTRA_ENV:
            self.create_custom_env_file_on_target(
                self.cloudify_agent.get('env', {}))
        }

        execution_env = utils.purge_none_values(execution_env)
        execution_env = utils.stringify_values(execution_env)

        self.logger.debug('Cloudify Agent will be created using the following '
                          'environment: {0}'.format(execution_env))

        return execution_env
Ejemplo n.º 2
0
    def _create_agent_env(self):
        # Try to get broker credentials from the tenant. If they aren't set
        # get them from the broker_config module
        tenant = self.cloudify_agent.get('rest_tenant', {})
        tenant_name = tenant.get('name', defaults.DEFAULT_TENANT_NAME)
        broker_user = tenant.get('rabbitmq_username',
                                 broker_config.broker_username)
        broker_pass = tenant.get('rabbitmq_password',
                                 broker_config.broker_password)
        broker_vhost = tenant.get('rabbitmq_vhost',
                                  broker_config.broker_vhost)

        execution_env = {
            # mandatory values calculated before the agent
            # is actually created
            env.CLOUDIFY_DAEMON_QUEUE: self.cloudify_agent['queue'],
            env.CLOUDIFY_DAEMON_NAME: self.cloudify_agent['name'],
            env.CLOUDIFY_REST_HOST: self.cloudify_agent['rest_host'],
            env.CLOUDIFY_BROKER_IP: self.cloudify_agent['broker_ip'],

            # Optional broker values
            env.CLOUDIFY_BROKER_USER: broker_user,
            env.CLOUDIFY_BROKER_PASS: broker_pass,
            env.CLOUDIFY_BROKER_VHOST: broker_vhost,
            env.CLOUDIFY_BROKER_SSL_ENABLED: broker_config.broker_ssl_enabled,
            env.CLOUDIFY_BROKER_SSL_CERT_PATH:
                self.cloudify_agent['broker_ssl_cert_path'],

            # these are variables that have default values that will be set
            # by the agent on the remote host if not set here
            env.CLOUDIFY_DAEMON_USER: self.cloudify_agent.get('user'),
            env.CLOUDIFY_REST_PORT: self.cloudify_agent.get('rest_port'),
            env.CLOUDIFY_REST_TOKEN: self.cloudify_agent.get('rest_token'),
            env.CLOUDIFY_REST_TENANT: tenant_name,
            env.CLOUDIFY_DAEMON_MAX_WORKERS: self.cloudify_agent.get(
                'max_workers'),
            env.CLOUDIFY_DAEMON_MIN_WORKERS: self.cloudify_agent.get(
                'min_workers'),
            env.CLOUDIFY_DAEMON_PROCESS_MANAGEMENT:
            self.cloudify_agent['process_management']['name'],
            env.CLOUDIFY_DAEMON_WORKDIR: self.cloudify_agent['workdir'],
            env.CLOUDIFY_DAEMON_EXTRA_ENV:
            self.create_custom_env_file_on_target(
                self.cloudify_agent.get('env', {})),
            env.CLOUDIFY_BYPASS_MAINTENANCE_MODE: get_is_bypass_maintenance(),
            env.CLOUDIFY_LOCAL_REST_CERT_PATH:
                self.cloudify_agent['agent_rest_cert_path'],
            env.CLOUDIFY_CLUSTER_NODES: base64.b64encode(json.dumps(
                self.cloudify_agent.get('cluster', [])))
        }

        execution_env = utils.purge_none_values(execution_env)
        execution_env = utils.stringify_values(execution_env)

        self.logger.debug('Cloudify Agent will be created using the following '
                          'environment: {0}'.format(execution_env))

        return execution_env
Ejemplo n.º 3
0
    def _create_agent_env(self):

        execution_env = {
            # mandatory values calculated before the agent
            # is actually created
            env.CLOUDIFY_DAEMON_QUEUE:
            self.cloudify_agent['queue'],
            env.CLOUDIFY_DAEMON_NAME:
            self.cloudify_agent['name'],
            env.CLOUDIFY_REST_HOST:
            self.cloudify_agent['rest_host'],
            env.CLOUDIFY_BROKER_IP:
            self.cloudify_agent['broker_ip'],

            # these are variables that have default values that will be set
            # by the agent on the remote host if not set here
            env.CLOUDIFY_DAEMON_USER:
            self.cloudify_agent.get('user'),
            # broker_ip might not be set yet, and retrieved from the manager
            env.CLOUDIFY_BROKER_PORT:
            self.cloudify_agent.get('broker_port'),
            env.CLOUDIFY_REST_PORT:
            self.cloudify_agent.get('rest_port'),
            env.CLOUDIFY_REST_TOKEN:
            self.cloudify_agent.get('rest_token'),
            env.CLOUDIFY_REST_TENANT:
            self.cloudify_agent.get('rest_tenant'),
            env.CLOUDIFY_DAEMON_MAX_WORKERS:
            self.cloudify_agent.get('max_workers'),
            env.CLOUDIFY_DAEMON_MIN_WORKERS:
            self.cloudify_agent.get('min_workers'),
            env.CLOUDIFY_DAEMON_PROCESS_MANAGEMENT:
            self.cloudify_agent['process_management']['name'],
            env.CLOUDIFY_DAEMON_WORKDIR:
            self.cloudify_agent['workdir'],
            env.CLOUDIFY_DAEMON_EXTRA_ENV:
            self.create_custom_env_file_on_target(
                self.cloudify_agent.get('env', {})),
            env.CLOUDIFY_BYPASS_MAINTENANCE_MODE:
            get_is_bypass_maintenance(),
            env.CLOUDIFY_LOCAL_REST_CERT_PATH:
            self.cloudify_agent['agent_rest_cert_path'],
            env.CLOUDIFY_BROKER_SSL_CERT_PATH:
            self.cloudify_agent['broker_ssl_cert_path']
        }

        execution_env = utils.purge_none_values(execution_env)
        execution_env = utils.stringify_values(execution_env)

        self.logger.debug('Cloudify Agent will be created using the following '
                          'environment: {0}'.format(execution_env))

        return execution_env
Ejemplo n.º 4
0
    def _create_agent_env(self):

        execution_env = {

            # mandatory values calculated before the agent
            # is actually created
            env.CLOUDIFY_MANAGER_IP:
            self.cloudify_agent['manager_ip'],
            env.CLOUDIFY_DAEMON_QUEUE:
            self.cloudify_agent['queue'],
            env.CLOUDIFY_DAEMON_NAME:
            self.cloudify_agent['name'],

            # these are variables that have default values that will be set
            # by the agent on the remote host if not set here
            env.CLOUDIFY_DAEMON_USER:
            self.cloudify_agent.get('user'),
            env.CLOUDIFY_BROKER_IP:
            self.cloudify_agent.get('broker_ip'),
            env.CLOUDIFY_BROKER_PORT:
            self.cloudify_agent.get('broker_port'),
            env.CLOUDIFY_MANAGER_PORT:
            self.cloudify_agent.get('manager_port'),
            env.CLOUDIFY_DAEMON_MAX_WORKERS:
            self.cloudify_agent.get('max_workers'),
            env.CLOUDIFY_DAEMON_MIN_WORKERS:
            self.cloudify_agent.get('min_workers'),
            env.CLOUDIFY_DAEMON_PROCESS_MANAGEMENT:
            self.cloudify_agent['process_management']['name'],
            env.CLOUDIFY_DAEMON_WORKDIR:
            self.cloudify_agent['workdir'],
            env.CLOUDIFY_DAEMON_EXTRA_ENV:
            self.create_custom_env_file_on_target(
                self.cloudify_agent.get('env', {}))
        }

        execution_env = utils.purge_none_values(execution_env)
        execution_env = utils.stringify_values(execution_env)

        self.logger.debug('Cloudify Agent will be created using the following '
                          'environment: {0}'.format(execution_env))

        return execution_env
Ejemplo n.º 5
0
    def _create_agent_env(self):

        execution_env = {
            # mandatory values calculated before the agent
            # is actually created
            env.CLOUDIFY_DAEMON_QUEUE: self.cloudify_agent['queue'],
            env.CLOUDIFY_DAEMON_NAME: self.cloudify_agent['name'],
            env.CLOUDIFY_FILE_SERVER_HOST:
                self.cloudify_agent['file_server_host'],
            env.CLOUDIFY_REST_HOST: self.cloudify_agent['rest_host'],
            env.CLOUDIFY_BROKER_IP: self.cloudify_agent['broker_ip'],

            # these are variables that have default values that will be set
            # by the agent on the remote host if not set here
            env.CLOUDIFY_DAEMON_USER: self.cloudify_agent.get('user'),
            # broker_ip might not be set yet, and retrieved from the manager

            env.CLOUDIFY_BROKER_PORT: self.cloudify_agent.get('broker_port'),
            env.CLOUDIFY_REST_PORT:
                self.cloudify_agent.get('rest_port'),
            env.CLOUDIFY_REST_PROTOCOL: self.cloudify_agent.get(
                'rest_protocol'),
            env.CLOUDIFY_FILE_SERVER_PORT:
                self.cloudify_agent.get('file_server_port'),
            env.CLOUDIFY_FILE_SERVER_PROTOCOL:
                self.cloudify_agent.get('file_server_protocol'),
            env.CLOUDIFY_SECURITY_ENABLED:
                self.cloudify_agent.get('security_enabled'),
            env.CLOUDIFY_REST_USERNAME:
                self.cloudify_agent.get('rest_username'),
            env.CLOUDIFY_REST_PASSWORD:
                self.cloudify_agent.get('rest_password'),
            env.CLOUDIFY_REST_TOKEN:
                self.cloudify_agent.get('rest_token'),
            env.CLOUDIFY_VERIFY_REST_CERTIFICATE:
                self.cloudify_agent.get('verify_rest_certificate'),
            env.CLOUDIFY_REST_CERT_CONTENT:
                self.cloudify_agent.get('rest_cert_content'),
            env.CLOUDIFY_DAEMON_MAX_WORKERS: self.cloudify_agent.get(
                'max_workers'),
            env.CLOUDIFY_DAEMON_MIN_WORKERS: self.cloudify_agent.get(
                'min_workers'),
            env.CLOUDIFY_DAEMON_PROCESS_MANAGEMENT:
            self.cloudify_agent['process_management']['name'],
            env.CLOUDIFY_DAEMON_WORKDIR: self.cloudify_agent['workdir'],
            env.CLOUDIFY_DAEMON_EXTRA_ENV:
            self.create_custom_env_file_on_target(
                self.cloudify_agent.get('env', {})),
            env.CLOUDIFY_BYPASS_MAINTENANCE_MODE: get_is_bypass_maintenance(),
            env.CLOUDIFY_AGENT_REST_CERT_PATH:
                self.cloudify_agent['agent_rest_cert_path'],
            env.CLOUDIFY_BROKER_SSL_CERT_PATH:
                self.cloudify_agent['broker_ssl_cert_path']
        }

        execution_env = utils.purge_none_values(execution_env)
        execution_env = utils.stringify_values(execution_env)

        self.logger.debug('Cloudify Agent will be created using the following '
                          'environment: {0}'.format(execution_env))

        return execution_env
Ejemplo n.º 6
0
    def _create_agent_env(self):
        tenant = get_tenant()
        tenant_name = tenant.get('name', defaults.DEFAULT_TENANT_NAME)
        tenant_user = tenant.get('rabbitmq_username',
                                 broker_config.broker_username)
        tenant_pass = tenant.get('rabbitmq_password',
                                 broker_config.broker_password)
        broker_vhost = tenant.get('rabbitmq_vhost',
                                  broker_config.broker_vhost)
        # Get the agent's broker credentials
        broker_user = self.cloudify_agent.get('broker_user', tenant_user)
        broker_pass = self.cloudify_agent.get('broker_pass', tenant_pass)

        manager_ip = self.cloudify_agent.get_manager_ip()
        network = self.cloudify_agent.get('network')
        execution_env = {
            # mandatory values calculated before the agent
            # is actually created
            env.CLOUDIFY_DAEMON_QUEUE: self.cloudify_agent['queue'],
            env.CLOUDIFY_DAEMON_NAME: self.cloudify_agent['name'],
            env.CLOUDIFY_REST_HOST: manager_ip,
            env.CLOUDIFY_BROKER_IP: ','.join(
                broker.networks[network] for broker in
                ctx.get_brokers(network=network)
            ),

            # Optional broker values
            env.CLOUDIFY_BROKER_USER: broker_user,
            env.CLOUDIFY_BROKER_PASS: broker_pass,
            env.CLOUDIFY_BROKER_VHOST: broker_vhost,
            env.CLOUDIFY_BROKER_SSL_ENABLED: broker_config.broker_ssl_enabled,
            env.CLOUDIFY_BROKER_SSL_CERT_PATH: (
                self.cloudify_agent['broker_ssl_cert_path']
            ),
            env.CLOUDIFY_HEARTBEAT: (
                self.cloudify_agent.get('heartbeat')
            ),

            # these are variables that have default values that will be set
            # by the agent on the remote host if not set here
            env.CLOUDIFY_DAEMON_USER: self.cloudify_agent.get('user'),
            env.CLOUDIFY_REST_PORT: self.cloudify_agent.get('rest_port'),
            env.CLOUDIFY_REST_TOKEN: get_rest_token(),
            env.CLOUDIFY_REST_TENANT: tenant_name,
            env.CLOUDIFY_DAEMON_MAX_WORKERS: self.cloudify_agent.get(
                'max_workers'),
            env.CLOUDIFY_DAEMON_MIN_WORKERS: self.cloudify_agent.get(
                'min_workers'),
            env.CLOUDIFY_DAEMON_PROCESS_MANAGEMENT:
            self.cloudify_agent['process_management']['name'],
            env.CLOUDIFY_DAEMON_WORKDIR: self.cloudify_agent['workdir'],
            env.CLOUDIFY_DAEMON_EXTRA_ENV:
            self.create_custom_env_file_on_target(
                self.cloudify_agent.get('env', {})),
            env.CLOUDIFY_BYPASS_MAINTENANCE_MODE: get_is_bypass_maintenance(),
            env.CLOUDIFY_LOCAL_REST_CERT_PATH: (
                self.cloudify_agent['agent_rest_cert_path']
            ),
            env.CLOUDIFY_CLUSTER_NODES: base64.b64encode(json.dumps(
                self.cloudify_agent.get('cluster', []))),
            env.CLOUDIFY_NETWORK_NAME: network,
            ENV_CFY_EXEC_TEMPDIR: self.cloudify_agent.get(
                'executable_temp_path'),
            ENV_AGENT_LOG_LEVEL: self.cloudify_agent.get('log_level'),
            ENV_AGENT_LOG_MAX_BYTES: self.cloudify_agent.get('log_max_bytes'),
            ENV_AGENT_LOG_MAX_HISTORY: self.cloudify_agent.get(
                'log_max_history')
        }

        execution_env = utils.purge_none_values(execution_env)
        execution_env = utils.stringify_values(execution_env)

        self.logger.debug('Cloudify Agent will be created using the following '
                          'environment: {0}'.format(execution_env))

        return execution_env
Ejemplo n.º 7
0
    def _create_agent_env(self):
        # pop to not leave creds around
        tenant = self.cloudify_agent.pop('tenant')
        tenant_name = tenant.get('name', defaults.DEFAULT_TENANT_NAME)
        tenant_user = tenant.get('rabbitmq_username',
                                 broker_config.broker_username)
        tenant_pass = tenant.get('rabbitmq_password',
                                 broker_config.broker_password)
        broker_vhost = tenant.get('rabbitmq_vhost', broker_config.broker_vhost)
        # Get the agent's broker credentials
        broker_user = self.cloudify_agent.get('broker_user', tenant_user)
        broker_pass = self.cloudify_agent.get('broker_pass', tenant_pass)

        network = self.cloudify_agent.get('network')
        execution_env = {
            # mandatory values calculated before the agent
            # is actually created
            env.CLOUDIFY_DAEMON_QUEUE:
            self.cloudify_agent['queue'],
            env.AGENT_NAME:
            self.cloudify_agent['name'],
            env.CLOUDIFY_REST_HOST:
            ','.join(self.cloudify_agent['rest_host']),
            env.CLOUDIFY_BROKER_IP:
            ','.join(self.cloudify_agent['broker_ip']),

            # Optional broker values
            env.CLOUDIFY_BROKER_USER:
            broker_user,
            env.CLOUDIFY_BROKER_PASS:
            broker_pass,
            env.CLOUDIFY_BROKER_VHOST:
            broker_vhost,
            env.CLOUDIFY_BROKER_SSL_ENABLED:
            broker_config.broker_ssl_enabled,
            env.CLOUDIFY_BROKER_SSL_CERT_PATH:
            (self.cloudify_agent['broker_ssl_cert_path']),
            env.CLOUDIFY_HEARTBEAT: (self.cloudify_agent.get('heartbeat')),

            # these are variables that have default values that will be set
            # by the agent on the remote host if not set here
            env.CLOUDIFY_DAEMON_USER:
            self.cloudify_agent.get('user'),
            env.CLOUDIFY_REST_PORT:
            self.cloudify_agent.get('rest_port'),
            env.CLOUDIFY_REST_TOKEN:
            get_rest_token(),
            env.CLOUDIFY_REST_TENANT:
            tenant_name,
            env.CLOUDIFY_DAEMON_MAX_WORKERS:
            self.cloudify_agent.get('max_workers'),
            env.CLOUDIFY_DAEMON_MIN_WORKERS:
            self.cloudify_agent.get('min_workers'),
            env.CLOUDIFY_DAEMON_PROCESS_MANAGEMENT:
            self.cloudify_agent['process_management']['name'],
            env.CLOUDIFY_DAEMON_WORKDIR:
            self.cloudify_agent['workdir'],
            env.CLOUDIFY_DAEMON_EXTRA_ENV:
            self.create_custom_env_file_on_target(
                self.cloudify_agent.get('env', {})),
            env.CLOUDIFY_BYPASS_MAINTENANCE_MODE:
            get_is_bypass_maintenance(),
            env.CLOUDIFY_LOCAL_REST_CERT_PATH:
            (self.cloudify_agent['agent_rest_cert_path']),
            env.CLOUDIFY_NETWORK_NAME:
            network,
            ENV_CFY_EXEC_TEMPDIR:
            self.cloudify_agent.get('executable_temp_path'),
            ENV_AGENT_LOG_LEVEL:
            self.cloudify_agent.get('log_level'),
            ENV_AGENT_LOG_MAX_BYTES:
            self.cloudify_agent.get('log_max_bytes'),
            ENV_AGENT_LOG_MAX_HISTORY:
            self.cloudify_agent.get('log_max_history')
        }

        execution_env = utils.purge_none_values(execution_env)
        execution_env = utils.stringify_values(execution_env)

        self.logger.debug('Cloudify Agent will be created using the following '
                          'environment: {0}'.format(execution_env))

        return execution_env