git://git.onelab.eu
/
sfa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
00fdc14
)
added upgrade_config(), used to upgrade from shell to ini format
author
Tony Mack
<tmack@paris.CS.Princeton.EDU>
Tue, 17 Jul 2012 19:20:34 +0000
(15:20 -0400)
committer
Tony Mack
<tmack@paris.CS.Princeton.EDU>
Tue, 17 Jul 2012 19:20:34 +0000
(15:20 -0400)
sfa/client/sfi.py
patch
|
blob
|
history
diff --git
a/sfa/client/sfi.py
b/sfa/client/sfi.py
index
80e8fc3
..
e7ac1e0
100644
(file)
--- a/
sfa/client/sfi.py
+++ b/
sfa/client/sfi.py
@@
-17,6
+17,7
@@
from lxml import etree
from StringIO import StringIO
from optparse import OptionParser
from pprint import PrettyPrinter
from StringIO import StringIO
from optparse import OptionParser
from pprint import PrettyPrinter
+from tempfile import mkstemp
from sfa.trust.certificate import Keypair, Certificate
from sfa.trust.gid import GID
from sfa.trust.certificate import Keypair, Certificate
from sfa.trust.gid import GID
@@
-527,19
+528,39
@@
class Sfi:
return
return
+ def upgrade_config(self, config_file):
+ """
+ upgrade from shell to ini format
+ """
+ fp, fn = mkstemp(suffix='sfi_config', text=True)
+ try:
+ tmp_config = Config(fn)
+ tmp_config.add_section('sfi')
+ tmp_config.load(config_file)
+ tmp_config.save(config_file)
+ except:
+ raise
+ finally:
+ os.unlink(fn)
+
+
####################
def read_config(self):
config_file = os.path.join(self.options.sfi_dir,"sfi_config")
try:
config = Config (config_file)
except:
####################
def read_config(self):
config_file = os.path.join(self.options.sfi_dir,"sfi_config")
try:
config = Config (config_file)
except:
- self.logger.critical("Failed to read configuration file %s"%config_file)
- self.logger.info("Make sure to remove the export clauses and to add quotes")
- if self.options.verbose==0:
- self.logger.info("Re-run with -v for more details")
- else:
- self.logger.log_exc("Could not read config file %s"%config_file)
- sys.exit(1)
+ try:
+ # try upgrading from old config format
+ self.upgrade_config(config_file)
+ except:
+ self.logger.critical("Failed to read configuration file %s"%config_file)
+ self.logger.info("Make sure to remove the export clauses and to add quotes")
+ if self.options.verbose==0:
+ self.logger.info("Re-run with -v for more details")
+ else:
+ self.logger.log_exc("Could not read config file %s"%config_file)
+ sys.exit(1)
errors = 0
# Set SliceMgr URL
errors = 0
# Set SliceMgr URL