Changeset eee2b2e for fedd/fedd_experiment_control.py
- Timestamp:
- Oct 6, 2008 4:00:19 PM (16 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
- Children:
- a97394b
- Parents:
- ea0a821
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/fedd_experiment_control.py
rea0a821 reee2b2e 16 16 import tempfile 17 17 import copy 18 import pickle 18 19 19 20 import traceback … … 113 114 self.trusted_certs = None 114 115 115 if config.create_experiment_cert_file: 116 self.cert_file = config.create_experiment_cert_file 117 self.cert_pwd = config.create_experiment_cert_pwd 118 if config.create_experiment_trusted_certs: 119 self.trusted_certs = config.create_experiment_trusted_certs 120 121 if config.proxy_cert_file: 122 if not self.cert_file: 123 self.cert_file = config.proxy_cert_file 124 self.cert_pwd = config.proxy_cert_pwd 125 if config.proxy_trusted_certs: 126 if not self.trusted_certs: 127 self.trusted_certs = config.proxy_trusted_certs 128 129 if config.cert_file: 130 if not self.cert_file: 131 self.cert_file = config.cert_file 132 self.cert_pwd = config.cert_pwd 133 if config.trusted_certs: 134 if not self.trusted_certs: 135 self.trusted_certs = config.trusted_certs 116 # Walk through the various relevant certificat specifying config 117 # attributes until the local certificate attributes can be resolved. 118 # The walk is from omst specific to most general specification. 119 for p in ("create_experiment_", "proxy_", ""): 120 filen = "%scert_file" % p 121 pwn = "%scert_pwd" % p 122 trustn = "%strusted_certs" % p 123 124 if getattr(config, filen, None): 125 if not self.cert_file: 126 self.cert_file = getattr(config, filen, None) 127 self.cert_pwd = getattr(config, pwn, None) 128 129 if getattr(config, trustn, None): 130 if not self.trusted_certs: 131 self.trusted_certs = getattr(config, trustn, None) 136 132 137 133 self.exp_stem = "fed-stem" … … 150 146 self.ssh_type = "rsa" 151 147 self.state = { } 148 self.state_filename = config.experiment_state_file 152 149 self.tclsh = "/usr/local/bin/otclsh" 153 150 self.tcl_splitter = "/usr/testbed/lib/ns2ir/parse.tcl" … … 178 175 raise service_error(service_error.internal, 179 176 "Cannot read sshpubkey") 177 178 # Grab saved state 179 if self.state_filename: 180 self.read_state() 180 181 181 182 # Confirm federation scripts in the right place … … 250 251 s.close() 251 252 d.close() 253 254 def write_state(self): 255 if os.access(self.state_filename, os.W_OK): 256 self.copy_file(self.state_filename, \ 257 "%s.bak" % self.state_filename) 258 try: 259 f = open(self.state_filename, 'w') 260 pickle.dump(self.state, f) 261 except IOError, e: 262 print >>sys.stderr, "Can't write file %s: %s" % \ 263 (self.state_filename, e) 264 except pickle.PicklingError, e: 265 print >>sys.stderr, "Pickling problem: %s" % e 266 267 def read_state(self): 268 try: 269 f = open(self.state_filename, "r") 270 self.state = pickle.load(f) 271 except IOError, e: 272 print >>sys.stderr, "Can't open %s: %s" % \ 273 (self.state_filename, e) 274 except pickle.UnpicklingError, e: 275 print >>sys.stderr, "Unpickling failed: %s" % e 252 276 253 277 def scp_file(self, file, user, host, dest=""): … … 1381 1405 } 1382 1406 self.state[eid] = self.state[expid] 1407 if self.state_filename: self.write_state() 1383 1408 return resp 1384 1409 … … 1486 1511 1487 1512 if fed_exp: 1513 ids = [] 1514 # experimentID is a list of dicts that are self-describing 1515 # identifiers. This finds all the fedids and localnames - the 1516 # keys of self.state - and puts them into ids. 1517 for id in fed_exp.get('experimentID', []): 1518 if id.has_key('fedid'): ids.append(id['fedid']) 1519 if id.has_key('localname'): ids.append(id['localname']) 1520 1488 1521 # Construct enough of the tbparams to make the stop_segment calls 1489 1522 # work … … 1516 1549 for tb in tbparams.keys(): 1517 1550 self.stop_segment(tb, tbparams[tb]['eid'], tbparams) 1551 1552 for id in ids: 1553 if self.state.has_key(id): del self.state[id] 1554 1555 if self.state_filename: self.write_state() 1518 1556 return { 'experiment': exp } 1519 1557 else:
Note: See TracChangeset
for help on using the changeset viewer.