Commit 29330605 authored by Gary Wong's avatar Gary Wong
Browse files

Don't bother obtaining an SA credential unless we actually need it.

parent 53da48f7
......@@ -123,14 +123,14 @@ def SimpleNode( d, elem, body ):
n.appendChild( d.createTextNode( body ) );
return n;
mycredential = get_self_credential()
mycredential = None
slice_urn = None
slice_uuid = None
if is_urn( args[ 0 ] ): slice_urn = args[ 0 ]
elif is_uuid( args[ 0 ] ): slice_uuid = args[ 0 ]
elif is_hrn( args[ 0 ] ):
if not mycredential: mycredential = get_self_credential()
rval, response = do_method( "sa", "Resolve",
dict( credential = mycredential,
type = "Slice",
......@@ -140,6 +140,7 @@ elif is_hrn( args[ 0 ] ):
if slice_urn:
# we were given a URN, and can request credentials from the SA
if not mycredential: mycredential = get_self_credential()
rval, response = do_method( "sa", "GetCredential",
dict( credential = mycredential,
type = "Slice",
......@@ -151,6 +152,7 @@ if slice_urn:
elif slice_uuid:
# we were given a UUID, or a slice HRN which resolved to one: use
# that UUID to request credentials from the SA (deprecated)
if not mycredential: mycredential = get_self_credential()
rval, response = do_method( "sa", "GetCredential",
dict( credential = mycredential,
type = "Slice",
......@@ -167,6 +169,7 @@ else:
delegate = None
if is_urn( args[ 1 ] ):
if not mycredential: mycredential = get_self_credential()
rval, response = do_method( "sa", "Resolve",
dict( credential = mycredential,
type = "User",
......@@ -174,6 +177,7 @@ if is_urn( args[ 1 ] ):
if not rval and "value" in response and "gid" in response[ "value" ]:
delegate = response[ "value" ][ "gid" ]
if is_uuid( args[ 1 ] ):
if not mycredential: mycredential = get_self_credential()
rval, response = do_method( "sa", "Resolve",
dict( credential = mycredential,
type = "User",
......@@ -181,6 +185,7 @@ if is_uuid( args[ 1 ] ):
if not rval and "value" in response and "gid" in response[ "value" ]:
delegate = response[ "value" ][ "gid" ]
elif is_hrn( args[ 1 ] ):
if not mycredential: mycredential = get_self_credential()
rval, response = do_method( "sa", "Resolve",
dict( credential = mycredential,
type = "User",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment