def get_block_allocation(module, cp_driver, lb_driver, network_domain, block):
 nat_rules = list_nat_rules(module, cp_driver, network_domain)
 balancers = list_balancers(module, lb_driver)
 pub_ip_block = get_public_ip_block(module, cp_driver, network_domain, block.id, False)
 pub_ips = expand_ip_block(pub_ip_block)
 block_detailed = {'id': block.id, 'addresses': []}
 for ip in pub_ips:
  allocated = False
  nat_match = [nat_rule for nat_rule in nat_rules if (nat_rule.external_ip == ip)]
  lb_match = [balancer for balancer in balancers if (balancer.ip == ip)]
  if ((len(nat_match) > 0) or (len(lb_match) > 0)):
   allocated = True
  else:
   allocated = False
  block_detailed['addresses'].append({'address': ip, 'allocated': allocated})
 return block_detailed

def get_block_allocation ( module , cp_driver , lb_driver , network_domain , block ) : nat_rules = list_nat_rules ( module , cp_driver , network_domain ) balancers = list_balancers ( module , lb_driver ) pub_ip_block = get_public_ip_block ( module , cp_driver , network_domain , block . id , False ) pub_ips = expand_ip_block ( pub_ip_block ) block_detailed = { 'id' : block . id , 'addresses' : [ ] } for ip in pub_ips : allocated = False nat_match = [ nat_rule for nat_rule in nat_rules if ( nat_rule . external_ip == ip ) ] lb_match = [ balancer for balancer in balancers if ( balancer . ip == ip ) ] if ( ( len ( nat_match ) > 0 ) or ( len ( lb_match ) > 0 ) ) : allocated = True else : allocated = False block_detailed [ 'addresses' ] . append ( { 'address' : ip , 'allocated' : allocated } ) return block_detailed
get public ip block allocation details .