From bedc366a1405b921e538df83db57b8f9c3f4f368 Mon Sep 17 00:00:00 2001
From: Anders Blomdell <anders.blomdell@control.lth.se>
Date: Tue, 9 Jan 2018 12:46:00 +0100
Subject: [PATCH] Always set UUID

---
 src/hostinfo/ifconfig.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/hostinfo/ifconfig.py b/src/hostinfo/ifconfig.py
index 3cc5186..7cad9dd 100755
--- a/src/hostinfo/ifconfig.py
+++ b/src/hostinfo/ifconfig.py
@@ -3,9 +3,11 @@ import subprocess
 import re
 import ipaddr
 import sys
+import uuid
 
 def get_nm_extra(device):
     result = ""
+    uuid_is_set = False
     try:
         import dbus
         bus = dbus.SystemBus()
@@ -37,10 +39,13 @@ def get_nm_extra(device):
             connection = settings['connection']
             if 'uuid' in connection:
                 result += 'UUID=%s\n' % connection['uuid']
+                uuid_is_set = True
             if 'zone' in connection:
                 result += 'ZONE=%s\n' % connection['zone']
     except:
         pass
+    if not uuid_is_set:
+        result += 'UUID=%s\n' % uuid.uuid4()
     return result
 
 def interface_is_static(i):
-- 
GitLab