3131from .util import gen_target_netloc , get_cert_from_target , get_cn_from_cert
3232
3333
34+ LOGGER = logging .getLogger (__name__ )
35+
36+
3437class ClientBuilder (object ):
3538 """Builder for the creation of a gNMI client.
3639 Supports construction of base Client and XRClient.
@@ -134,8 +137,8 @@ def set_os(self, name=None):
134137 if name not in self .os_class_map .keys ():
135138 raise Exception ("OS not supported!" )
136139 else :
140+ LOGGER .debug ("Using %s wrapper." , name or "Client" )
137141 self .__client_class = self .os_class_map [name ]
138- logging .debug ("Using %s wrapper." , name or "Client" )
139142 return self
140143
141144 def set_secure (
@@ -257,7 +260,7 @@ def set_channel_option(self, name, value):
257260 found_index = index
258261 break
259262 if found_index is not None :
260- logging .warning ("Found existing channel option %s, overwriting!" , name )
263+ LOGGER .warning ("Found existing channel option %s, overwriting!" , name )
261264 self .__channel_options [found_index ] = new_option
262265 else :
263266 self .__channel_options .append (new_option )
@@ -279,26 +282,26 @@ def construct(self):
279282 self .__root_certificates , self .__private_key , self .__certificate_chain
280283 )
281284 if self .__username and self .__password :
285+ LOGGER .debug ("Using username/password call authentication." )
282286 channel_metadata_creds = grpc .metadata_call_credentials (
283287 CiscoAuthPlugin (self .__username , self .__password )
284288 )
285- logging .debug ("Using username/password call authentication." )
286289 if channel_ssl_creds and channel_metadata_creds :
290+ LOGGER .debug ("Using SSL/metadata authentication composite credentials." )
287291 channel_creds = grpc .composite_channel_credentials (
288292 channel_ssl_creds , channel_metadata_creds
289293 )
290- logging .debug ("Using SSL/metadata authentication composite credentials." )
291294 else :
295+ LOGGER .debug ("Using SSL credentials, no metadata authentication." )
292296 channel_creds = channel_ssl_creds
293- logging .debug ("Using SSL credentials, no metadata authentication." )
294297 if self .__ssl_target_name_override is not False :
295298 if self .__ssl_target_name_override is None :
296299 if not self .__root_certificates :
297300 raise Exception ("Deriving override requires root certificate!" )
298301 self .__ssl_target_name_override = get_cn_from_cert (
299302 self .__root_certificates
300303 )
301- logging .warning (
304+ LOGGER .warning (
302305 "Overriding SSL option from certificate could increase MITM susceptibility!"
303306 )
304307 self .set_channel_option (
0 commit comments