components/openstack/keystone/files/keystone
branchs11u3-sru
changeset 6035 c9748fcc32de
parent 4625 18adb92d4193
child 6851 f984e52b96bb
equal deleted inserted replaced
6016:a477397bba8b 6035:c9748fcc32de
    17 import os
    17 import os
    18 import sys
    18 import sys
    19 
    19 
    20 import smf_include
    20 import smf_include
    21 
    21 
    22 from subprocess import CalledProcessError, check_call
    22 from subprocess import CalledProcessError, check_call, Popen
       
    23 
       
    24 
       
    25 def httpd(cmd):
       
    26     cmd = ['/usr/apache2/2.4/bin/httpd', '-f',
       
    27            '/var/lib/keystone/keystone.httpd.conf', '-k', cmd]
       
    28     try:
       
    29         Popen(cmd, stdout=sys.stdout, stderr=sys.stderr)
       
    30     except CalledProcessError as err:
       
    31         print >> sys.stderr, 'Error executing %s: %s' % (cmd, err)
       
    32         sys.exit(smf_include.SMF_EXIT_ERR_FATAL)
       
    33 
       
    34     sys.exit(smf_include.SMF_EXIT_OK)
    23 
    35 
    24 
    36 
    25 def start():
    37 def start():
    26     # sync the database to make sure it's ready
    38     # sync the database to make sure it's ready
    27     cmd = ["/usr/bin/keystone-manage", "db_sync"]
    39     cmd = ['/usr/bin/keystone-manage', 'db_sync']
    28     try:
    40     try:
    29         check_call(cmd)
    41         check_call(cmd)
    30     except CalledProcessError as err:
    42     except CalledProcessError as err:
    31         print "Unable to create database for Keystone:  %s" % err
    43         print 'Unable to create database for Keystone:  %s' % err
    32         sys.exit(smf_include.SMF_EXIT_ERR_CONFIG)
    44         sys.exit(smf_include.SMF_EXIT_ERR_CONFIG)
    33 
    45 
    34     smf_include.smf_subprocess("/usr/lib/keystone/keystone-all")
    46     httpd('start')
    35 
    47 
    36 if __name__ == "__main__":
    48 
    37     os.putenv("LC_ALL", "C")
    49 def stop():
       
    50     httpd('stop')
       
    51 
       
    52 
       
    53 def restart():
       
    54     httpd('restart')
       
    55 
       
    56 
       
    57 if __name__ == '__main__':
       
    58     os.putenv('LC_ALL', 'C')
    38     smf_include.smf_main()
    59     smf_include.smf_main()