Skip to content

Commit

Permalink
Don't try legacy installs
Browse files Browse the repository at this point in the history
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
  • Loading branch information
stlaz authored and tiran committed Nov 13, 2018
1 parent 8f9b0fc commit 383311a
Showing 1 changed file with 2 additions and 85 deletions.
87 changes: 2 additions & 85 deletions ipaserver/install/dsinstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import shutil
import pwd
import os
import re
import time
import tempfile
import stat
Expand Down Expand Up @@ -96,30 +95,7 @@ def schema_dirname(serverid):
return config_dirname(serverid) + "/schema/"


def __remove_instance_legacy(serverid, force=False):
"""A wrapper around the 'remove-ds.pl' script used by
389ds to remove a single directory server instance. In case of error
additional call with the '-f' flag is performed (forced removal). If this
also fails, then an exception is raised.
"""
instance_name = ''.join([DS_INSTANCE_PREFIX, serverid])
args = [paths.REMOVE_DS_PL, '-i', instance_name]
if force:
args.append('-f')
logger.debug("Forcing instance removal")

try:
ipautil.run(args)
except ipautil.CalledProcessError:
if force:
logger.error("Instance removal failed.")
raise
logger.debug("'%s' failed. "
"Attempting to force removal", paths.REMOVE_DS_PL)
remove_ds_instance(serverid, force=True)


def __remove_instance_python(serverid):
def remove_ds_instance(serverid):
"""Call the lib389 api to remove the instance. Because of the
design of the api, there is no "force" command. Provided a marker
file exists, it will attempt the removal, and the marker is the *last*
Expand All @@ -140,15 +116,6 @@ def __remove_instance_python(serverid):
logger.debug("Instance removed correctly.")


def remove_ds_instance(serverid, force=False):
if os.path.exists(paths.REMOVE_DS_PL):
# We still have legacy tools. Lets use them.
__remove_instance_legacy(serverid, force)
else:
# 389 have removed their perl tools \o/. Use the api driven installer
__remove_instance_python(serverid)


def get_ds_instances():
'''
Return a sorted list of all 389ds instances.
Expand Down Expand Up @@ -580,49 +547,7 @@ def __setup_sub_dict(self):
' '.join(replication.TOTAL_EXCLUDES),
)

def __create_instance_legacy(self):
pent = pwd.getpwnam(DS_USER)

self.backup_state("serverid", self.serverid)
self.fstore.backup_file(paths.SYSCONFIG_DIRSRV)

self.sub_dict['BASEDC'] = self.realm.split('.')[0].lower()
base_txt = ipautil.template_str(BASE_TEMPLATE, self.sub_dict)
logger.debug("%s", base_txt)

target_fname = paths.DIRSRV_BOOT_LDIF
base_fd = open(target_fname, "w")
base_fd.write(base_txt)
base_fd.close()

# Must be readable for dirsrv
os.chmod(target_fname, 0o440)
os.chown(target_fname, pent.pw_uid, pent.pw_gid)

inf_txt = ipautil.template_str(INF_TEMPLATE, self.sub_dict)
logger.debug("writing inf template")
inf_fd = ipautil.write_tmp_file(inf_txt)
inf_txt = re.sub(r"RootDNPwd=.*\n", "", inf_txt)
logger.debug("%s", inf_txt)
args = [
paths.SETUP_DS_PL, "--silent",
"--logfile", "-",
"-f", inf_fd.name,
]
logger.debug("calling setup-ds.pl")
try:
ipautil.run(args)
logger.debug("completed creating DS instance")
except ipautil.CalledProcessError as e:
raise RuntimeError("failed to create DS instance %s" % e)

# check for open port 389 from now on
self.open_ports.append(389)

inf_fd.close()
os.remove(paths.DIRSRV_BOOT_LDIF)

def __create_instance_python(self):
def __create_instance(self):
# We only import lib389 now, we can't always guarantee its presence
# yet. After f28, this can be made a dependency proper.
from lib389.instance.setup import SetupDs
Expand Down Expand Up @@ -678,14 +603,6 @@ def __create_instance_python(self):
# Done!
logger.debug("completed creating DS instance")

def __create_instance(self):
if os.path.exists(paths.SETUP_DS_PL):
# We still have legacy tools. Lets use them.
self.__create_instance_legacy()
else:
# 389 have removed its perl tools \o/. Use the api driven installer
self.__create_instance_python()

def __update_dse_ldif(self):
"""
This method updates dse.ldif right after instance creation. This is
Expand Down

0 comments on commit 383311a

Please sign in to comment.