Index: fedd/federation/protogeni_access.py
===================================================================
--- fedd/federation/protogeni_access.py	(revision 5c3516062ee3a90b7f4f399f025a6cf240771244)
+++ fedd/federation/protogeni_access.py	(revision d49c11ccb87bd1af17a3a12cc7f8e8a90207db1f)
@@ -931,7 +931,17 @@
 	    slice_cred = segment_commands.pg_call(self.sa_url, 'Register',
 		    param, ctxt)
-	    #f = open("./slice_cred", "w")
-	    #print >>f, slice_cred
-	    #f.close()
+	    # Resolve the slice to get the URN that PG has assigned it.
+	    param = {
+		    'credential': gcred,
+		    'type': 'Slice',
+		    'hrn': slicename
+		    }
+	    data = segment_commands.pg_call(self.sa_url, 'Resolve', param,
+		    ctxt)
+	    if 'urn' in data:
+		slice_urn = data['urn']
+	    else:
+		raise service_error(service_error.federant, 
+			"No URN returned for slice %s" % hrn)
 	    # Populate the ssh keys (let PG format them)
 	    param = {
@@ -940,55 +950,39 @@
 	    keys =  segment_commands.pg_call(self.sa_url, 'GetKeys', param, 
 		    ctxt)
-	    # Grab and redeem a ticket
+	    # Create a Sliver
 	    param = {
-		    'credential': slice_cred, 
-		    'rspec': rspec,
-		    }
-	    ticket = segment_commands.pg_call(self.cm_url, 'GetTicket', param,
-		    ctxt)
-	    #f = open("./ticket", "w")
-	    #print >>f, ticket
-	    #f.close()
-	    param = { 
-		    'credential': slice_cred, 
-		    'keys': keys,
-		    'ticket': ticket,
+		    'credentials': [ slice_cred ],
+		    'rspec': rspec, 
+		    'keys': keys, 
+		    'slice_urn': slice_urn,
 		    }
 	    sliver_cred, manifest = segment_commands.pg_call(self.cm_url, 
-		    'RedeemTicket', param, ctxt)
-	    #f = open("./sliver_cred", "w")
-	    #print >>f, sliver_cred
-	    #f.close()
-	    #f = open("./manifest", "w")
-	    #print >>f, manifest
-	    #f.close()
-	    # start 'em up
-	    param = { 
-		    'credential': sliver_cred,
-		    }
-	    segment_commands.pg_call(self.cm_url, 'StartSliver', param, ctxt)
+		    'CreateSliver', param, ctxt)
 	except segment_commands.ProtoGENIError, e:
 	    raise service_error(service_error.federant,
 		    "ProtoGENI: %s %s" % (e.code, e))
 
-	return (slice_cred, sliver_cred, manifest)
-
-    def wait_for_slice(self, segment_commands, slice_cred, ctxt, timeout=None):
+	return (slice_urn, slice_cred, sliver_cred, manifest)
+
+    def wait_for_slice(self, segment_commands, sliver_cred, slice_urn, ctxt, 
+	    timeout=None):
 	"""
 	Wait for the given slice to finish its startup.  Return the final
 	status.
 	"""
-	status = 'notready'
+	completed_states = ('failed', 'ready')
+	status = 'changing'
 	if timeout is not None:
 	    end = time.time() + timeout
 	try:
-	    while status == 'notready':
+	    while status not in completed_states:
 		param = { 
-			'credential': slice_cred
+			'credentials': [ sliver_cred ],
+			'slice_urn': slice_urn,
 			}
 		r = segment_commands.pg_call(self.cm_url,
-			'SliceStatus', param, ctxt)
-		status = r.get('status', 'notready')
-		if status == 'notready':
+			'SliverStatus', param, ctxt)
+		status = r.get('status', 'changing')
+		if status not in completed_states:
 		    if timeout is not None and time.time() > end:
 			return 'timeout'
@@ -1000,5 +994,5 @@
 	return status
 
-    def delete_slice(self, segment_commands, slice_cred, ctxt):
+    def delete_slice(self, segment_commands, slice_cred, slice_urn, ctxt):
 	"""
 	Delete the slice resources.  An error from the service is ignores,
@@ -1006,5 +1000,8 @@
 	"""
 	try:
-	    param = { 'credential': slice_cred }
+	    param = { 
+		    'credentials': [ slice_cred, ],
+		    'slice_urn': slice_urn,
+		    }
 	    segment_commands.pg_call(self.cm_url, 'DeleteSlice',
 		    param, ctxt)
@@ -1037,5 +1034,5 @@
 	slicename = self.get_free_slicename(segment_commands, user, gcred, ctxt)
 	self.log.info("Creating %s" % slicename)
