faf1e5
From 2b7bcfb3cfb6ac668627b26c83a2d60a29a75392 Mon Sep 17 00:00:00 2001
faf1e5
From: Eduardo Otubo <otubo@redhat.com>
faf1e5
Date: Tue, 14 Apr 2020 14:21:35 +0200
faf1e5
Subject: [PATCH] cmd:main.py: Fix missing 'modules-init' key in modes dict
faf1e5
faf1e5
RH-Author: Eduardo Otubo <otubo@redhat.com>
faf1e5
Message-id: <20200414104642.19930-1-otubo@redhat.com>
faf1e5
Patchwork-id: 94672
faf1e5
O-Subject: [RHEL-7.8.z cloud-init PATCH] cmd:main.py: Fix missing 'modules-init' key in modes dict
faf1e5
Bugzilla: 1802173
faf1e5
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
faf1e5
RH-Acked-by: Mohammed Gamal <mgamal@redhat.com>
faf1e5
RH-Acked-by: Cathy Avery <cavery@redhat.com>
faf1e5
faf1e5
commit bdd9c0ac9bcd68ec1ac3b2038dad0ba3dbd83341
faf1e5
Author: Antonio Romito <antonio.romito@manicom.io>
faf1e5
Date:   Tue Apr 9 14:54:23 2019 +0000
faf1e5
faf1e5
    cmd:main.py: Fix missing 'modules-init' key in modes dict
faf1e5
faf1e5
    Cloud-init's main.py will fail when presented with a new
faf1e5
    stage name 'modules-init' if upgrading an older cloud-init.
faf1e5
    Fix this by initializing unknown stage names before accessing.
faf1e5
faf1e5
    LP: #1815109
faf1e5
faf1e5
Signed-off-by: Eduardo Otubo <otubo@redhat.com>
faf1e5
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
faf1e5
---
faf1e5
 cloudinit/cmd/main.py | 9 +++++----
faf1e5
 1 file changed, 5 insertions(+), 4 deletions(-)
faf1e5
faf1e5
diff --git a/cloudinit/cmd/main.py b/cloudinit/cmd/main.py
faf1e5
index 933c019..a5446da 100644
faf1e5
--- a/cloudinit/cmd/main.py
faf1e5
+++ b/cloudinit/cmd/main.py
faf1e5
@@ -632,13 +632,14 @@ def status_wrapper(name, args, data_d=None, link_d=None):
faf1e5
         'start': None,
faf1e5
         'finished': None,
faf1e5
     }
faf1e5
+
faf1e5
     if status is None:
faf1e5
         status = {'v1': {}}
faf1e5
-        for m in modes:
faf1e5
-            status['v1'][m] = nullstatus.copy()
faf1e5
         status['v1']['datasource'] = None
faf1e5
-    elif mode not in status['v1']:
faf1e5
-        status['v1'][mode] = nullstatus.copy()
faf1e5
+
faf1e5
+    for m in modes:
faf1e5
+        if m not in status['v1']:
faf1e5
+            status['v1'][m] = nullstatus.copy()
faf1e5
 
faf1e5
     v1 = status['v1']
faf1e5
     v1['stage'] = mode
faf1e5
-- 
faf1e5
1.8.3.1
faf1e5