We got the license issue sorted out.

So the main comment I have on this code is that if we use this approach and the vm on GCE runs into a network hiccup of some kind, we will end up not including the license ids in the resulting image. It would be ideal if instead of relying on URLError, we did an explicit check to see if we are running on GCE or not and skip this code if we are not.

We used to rely on being able to reach metadata.google.com as a way to detect that, however, we are moving towards using DMI/SMBOIS information for precisely this reason. See https://developers.google.com/compute/docs/instances#dmi