Example #1
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)
Example #2
0
    def process_args(self, argv, installer_file_layout=None):
        usage = "usage: %prog [options] installer_name"
        parser = OptionParser(usage=usage)
        cmdline_script_utils.add_standard_cmdline_options(parser)
        parser.add_option("--config-choices-file", dest="config_choices_file",
                          default=None, help="If specified, get configuration choices from this json file, rather than interactively from the user")
        parser.add_option("--config-choices-history-file", dest="history_file",
                          default=None, help="If specified, save config choices to this file")
        parser.add_option("--upgrade", "-u", dest="upgrade_from", action="store",
                          default=None,
                          help="If specified, we are doing an upgrade from the app backed up to the specified source directory")
        parser.add_option("--application-archive", "-a", dest="application_archive", action="store",
                          default=None,
                          help="If specified, override the application_archive property in config choices file with this value")
        parser.add_option("--no-rollback-on-failed-upgrades", dest="no_rollback_on_failed_upgrades",
                          default=False, action="store_true",
                          help="If specified, do not roll back a failed upgrade (helpful for debugging).")
        parser.add_option("-y", "--use-defaults", dest="use_defaults",
                          default=False, action="store_true",
                          help="If specified, always pick default for input options")
        (self.options, args) = parser.parse_args(args=argv)

        if len(args)>1:
            parser.error("Extra arguments - expecting only installer name")

        if self.options.config_choices_file:
            config_choices_file = os.path.abspath(os.path.expanduser(self.options.config_choices_file))
            if not os.path.exists(config_choices_file):
                parser.error("Configuration choices file %s does not exist" % config_choices_file)
            self.config_choices = ConfigChoices(config_choices_file)
        else:
            self.config_choices = ConfigChoices(use_defaults=self.options.use_defaults)

        # processing of --application-archive option
        if self.options.application_archive:
            app_archive = os.path.abspath(os.path.expanduser(self.options.application_archive))
            if not os.path.exists(app_archive):
                parser.error("Application archive %s does not exist" % app_archive)
            if self.options.config_choices_file:
                self.config_choices.choices_from_file[APPLICATION_ARCHIVE_PROP] = app_archive
            else:
                self.config_choices.app_archive_value = app_archive
            
        # figure out which installer we are running
        if installer_file_layout:
            self.installer_name = installer_file_layout.installer_name
            if len(args)==1 and installer_file_layout.installer_name!=args[0]:
                parser.error("installer name '%s' provided on commmand line does not match installer name provided by installer_file_layout '%s'"
                             % (args[0], installer_file_layout.installer_name))
        elif self.options.config_choices_file:
            if len(args)>0:
                parser.error("Do not specify installer on command line if running from a config choices file")
            self.installer_name = self.config_choices.get_installer_name()
        else:
            if len(args)==0:
                parser.error("Must provide name of installer")
            self.installer_name = args[0]

        self.config_choices.set_installer_name(self.installer_name)

        (self.installer_file_layout, self.deployment_home) = \
            cmdline_script_utils.process_standard_options(self.options,
                                                          parser,
                                                          installer_file_layout,
                                                          installer_name=self.installer_name)

        if self.options.upgrade_from:
            self.upgrade_from = os.path.abspath(os.path.expanduser(self.options.upgrade_from))
            if not os.path.isdir(self.upgrade_from):
                parser.error("Application backup directory %s does not exist" % self.upgrade_from)

        self.error_file = os.path.join(self.installer_file_layout.get_log_directory(),
                                       "user_error.json")
        self.config_error_file = get_config_error_file(self.installer_file_layout)

        if self.options.mgt_backends:
            import mgt_registration
            mgt_registration.validate_backend_names(self.options.mgt_backends, parser)
            # save backends in history for use in upgrades
            self.config_choices.choice_history[MGT_BACKENDS_PROP] = self.options.mgt_backends
        elif self.config_choices.choices_from_file and \
                self.config_choices.choices_from_file.has_key(MGT_BACKENDS_PROP):
            # If a previous run had management backends specified, use those
            self.options.mgt_backends = self.config_choices.choices_from_file[MGT_BACKENDS_PROP]
            import mgt_registration
            mgt_registration.validate_backend_names(self.options.mgt_backends, parser)