summaryrefslogtreecommitdiff
path: root/cloudinit/helpers.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/helpers.py')
-rw-r--r--cloudinit/helpers.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/cloudinit/helpers.py b/cloudinit/helpers.py
index fc5011ec..b8f9d2c3 100644
--- a/cloudinit/helpers.py
+++ b/cloudinit/helpers.py
@@ -20,6 +20,7 @@ from cloudinit.settings import (PER_INSTANCE, PER_ALWAYS, PER_ONCE,
from cloudinit import log as logging
from cloudinit import type_utils
+from cloudinit import persistence
from cloudinit import util
LOG = logging.getLogger(__name__)
@@ -317,7 +318,9 @@ class ContentHandlers(object):
return list(self.registered.items())
-class Paths(object):
+class Paths(persistence.CloudInitPickleMixin):
+ _ci_pkl_version = 1
+
def __init__(self, path_cfgs, ds=None):
self.cfgs = path_cfgs
# Populate all the initial paths
@@ -354,6 +357,18 @@ class Paths(object):
# Set when a datasource becomes active
self.datasource = ds
+ def _unpickle(self, ci_pkl_version: int) -> None:
+ """Perform deserialization fixes for Paths."""
+ if not hasattr(self, "run_dir"):
+ # On older versions of cloud-init the Paths class do not
+ # have the run_dir attribute. This is problematic because
+ # when loading the pickle object on newer versions of cloud-init
+ # we will rely on this attribute. To fix that, we are now
+ # manually adding that attribute here.
+ self.run_dir = Paths(
+ path_cfgs=self.cfgs,
+ ds=self.datasource).run_dir
+
# get_ipath_cur: get the current instance path for an item
def get_ipath_cur(self, name=None):
return self._get_path(self.instance_link, name)