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)
def upgrade(backup_dir, file_layout, deployment_home, options, atomic_upgrade=True): old_resources = get_old_resources(backup_dir) mgrs_and_pkgs = cmdline_script_utils.get_mgrs_and_pkgs(file_layout, deployment_home, options, file_layout.get_install_script_file()) undo_list = [] for (m, p) in mgrs_and_pkgs: id = m.metadata.id try: if old_resources.has_key(id) and old_resources[id].key['name']==m.metadata.key['name'] and \ m.metadata.key['version']>=old_resources[id].key['version']: logger.info("Calling upgrade for resource %s" % id) m.upgrade(p, old_resources[id], backup_dir) else: if not m.is_installed(): logger.info("Installing resource %s" % id) m.install(p) else: logger.info("Resource %s already installed" % id) m.metadata.set_installed() if m.is_service() and not m.is_running(): m.start() undo_list.append(m) except: if not atomic_upgrade: raise exc_info = (exc_class, exc_val, exc_tb) = sys.exc_info() logger.exception("Upgrade of %s failed, will attempt undo" % m.id) _undo_bad_install(m, undo_list, deployment_home, "%s(%s)" % (exc_class.__name__, exc_val)) user_error = convert_exc_to_user_error(exc_info, errors[ERR_UPGRADE_ROLLBACK], msg_args={'id':m.id}, user_error_class=UpgradeRollbackInProgress) user_error.resource_id = m raise user_error install_target_mgr = get_install_target_mgr(mgrs_and_pkgs) managers = [mgr for (mgr, pkg) in mgrs_and_pkgs] install_target_mgr.write_resources_to_file(managers) if options.mgt_backends: import mgt_registration import install_context mgt_registration.register_with_mgt_backends(options.mgt_backends, managers, deployment_home, sudo_password=install_context.get_sudo_password(), upgrade=True) return 0