Fixed path issues with keystone-import.
Made it a python script so that we wouldn't be dealing with load path issues - or execing a python script a bazillion times. Change-Id: Ib0c1b74e8bc2b2f96962e1cee5dc20efff642ad3
This commit is contained in:
parent
eee307a896
commit
acb2d074d3
|
@ -1,4 +1,4 @@
|
||||||
#! /usr/bin/env bash
|
#!/usr/bin/env python
|
||||||
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
|
|
||||||
|
@ -19,6 +19,23 @@
|
||||||
# This file is to read a export file from Nova that will import users, tenants and EC2 credentials
|
# This file is to read a export file from Nova that will import users, tenants and EC2 credentials
|
||||||
# The file should be in the keystone-manage format
|
# The file should be in the keystone-manage format
|
||||||
|
|
||||||
while read line; do
|
import os
|
||||||
./bin/keystone-manage $line
|
import sys
|
||||||
done < $1
|
import shlex
|
||||||
|
|
||||||
|
# If ../../keystone/__init__.py exists, add ../ to Python search path, so that
|
||||||
|
# it will override what happens to be installed in /usr/(local/)lib/python...
|
||||||
|
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
|
||||||
|
os.pardir,
|
||||||
|
os.pardir))
|
||||||
|
if os.path.exists(os.path.join(possible_topdir, 'keystone', '__init__.py')):
|
||||||
|
sys.path.insert(0, possible_topdir)
|
||||||
|
|
||||||
|
import keystone.manage
|
||||||
|
|
||||||
|
with open(sys.argv[1], 'r') as line:
|
||||||
|
try:
|
||||||
|
keystone.manage.main(shlex.split(line))
|
||||||
|
except Exception as exc:
|
||||||
|
# Main prints all of the errors we need
|
||||||
|
sys.exit(1)
|
||||||
|
|
|
@ -229,9 +229,9 @@ def process(*args):
|
||||||
print ("ERROR: unrecognized command %s %s" % (object_type, command))
|
print ("ERROR: unrecognized command %s %s" % (object_type, command))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main(args=None):
|
||||||
try:
|
try:
|
||||||
process(*parse_args())
|
process(*parse_args(args))
|
||||||
except optparse.OptParseError as exc:
|
except optparse.OptParseError as exc:
|
||||||
print >> sys.stderr, exc
|
print >> sys.stderr, exc
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
@ -244,8 +244,11 @@ def main():
|
||||||
else:
|
else:
|
||||||
print "ERROR: %s: %s" % (exc.args[0], info)
|
print "ERROR: %s: %s" % (exc.args[0], info)
|
||||||
logging.error(exc.args[0], exc_info=info)
|
logging.error(exc.args[0], exc_info=info)
|
||||||
sys.exit(1)
|
raise exc
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
try:
|
||||||
|
main()
|
||||||
|
except Exception as exc:
|
||||||
|
sys.exit(1)
|
||||||
|
|
Loading…
Reference in New Issue