Changeset 23dec62
- Timestamp:
- Sep 17, 2009 2:45:04 PM (15 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-2.00, version-3.01, version-3.02
- Children:
- 68bb551
- Parents:
- 5a03ea5
- Location:
- fedd
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/fedd_client.py
r5a03ea5 r23dec62 234 234 help="Size of output in pixels (diagrams are square") 235 235 236 class fedd_start_opts(fedd_client_opts): 237 def __init__(self): 238 fedd_client_opts.__init__(self) 239 self.add_option("-f", "--file", dest="file", 240 help="experiment description file") 241 236 242 def exit_with_fault(dict, out=sys.stderr): 237 243 """ Print an error message and exit. … … 299 305 raise OptionValueError("Bad node description: %s" % value) 300 306 301 def get_user_info(self, access_keys ):307 def get_user_info(self, access_keys=None): 302 308 pw = pwd.getpwuid(os.getuid()); 303 309 try_cert=None … … 309 315 if not os.access(try_cert, os.R_OK): 310 316 try_cert = None 311 if len(access_keys) == 0:317 if access_keys is not None and len(access_keys) == 0: 312 318 for k in ["%s/.ssh/id_rsa.pub", "%s/.ssh/id_dsa.pub", 313 319 "%s/.ssh/identity.pub"]: … … 1223 1229 sys.exit("No log returned") 1224 1230 1231 class terminate_segment(fedd_rpc): 1232 def __init__(self): 1233 """ 1234 Termination request 1235 """ 1236 1237 fedd_rpc.__init__(self, "TerminateSegment") 1238 1239 def __call__(self): 1240 """ 1241 The control flow. Compose the request and print the response. 1242 """ 1243 # Process the options using the customized option parser defined above 1244 parser = fedd_terminate_opts() 1245 1246 (opts, args) = parser.parse_args() 1247 1248 (user, cert) = self.get_user_info([]) 1249 if opts.trusted: 1250 if ( not os.access(opts.trusted, os.R_OK) ) : 1251 sys.exit("Cannot read trusted certificates (%s)" % opts.trusted) 1252 1253 if opts.debug > 0: opts.tracefile=sys.stderr 1254 1255 if opts.cert != None: cert = opts.cert 1256 1257 if cert == None: 1258 sys.exit("No certificate given (--cert) or found") 1259 1260 if os.access(cert, os.R_OK): 1261 fid = fedid(file=cert) 1262 else: 1263 sys.exit("Cannot read certificate (%s)" % cert) 1264 1265 if opts.exp_name and opts.exp_certfile: 1266 sys.exit("Only one of --experiment_cert and " +\ 1267 "--experiment_name permitted") 1268 1269 if opts.print_log and opts.logfile: 1270 sys.exit("Only one of --logfile and --print_log is permitted") 1271 elif opts.print_log: 1272 out = sys.stdout 1273 elif opts.logfile: 1274 try: 1275 out = open(opts.logfile, "w") 1276 except IOError,e: 1277 sys.exit("Cannot open logfile: %s" %e) 1278 else: 1279 out = None 1280 1281 exp_id = None 1282 1283 if opts.exp_certfile: 1284 exp_id = { 'fedid': fedid(file=opts.exp_certfile) } 1285 1286 if opts.exp_name: 1287 exp_id = { 'localname' : opts.exp_name } 1288 1289 if not exp_id: 1290 sys.exit("Must give one of --experiment_cert and " +\ 1291 "--experiment_name"); 1292 1293 req = { 'allocID': exp_id, 'force': opts.force } 1294 1295 try: 1296 resp_dict = self.do_rpc(req, 1297 opts.url, opts.transport, cert, opts.trusted, 1298 serialize_only=opts.serialize_only, 1299 tracefile=opts.tracefile) 1300 except self.RPCException, e: 1301 exit_with_fault(\ 1302 {'desc': e.desc, 'errstr': e.errstr, 'code': e.code}) 1303 except RuntimeError, e: 1304 print e 1305 sys.exit("Error processing RPC: %s" % e) 1306 1307 if out: 1308 log = resp_dict.get('deallocationLog', None) 1309 if log: 1310 print >>out, log 1311 out.close() 1312 else: 1313 out.close() 1314 sys.exit("No log returned") 1315 1225 1316 class create(fedd_rpc): 1226 1317 def __init__(self): … … 1597 1688 out.close() 1598 1689 1690 class start_segment(fedd_rpc): 1691 def __init__(self): 1692 fedd_rpc.__init__(self, "StartSegment") 1693 def __call__(self): 1694 # Process the options using the customized option parser defined above 1695 parser = fedd_start_opts() 1696 1697 (opts, args) = parser.parse_args() 1698 1699 if opts.trusted: 1700 if ( not os.access(opts.trusted, os.R_OK) ) : 1701 sys.exit("Cannot read trusted certificates (%s)" % opts.trusted) 1702 1703 if opts.debug > 0: opts.tracefile=sys.stderr 1704 1705 (user, cert) = self.get_user_info() 1706 1707 if opts.cert != None: cert = opts.cert 1708 1709 if cert == None: 1710 sys.exit("No certificate given (--cert) or found") 1711 1712 if os.access(cert, os.R_OK): 1713 fid = fedid(file=cert) 1714 else: 1715 sys.exit("Cannot read certificate (%s)" % cert) 1716 1717 if opts.file: 1718 try: 1719 top = topdl.topology_from_xml(filename=opts.file, 1720 top='experiment') 1721 except IOError: 1722 sys.exit("Cannot read description file (%s)" %opts.file) 1723 else: 1724 sys.exit("Must specify an experiment description (--file)") 1725 1726 msg = { 1727 'segmentdescription': { 'topdldescription': top.to_dict() }, 1728 'allocID': pack_id(fid), 1729 'master': False, 1730 } 1731 1732 if opts.debug > 1: print >>sys.stderr, msg 1733 1734 try: 1735 resp_dict = self.do_rpc(msg, 1736 opts.url, opts.transport, cert, opts.trusted, 1737 serialize_only=opts.serialize_only, 1738 tracefile=opts.tracefile) 1739 except self.RPCException, e: 1740 exit_with_fault(\ 1741 {'desc': e.desc, 'errstr': e.errstr, 'code': e.code}) 1742 except RuntimeError, e: 1743 sys.exit("Error processing RPC: %s" % e) 1744 1745 if opts.debug > 1: print >>sys.stderr, resp_dict 1746 print resp_dict 1747 1748 1599 1749 1600 1750 cmds = {\ … … 1613 1763 'spewlog': spew_log(),\ 1614 1764 'topdl_image': topdl_image(),\ 1765 'start_segment': start_segment(),\ 1766 'terminate_segment': terminate_segment(),\ 1615 1767 } 1616 1768 -
fedd/federation/deter_impl.py
r5a03ea5 r23dec62 2 2 3 3 import emulab_access 4 import dragon_access 4 5 from experiment_control import experiment_control_local 5 6 from split import split_local … … 48 49 if self.access_type == "emulab": 49 50 self.access = emulab_access.access(config, self.auth) 51 elif self.access_type == "dragon": 52 self.access = dragon_access.access(config, self.auth) 50 53 else: 51 54 raise RuntimeError("Unknown access_type: %s" % \
Note: See TracChangeset
for help on using the changeset viewer.