3131from .util import gen_target_netloc , get_cert_from_target , get_cn_from_cert
3232
3333
34+ LOGGER = logging .getLogger (__name__ )
35+ logger = LOGGER
36+
37+
3438class ClientBuilder (object ):
3539 """Builder for the creation of a gNMI client.
3640 Supports construction of base Client and XRClient.
@@ -134,8 +138,8 @@ def set_os(self, name=None):
134138 if name not in self .os_class_map .keys ():
135139 raise Exception ("OS not supported!" )
136140 else :
141+ LOGGER .debug ("Using %s wrapper." , name or "Client" )
137142 self .__client_class = self .os_class_map [name ]
138- logging .debug ("Using %s wrapper." , name or "Client" )
139143 return self
140144
141145 def set_secure (
@@ -257,7 +261,7 @@ def set_channel_option(self, name, value):
257261 found_index = index
258262 break
259263 if found_index is not None :
260- logging .warning ("Found existing channel option %s, overwriting!" , name )
264+ LOGGER .warning ("Found existing channel option %s, overwriting!" , name )
261265 self .__channel_options [found_index ] = new_option
262266 else :
263267 self .__channel_options .append (new_option )
@@ -279,26 +283,26 @@ def construct(self):
279283 self .__root_certificates , self .__private_key , self .__certificate_chain
280284 )
281285 if self .__username and self .__password :
286+ LOGGER .debug ("Using username/password call authentication." )
282287 channel_metadata_creds = grpc .metadata_call_credentials (
283288 CiscoAuthPlugin (self .__username , self .__password )
284289 )
285- logging .debug ("Using username/password call authentication." )
286290 if channel_ssl_creds and channel_metadata_creds :
291+ LOGGER .debug ("Using SSL/metadata authentication composite credentials." )
287292 channel_creds = grpc .composite_channel_credentials (
288293 channel_ssl_creds , channel_metadata_creds
289294 )
290- logging .debug ("Using SSL/metadata authentication composite credentials." )
291295 else :
296+ LOGGER .debug ("Using SSL credentials, no metadata authentication." )
292297 channel_creds = channel_ssl_creds
293- logging .debug ("Using SSL credentials, no metadata authentication." )
294298 if self .__ssl_target_name_override is not False :
295299 if self .__ssl_target_name_override is None :
296300 if not self .__root_certificates :
297301 raise Exception ("Deriving override requires root certificate!" )
298302 self .__ssl_target_name_override = get_cn_from_cert (
299303 self .__root_certificates
300304 )
301- logging .warning (
305+ LOGGER .warning (
302306 "Overriding SSL option from certificate could increase MITM susceptibility!"
303307 )
304308 self .set_channel_option (
0 commit comments