def deregister_instances(name, instances, region=None, key=None, keyid=None, profile=None):
 if (isinstance(instances, str) or isinstance(instances, six.text_type)):
  instances = [instances]
 conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
 try:
  registered_instances = conn.deregister_instances(name, instances)
 except boto.exception.BotoServerError as error:
  if (error.error_code == 'InvalidInstance'):
   log.warning('One or more of instance(s) {0} are not part of ELB {1}. deregister_instances not performed.'.format(instances, name))
   return None
  else:
   log.warning(error)
   return False
 registered_instance_ids = [instance.id for instance in registered_instances]
 deregister_failures = set(instances).intersection(set(registered_instance_ids))
 if deregister_failures:
  log.warning('Instance(s): {0} not deregistered from ELB {1}.'.format(list(deregister_failures), name))
  deregister_result = False
 else:
  deregister_result = True
 return deregister_result

def deregister_instances ( name , instances , region = None , key = None , keyid = None , profile = None ) : if ( isinstance ( instances , str ) or isinstance ( instances , six . text_type ) ) : instances = [ instances ] conn = _get_conn ( region = region , key = key , keyid = keyid , profile = profile ) try : registered_instances = conn . deregister_instances ( name , instances ) except boto . exception . BotoServerError as error : if ( error . error_code == 'InvalidInstance' ) : log . warning ( 'One or more of instance(s) {0} are not part of ELB {1}. deregister_instances not performed.' . format ( instances , name ) ) return None else : log . warning ( error ) return False registered_instance_ids = [ instance . id for instance in registered_instances ] deregister_failures = set ( instances ) . intersection ( set ( registered_instance_ids ) ) if deregister_failures : log . warning ( 'Instance(s): {0} not deregistered from ELB {1}.' . format ( list ( deregister_failures ) , name ) ) deregister_result = False else : deregister_result = True return deregister_result
deregister instances with an elb .