2
# Copyright (C) 2015-2016 Bigstep Cloud Ltd.
4
# Author: Alexandru Sirbu <alexandru.sirbu@bigstep.com>
10
from cloudinit import log as logging
11
from cloudinit import sources
12
from cloudinit import url_helper
13
from cloudinit import util
15
LOG = logging.getLogger(__name__)
18
class DataSourceBigstep(sources.DataSource):
19
def __init__(self, sys_cfg, distro, paths):
20
sources.DataSource.__init__(self, sys_cfg, distro, paths)
22
self.vendordata_raw = ""
23
self.userdata_raw = ""
25
def get_data(self, apply_filter=False):
26
url = get_url_from_file()
29
response = url_helper.readurl(url)
30
decoded = json.loads(response.contents)
31
self.metadata = decoded["metadata"]
32
self.vendordata_raw = decoded["vendordata_raw"]
33
self.userdata_raw = decoded["userdata_raw"]
37
def get_url_from_file():
39
content = util.load_file("/var/lib/cloud/data/seed/bigstep/url")
41
# If the file doesn't exist, then the server probably isn't a Bigstep
42
# instance; otherwise, another problem exists which needs investigation
43
if e.errno == errno.ENOENT:
49
# Used to match classes to dependencies
51
(DataSourceBigstep, (sources.DEP_FILESYSTEM, sources.DEP_NETWORK)),
55
# Return a list of data sources that match this set of dependencies
56
def get_datasource_list(depends):
57
return sources.list_from_depends(depends, datasources)