def get_data(self): if not on_hetzner(): return False nic = cloudnet.find_fallback_nic() with cloudnet.EphemeralIPv4Network(nic, "169.254.0.1", 16, "169.254.255.255"): md = hc_helper.read_metadata(self.metadata_address, timeout=self.timeout, sec_between=self.wait_retry, retries=self.retries) ud = hc_helper.read_userdata(self.userdata_address, timeout=self.timeout, sec_between=self.wait_retry, retries=self.retries) self.userdata_raw = ud self.metadata_full = md """hostname is name provided by user at launch. The API enforces it is a valid hostname, but it is not guaranteed to be resolvable in dns or fully qualified.""" self.metadata['instance-id'] = md['instance-id'] self.metadata['local-hostname'] = md['hostname'] self.metadata['network-config'] = md.get('network-config', None) self.metadata['public-keys'] = md.get('public-keys', None) self.vendordata_raw = md.get("vendor_data", None) return True
def get_data(self): if not on_hetzner(): return False nic = cloudnet.find_fallback_nic() with cloudnet.EphemeralIPv4Network(nic, "169.254.0.1", 16, "169.254.255.255"): md = hc_helper.read_metadata(self.metadata_address, timeout=self.timeout, sec_between=self.wait_retry, retries=self.retries) ud = hc_helper.read_userdata(self.userdata_address, timeout=self.timeout, sec_between=self.wait_retry, retries=self.retries) # Hetzner cloud does not support binary user-data. So here, do a # base64 decode of the data if we can. The end result being that a # user can provide base64 encoded (possibly gzipped) data as user-data. # # The fallout is that in the event of b64 encoded user-data, # /var/lib/cloud-init/cloud-config.txt will not be identical to the # user-data provided. It will be decoded. self.userdata_raw = hc_helper.maybe_b64decode(ud) self.metadata_full = md # hostname is name provided by user at launch. The API enforces it is # a valid hostname, but it is not guaranteed to be resolvable in dns or # fully qualified. self.metadata['instance-id'] = md['instance-id'] self.metadata['local-hostname'] = md['hostname'] self.metadata['network-config'] = md.get('network-config', None) self.metadata['public-keys'] = md.get('public-keys', None) self.vendordata_raw = md.get("vendor_data", None) return True
def get_data(self): if not on_hetzner(): return False nic = cloudnet.find_fallback_nic() with cloudnet.EphemeralIPv4Network(nic, "169.254.0.1", 16, "169.254.255.255"): md = hc_helper.read_metadata( self.metadata_address, timeout=self.timeout, sec_between=self.wait_retry, retries=self.retries) ud = hc_helper.read_userdata( self.userdata_address, timeout=self.timeout, sec_between=self.wait_retry, retries=self.retries) self.userdata_raw = ud self.metadata_full = md """hostname is name provided by user at launch. The API enforces it is a valid hostname, but it is not guaranteed to be resolvable in dns or fully qualified.""" self.metadata['instance-id'] = md['instance-id'] self.metadata['local-hostname'] = md['hostname'] self.metadata['network-config'] = md.get('network-config', None) self.metadata['public-keys'] = md.get('public-keys', None) self.vendordata_raw = md.get("vendor_data", None) return True
def _get_data(self): (on_hetzner, serial) = get_hcloud_data() if not on_hetzner: return False try: with EphemeralDHCPv4( iface=net.find_fallback_nic(), connectivity_url_data={ "url": BASE_URL_V1 + "/metadata/instance-id", }, ): md = hc_helper.read_metadata( self.metadata_address, timeout=self.timeout, sec_between=self.wait_retry, retries=self.retries, ) ud = hc_helper.read_userdata( self.userdata_address, timeout=self.timeout, sec_between=self.wait_retry, retries=self.retries, ) except (NoDHCPLeaseError) as e: LOG.error("Bailing, DHCP Exception: %s", e) raise # Hetzner cloud does not support binary user-data. So here, do a # base64 decode of the data if we can. The end result being that a # user can provide base64 encoded (possibly gzipped) data as user-data. # # The fallout is that in the event of b64 encoded user-data, # /var/lib/cloud-init/cloud-config.txt will not be identical to the # user-data provided. It will be decoded. self.userdata_raw = hc_helper.maybe_b64decode(ud) self.metadata_full = md # hostname is name provided by user at launch. The API enforces it is # a valid hostname, but it is not guaranteed to be resolvable in dns or # fully qualified. self.metadata["instance-id"] = md["instance-id"] self.metadata["local-hostname"] = md["hostname"] self.metadata["network-config"] = md.get("network-config", None) self.metadata["public-keys"] = md.get("public-keys", None) self.vendordata_raw = md.get("vendor_data", None) # instance-id and serial from SMBIOS should be identical if self.get_instance_id() != serial: raise RuntimeError( "SMBIOS serial does not match instance ID from metadata") return True
def get_data(self): local_ip_nic = ho_helper.add_local_ip() md = ho_helper.read_metadata(self.metadata_address, timeout=self.timeout, sec_between=self.wait_retry, retries=self.retries) ud = ho_helper.read_userdata(self.userdata_address, timeout=self.timeout, sec_between=self.wait_retry, retries=self.retries) self.userdata_raw = ud self.metadata_full = md self.metadata['instance-id'] = md.get('instance-id', None) self.metadata['local-hostname'] = md.get('hostname', None) self.metadata['network-config'] = md.get('network-config', None) self.metadata['public-keys'] = md.get('public-keys', None) self.vendordata_raw = md.get("vendor_data", None) ho_helper.remove_local_ip(local_ip_nic) return True