+
+ def redeem_ticket(self, opts, args):
+ ticket_file = args[0]
+
+ # get slice hrn from the ticket
+ # use this to get the right slice credential
+ ticket = SfaTicket(filename=ticket_file)
+ ticket.decode()
+ slice_hrn = ticket.attributes['slivers'][0]['hrn']
+ user_cred = self.get_user_cred()
+ slice_cred = self.get_slice_cred(slice_hrn).save_to_string(save_parents=True)
+
+ # get a list node hostnames from the nodespecs in the rspec
+ rspec = RSpec()
+ rspec.parseString(ticket.rspec)
+ nodespecs = rspec.getDictsByTagName('NodeSpec')
+ hostnames = [nodespec['name'] for nodespec in nodespecs]
+
+ # create an xmlrpc connection to the component manager at each of these
+ # components and gall redeem_ticket
+ connections = {}
+ for hostname in hostnames:
+ try:
+ cm_port = "12346"
+ url = "https://%(hostname)s:%(cm_port)s" % locals()
+ print "Calling get_ticket at %(url)s " % locals(),
+ cm = xmlrpcprotocol.get_server(url, self.key_file, self.cert_file)
+ cm.redeem_ticket(slice_cred, ticket.save_to_string(save_parents=True))
+ print "Success"
+ except socket.gaierror:
+ print "Failed:",
+ print "Componet Manager not accepting requests"
+ except Exception, e:
+ print "Failed:", e.message
+
+ return