コード例 #1
0
ファイル: install_engine.py プロジェクト: quaddra/engage
    def _run_worker(self, multi_node=False):
        import install_plan
        import install_sequencer
        import install_context as ctx
        efl = self.engage_file_layout
        install_script_file = efl.get_install_script_file()
        if not os.path.exists(install_script_file):
            raise CmdLineError(errors[ERR_BAD_SOLN_FILE],
                               msg_args={"filename":install_script_file})
        library_file = efl.get_preprocessed_library_file()
        resource_list = parse_install_soln(install_script_file)
        self.logger.info("Using software library %s." % library_file)
        library = parse_library_files(efl)
        gp = password.generate_pw_file_if_necessary
        self.pw_database = \
            gp(efl, self.deployment_home, resource_list, library,
               installer_supplied_pw_key_list=self.installer_supplied_pw_key_list,
               master_password_file=self.options.master_password_file,
               read_master_pw_from_stdin=self.options.subproc,
               suppress_master_password_file=self.options.suppress_master_password_file,
               generate_random_passwords=self.options.generate_random_passwords,
               dry_run=self.options.dry_run)
        if not self.pw_database:
            # if no password file is being used, created a dummy password
            # object
            self.pw_database = pw_repository.PasswordRepository("")
        ctx.setup_context(efl, self.options.subproc, library, self.pw_database)
        if self.options.dry_run:
            self.logger.info("Dry run complete.")
            return
        ## if self.options.generate_password_file:
        ##     self.logger.info("Password file at %s, password salt file at %s." %
        ##                      (efl.get_password_database_file(),
        ##                       efl.get_password_salt_file()))
        ##     return

        if multi_node:
            install_sequencer.run_multi_node_install(install_plan.create_multi_node_install_plan(resource_list),
                                                     library,
                                                     self.options.force_stop_on_error)
            # TODO: need to consider whether we need to make any calls to the management API
            # for the master node in multi-node. Is there a way to register cross-node dependencies?
        else: # single node or slave
            mgr_pkg_list = [install_sequencer.get_manager_and_package(instance_md, library)
                            for instance_md in install_plan.create_install_plan(resource_list)]
            install_sequencer.run_install(mgr_pkg_list, library, self.options.force_stop_on_error)
            if self.options.mgt_backends:
                import mgt_registration
                mgt_registration.register_with_mgt_backends(self.options.mgt_backends,
                                                            [mgr for (mgr, pkg) in mgr_pkg_list],
                                                            self.deployment_home,
                                                            sudo_password=ctx.get_sudo_password(),
                                                            upgrade=False)
コード例 #2
0
def get_mgrs_and_pkgs(file_layout, deployment_home, options,
                      resource_file=None):
    """Perform common initialization operations, returning
    a list of (mgr, pkg) pairs sorted in dependency order.
    """
    import library
    import install_plan
    l = library.parse_library_files(file_layout)
    import engage.engine.password
    pw_database = engage.engine.password.get_password_db(file_layout, options)
    import install_context
    install_context.setup_context(file_layout, options.subproc, l, pw_database)

    if not resource_file:
        resource_file = file_layout.get_installed_resources_file(deployment_home)

    def get_manager_and_pkg(resource):
        if resource.package!=None:
            # new style packags are on the resource
            package = resource.package
            resource_manager_class = resource.get_resource_manager_class()
        else:
            entry = l.get_entry(resource)
            assert entry, "Unable to find entry for resource %s in library file %s" % (resource.id, file_layout.get_software_library_file())
            resource_manager_class = entry.get_manager_class()
            package = entry.get_package()
        mgr = resource_manager_class(resource)
        import install_context
        mgr.install_context = install_context
        return (mgr, package)
        
    with open(resource_file, "rb") as f:
        resource_list_json = json.load(f)
    rlist =  [parse_resource_from_json(resource_json) for
              resource_json in resource_list_json]
    return [get_manager_and_pkg(r) for r in install_plan.create_install_plan(rlist)]