-	slice_cred, sliver_cred, manifest = self.allocate_slice(
+	slice_urn, slice_cred, sliver_cred, manifest = self.allocate_slice(
 		segment_commands, slicename, rspec, gcred, ctxt)
 
@@ -1062,17 +1059,18 @@
 
 	# Now we wait for the nodes to start on PG
-	status = self.wait_for_slice(segment_commands, slice_cred, ctxt,
-		timeout=300)
+	status = self.wait_for_slice(segment_commands, sliver_cred, slice_urn, 
+		ctxt, timeout=300)
 	if status == 'failed':
 	    self.log.error('Sliver failed to start on ProtoGENI')
-	    self.delete_slice(segment_commands, slice_cred, ctxt)
+	    self.delete_slice(segment_commands, slice_cred, slice_urn, ctxt)
 	    return False
 	elif status == 'timeout':
 	    self.log.error('Sliver failed to start on ProtoGENI (timeout)')
-	    self.delete_slice(segment_commands, slice_cred, ctxt)
+	    self.delete_slice(segment_commands, slice_cred, slice_urn, ctxt)
 	    return False
 	else:
 	    # All good: save ProtoGENI info in shared state
 	    self.state_lock.acquire()
+	    self.allocation[aid]['slice_urn'] = slice_urn
 	    self.allocation[aid]['slice_name'] = slicename
 	    self.allocation[aid]['slice_credential'] = slice_cred
@@ -1355,5 +1353,5 @@
 
     def stop_segment(self, segment_commands, user, stagingdir, slice_cred,
-	    certfile, certpw):
+	    slice_urn, certfile, certpw):
 	"""
 	Stop a sub experiment by calling swapexp on the federant
@@ -1368,5 +1366,5 @@
 		self.log.error('Removing Sliver on ProtoGENI')
 		ctxt = fedd_ssl_context(my_cert=certfile, password=certpw)
-		self.delete_slice(segment_commands, slice_cred, ctxt)
+		self.delete_slice(segment_commands, slice_cred, slice_urn, ctxt)
 	    return True
 	except self.ssh_cmd_timeout:
@@ -1390,4 +1388,5 @@
 	    cf, user, ssh_key, cpw = self.allocation[aid]['credentials']
 	    slice_cred = self.allocation[aid].get('slice_credential', None)
+	    slice_urn = self.allocation[aid].get('slice_urn', None)
 	    ename = self.allocation[aid].get('experiment', None)
 	else:
@@ -1406,8 +1405,9 @@
 		debug=self.create_debug, ch_url = self.ch_url,
 		sa_url=self.sa_url, cm_url=self.cm_url)
-	self.stop_segment(segment_commands, user, staging, slice_cred, cf, cpw)
+	self.stop_segment(segment_commands, user, staging, slice_cred,
+		slice_urn, cf, cpw)
 	return { 'allocID': req['allocID'] }
 
-    def renew_segment(self, segment_commands, name, scred, interval, 
+    def renew_segment(self, segment_commands, name, scred, slice_urn, interval, 
 	    certfile, certpw):
 	"""
@@ -1445,7 +1445,4 @@
 	    new_scred = segment_commands.pg_call(self.sa_url, 'GetCredential',
 		    param, ctxt)
-	    #f = open('./new_slice_cred', 'w')
-	    #print >>f, new_scred
-	    #f.close()
 
 	except segment_commands.ProtoGENIError, e:
@@ -1455,5 +1452,6 @@
 	    print 'Calling RenewSlice (CM)'
 	    param = {
-		    'credential': new_scred,
+		    'credentials': [new_scred,],
+		    'slice_urn': slice_urn,
 		    }
 	    r = segment_commands.pg_call(self.cm_url, 'RenewSlice', param, ctxt)
@@ -1475,4 +1473,5 @@
 		name = self.allocation[aid].get('slice_name', None)
 		scred = self.allocation[aid].get('slice_credential', None)
+		slice_urn = self.allocation[aid].get('slice_urn', None)
 		cf, user, ssh_key, cpw = self.allocation[aid]['credentials']
 	    else:
@@ -1487,5 +1486,5 @@
 
 	    # There's a ProtoGENI slice associated with the segment; renew it.
-	    if name and scred:
+	    if name and scred and slice_urn:
 		segment_commands = protogeni_proxy(log=self.log, 
 			debug=self.create_debug, keyfile=ssh_key,
@@ -1493,5 +1492,5 @@
 			ch_url = self.ch_url)
 		new_scred = self.renew_segment(segment_commands, name, scred, 
-			self.renewal_interval, cf, cpw)
+			slice_urn, self.renewal_interval, cf, cpw)
 		if new_scred:
 		    self.log.info("Slice %s renewed until %s GMT" % \
