From de85336abb7861e4ea4df2e296eb33d179c7c9bd Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 23 Jan 2017 14:41:22 +0000 Subject: [cloud] Add ability to retrieve Google Compute Engine metadata For some unspecified "security" reason, the Google Compute Engine metadata server will refuse any requests that do not include the non-standard HTTP header "Metadata-Flavor: Google". Attempt to autodetect such requests (by comparing the hostname against "metadata.google.internal"), and add the "Metadata-Flavor: Google" header if applicable. Enable this feature in the CONFIG=cloud build, and include a sample embedded script allowing iPXE to boot from a script configured as metadata via e.g. # Create shared boot image make bin/ipxe.usb CONFIG=cloud EMBED=config/cloud/gce.ipxe # Configure per-instance boot script gcloud compute instances add-metadata \ --metadata-from-file ipxeboot=boot.ipxe Signed-off-by: Michael Brown --- src/config/cloud/gce.ipxe | 7 +++++++ src/config/cloud/general.h | 4 ++++ 2 files changed, 11 insertions(+) create mode 100644 src/config/cloud/gce.ipxe (limited to 'src/config/cloud') diff --git a/src/config/cloud/gce.ipxe b/src/config/cloud/gce.ipxe new file mode 100644 index 000000000..95330d718 --- /dev/null +++ b/src/config/cloud/gce.ipxe @@ -0,0 +1,7 @@ +#!ipxe + +echo Google Compute Engine - iPXE boot via metadata +ifstat || +dhcp || +route || +chain -ar http://metadata.google.internal/computeMetadata/v1/instance/attributes/ipxeboot diff --git a/src/config/cloud/general.h b/src/config/cloud/general.h index e69de29bb..99028c147 100644 --- a/src/config/cloud/general.h +++ b/src/config/cloud/general.h @@ -0,0 +1,4 @@ +/* Allow retrieval of metadata (such as an iPXE boot script) from + * Google Compute Engine metadata server. + */ +#define HTTP_HACK_GCE -- cgit v1.2.3-55-g7522