def install_additional_plugins(self):
        lgr.info('Installing additional plugins...')
        additional = self.modules['additional_plugins']

        for module, source in additional.items():
            module_name = get_module_name(module)
            lgr.info('Installing module {0} from {1}.'.format(
                module_name, source))
            utils.install_module(source, self.venv)
            self.final_set['plugins'].append(module_name)
    def install_additional_plugins(self):
        lgr.info('Installing additional plugins...')
        additional = self.modules['additional_plugins']

        for module, source in additional.items():
            module_name = get_module_name(module)
            lgr.info('Installing module {0} from {1}.'.format(
                module_name, source))
            utils.install_module(source, self.venv)
            self.final_set['plugins'].append(module_name)
    def install_core_plugins(self):
        lgr.info('Installing core plugins...')
        core = self.modules['core_plugins']

        for module in CORE_PLUGINS_LIST:
            module_name = get_module_name(module)
            if module in core and core[module] == 'exclude':
                lgr.info('Module {0} is excluded. '
                         'it will not be a part of the agent.'.format(
                             module_name))
            elif core.get(module):
                lgr.info('Installing module {0} from {1}.'.format(
                    module_name, core[module]))
                utils.install_module(core[module], self.venv)
                self.final_set['plugins'].append(module_name)
            elif module not in core:
                lgr.info('Module {0} will be installed as a part of '
                         'cloudify-agent (if applicable).'.format(module_name))
    def install_core_plugins(self):
        lgr.info('Installing core plugins...')
        core = self.modules['core_plugins']

        for module in CORE_PLUGINS_LIST:
            module_name = get_module_name(module)
            if module in core and core[module] == 'exclude':
                lgr.info(
                    'Module {0} is excluded. '
                    'it will not be a part of the agent.'.format(module_name))
            elif core.get(module):
                lgr.info('Installing module {0} from {1}.'.format(
                    module_name, core[module]))
                utils.install_module(core[module], self.venv)
                self.final_set['plugins'].append(module_name)
            elif module not in core:
                lgr.info('Module {0} will be installed as a part of '
                         'cloudify-agent (if applicable).'.format(module_name))
 def install_core_modules(self):
     lgr.info('Installing core modules...')
     core = self.modules['core_modules']
     # we must run through the CORE_MODULES_LIST so that dependencies are
     # installed in order
     for module in CORE_MODULES_LIST:
         module_name = get_module_name(module)
         if module in core:
             lgr.info('Installing module {0} from {1}.'.format(
                 module_name, core[module]))
             utils.install_module(core[module], self.venv)
             self.final_set['modules'].append(module_name)
         elif module not in core and module in MANDATORY_MODULES:
             lgr.info('Module {0} will be installed as a part of '
                      'cloudify-agent (This is a mandatory module).'.format(
                          module_name))
         elif module not in core:
             lgr.info('Module {0} will be installed as a part of '
                      'cloudify-agent (if applicable).'.format(module_name))
 def install_core_modules(self):
     lgr.info('Installing core modules...')
     core = self.modules['core_modules']
     # we must run through the CORE_MODULES_LIST so that dependencies are
     # installed in order
     for module in CORE_MODULES_LIST:
         module_name = get_module_name(module)
         if module in core:
             lgr.info('Installing module {0} from {1}.'.format(
                 module_name, core[module]))
             utils.install_module(core[module], self.venv)
             self.final_set['modules'].append(module_name)
         elif module not in core and module in MANDATORY_MODULES:
             lgr.info('Module {0} will be installed as a part of '
                      'cloudify-agent (This is a mandatory module).'.format(
                          module_name))
         elif module not in core:
             lgr.info('Module {0} will be installed as a part of '
                      'cloudify-agent (if applicable).'.format(module_name))
 def install_agent(self):
     lgr.info('Installing cloudify-agent module from {0}'.format(
         self.modules['agent']))
     utils.install_module(self.modules['agent'], self.venv)
     self.final_set['modules'].append('cloudify-agent')
 def install_modules(self, modules):
     for module in modules:
         lgr.info('Installing module {0}'.format(module))
         utils.install_module(module, self.venv)
