@@ -23,11 +23,6 @@ def get_api_key(client, username, secret):
2323 # Try to use a client with username/api key
2424 if len (secret ) == 64 :
2525 try :
26- # real_transport = getattr(client.transport, 'transport', transport)
27- if isinstance (client .transport .transport , transports .RestTransport ):
28- client .auth = auth .BasicHTTPAuthentication (username , secret )
29- else :
30- client .auth = auth .BasicAuthentication (username , secret )
3126 client ['Account' ].getCurrentUser ()
3227 return secret
3328 except SoftLayer .SoftLayerAPIError as ex :
@@ -37,12 +32,10 @@ def get_api_key(client, username, secret):
3732 # Try to use a client with username/password
3833 client .authenticate_with_password (username , secret )
3934
40- user_record = client ['Account' ].getCurrentUser (
41- mask = 'id, apiAuthenticationKeys' )
35+ user_record = client ['Account' ].getCurrentUser (mask = 'id, apiAuthenticationKeys' )
4236 api_keys = user_record ['apiAuthenticationKeys' ]
4337 if len (api_keys ) == 0 :
44- return client ['User_Customer' ].addApiAuthenticationKey (
45- id = user_record ['id' ])
38+ return client ['User_Customer' ].addApiAuthenticationKey (id = user_record ['id' ])
4639 return api_keys [0 ]['authenticationKey' ]
4740
4841
@@ -54,7 +47,8 @@ def cli(env):
5447 username , secret , endpoint_url , timeout = get_user_input (env )
5548
5649 env .client .transport .transport .endpoint_url = endpoint_url
57- api_key = get_api_key (env .client , username , secret )
50+ new_client = SoftLayer .client (username = username , api_key = secret , endpoint_url = endpoint_url , timeout = timeout )
51+ api_key = get_api_key (new_client , username , secret )
5852
5953 path = '~/.softlayer'
6054 if env .config_file :
0 commit comments