Skip to content

Commit

Permalink
fix: jans-linux-setup code smell
Browse files Browse the repository at this point in the history
  • Loading branch information
devrimyatar committed Apr 30, 2022
1 parent 3c57d5e commit b790c01
Show file tree
Hide file tree
Showing 20 changed files with 73 additions and 73 deletions.
2 changes: 1 addition & 1 deletion jans-linux-setup/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class SampleInstaller(JettyInstaller):
self.oxtrust_war = 'https://ox.gluu.org/maven/org/gluu/oxtrust-server/%s/oxtrust-server-%s.war' % (Config.oxVersion, Config.oxVersion)
self.templates_folder = os.path.join(Config.templateFolder, 'sample-app') # folder where themplates of this application exists
self.output_folder = os.path.join(Config.outputFolder, 'sample-app') # folder where rendered templates to be written
self.output_folder = os.path.join(Config.output_dir, 'sample-app') # folder where rendered templates to be written
self.app_client_jks_fn = os.path.join(Config.certFolder, 'sample-app.jks')
Expand Down
6 changes: 3 additions & 3 deletions jans-linux-setup/jans_setup/jans_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ def ami_packaged():
sys.exit()

if paths.IAMPACKAGED:
Config.outputFolder = os.path.join(__STATIC_SETUP_DIR__, 'output')
if not os.path.exists(Config.outputFolder):
os.makedirs(Config.outputFolder)
Config.output_dir = os.path.join(__STATIC_SETUP_DIR__, 'output')
if not os.path.exists(Config.output_dir):
os.makedirs(Config.output_dir)

# initialize config object
Config.init(paths.INSTALL_DIR)
Expand Down
12 changes: 6 additions & 6 deletions jans-linux-setup/jans_setup/openbanking/setup_app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def progress(self, service_name, msg, incr=False):
self.jans_max_mem = int(base.current_mem_size * .85 * 1000) # 85% of physical memory
self.application_max_ram = int(int(Config.jans_max_mem) * .8)

self.outputFolder = os.path.join(self.install_dir, 'output')
self.output_dir = os.path.join(self.install_dir, 'output')
self.templateFolder = os.path.join(self.install_dir, 'templates')
self.staticFolder = os.path.join(self.install_dir, 'static')

Expand All @@ -203,7 +203,7 @@ def progress(self, service_name, msg, incr=False):
self.jans_python_readme = os.path.join(self.jansOptPythonFolder, 'libs/python.txt')
self.jansRDBMProperties = os.path.join(self.configFolder, 'jans-sql.properties')

self.system_profile_update_systemd = os.path.join(self.outputFolder, 'system_profile_systemd')
self.system_profile_update_systemd = os.path.join(self.output_dir, 'system_profile_systemd')

# OpenID key generation default setting
self.default_openid_jks_dn_name = 'CN=Jans Auth CA Certificates'
Expand All @@ -213,10 +213,10 @@ def progress(self, service_name, msg, incr=False):

self.post_messages = []

self.ldif_base = os.path.join(self.outputFolder, 'base.ldif')
self.ldif_attributes = os.path.join(self.outputFolder, 'attributes.ldif')
self.ldif_scopes = os.path.join(self.outputFolder, 'scopes.ldif')
self.ldif_configuration = os.path.join(self.outputFolder, 'configuration.ldif')
self.ldif_base = os.path.join(self.output_dir, 'base.ldif')
self.ldif_attributes = os.path.join(self.output_dir, 'attributes.ldif')
self.ldif_scopes = os.path.join(self.output_dir, 'scopes.ldif')
self.ldif_configuration = os.path.join(self.output_dir, 'configuration.ldif')