Ejemplo n.º 9
0
def create(config=None, config_file=None, force=False, verbose=True):
    """Creates an agent package (tar.gz)

    This will try to identify the distribution of the host you're running on.
    If it can't identify it for some reason, you'll have to supply a
    `distribution` config object in the config.yaml.

    A virtualenv will be created under `/DISTRIBUTION-agent/env` unless
    configured in the yaml under the `venv` property.
    The order of the modules' installation is as follows:

    cloudify-rest-service
    cloudify-plugins-common
    cloudify-script-plugin
    cloudify-diamond-plugin
    agent and plugin installers from cloudify-manager
    any additional modules specified under `additional_modules` in the yaml.

    Once all modules are installed, a tar.gz file will be created. The
    `output_tar` config object can be specified to determine the path to the
    output file. If omitted, a default path will be given with the
    format `/DISTRIBUTION-agent.tar.gz`.
    """
    _set_global_verbosity_level(verbose)

    if not config:
        config = _import_config(config_file) if config_file else \
            _import_config()
        config = {} if not config else config
    try:
        distro = config.get('distribution', platform.dist()[0])
        release = config.get('release', platform.dist()[2])
    except Exception as ex:
        lgr.error('distribution not found in configuration '
                  'and could not be retrieved automatically. '
                  'please specify the distribution in the yaml. '
                  '({0})'.format(ex.message))
        sys.exit(1)

    python = config.get('python_path', '/usr/bin/python')
    venv = config.get('venv', DEFAULT_VENV_PATH.format(distro, release))
    keep_venv = config.get('keep_venv', False)
    destination_tar = config.get('output_tar',
                                 DEFAULT_OUTPUT_TAR_PATH.format(
                                     distro, release))

    lgr.debug('distibution is: {0}'.format(distro))
    lgr.debug('distribution release is: {0}'.format(release))
    lgr.debug('python path is: {0}'.format(python))
    lgr.debug('venv is: {0}'.format(venv))
    lgr.debug('destination tarfile is: {0}'.format(destination_tar))

    # virtualenv
    if os.path.isdir(venv):
        if force:
            lgr.info('removing previous venv...')
            shutil.rmtree(venv)
        else:
            lgr.error('virtualenv already exists at {0}. '
                      'You can use the -f flag or delete the '
                      'previous env.'.format(venv))
            sys.exit(2)

    lgr.info('creating virtual environment: {0}'.format(venv))
    utils.make_virtualenv(venv, python)

    # output file
    if os.path.isfile(destination_tar) and force:
        lgr.info('removing previous agent package...')
        os.remove(destination_tar)
    if os.path.exists(destination_tar):
            lgr.error('destination tar already exists: {0}'.format(
                destination_tar))
            sys.exit(9)

    # create modules dictionary
    lgr.debug('retrieving modules to install...')
    modules = {}
    modules['base'] = BASE_MODULES
    modules['management'] = MANAGEMENT_MODULES
    modules['additional'] = []
    modules = _merge_modules(modules, config)

    lgr.debug('modules to install: {0}'.format(json.dumps(
        modules, sort_keys=True, indent=4, separators=(',', ': '))))

    # install external
    lgr.info('installing external modules...')
    for ext_module in EXTERNAL_MODULES:
        utils.install_module(ext_module, venv)

    # install base
    lgr.info('installing base modules...')
    base = modules['base']

    if base.get('rest_client'):
        utils.install_module(base['rest_client'], venv)
    if base.get('plugins_common'):
        utils.install_module(base['plugins_common'], venv)
    if base.get('script_plugin'):
        utils.install_module(base['script_plugin'], venv)
    if base.get('diamond_plugin'):
        utils.install_module(base['diamond_plugin'], venv)

    # install management
    lgr.debug('retrieiving management modules code...')
    version = config.get('management_modules_version', 'master')
    manager_tmp_dir = _get_manager(MANAGER_REPO_URL.format(version), venv)

    lgr.info('installing management modules...')
    for mgmt_module in modules['management'].values():
        if os.path.isdir(os.path.join(manager_tmp_dir, mgmt_module)):
            utils.install_module(os.path.join(
                manager_tmp_dir, mgmt_module), venv)
        else:
            if mgmt_module:
                utils.install_module(mgmt_module, venv)

    # install additional
    lgr.info('installing additional plugins...')
    for module in modules['additional']:
        utils.install_module(module, venv)

    # create agent tar
    lgr.info('creating tar file: {0}'.format(destination_tar))
    utils.tar(venv, destination_tar)
    if not keep_venv:
        lgr.info('removing origin venv')
        shutil.rmtree(venv)
Ejemplo n.º 10
0
 def install_agent(self):
     lgr.info('Installing cloudify-agent module from {0}'.format(
         self.modules['agent']))
     utils.install_module(self.modules['agent'], self.venv)
     self.final_set['modules'].append('cloudify-agent')
Ejemplo n.º 11
0
 def install_modules(self, modules):
     for module in modules:
         lgr.info('Installing module {0}'.format(module))
         utils.install_module(module, self.venv)