def apply_security_groups(name, security_groups, region=None, key=None, keyid=None, profile=None):
 conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
 if isinstance(security_groups, string_types):
  security_groups = json.loads(security_groups)
 try:
  conn.apply_security_groups_to_lb(name, security_groups)
  msg = 'Applied security_groups on ELB {0}'.format(name)
  log.info(msg)
  return True
 except boto.exception.BotoServerError as e:
  log.debug(e)
  msg = 'Failed to appply security_groups on ELB {0}: {1}'
  msg = msg.format(name, e.message)
  log.error(msg)
  return False

def apply_security_groups ( name , security_groups , region = None , key = None , keyid = None , profile = None ) : conn = _get_conn ( region = region , key = key , keyid = keyid , profile = profile ) if isinstance ( security_groups , string_types ) : security_groups = json . loads ( security_groups ) try : conn . apply_security_groups_to_lb ( name , security_groups ) msg = 'Applied security_groups on ELB {0}' . format ( name ) log . info ( msg ) return True except boto . exception . BotoServerError as e : log . debug ( e ) msg = 'Failed to appply security_groups on ELB {0}: {1}' msg = msg . format ( name , e . message ) log . error ( msg ) return False
apply security groups to elb .