self.ce_templates = {
self.jans_python_readme: True,
Expand Down
18 changes: 9 additions & 9 deletions jans-linux-setup/jans_setup/setup_app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Config:
network = '/etc/sysconfig/network'
jetty_home = '/opt/jetty'
node_home = '/opt/node'
outputFolder = None
output_dir = None
jetty_base = os.path.join(jansOptFolder, 'jetty')
dist_app_dir = os.path.join(distFolder, 'app')
dist_jans_dir = os.path.join(distFolder, 'jans')
Expand Down Expand Up @@ -79,8 +79,8 @@ def init(self, install_dir=INSTALL_DIR):
self.thread_queue = None
self.jetty_user = 'jetty'
self.dump_config_on_error = False
if not self.outputFolder:
self.outputFolder = os.path.join(install_dir, 'output')
if not self.output_dir:
self.output_dir = os.path.join(install_dir, 'output')

self.ldap_bin_dir = os.path.join(self.ldap_base_dir, 'bin')
if base.snap:
Expand Down Expand Up @@ -269,16 +269,16 @@ def progress(self, service_name, msg, incr=False):
self.jansRDBMProperties = os.path.join(self.configFolder, 'jans-sql.properties')
self.jansSpannerProperties = os.path.join(self.configFolder, 'jans-spanner.properties')

self.ldif_base = os.path.join(self.outputFolder, 'base.ldif')
self.ldif_attributes = os.path.join(self.outputFolder, 'attributes.ldif')
self.ldif_scopes = os.path.join(self.outputFolder, 'scopes.ldif')
self.ldif_base = os.path.join(self.output_dir, 'base.ldif')
self.ldif_attributes = os.path.join(self.output_dir, 'attributes.ldif')
self.ldif_scopes = os.path.join(self.output_dir, 'scopes.ldif')

self.ldif_metric = os.path.join(self.staticFolder, 'metric/o_metric.ldif')
self.ldif_site = os.path.join(self.install_dir, 'static/cache-refresh/o_site.ldif')
self.ldif_configuration = os.path.join(self.outputFolder, 'configuration.ldif')
self.ldif_configuration = os.path.join(self.output_dir, 'configuration.ldif')

self.system_profile_update_init = os.path.join(self.outputFolder, 'system_profile_init')
self.system_profile_update_systemd = os.path.join(self.outputFolder, 'system_profile_systemd')
self.system_profile_update_init = os.path.join(self.output_dir, 'system_profile_init')
self.system_profile_update_systemd = os.path.join(self.output_dir, 'system_profile_systemd')

### rsyslog file customised for init.d
self.rsyslogUbuntuInitFile = os.path.join(self.install_dir, 'static/system/ubuntu/rsyslog')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self):

self.templates_folder = os.path.join(Config.templateFolder, self.service_name)
self.rs_protect_fn = os.path.join(Config.install_dir, 'setup_app/data/config-api-rs-protect.json')
self.output_folder = os.path.join(Config.outputFolder,'jans-config-api')
self.output_folder = os.path.join(Config.output_dir,'jans-config-api')
self.scope_ldif_fn = os.path.join(self.output_folder, 'scopes.ldif')
self.clients_ldif_fn = os.path.join(self.output_folder, 'clients.ldif')
self.dynamic_conf_json = os.path.join(self.output_folder, 'dynamic-conf.json')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def couchbaseProperties(self):
prop = open(os.path.join(Config.templateFolder, prop_file)).read()
prop_dict = self.couchbaseDict()
prop = prop % prop_dict
out_file = os.path.join(Config.outputFolder, prop_file)
out_file = os.path.join(Config.output_dir, prop_file)
self.writeFile(out_file, prop)
self.writeFile(Config.jansCouchebaseProperties, prop)

Expand Down
2 changes: 1 addition & 1 deletion jans-linux-setup/jans_setup/setup_app/installers/eleven.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self):
self.register_progess()


self.output_folder = os.path.join(Config.outputFolder, 'jans-eleven')
self.output_folder = os.path.join(Config.output_dir, 'jans-eleven')
self.template_folder = os.path.join(Config.templateFolder, 'jans-eleven')
self.eleven_conf_json = os.path.join(self.output_folder, 'jans-eleven.json')

Expand Down
2 changes: 1 addition & 1 deletion jans-linux-setup/jans_setup/setup_app/installers/fido.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self):
self.register_progess()

self.fido2ConfigFolder = os.path.join(Config.configFolder, 'fido2')
self.output_folder = os.path.join(Config.outputFolder, 'jans-fido2')
self.output_folder = os.path.join(Config.output_dir, 'jans-fido2')
self.template_folder = os.path.join(Config.templateFolder, 'jans-fido2')
self.fido2_dynamic_conf_json = os.path.join(self.output_folder, 'dynamic-conf.json')
self.fido2_static_conf_json = os.path.join(self.output_folder, 'static-conf.json')
Expand Down
2 changes: 1 addition & 1 deletion jans-linux-setup/jans_setup/setup_app/installers/httpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self):


self.templates_folder = os.path.join(Config.templateFolder, 'apache')
self.output_folder = os.path.join(Config.outputFolder, 'apache')
self.output_folder = os.path.join(Config.output_dir, 'apache')

self.apache2_conf = os.path.join(self.output_folder, 'httpd.conf')
self.apache2_ssl_conf = os.path.join(self.output_folder, 'https_jans.conf')
Expand Down
8 changes: 4 additions & 4 deletions jans-linux-setup/jans_setup/setup_app/installers/jans.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def makeFolders(self):
# Create these folder on all instances
for folder in (Config.jansOptFolder, Config.jansOptBinFolder, Config.jansOptSystemFolder,
Config.jansOptPythonFolder, Config.configFolder, Config.certFolder,
Config.outputFolder, Config.osDefault, os.path.join(Config.distFolder, 'scripts')):
Config.output_dir, Config.osDefault, os.path.join(Config.distFolder, 'scripts')):

