#NEWLINE# def detach_lb( kwargs = None , call = None ) : #NEWLINE# #INDENT# '\n    Remove an existing node/member from an existing load-balancer configuration.\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt-cloud -f detach_lb gce name=lb member=myinstance\n    ' #NEWLINE# if ( call != 'function' ) : #NEWLINE# #INDENT# raise SaltCloudSystemExit ( 'The detach_lb function must be called with -f or --function.' ) #NEWLINE# #UNINDENT# if ( ( not kwargs ) or ( 'name' not in kwargs ) ) : #NEWLINE# #INDENT# log . error ( 'A load-balancer name must be specified.' ) #NEWLINE# return False #NEWLINE# #UNINDENT# if ( 'member' not in kwargs ) : #NEWLINE# #INDENT# log . error ( 'A node name name must be specified.' ) #NEWLINE# return False #NEWLINE# #UNINDENT# conn = get_conn ( ) #NEWLINE# lb_conn = get_lb_conn ( conn ) #NEWLINE# lb = lb_conn . get_balancer ( kwargs [ 'name' ] ) #NEWLINE# member_list = lb_conn . balancer_list_members ( lb ) #NEWLINE# remove_member = None #NEWLINE# for member in member_list : #NEWLINE# #INDENT# if ( member . id == kwargs [ 'member' ] ) : #NEWLINE# #INDENT# remove_member = member #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# if ( not remove_member ) : #NEWLINE# #INDENT# log . error ( 'The specified member {0} was not a member of LB {1}.' . format ( kwargs [ 'member' ] , kwargs [ 'name' ] ) ) #NEWLINE# return False #NEWLINE# #UNINDENT# salt . utils . cloud . fire_event ( 'event' , 'detach load_balancer' , 'salt/cloud/loadbalancer/detaching' , kwargs , transport = __opts__ [ 'transport' ] ) #NEWLINE# result = lb_conn . balancer_detach_member ( lb , remove_member ) #NEWLINE# salt . utils . cloud . fire_event ( 'event' , 'detached load_balancer' , 'salt/cloud/loadbalancer/detached' , kwargs , transport = __opts__ [ 'transport' ] ) #NEWLINE# return result