← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~farcaller/cloud-init:nocloud-dmi into cloud-init:master

 

Vladimir Pouzanov has proposed merging ~farcaller/cloud-init:nocloud-dmi into cloud-init:master.

Requested reviews:
  cloud-init commiters (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~farcaller/cloud-init/+git/cloud-init/+merge/324273

provide a way to seed NoCloud from network without image modification (bug 1691772).
-- 
Your team cloud-init commiters is requested to review the proposed merge of ~farcaller/cloud-init:nocloud-dmi into cloud-init:master.
diff --git a/cloudinit/sources/DataSourceNoCloud.py b/cloudinit/sources/DataSourceNoCloud.py
index c68f6b8..5e7e179 100644
--- a/cloudinit/sources/DataSourceNoCloud.py
+++ b/cloudinit/sources/DataSourceNoCloud.py
@@ -52,6 +52,19 @@ class DataSourceNoCloud(sources.DataSource):
             util.logexc(LOG, "Unable to parse command line data")
             return False
 
+        try:
+            # Parse the system serial label from dmi. If not empty, try parsing
+            # like the commandline
+            md = {}
+            serial = util.read_dmi_data('system-serial-number')
+            if not serial is None:
+                if load_cmdline_data(md, serial):
+                    found.append("dmi")
+                    mydata = _merge_new_seed(mydata, {'meta-data': md})
+        except Exception:
+            util.logexc(LOG, "Unable to parse dmi data")
+            return False
+
         # Check to see if the seed dir has data.
         pp2d_kwargs = {'required': ['user-data', 'meta-data'],
                        'optional': ['vendor-data', 'network-config']}
diff --git a/tools/ds-identify b/tools/ds-identify
index aff26eb..b272d18 100755
--- a/tools/ds-identify
+++ b/tools/ds-identify
@@ -544,6 +544,9 @@ dscheck_NoCloud() {
     case " ${DI_KERNEL_CMDLINE} " in
         *\ ds=nocloud*) return ${DS_FOUND};;
     esac
+    case " ${DI_DMI_PRODUCT_SERIAL} " in
+        *\ ds=nocloud*) return ${DS_FOUND};;
+    esac
     for d in nocloud nocloud-net; do
         check_seed_dir "$d" meta-data user-data && return ${DS_FOUND}
     done

Follow ups