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