#NEWLINE# def _configure_services( self , grpname , srvrs ) : #NEWLINE# #INDENT# to_add = srvrs #NEWLINE# to_remove = [ ] #NEWLINE# try : #NEWLINE# #INDENT# bindings = servicegroup_servicegroupmember_binding . get ( self . ns_session , grpname ) #NEWLINE# existing = [ ( b . ip , b . port ) for b in bindings if ( b . port != 0 ) ] #NEWLINE# to_remove = list ( ( set ( existing ) - set ( srvrs ) ) ) #NEWLINE# to_add = list ( ( set ( srvrs ) - set ( existing ) ) ) #NEWLINE# to_leave = list ( ( set ( srvrs ) & set ( existing ) ) ) #NEWLINE# #UNINDENT# except nitro_exception as e : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# for s in to_remove : #NEWLINE# #INDENT# binding = servicegroup_servicegroupmember_binding ( ) #NEWLINE# binding . servicegroupname = grpname #NEWLINE# binding . ip = s [ 0 ] #NEWLINE# binding . port = s [ 1 ] #NEWLINE# logger . info ( ( 'Unbinding %s:%s from service group %s ' % ( s [ 0 ] , s [ 1 ] , grpname ) ) ) #NEWLINE# servicegroup_servicegroupmember_binding . delete ( b . ns_session , binding ) #NEWLINE# #UNINDENT# for s in to_add : #NEWLINE# #INDENT# binding = servicegroup_servicegroupmember_binding ( ) #NEWLINE# binding . servicegroupname = grpname #NEWLINE# binding . ip = s [ 0 ] #NEWLINE# binding . port = s [ 1 ] #NEWLINE# logger . info ( ( 'Binding %s:%s from service group %s ' % ( s [ 0 ] , s [ 1 ] , grpname ) ) ) #NEWLINE# servicegroup_servicegroupmember_binding . add ( self . ns_session , binding ) #NEWLINE# #UNINDENT# for s in to_leave : #NEWLINE# #INDENT# logger . info ( ( '%s:%s is already bound to  service group %s' % ( s [ 0 ] , s [ 1 ] , grpname ) ) )