← Back to team overview

cloud-init-dev team mailing list archive

[Merge] lp:~alexandru-sirbu/cloud-init/bigstep-datasource-improvements into lp:cloud-init

 

Alex Sirbu has proposed merging lp:~alexandru-sirbu/cloud-init/bigstep-datasource-improvements into lp:cloud-init.

Requested reviews:
  cloud init development team (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~alexandru-sirbu/cloud-init/bigstep-datasource-improvements/+merge/288251

Based on the proposal of smoser:

<smoser> Odd_Bloke, when you dont have that file there..
<smoser> i dontrecall. does cloud-init warn that the ds raised exception ?
<smoser> can you just try and catch the load_file and return false if not there ?

+ Added Bigstep as one of the default datasources in the settings.py file
-- 
Your team cloud init development team is requested to review the proposed merge of lp:~alexandru-sirbu/cloud-init/bigstep-datasource-improvements into lp:cloud-init.
=== modified file 'cloudinit/settings.py'
--- cloudinit/settings.py	2015-03-04 17:42:34 +0000
+++ cloudinit/settings.py	2016-03-07 09:36:05 +0000
@@ -42,6 +42,7 @@
         'CloudSigma',
         'CloudStack',
         'SmartOS',
+        'Bigstep',
         # At the end to act as a 'catch' when none of the above work...
         'None',
     ],

=== modified file 'cloudinit/sources/DataSourceBigstep.py'
--- cloudinit/sources/DataSourceBigstep.py	2016-03-02 08:53:47 +0000
+++ cloudinit/sources/DataSourceBigstep.py	2016-03-07 09:36:05 +0000
@@ -5,6 +5,7 @@
 #
 
 import json
+import errno
 
 from cloudinit import log as logging
 from cloudinit import sources
@@ -22,7 +23,13 @@
         self.userdata_raw = ""
 
     def get_data(self, apply_filter=False):
-        url = get_url_from_file()
+        try:
+            url = get_url_from_file()
+        except IOError as e:
+            if e.errno == errno.ENOENT:
+                return False
+            else:
+                raise
         response = url_helper.readurl(url)
         decoded = json.loads(response.contents)
         self.metadata = decoded["metadata"]