#!/usr/bin/env python3
# Author: Brian Shorland - BlueCat Networks

import bamclient as BAM

soap_client = BAM.bam_login()
props = ""
if BAM.GetGCPDeviceTypeID(soap_client) == False:
    print(
        BAM.bcolours.GREEN + BAM.bcolours.BOLD +
        '[Google CloudAtlas] Adding Google Compute Platform DeviceTypes to BlueCat Address Manager '
        + BAM.bcolours.ENDC)
    GCPDevType = BAM.AddDeviceType(soap_client, "Google Cloud Platform", props)
    GCPInstanceSubType = BAM.AddDeviceSubType(soap_client, GCPDevType,
                                              "Google Compute Engine", props)
else:
    print(
        BAM.bcolours.GREEN + BAM.bcolours.BOLD +
        '[Google CloudAtlas] Google Compute Platform DeviceTypes already in BlueCat Address Manager '
        + BAM.bcolours.ENDC)
    x = BAM.GetGCPDeviceTypeID(soap_client)
    GCPDevType = x
    GCPInstanceSubType = soap_client.service.getEntityByName(
        x, "Google Compute Engine", 'DeviceSubtype')['id']
print("")

print(BAM.bcolours.GREEN + BAM.bcolours.BOLD +
      '[Google CloudAtlas] Alpha Code ' + BAM.bcolours.ENDC)

import googleapiclient.discovery
from googleapiclient import discovery
# Author: Brian Shorland - BlueCat Networks

from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.compute import ComputeManagementClient
from azure.mgmt.network import NetworkManagementClient

import bamclient as BAM
soap_client = BAM.bam_login()
props = ""
if BAM.GetAzureDeviceTypeID(soap_client) == False:
    print(
        BAM.bcolours.GREEN + BAM.bcolours.BOLD +
        '[Azure CloudAtlas] Adding Azure DeviceTypes to BlueCat Address Manager '
        + BAM.bcolours.ENDC)
    AzureDevType = BAM.AddDeviceType(soap_client, "Microsoft Azure", props)
    AzureInsanceSubType = BAM.AddDeviceSubType(soap_client, AzureDevType,
                                               "Azure Virtual Machine", props)
else:
    print(
        BAM.bcolours.GREEN + BAM.bcolours.BOLD +
        '[Azure CloudAtlas] Azure DeviceTypes already in BlueCat Address Manager '
        + BAM.bcolours.ENDC)
    x = BAM.GetAzureDeviceTypeID(soap_client)
    AzureDevType = x
    AzureInsanceSubType = soap_client.service.getEntityByName(
        x, "Azure Virtual Machine", 'DeviceSubtype')['id']
print("")

azure_subscription = ""
azure_client = ""
azure_client_secret = ""
azure_tenent_id = ""
	or udf[1] == "PublicDNSName"
	or udf[1] == "PrivateDNSName"
	or udf[1] == "IPv4PublicIP"
	or udf[1] == "AvailabilityZone"): CheckUDFs_count = CheckUDFs_count + 1

# If one of UDFs not exists, exit

if CheckUDFs_count < 6:
	print("Exit. Please check your UDFs configured on BAM")
	exit()

props = ""
if BAM.GetAWSDeviceTypeID(soap_client) == False:
	print (BAM.bcolours.GREEN + BAM.bcolours.BOLD + '[AWS CloudAtlas] Adding AWS DeviceTypes to BlueCat Address Manager ' + BAM.bcolours.ENDC )
	AWSDevType = BAM.AddDeviceType(soap_client,"Amazon Web Services",props)
	AWSInsanceSubType = BAM.AddDeviceSubType(soap_client,AWSDevType,"AWS EC2 Instance",props)
else:
	print (BAM.bcolours.GREEN + BAM.bcolours.BOLD + '[AWS CloudAtlas] AWS DeviceTypes already in BlueCat Address Manager ' + BAM.bcolours.ENDC )
	x = BAM.GetAWSDeviceTypeID(soap_client)
	AWSDevType = x
	AWSInsanceSubType = soap_client.service.getEntityByName(x, "AWS EC2 Instance", 'DeviceSubtype')['id']

print("")

print (BAM.bcolours.GREEN + BAM.bcolours.BOLD + '[AWS CloudAtlas] AWS Region: ' + region_name + BAM.bcolours.ENDC )
print (BAM.bcolours.GREEN + BAM.bcolours.BOLD + '[AWS CloudAtlas] AWS Access Key: ' + aws_access_key_id + BAM.bcolours.ENDC )
print (BAM.bcolours.GREEN + BAM.bcolours.BOLD + '[AWS CloudAtlas] AWS Secret Access Key: ' + aws_secret_access_key + BAM.bcolours.ENDC )

ec2 = boto3.resource('ec2',region_name=region_name,aws_access_key_id=aws_access_key_id,aws_secret_access_key=aws_secret_access_key)

for instance in ec2.instances.all():