summaryrefslogtreecommitdiffstats
path: root/base/deploy/src/scriptlets/configuration.jy
blob: f7366c723b010e5170939a504eb59a9c709d474c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/jython

# System Python Imports
import os
import pickle
import sys


# PKI Python Imports
import pkijython as jyutil
import pkiconfig as config
from pkiconfig import pki_master_jython_dict as master
import pkimessages as log


# System Java Imports
from java.lang import System as javasystem


def main(argv):
    # Establish 'master' as the PKI jython dictionary
    master = dict()

    # import the master dictionary from 'pkispawn'
    master = pickle.loads(argv[1])

    # IMPORTANT:  Unfortunately, 'jython 2.2' does NOT support logging!
    #
    #             Until, and unless, 'jython 2.5' or later is used,
    #             debugging will basically be limited to using 'print'
    #             since creating a logging mechanism for 'jython 2.2'
    #             would not make sense at this point in time, although
    #             a 'customized' manual log process could be created.
    #
    #             Regardless of 'jython' version, the log file generated
    #             by this standalone 'jython' process would be unique and
    #             separate to the log file generated for the PKI
    #             deployment scriptlets 'python' process, as they exist
    #             as two separate processes (until and unless 'jython 2.7'
    #             could be used to completely replace 'python 2.7',
    #             in which case a single process could be executed
    #             end-to-end from installation through configuration).
    #
    if master['pki_jython_log_level'] >= config.PKI_JYTHON_DEBUG_LOG_LEVEL:
        # javasystem.out.println("Hello")
        print "%s %s" %\
              (log.PKI_JYTHON_INDENTATION_2, sys.path)
        print "%s %s" %\
              (log.PKI_JYTHON_INDENTATION_2,
               javasystem.getProperties()['java.class.path'])
        for key in master:
            print "%s '%s' = '%s'" %\
                  (log.PKI_JYTHON_INDENTATION_2, key, master[key])

    # Initialize token
    jyutil.security_databases.initialize_token(
        master['pki_client_database_path'],
        master['pki_dry_run_flag'],
        master['pki_jython_log_level'])

    # Log into token
    jyutil.security_databases.log_into_token(
        master['pki_client_database_path'],
        master['pki_client_password_conf'],
        master['pki_dry_run_flag'],
        master['pki_jython_log_level'])


if __name__ == "__main__":
    main(sys.argv)