def subnet_details()

in eksupdate/src/preflight_module.py [0:0]


def subnet_details(log_details,errors,cluster_name,region,report,customer_report):
    loading_config(cluster_name,region)
    try:
        print('\n')
        log_pusher(log_details,cluster_name,region,'Checking Available IP for subnets associated with cluster.....')
        print('Checking Available IP for subnets associated with cluster.....')
        eks = boto3.client('eks',region_name = region)
        cluster_details = eks.describe_cluster(
        name=cluster_name
        )
        subnets = []
        customer_report['subnet'] = []
        error = []
        for subnet_id in cluster_details['cluster']['resourcesVpcConfig']['subnetIds']:
            ec2 = boto3.resource('ec2',region_name = region)
            subnet = ec2.Subnet(subnet_id)
            if subnet.available_ip_address_count < 5 :
                error.append('Subnet ID ' + str(subnet_id) + ' doesnt have a minimum of 5 available IP')
            log_pusher(log_details,cluster_name,region,'Subnet ID ' + str(subnet_id) + ' have a ' + str(subnet.available_ip_address_count) +' available IP address')
            customer_report['subnet'].append('Subnet ID ' + str(subnet_id) + ' have a ' + str(subnet.available_ip_address_count) +' available IP address')
            print('Subnet ID ' + str(subnet_id) + ' have a ' + str(subnet.available_ip_address_count) +' available IP address')
            subnets.append({subnet_id : subnet.available_ip_address_count})
        #report['subnets'] = subnets
        if len(error) > 0 :
            report['preflight_status'] = False
            errors.append('Available IPs for Subnet verification failed')
            log_pusher(log_details,cluster_name,region,'Available IPs for Subnet verification failed')
            print('Available IPs for Subnet verification failed')
            customer_report['subnet'].append('Available IP for Subnet verification failed')
            for e in error:
                customer_report['subnet'].append(e)
                print(e)
        else :
            customer_report['subnet'].append('Available IP for Subnet verified')
            log_pusher(log_details,cluster_name,region,'Available IPs for Subnet verified')
            print('Available IPs for Subnet verified')
    except Exception as e: 
        
        errors.append('Some error occured while fetching subnet details {err}'.format(err=e))
        log_pusher(log_details,cluster_name,region,'Some error occured while fetching subnet details {err}'.format(err=e))
        print('Some error occured while fetching subnet details {err}'.format(err=e))
        report['preflight_status'] = False