def _get_data(self): if not self._is_platform_viable(): return False self.system_uuid = _read_system_uuid() # network may be configured if iscsi root. If that is the case # then read_initramfs_config will return non-None. if _is_iscsi_root(): data = read_opc_metadata() else: with dhcp.EphemeralDHCPv4(net.find_fallback_nic()): data = read_opc_metadata() self._crawled_metadata = data self.metadata = { "availability-zone": data["ociAdName"], "instance-id": data["id"], "launch-index": 0, "local-hostname": data["hostname"], "name": data["displayName"], } if "metadata" in data: user_data = data["metadata"].get("user_data") if user_data: self.userdata_raw = base64.b64decode(user_data) self.metadata["public_keys"] = data["metadata"].get( "ssh_authorized_keys") return True
def _get_data(self): if not self._is_platform_viable(): return False self.system_uuid = _read_system_uuid() # network may be configured if iscsi root. If that is the case # then read_initramfs_config will return non-None. fetch_vnics_data = self.ds_cfg.get( "configure_secondary_nics", BUILTIN_DS_CONFIG["configure_secondary_nics"], ) network_context = noop() if not _is_iscsi_root(): network_context = dhcp.EphemeralDHCPv4( iface=net.find_fallback_nic(), connectivity_url_data={ "url": METADATA_PATTERN.format(version=2, path="instance"), "headers": V2_HEADERS, }, ) with network_context: fetched_metadata = read_opc_metadata( fetch_vnics_data=fetch_vnics_data) data = self._crawled_metadata = fetched_metadata.instance_data self.metadata_address = METADATA_ROOT.format( version=fetched_metadata.version) self._vnics_data = fetched_metadata.vnics_data self.metadata = { "availability-zone": data["ociAdName"], "instance-id": data["id"], "launch-index": 0, "local-hostname": data["hostname"], "name": data["displayName"], } if "metadata" in data: user_data = data["metadata"].get("user_data") if user_data: self.userdata_raw = base64.b64decode(user_data) self.metadata["public_keys"] = data["metadata"].get( "ssh_authorized_keys") return True
def _get_data(self): if not self._is_platform_viable(): return False # network may be configured if iscsi root. If that is the case # then read_initramfs_config will return non-None. if _is_iscsi_root(): data = self.crawl_metadata() else: with dhcp.EphemeralDHCPv4(net.find_fallback_nic()): data = self.crawl_metadata() self._crawled_metadata = data vdata = data['2013-10-17'] self.userdata_raw = vdata.get('user_data') self.system_uuid = vdata['system_uuid'] vd = vdata.get('vendor_data') if vd: self.vendordata_pure = vd try: self.vendordata_raw = sources.convert_vendordata(vd) except ValueError as e: LOG.warning("Invalid content in vendor-data: %s", e) self.vendordata_raw = None mdcopies = ('public_keys', ) md = dict([(k, vdata['meta_data'].get(k)) for k in mdcopies if k in vdata['meta_data']]) mdtrans = ( # oracle meta_data.json name, cloudinit.datasource.metadata name ('availability_zone', 'availability-zone'), ('hostname', 'local-hostname'), ('launch_index', 'launch-index'), ('uuid', 'instance-id'), ) for dsname, ciname in mdtrans: if dsname in vdata['meta_data']: md[ciname] = vdata['meta_data'][dsname] self.metadata = md return True