summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceBigstep.py
diff options
context:
space:
mode:
authorAlex Sirbu <alexandru.sirbu@bigstep.com>2016-03-07 12:30:08 +0000
committerAlex Sirbu <alexandru.sirbu@bigstep.com>2016-03-07 12:30:08 +0000
commitd23868d6d3e35a91c348b94ce8416f56514aaf15 (patch)
tree07d309ff8273fb613a37806352646120484b52e4 /cloudinit/sources/DataSourceBigstep.py
parent9ec6c876b72ccfa2ae590505fe6dbf7c0c561520 (diff)
downloadvyos-cloud-init-d23868d6d3e35a91c348b94ce8416f56514aaf15.tar.gz
vyos-cloud-init-d23868d6d3e35a91c348b94ce8416f56514aaf15.zip
Implemented review concerning position of try and more information about the caught exception.
Diffstat (limited to 'cloudinit/sources/DataSourceBigstep.py')
-rw-r--r--cloudinit/sources/DataSourceBigstep.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/cloudinit/sources/DataSourceBigstep.py b/cloudinit/sources/DataSourceBigstep.py
index 2d66c609..b5ee4129 100644
--- a/cloudinit/sources/DataSourceBigstep.py
+++ b/cloudinit/sources/DataSourceBigstep.py
@@ -23,13 +23,9 @@ class DataSourceBigstep(sources.DataSource):
self.userdata_raw = ""
def get_data(self, apply_filter=False):
- try:
- url = get_url_from_file()
- except IOError as e:
- if e.errno == errno.ENOENT:
- return False
- else:
- raise
+ url = get_url_from_file()
+ if url is None:
+ return False
response = url_helper.readurl(url)
decoded = json.loads(response.contents)
self.metadata = decoded["metadata"]
@@ -39,7 +35,15 @@ class DataSourceBigstep(sources.DataSource):
def get_url_from_file():
- content = util.load_file("/var/lib/cloud/data/seed/bigstep/url")
+ 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
# Used to match classes to dependencies