Re: [Freeipa-devel] [PATCH 0258] Server Upgrade: move code from ipa-upgrade config into separate module

2015-05-25 Thread Jan Cholasta

Dne 25.5.2015 v 16:46 Martin Basti napsal(a):

On 22/05/15 18:13, Martin Basti wrote:

IPA services upgrade is executed only by ipa-server-upgrade,
ipa-upgradeconfig will not work.

Patch attached.

https://fedorahosted.org/freeipa/ticket/4904




Updated patch attached.


Thanks, ACK.

Pushed to master: 027515230a93a7a60983d3eca26a97a0d9c3610e

--
Jan Cholasta

--
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code


Re: [Freeipa-devel] [PATCH 0258] Server Upgrade: move code from ipa-upgrade config into separate module

2015-05-25 Thread Martin Basti

On 22/05/15 18:13, Martin Basti wrote:
IPA services upgrade is executed only by ipa-server-upgrade, 
ipa-upgradeconfig will not work.


Patch attached.

https://fedorahosted.org/freeipa/ticket/4904




Updated patch attached.

--
Martin Basti

From 021bcf3ee911b472425a8ca4931570d5154100b5 Mon Sep 17 00:00:00 2001
From: Martin Basti 
Date: Fri, 22 May 2015 17:38:16 +0200
Subject: [PATCH] Server Upgrade: Move code from ipa-upgradeconfig to separate
 module

This also prevent the script ipa-upgradeconfig execute upgrading.
Upgrade of services is called from ipa-server-upgrade

https://fedorahosted.org/freeipa/ticket/4904
---
 install/tools/ipa-upgradeconfig| 1412 +---
 ipaserver/install/ipa_server_upgrade.py|   15 +-
 .../install/server.py  |  105 +-
 3 files changed, 30 insertions(+), 1502 deletions(-)
 copy install/tools/ipa-upgradeconfig => ipaserver/install/server.py (94%)
 mode change 100755 => 100644

diff --git a/install/tools/ipa-upgradeconfig b/install/tools/ipa-upgradeconfig
index dfef1e0aa8b1507b7aa4907e9b688ce99253b87c..43292966a29c9077443913bdda1c81aa3de06a10 100755
--- a/install/tools/ipa-upgradeconfig
+++ b/install/tools/ipa-upgradeconfig
@@ -19,1417 +19,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see .
 
-"""
-Upgrade configuration files to a newer template.
-"""
-
 import sys
-import re
-import os
-import shutil
-import pwd
-import fileinput
-import ConfigParser
-import grp
 
-from ipalib import api
-import SSSDConfig
-import ipalib.util
-import ipalib.errors
-from ipaplatform import services
-from ipaplatform.tasks import tasks
-from ipapython import ipautil, sysrestore, version, certdb
-from ipapython.config import IPAOptionParser
-from ipapython.ipa_log_manager import *
-from ipapython import certmonger
-from ipapython import dogtag
-from ipaplatform.paths import paths
-from ipaserver.install import installutils
-from ipaserver.install import dsinstance
-from ipaserver.install import httpinstance
-from ipaserver.install import memcacheinstance
-from ipaserver.install import bindinstance
-from ipaserver.install import service
-from ipaserver.install import cainstance
-from ipaserver.install import certs
-from ipaserver.install import otpdinstance
-from ipaserver.install import sysupgrade
-from ipaserver.install import dnskeysyncinstance
-
-
-def parse_options():
-parser = IPAOptionParser(version=version.VERSION)
-parser.add_option("-d", "--debug", dest="debug", action="store_true",
-  default=False, help="print debugging information")
-parser.add_option("-q", "--quiet", dest="quiet",
-  action="store_true",
-  default=False, help="Output only errors")
-
-options, args = parser.parse_args()
-safe_options = parser.get_safe_opts(options)
-
-return safe_options, options
-
-class KpasswdInstance(service.SimpleServiceInstance):
-def __init__(self):
-service.SimpleServiceInstance.__init__(self, "ipa_kpasswd")
-
-def uninstall_ipa_kpasswd():
-"""
-We can't use the full service uninstaller because that will attempt
-to stop and disable the service which by now doesn't exist. We just
-want to clean up sysrestore.state to remove all references to
-ipa_kpasswd.
-"""
-ipa_kpasswd = KpasswdInstance()
-
-running = ipa_kpasswd.restore_state("running")
-enabled = not ipa_kpasswd.restore_state("enabled")
-
-if enabled is not None and not enabled:
-ipa_kpasswd.remove()
-
-def backup_file(filename, ext):
-"""Make a backup of filename using ext as the extension. Do not overwrite
-   previous backups."""
-if not os.path.isabs(filename):
-raise ValueError("Absolute path required")
-
-backupfile = filename + ".bak"
-(reldir, file) = os.path.split(filename)
-
-while os.path.exists(backupfile):
-backupfile = backupfile + "." + str(ext)
-
-try:
-shutil.copy2(filename, backupfile)
-except IOError, e:
-if e.errno == 2: # No such file or directory
-pass
-else:
-raise e
-
-def update_conf(sub_dict, filename, template_filename):
-template = ipautil.template_file(template_filename, sub_dict)
-fd = open(filename, "w")
-fd.write(template)
-fd.close()
-
-def find_hostname():
-"""Find the hostname currently configured in ipa-rewrite.conf"""
-filename=paths.HTTPD_IPA_REWRITE_CONF
-
-if not ipautil.file_exists(filename):
-return None
-
-pattern = "^[\s#]*.*https:\/\/([A-Za-z0-9\.\-]*)\/.*"
-p = re.compile(pattern)
-for line in fileinput.input(filename):
-if p.search(line):
-fileinput.close()
-return p.search(line).group(1)
-fileinput.close()
-
-raise RuntimeError("Unable to determine the fully qualified hostname from %s" % filename)
-
-