1010from SoftLayer .CLI import environment
1111from SoftLayer .CLI import exceptions
1212from SoftLayer .CLI import formatting
13+ from SoftLayer import transports
1314from SoftLayer import utils
1415
1516
@@ -22,7 +23,11 @@ def get_api_key(client, username, secret):
2223 # Try to use a client with username/api key
2324 if len (secret ) == 64 :
2425 try :
25- client .auth = auth .BasicAuthentication (username , secret )
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 )
2631 client ['Account' ].getCurrentUser ()
2732 return secret
2833 except SoftLayer .SoftLayerAPIError as ex :
@@ -103,17 +108,22 @@ def get_user_input(env):
103108 secret = env .getpass ('API Key or Password' , default = defaults ['api_key' ])
104109
105110 # Ask for which endpoint they want to use
111+ endpoint = defaults .get ('endpoint_url' , 'public' )
106112 endpoint_type = env .input (
107- 'Endpoint (public|private|custom)' , default = 'public' )
113+ 'Endpoint (public|private|custom)' , default = endpoint )
108114 endpoint_type = endpoint_type .lower ()
109115
110- if endpoint_type == 'custom' :
111- endpoint_url = env .input ('Endpoint URL' ,
112- default = defaults ['endpoint_url' ])
116+ if endpoint_type == 'public' :
117+ endpoint_url = SoftLayer .API_PUBLIC_ENDPOINT
113118 elif endpoint_type == 'private' :
114119 endpoint_url = SoftLayer .API_PRIVATE_ENDPOINT
115120 else :
116- endpoint_url = SoftLayer .API_PUBLIC_ENDPOINT
121+ if endpoint_type == 'custom' :
122+ endpoint_url = env .input ('Endpoint URL' , default = endpoint )
123+ else :
124+ endpoint_url = endpoint
125+
126+ print ("SETTING enpoint to %s " % endpoint_url )
117127
118128 # Ask for timeout
119129 timeout = env .input ('Timeout' , default = defaults ['timeout' ] or 0 )
0 commit comments