if not os.path.exists(folder):
self.run([paths.cmd_mkdir, '-p', folder])
Expand Down Expand Up @@ -323,11 +323,11 @@ def update_hostname(self):
self.run(['/usr/bin/hostnamectl', 'set-hostname', Config.hostname])
else:
if Config.os_type in ['debian', 'ubuntu']:
self.copyFile("%s/hostname" % Config.outputFolder, Config.etc_hostname)
self.copyFile("%s/hostname" % Config.output_dir, Config.etc_hostname)
self.run(['/bin/chmod', '-f', '644', Config.etc_hostname])

if Config.os_type in ['centos', 'red', 'fedora']:
self.copyFile("%s/network" % Config.outputFolder, Config.network)
self.copyFile("%s/network" % Config.output_dir, Config.network)

self.run(['/bin/hostname', Config.hostname])

Expand Down Expand Up @@ -365,7 +365,7 @@ def copy_output(self):
for dest_fn in list(Config.ce_templates.keys()):
if Config.ce_templates[dest_fn]:
fn = os.path.split(dest_fn)[-1]
output_fn = os.path.join(Config.outputFolder, fn)
output_fn = os.path.join(Config.output_dir, fn)
try:
self.logIt("Copying %s to %s" % (output_fn, dest_fn))
dest_dir = os.path.dirname(dest_fn)
Expand Down
6 changes: 3 additions & 3 deletions jans-linux-setup/jans_setup/setup_app/installers/jans_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self):
]

self.templates_folder = os.path.join(Config.templateFolder, self.service_name)
self.output_folder = os.path.join(Config.outputFolder, self.service_name)
self.output_folder = os.path.join(Config.output_dir, self.service_name)

self.ldif_config = os.path.join(self.output_folder, 'configuration.ldif')
self.ldif_role_scope_mappings = os.path.join(self.output_folder, 'role-scope-mappings.ldif')
Expand Down Expand Up @@ -125,8 +125,8 @@ def render_import_templates(self):
Config.templateRenderingDict['oxauth_error_base64'] = self.generate_base64_ldap_file(self.oxauth_error_json)
Config.templateRenderingDict['oxauth_openid_key_base64'] = self.generate_base64_ldap_file(self.oxauth_openid_jwks_fn)

self.ldif_scripts = os.path.join(Config.outputFolder, 'scripts.ldif')
self.renderTemplateInOut(self.ldif_scripts, Config.templateFolder, Config.outputFolder)
self.ldif_scripts = os.path.join(Config.output_dir, 'scripts.ldif')
self.renderTemplateInOut(self.ldif_scripts, Config.templateFolder, Config.output_dir)
for temp in (self.ldif_config, self.ldif_role_scope_mappings):
self.renderTemplateInOut(temp, self.templates_folder, self.output_folder)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self):
config_dir = home_dir.joinpath('.config')
config_dir.mkdir(parents=True, exist_ok=True)

