in ad-joining/register-computer/main.py [0:0]
def __get_computer_ou_from_metadata(gce_instance):
gce_instance_name = gce_instance["name"]
logging.debug("Checking instance '%s' for target OU in metadata", gce_instance_name)
if ("metadata" in gce_instance.keys() and "items" in gce_instance["metadata"]):
target_ou = next((x for x in gce_instance["metadata"]["items"] if x["key"].lower() == "target_ou"), None)
if target_ou:
return target_ou["value"]
else:
logging.info("Instance '%s' metadata is missing a custom OU" % gce_instance_name)
else:
logging.info("Instance '%s' does not have metadata" % gce_instance_name)
return