- 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
- Location:
- fedd
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/fedd_config_file.py
rea0a821 reee2b2e 29 29 "create_experiment_cert_file", "create_experiment_cert_pwd", 30 30 "create_experiment_trusted_certs", "federation_script_dir", 31 "ssh_pubkey_file") 31 "ssh_pubkey_file", "experiment_state_file") 32 id_list_attrs = ("restricted",) 32 33 33 34 … … 43 44 for a in config_file.emulab_attrs + config_file.id_attrs: 44 45 setattr(self, a, None) 46 47 for a in config_file.id_list_attrs: 48 setattr(self, a, []) 45 49 46 50 self.attrs = { } … … 48 52 self.fedid_default = "user" 49 53 self.access = { } 50 self.restricted = []51 54 52 55 if config: … … 144 147 '|'.join(config_file.emulab_attrs + config_file.id_attrs) + \ 145 148 '):\s*(.*)', re.IGNORECASE) 149 list_re = re.compile("(" + '|'.join(config_file.id_list_attrs) + \ 150 "):\s*(.*)", re.IGNORECASE) 146 151 attr_re = re.compile('attribute:\s*([\._\-a-z0-9]+)\s+value:\s*(.*)', 147 152 re.IGNORECASE) … … 150 155 access_name + '\s*\)', re.IGNORECASE) 151 156 trustfile_re = re.compile("trustfile:\s*(.*)", re.IGNORECASE) 152 restricted_re = re.compile("restricted:\s*(.*)", re.IGNORECASE)153 157 154 158 def parse_name(n): … … 177 181 continue 178 182 183 # List attributes 184 m = list_re.match(line) 185 if m != None: 186 attr, val = m.group(1,2) 187 l = getattr(self, attr.lower()) 188 l.append(val) 189 continue 190 191 179 192 # Extended (attribute: x value: y) attribute line 180 193 m = attr_re.match(line) … … 206 219 if m != None: 207 220 self.read_trust(m.group(1)) 208 continue209 # Restricted node types210 211 m = restricted_re.match(line)212 if m != None:213 self.restricted.append(m.group(1))214 221 continue 215 222 -
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.