self.output_folder = os.path.join(Config.outputFolder, self.service_name)
self.output_folder = os.path.join(Config.output_dir, self.service_name)
self.jans_cli_install_dir = os.path.join(Config.jansOptFolder, 'jans-cli')
self.config_ini_fn = config_dir.joinpath('jans-cli.ini')
self.ldif_client = os.path.join(self.output_folder, 'client.ldif')
Expand Down
12 changes: 6 additions & 6 deletions jans-linux-setup/jans_setup/setup_app/installers/jetty.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,29 +179,29 @@ def installJettyService(self, serviceConfiguration, supportCustomizations=False,
self.update_rendering_dict()

try:
self.renderTemplateInOut(serviceName, '%s/jetty' % Config.templateFolder, '%s/jetty' % Config.outputFolder)
self.renderTemplateInOut(serviceName, '%s/jetty' % Config.templateFolder, '%s/jetty' % Config.output_dir)
except:
self.logIt("Error rendering service '%s' defaults" % serviceName, True)

jettyServiceConfiguration = '%s/jetty/%s' % (Config.outputFolder, serviceName)
jettyServiceConfiguration = '%s/jetty/%s' % (Config.output_dir, serviceName)
self.copyFile(jettyServiceConfiguration, Config.osDefault)
self.run([paths.cmd_chown, 'root:root', os.path.join(Config.osDefault, serviceName)])

# Render web eources file
try:
web_resources = '%s_web_resources.xml' % serviceName
if os.path.exists('%s/jetty/%s' % (Config.templateFolder, web_resources)):
self.renderTemplateInOut(web_resources, '%s/jetty' % Config.templateFolder, '%s/jetty' % Config.outputFolder)
self.copyFile('%s/jetty/%s' % (Config.outputFolder, web_resources), "%s/%s/webapps" % (self.jetty_base, serviceName))
self.renderTemplateInOut(web_resources, '%s/jetty' % Config.templateFolder, '%s/jetty' % Config.output_dir)
self.copyFile('%s/jetty/%s' % (Config.output_dir, web_resources), "%s/%s/webapps" % (self.jetty_base, serviceName))
except:
self.logIt("Error rendering service '%s' web_resources.xml" % serviceName, True)

# Render web context file
try:
web_context = '%s.xml' % serviceName
if os.path.exists('%s/jetty/%s' % (Config.templateFolder, web_context)):
self.renderTemplateInOut(web_context, '%s/jetty' % Config.templateFolder, '%s/jetty' % Config.outputFolder)
self.copyFile('%s/jetty/%s' % (Config.outputFolder, web_context), "%s/%s/webapps" % (self.jetty_base, serviceName))
self.renderTemplateInOut(web_context, '%s/jetty' % Config.templateFolder, '%s/jetty' % Config.output_dir)
self.copyFile('%s/jetty/%s' % (Config.output_dir, web_context), "%s/%s/webapps" % (self.jetty_base, serviceName))
except:
self.logIt("Error rendering service '%s' context xml" % serviceName, True)

Expand Down
16 changes: 8 additions & 8 deletions jans-linux-setup/jans_setup/setup_app/installers/opendj.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def extractOpenDJ(self):
except:
self.logIt("Error encountered while doing unzip %s -d /opt/" % (opendj_archive))

realLdapBaseFolder = os.path.realpath(Config.ldap_base_dir)
self.run([paths.cmd_chown, '-R', 'ldap:ldap', realLdapBaseFolder])
real_ldap_base_dir = os.path.realpath(Config.ldap_base_dir)
self.run([paths.cmd_chown, '-R', 'ldap:ldap', real_ldap_base_dir])

if Config.opendj_install == InstallTypes.REMOTE:
self.run([paths.cmd_ln, '-s', '/opt/opendj/template/config/', '/opt/opendj/config'])
Expand All @@ -119,19 +119,19 @@ def install_opendj(self):
# self.run([paths.cmd_mkdir, Config.ldap_base_dir])

# Copy opendj-setup.properties so user ldap can find it in /opt/opendj
setupPropsFN = os.path.join(Config.ldap_base_dir, 'opendj-setup.properties')
shutil.copy("%s/opendj-setup.properties" % Config.outputFolder, setupPropsFN)
setup_props_fn = os.path.join(Config.ldap_base_dir, 'opendj-setup.properties')
shutil.copy("%s/opendj-setup.properties" % Config.output_dir, setup_props_fn)

self.run([paths.cmd_chown, 'ldap:ldap', setupPropsFN])
self.run([paths.cmd_chown, 'ldap:ldap', setup_props_fn])


ldapSetupCommand = os.path.join(os.path.dirname(Config.ldap_bin_dir ), 'setup')
ldap_setup_command = os.path.join(os.path.dirname(Config.ldap_bin_dir ), 'setup')

setupCmd = " ".join([ldapSetupCommand,
setupCmd = " ".join([ldap_setup_command,
'--no-prompt',
'--cli',
'--propertiesFilePath',
setupPropsFN,
setup_props_fn,
'--acceptLicense'])
if base.snap:
self.run(setupCmd, shell=True)
Expand Down
2 changes: 1 addition & 1 deletion jans-linux-setup/jans_setup/setup_app/installers/rdbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self):
self.install_var = 'rdbm_install'
self.register_progess()
self.qchar = '`' if Config.rdbm_type in ('mysql', 'spanner') else '"'
self.output_dir = os.path.join(Config.outputFolder, Config.rdbm_type)
self.output_dir = os.path.join(Config.output_dir, Config.rdbm_type)

def install(self):

Expand Down
2 changes: 1 addition & 1 deletion jans-linux-setup/jans_setup/setup_app/installers/scim.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self):
self.register_progess()

self.templates_folder = os.path.join(Config.templateFolder, self.service_name)
self.output_folder = os.path.join(Config.outputFolder, self.service_name)
self.output_folder = os.path.join(Config.output_dir, self.service_name)

self.dynamic_config_fn = os.path.join(self.output_folder, 'dynamic-conf.json')
self.static_config_fn = os.path.join(self.output_folder, 'static-conf.json')
Expand Down
Loading

0 comments on commit b790c01

Please sign in to comment.