summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceBigstep.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/sources/DataSourceBigstep.py')
-rw-r--r--cloudinit/sources/DataSourceBigstep.py40
1 files changed, 22 insertions, 18 deletions
diff --git a/cloudinit/sources/DataSourceBigstep.py b/cloudinit/sources/DataSourceBigstep.py
index 426a762e..8d01b563 100644
--- a/cloudinit/sources/DataSourceBigstep.py
+++ b/cloudinit/sources/DataSourceBigstep.py
@@ -6,6 +6,7 @@
import errno
import json
+import os
from cloudinit import sources, url_helper, util
@@ -15,13 +16,13 @@ class DataSourceBigstep(sources.DataSource):
dsname = "Bigstep"
def __init__(self, sys_cfg, distro, paths):
- sources.DataSource.__init__(self, sys_cfg, distro, paths)
+ super().__init__(sys_cfg, distro, paths)
self.metadata = {}
self.vendordata_raw = ""
self.userdata_raw = ""
- def _get_data(self, apply_filter=False):
- url = get_url_from_file()
+ def _get_data(self, apply_filter=False) -> bool:
+ url = self._get_url_from_file()
if url is None:
return False
response = url_helper.readurl(url)
@@ -31,22 +32,25 @@ class DataSourceBigstep(sources.DataSource):
self.userdata_raw = decoded["userdata_raw"]
return True
- def _get_subplatform(self):
+ def _get_subplatform(self) -> str:
"""Return the subplatform metadata source details."""
- return "metadata (%s)" % get_url_from_file()
-
-
-def get_url_from_file():
- try:
- content = util.load_file("/var/lib/cloud/data/seed/bigstep/url")
- except IOError as e:
- # If the file doesn't exist, then the server probably isn't a Bigstep
- # instance; otherwise, another problem exists which needs investigation
- if e.errno == errno.ENOENT:
- return None
- else:
- raise
- return content
+ return f"metadata ({self._get_url_from_file()})"
+
+ def _get_url_from_file(self):
+ url_file = os.path.join(
+ self.paths.cloud_dir, "data", "seed", "bigstep", "url"
+ )
+ try:
+ content = util.load_file(url_file)
+ except IOError as e:
+ # If the file doesn't exist, then the server probably isn't a
+ # Bigstep instance; otherwise, another problem exists which needs
+ # investigation
+ if e.errno == errno.ENOENT:
+ return None
+ else:
+ raise
+ return content
# Used to match classes to dependencies