sailesh1993 / rpms / cloud-init

Forked from rpms/cloud-init a year ago
Clone
18322d
From a3b9673481bbe2fa35986aa757fd5321c3a7a371 Mon Sep 17 00:00:00 2001
18322d
From: Eduardo Otubo <otubo@redhat.com>
18322d
Date: Wed, 12 Feb 2020 13:08:38 +0100
18322d
Subject: [PATCH] cmd:main.py: Fix missing 'modules-init' key in modes dict
18322d
18322d
RH-Author: Eduardo Otubo <otubo@redhat.com>
18322d
Message-id: <20200212130838.24592-1-otubo@redhat.com>
18322d
Patchwork-id: 93781
18322d
O-Subject: [RHEL-7.9/RHEL-8.2.0 cloud-init PATCH] cmd:main.py: Fix missing 'modules-init' key in modes dict
18322d
Bugzilla: 1802140
18322d
RH-Acked-by: Cathy Avery <cavery@redhat.com>
18322d
RH-Acked-by: Mohammed Gamal <mgamal@redhat.com>
18322d
18322d
BZ: 1673170
18322d
BRANCH: rhel7/master-18.5
18322d
UPSTREAM: bdd9c0ac
18322d
BREW: 26372362
18322d
18322d
BZ: 1802140
18322d
BRANCH: rhel820/master-18.5
18322d
UPSTREAM: bdd9c0ac
18322d
BREW: 26372415
18322d
18322d
commit 96557ca26a73c490aee74a811c3a44ef1ac11d84
18322d
Author: Antonio Romito <antonio.romito@manicom.io>
18322d
Date:   Tue Apr 9 14:54:23 2019 +0000
18322d
18322d
    cmd:main.py: Fix missing 'modules-init' key in modes dict
18322d
18322d
    Cloud-init's main.py will fail when presented with a new
18322d
    stage name 'modules-init' if upgrading an older cloud-init.
18322d
    Fix this by initializing unknown stage names before accessing.
18322d
18322d
    LP: #1815109
18322d
18322d
Signed-off-by: Eduardo Otubo <otubo@redhat.com>
18322d
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
18322d
---
18322d
 cloudinit/cmd/main.py | 9 +++++----
18322d
 1 file changed, 5 insertions(+), 4 deletions(-)
18322d
18322d
diff --git a/cloudinit/cmd/main.py b/cloudinit/cmd/main.py
18322d
index 933c019..a5446da 100644
18322d
--- a/cloudinit/cmd/main.py
18322d
+++ b/cloudinit/cmd/main.py
18322d
@@ -632,13 +632,14 @@ def status_wrapper(name, args, data_d=None, link_d=None):
18322d
         'start': None,
18322d
         'finished': None,
18322d
     }
18322d
+
18322d
     if status is None:
18322d
         status = {'v1': {}}
18322d
-        for m in modes:
18322d
-            status['v1'][m] = nullstatus.copy()
18322d
         status['v1']['datasource'] = None
18322d
-    elif mode not in status['v1']:
18322d
-        status['v1'][mode] = nullstatus.copy()
18322d
+
18322d
+    for m in modes:
18322d
+        if m not in status['v1']:
18322d
+            status['v1'][m] = nullstatus.copy()
18322d
 
18322d
     v1 = status['v1']
18322d
     v1['stage'] = mode
18322d
-- 
18322d
1.8.3.1
18322d