- Timestamp:
- Sep 30, 2009 3:45:43 PM (15 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-2.00, version-3.01, version-3.02
- Children:
- ab33158
- Parents:
- 6c1981f
- Location:
- fedd
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/abac_client.py
r6c1981f r181cf9c 227 227 self.add_option("-l","--label", action="store", dest="label", 228 228 type="string", help="Label for output") 229 self.add_option("-i", "--context_id", action="store", dest="id", 230 type="string", 231 help="Negotiation context identifier (required)") 232 self.add_option("-g", "--goal", action="store", dest="goal", 233 type="string", 234 help="Trust target goal for negotiation (required)") 229 235 if add_node_callback: 230 236 self.add_option("-n", "--node", action="callback", type="string", … … 494 500 # out_certfile = opts.out_certfile 495 501 496 print " file =%s" % opts.file502 print "New context using file: %s" % opts.file 497 503 # msg = { 'ContextIn': { 'contextFile': opts.file } } 498 504 msg = { 'contextFile': opts.file } … … 513 519 if opts.debug > 1: print >>sys.stderr, resp_dict 514 520 515 ea = resp_dict.get('experimentAccess', None) 521 # ea = resp_dict.get('experimentAccess', None) 522 id = resp_dict.get('contextID', None) 523 print "New context loaded w/id = %s" % id 524 525 class negotiate(abac_rpc): 526 def __init__(self): 527 abac_rpc.__init__(self, "Negotiate") 528 def __call__(self): 529 access_keys = [] 530 # Process the options using the customized option parser defined above 531 parser = abac_create_opts(access_keys, self.add_ssh_key, 532 self.add_x509_cert) 533 534 (opts, args) = parser.parse_args() 535 536 if opts.trusted: 537 if ( not os.access(opts.trusted, os.R_OK) ) : 538 sys.exit("Cannot read trusted certificates (%s)" % opts.trusted) 539 540 if not opts.project : 541 parser.error('--project is required') 542 543 if opts.debug > 0: opts.tracefile=sys.stderr 544 545 (user, cert) = self.get_user_info(access_keys) 546 547 if opts.user: user = opts.user 548 549 if opts.cert != None: cert = opts.cert 550 551 if cert == None: 552 sys.exit("No certificate given (--cert) or found") 553 554 if os.access(cert, os.R_OK): 555 fid = fedid(file=cert) 556 if opts.use_fedid == True: 557 user = fid 558 else: 559 sys.exit("Cannot read certificate (%s)" % cert) 560 561 if opts.file: 562 exp_desc = "" 563 try: 564 f = open(opts.file, 'r') 565 for line in f: 566 exp_desc += line 567 f.close() 568 except IOError: 569 sys.exit("Cannot read description file (%s)" %opts.file) 570 else: 571 sys.exit("Must specify an experiment description (--file)") 572 573 if not opts.master: 574 sys.exit("Must specify a master testbed (--master)") 575 576 out_certfile = opts.out_certfile 577 578 msg = { 579 'experimentdescription': { 'ns2description': exp_desc }, 580 'master': opts.master, 581 'exportProject': { 'localname': opts.project }, 582 'user' : [ {\ 583 'userID': pack_id(user), \ 584 'access': [ { a.type: a.buf } for a in access_keys]\ 585 } ] 586 } 587 588 if opts.exp_name: 589 msg['experimentID'] = { 'localname': opts.exp_name } 590 591 if opts.debug > 1: print >>sys.stderr, msg 592 593 try: 594 resp_dict = self.do_rpc(msg, 595 opts.url, opts.transport, cert, opts.trusted, 596 serialize_only=opts.serialize_only, 597 tracefile=opts.tracefile) 598 except self.RPCException, e: 599 exit_with_fault(\ 600 {'desc': e.desc, 'errstr': e.errstr, 'code': e.code}) 601 except RuntimeError, e: 602 sys.exit("Error processing RPC: %s" % e) 603 604 if opts.debug > 1: print >>sys.stderr, resp_dict 605 606 ea = resp_dict.get('goal') 516 607 if out_certfile and ea and ea.has_key('X509'): 517 608 try: … … 530 621 print "status: %s" % st 531 622 532 class negotiate(abac_rpc):623 class access(abac_rpc): 533 624 def __init__(self): 534 abac_rpc.__init__(self, " Negotiate")625 abac_rpc.__init__(self, "Access") 535 626 def __call__(self): 536 627 access_keys = [] 537 628 # Process the options using the customized option parser defined above 538 parser = abac_ create_opts(access_keys, self.add_ssh_key,629 parser = abac_access_opts(access_keys, self.add_ssh_key, 539 630 self.add_x509_cert) 540 631 … … 545 636 sys.exit("Cannot read trusted certificates (%s)" % opts.trusted) 546 637 547 if not opts.project :548 parser.error('--project is required')549 550 638 if opts.debug > 0: opts.tracefile=sys.stderr 551 639 552 640 (user, cert) = self.get_user_info(access_keys) 553 641 554 if opts.user: user = opts.user642 # if opts.user: user = opts.user 555 643 556 644 if opts.cert != None: cert = opts.cert … … 566 654 sys.exit("Cannot read certificate (%s)" % cert) 567 655 568 if opts.file: 569 exp_desc = "" 570 try: 571 f = open(opts.file, 'r') 572 for line in f: 573 exp_desc += line 574 f.close() 575 except IOError: 576 sys.exit("Cannot read description file (%s)" %opts.file) 577 else: 578 sys.exit("Must specify an experiment description (--file)") 579 580 if not opts.master: 581 sys.exit("Must specify a master testbed (--master)") 582 583 out_certfile = opts.out_certfile 656 if not opts.id: 657 sys.exit("Must specify a negotiator id (--id)") 658 659 if not opts.goal: 660 sys.exit("Must specify a goal (--goal)") 661 662 # out_certfile = opts.out_certfile 584 663 585 664 msg = { 586 'experimentdescription': { 'ns2description': exp_desc }, 587 'master': opts.master, 588 'exportProject': { 'localname': opts.project }, 589 'user' : [ {\ 590 'userID': pack_id(user), \ 591 'access': [ { a.type: a.buf } for a in access_keys]\ 592 } ] 665 'context': { 'contextID': opts.id }, 666 'goal': opts.goal 593 667 } 594 595 if opts.exp_name:596 msg['experimentID'] = { 'localname': opts.exp_name }597 668 598 669 if opts.debug > 1: print >>sys.stderr, msg … … 611 682 if opts.debug > 1: print >>sys.stderr, resp_dict 612 683 613 ea = resp_dict.get('experimentAccess', None) 614 if out_certfile and ea and ea.has_key('X509'): 615 try: 616 f = open(out_certfile, "w") 617 print >>f, ea['X509'] 618 f.close() 619 except IOError: 620 sys.exit('Could not write to %s' % out_certfile) 621 eid = resp_dict.get('experimentID', None) 622 if eid: 623 for id in eid: 624 for k in id.keys(): 625 print "%s: %s" % (k, id[k]) 626 st = resp_dict.get('experimentStatus', None) 627 if st: 628 print "status: %s" % st 629 630 class access(abac_rpc): 631 def __init__(self): 632 abac_rpc.__init__(self, "Access") 633 def __call__(self): 634 access_keys = [] 635 # Process the options using the customized option parser defined above 636 parser = abac_create_opts(access_keys, self.add_ssh_key, 637 self.add_x509_cert) 638 639 (opts, args) = parser.parse_args() 640 641 if opts.trusted: 642 if ( not os.access(opts.trusted, os.R_OK) ) : 643 sys.exit("Cannot read trusted certificates (%s)" % opts.trusted) 644 645 if not opts.project : 646 parser.error('--project is required') 647 648 if opts.debug > 0: opts.tracefile=sys.stderr 649 650 (user, cert) = self.get_user_info(access_keys) 651 652 if opts.user: user = opts.user 653 654 if opts.cert != None: cert = opts.cert 655 656 if cert == None: 657 sys.exit("No certificate given (--cert) or found") 658 659 if os.access(cert, os.R_OK): 660 fid = fedid(file=cert) 661 if opts.use_fedid == True: 662 user = fid 663 else: 664 sys.exit("Cannot read certificate (%s)" % cert) 665 666 if not opts.id: 667 sys.exit("Must specify a negotiator id (--id)") 668 669 if not opts.goal: 670 sys.exit("Must specify a goal (--file)") 671 672 out_certfile = opts.out_certfile 673 674 msg = { 675 'context': { 'contextID': opts.contextID }, 676 'goal': opts.goal 677 } 678 679 if opts.exp_name: 680 msg['experimentID'] = { 'localname': opts.exp_name } 681 682 if opts.debug > 1: print >>sys.stderr, msg 683 684 try: 685 resp_dict = self.do_rpc(msg, 686 opts.url, opts.transport, cert, opts.trusted, 687 serialize_only=opts.serialize_only, 688 tracefile=opts.tracefile) 689 except self.RPCException, e: 690 exit_with_fault(\ 691 {'desc': e.desc, 'errstr': e.errstr, 'code': e.code}) 692 except RuntimeError, e: 693 sys.exit("Error processing RPC: %s" % e) 694 695 if opts.debug > 1: print >>sys.stderr, resp_dict 696 697 ea = resp_dict.get('experimentAccess', None) 698 if out_certfile and ea and ea.has_key('X509'): 699 try: 700 f = open(out_certfile, "w") 701 print >>f, ea['X509'] 702 f.close() 703 except IOError: 704 sys.exit('Could not write to %s' % out_certfile) 705 eid = resp_dict.get('experimentID', None) 706 if eid: 707 for id in eid: 708 for k in id.keys(): 709 print "%s: %s" % (k, id[k]) 710 st = resp_dict.get('experimentStatus', None) 711 if st: 712 print "status: %s" % st 684 result = resp_dict.get('result', None) 685 goal = resp_dict.get('goal', None) 686 print "%s: %s" % (goal, result) 713 687 714 688 def exit_with_fault(dict, out=sys.stderr): -
fedd/federation/abac_remote_service.py
r6c1981f r181cf9c 38 38 request_body_name=None, tracefile=None): 39 39 self.service_name = service_name 40 41 if getattr(fedd_abac_services.feddABACBindingSOAP, service_name, None): 42 self.locator = fedd_abac_services.feddABACServiceLocator 43 self.port_name = 'getfeddABACPortType' 44 # feddABAC has no internal implementation but might in the future 45 # elif getattr(fedd_internal_services.feddInternalBindingSOAP, 46 # service_name, None): 47 # self.locator = fedd_internal_services.feddInternalServiceLocator 48 # self.port_name = 'getfeddABACInternalPortType' 40 self.locator = fedd_abac_services.feddABACServiceLocator 41 self.port_name = 'getfeddABACPortType' 49 42 50 43 if request_message: self.request_message = request_message
Note: See TracChangeset
for help on using the changeset viewer.