예제 #1
0
def run(req, logger):
    install_spec_option_no = select_configuration(req.installer_file_layout,
                                                  req.config_choices)
        
    # need to manually record the deployment home in the choice history, as it is used
    # to validate other inputs
    req.config_choices.choice_history["Install directory"] = req.deployment_home

    # create the install spec
    target_machine = get_target_machine_resource(req.deployment_home, req.installer_file_layout.get_log_directory())
    hosts = create_install_spec(target_machine,
                                req.installer_file_layout.get_install_spec_template_file(install_spec_option_no),
                                req.installer_file_layout.get_install_spec_file(install_spec_option_no),
              req.installer_file_layout, logger)

    # here is were we handle any additional configuration inputs
    password_list = set_install_spec_properties(req.installer_file_layout,
                                                install_spec_option_no,
                                                req.config_choices,
                                                target_machine, logger)
    

    # save the history file to user location, if provided
    if req.options.history_file:
        req.config_choices.save_history_file(os.path.abspath(os.path.expanduser(req.options.history_file)))
    # if fresh install, always save choices to config directory, for use in future upgradesa
    req.config_choices.save_history_file(os.path.join(req.installer_file_layout.get_config_choices_file(req.deployment_home)))
    
    # run the configuration engine
    preprocess_and_run_config_engine(req.installer_file_layout,
        req.installer_file_layout.get_install_spec_file(install_spec_option_no))

    if not req.upgrade_from: # this is a fresh install
        for host in hosts:
            if host["id"] != "master-host":
                setup_slave_host(host, req.deployment_home, pw_file, pw_salt_file)
        install_engine_args = \
            cmdline_script_utils.extract_standard_options(req.options)

        logger.debug("Invoking install engine with arguments %s" %
                     install_engine_args)
        return install_engine.main(install_engine_args,
                                   installer_supplied_pw_key_list=password_list,
                                   file_layout=req.installer_file_layout)
    else:
        # TODO PW: Fix this to use new passwords
        return upgrade_engine.upgrade(req.upgrade_from,
                                      req.installer_file_layout,
                                      req.deployment_home, req.options,
                                      atomic_upgrade=(not req.options.no_rollback_on_failed_upgrades))
예제 #2
0
    def process_args(self, argv, engage_file_layout=None):
        usage = "usage: %prog [options] install_specification_file"
        parser = OptionParser(usage=usage)
        parser.add_option("-a", "--additive-install", default=False,
                          action="store_true",
                          help="If specified, an install already exists and we are adding resources to the deployment")
        cmdline_script_utils.add_standard_cmdline_options(parser,
                                                          uses_pw_file=True)
        (self.options, args) = parser.parse_args(args=argv)

        if len(args)!=1:
            parser.error("Incorrect number of arguments - expecting install spec name")
        self.input_spec_file = args[0]
        if not os.path.exists(self.input_spec_file):
            parser.error("Install specification file %s does not exist" %
                         self.input_spec_file)

        (self.efl, self.deployment_home) = \
            cmdline_script_utils.process_standard_options(self.options, parser,
                                                          engage_file_layout,
                                                          installer_name=None)
        ir_file = self.efl.get_installed_resources_file(self.deployment_home)
        if self.options.additive_install:
            if not os.path.exists(ir_file):
                parser.error("--additive-install specified, but existing install file %s does not exist" % ir_file)
        else:
            if os.path.exists(ir_file):
                parser.error("Installed resources file %s already exists. Specify --additive-install if you want to add resources to this deployment home" %
                             ir_file)
                
        self.error_file = os.path.join(self.efl.get_log_directory(),
                                       "user_error.json")
        self.config_error_file = config_engine.get_config_error_file(self.efl)

        self.tr = get_target_machine_resource(self.deployment_home,
                                              self.efl.get_log_directory())

        if self.options.mgt_backends:
            import mgt_registration
            mgt_registration.validate_backend_names(self.options.mgt_backends,
                                                    parser)