Update so that the content types searched for launch-index
variable has a little more meaning and by default look in metadata for 'launch-index' and have ec2 instead look for a different variable (thus allowing more datasources to just work).
This commit is contained in:
parent
32286226e6
commit
478e00a997
@ -76,8 +76,9 @@ class Cloud(object):
|
||||
def get_instance_id(self):
|
||||
return self.datasource.get_instance_id()
|
||||
|
||||
def get_launch_index(self):
|
||||
return self.datasource.get_launch_index()
|
||||
@property
|
||||
def launch_index(self):
|
||||
return self.datasource.launch_index
|
||||
|
||||
def get_public_ssh_keys(self):
|
||||
return self.datasource.get_public_ssh_keys()
|
||||
|
@ -77,7 +77,10 @@ class DataSourceEc2(sources.DataSource):
|
||||
self.metadata_address)
|
||||
return False
|
||||
|
||||
def get_launch_index(self):
|
||||
@property
|
||||
def launch_index(self):
|
||||
if not self.metadata:
|
||||
return None
|
||||
return self.metadata.get('ami-launch-index')
|
||||
|
||||
def get_instance_id(self):
|
||||
|
@ -68,13 +68,18 @@ class DataSource(object):
|
||||
return self._filter_userdata(self.userdata)
|
||||
return self.userdata
|
||||
|
||||
def get_launch_index(self):
|
||||
@property
|
||||
def launch_index(self):
|
||||
if not self.metadata:
|
||||
return None
|
||||
if 'launch-index' in self.metadata:
|
||||
return self.metadata['launch-index']
|
||||
return None
|
||||
|
||||
def _filter_userdata(self, processed_ud):
|
||||
if not processed_ud:
|
||||
return processed_ud
|
||||
idx = self.get_launch_index()
|
||||
idx = self.launch_index
|
||||
if idx is None:
|
||||
return processed_ud
|
||||
# First do a scan to see if any one with launch-index
|
||||
|
@ -53,7 +53,8 @@ ARCHIVE_UNDEF_TYPE = "text/cloud-config"
|
||||
ATTACHMENT_FIELD = 'Number-Attachments'
|
||||
|
||||
# Only the following content types can have there launch index examined
|
||||
CAN_HAVE_LAUNCH_INDEX = ["text/cloud-config", "text/cloud-config-archive"]
|
||||
# in there payload, evey other content type can still provide a header
|
||||
EXAMINE_FOR_LAUNCH_INDEX = ["text/cloud-config", "text/cloud-config-archive"]
|
||||
|
||||
|
||||
class UserDataProcessor(object):
|
||||
@ -101,7 +102,7 @@ class UserDataProcessor(object):
|
||||
def _attach_launch_index(self, msg):
|
||||
header_idx = msg.get('Launch-Index', None)
|
||||
payload_idx = None
|
||||
if msg.get_content_type() in CAN_HAVE_LAUNCH_INDEX:
|
||||
if msg.get_content_type() in EXAMINE_FOR_LAUNCH_INDEX:
|
||||
try:
|
||||
# See if it has a launch-index field
|
||||
# that might affect the final header
|
||||
|
Loading…
Reference in New Issue
Block a user