def get_ou_name()

in customizations/AccountFactory/BatchUpdate/update_pp.py [0:0]


def get_ou_name(acct_id):
    '''Retrieve the OU name'''

    ou_list = list_all_ou()
    ou_map = {}
    output = None

    for ou_id in ou_list:
        try:
            ou_info = ORG.describe_organizational_unit(OrganizationalUnitId=ou_id)
            ou_name = ou_info['OrganizationalUnit']['Name']
        except Exception as exe:
            error_and_exit('Unable to get the OU information' + str(exe))

        acct_list = list_of_accounts_in_ou(ou_id)

        for acct in acct_list:
            ou_map[acct['Id']] = ou_name

    if acct_id in ou_map:
        output = ou_map[acct_id]
    else:
        error_and_continue('Unable to find OU name for ' + str(acct_id))

    return output