From 0469f70c8fde69cfbcbc7181a69964aafba50bbc Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Wed, 13 Nov 2019 18:21:29 +0000 Subject: Fix metadata check when local-hostname is null (#32) Fix traceback when running with a config drive containing a metadata file which has local-hostname set to null. Cloud-init ignores absent local-hostname or None values. LP: #1852100 --- cloudinit/sources/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cloudinit/sources') diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py index a319322b..e6baf8f4 100644 --- a/cloudinit/sources/__init__.py +++ b/cloudinit/sources/__init__.py @@ -568,7 +568,7 @@ class DataSource(object): defhost = "localhost" domain = defdomain - if not self.metadata or 'local-hostname' not in self.metadata: + if not self.metadata or not self.metadata.get('local-hostname'): if metadata_only: return None # this is somewhat questionable really. -- cgit v1.2.3