From 6a803e2fba17ab74973038c1a93654c3127c223f Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Sun, 26 Aug 2012 15:04:06 -0700 Subject: Add the capability to understand and filter on userdata based on a launch-index (or leave userdata alone if none is provided by the datasource). This works by doing the following. 1. Adjusting the userdata processor to attempt to inject a "Launch-Index" header into the messages headers (by either taking a header that already exists or by looking into the payload to see if it exists there). 2. Adjust the get_userdata ds function to apply a filter on the returned userdata (defaulting to false) that will now use the datasources get_launch_index value to restrict the 'final' message used in consuming user data (the same behavior if not existent). 3. Further down the line processes that use the 'resultant' userdata now will only see the ones for there own launch index (ie cloud-config will be restricted automatically and so on) and are unaffected (although they can now ask the cloud object or the datasource for its launch index via the above new ds method. --- cloudinit/cloud.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'cloudinit/cloud.py') diff --git a/cloudinit/cloud.py b/cloudinit/cloud.py index 620b3c07..af69a541 100644 --- a/cloudinit/cloud.py +++ b/cloudinit/cloud.py @@ -70,12 +70,15 @@ class Cloud(object): return fn # The rest of thes are just useful proxies - def get_userdata(self): - return self.datasource.get_userdata() + def get_userdata(self, apply_filter=True): + return self.datasource.get_userdata(apply_filter) def get_instance_id(self): return self.datasource.get_instance_id() + def get_launch_index(self): + return self.datasource.get_launch_index() + def get_public_ssh_keys(self): return self.datasource.get_public_ssh_keys() -- cgit v1.2.3