summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@nelson>2010-01-08 00:11:07 -0500
committerScott Moser <smoser@nelson>2010-01-08 00:11:07 -0500
commit788a3bfb0165caacade779a5b99891e04cdf7123 (patch)
tree73f546e96e90cb5cb90bfa9fa3b516896a8b2192
parentbddf1df6cd1d2dad82d6cc3bc5ff13df7f4d8691 (diff)
downloadvyos-cloud-init-788a3bfb0165caacade779a5b99891e04cdf7123.tar.gz
vyos-cloud-init-788a3bfb0165caacade779a5b99891e04cdf7123.zip
fixes found testing in ec2
-rwxr-xr-xec2-init.py4
-rw-r--r--ec2init/DataSourceEc2.py9
-rw-r--r--ec2init/__init__.py11
3 files changed, 10 insertions, 14 deletions
diff --git a/ec2-init.py b/ec2-init.py
index 45932fa7..8d6c0932 100755
--- a/ec2-init.py
+++ b/ec2-init.py
@@ -32,7 +32,7 @@ def main():
cloud.sem_and_run("consume_userdata", "once-per-instance",
cloud.consume_userdata,[],False)
except:
- warn("consuming user data failed!")
+ warn("consuming user data failed!\n")
raise
# set the defaults (like what ec2-set-defaults.py did)
@@ -40,7 +40,7 @@ def main():
generate_sources_list(cloud.get_mirror())
apply_locale(cloud.get_locale())
except:
- warn("failed to set defaults")
+ warn("failed to set defaults\n")
# set the ssh keys up
cloud.apply_credentials()
diff --git a/ec2init/DataSourceEc2.py b/ec2init/DataSourceEc2.py
index c7415c0a..6bf7f2b5 100644
--- a/ec2init/DataSourceEc2.py
+++ b/ec2init/DataSourceEc2.py
@@ -37,8 +37,9 @@ class DataSourceEc2(DataSource.DataSource):
try:
if not self.wait_for_metadata_service():
return False
- self.metadata = boto.utils.get_instance_userdata(api_ver)
- self.userdata_raw = boto.utils.get_instance_metadata(api_ver)
+ self.userdata_raw = boto.utils.get_instance_userdata(self.api_ver)
+ self.metadata = boto.utils.get_instance_metadata(self.api_ver)
+ return True
except Exception as e:
print e
return False
@@ -54,8 +55,8 @@ class DataSourceEc2(DataSource.DataSource):
def get_locale(self):
az = self.metadata['placement']['availability-zone']
- if self.location_locale_map.has_key[az[0:2]]:
- return(self.location_locale_map[az])
+ if self.location_locale_map.has_key(az[0:2]):
+ return(self.location_locale_map[az[0:2]])
else:
return(self.location_locale_map["default"])
diff --git a/ec2init/__init__.py b/ec2init/__init__.py
index d9d24969..a0ef24c2 100644
--- a/ec2init/__init__.py
+++ b/ec2init/__init__.py
@@ -80,7 +80,7 @@ class EC2Init:
s = source()
if s.get_data():
self.datasource = s
- return
+ return True
except Exception as e:
pass
raise Exception("Could not find data source")
@@ -93,13 +93,8 @@ class EC2Init:
self.store_userdata()
def store_userdata(self):
- f = open(userdata_raw,"wb")
- f.write(self.datasource.get_userdata_raw())
- f.close()
-
- f = open(userdata,"wb")
- f.write(self.get_userdata())
- f.close()
+ write_file(userdata_raw, self.datasource.get_userdata_raw(), 0644)
+ write_file(userdata, self.datasource.get_userdata(), 0644)
def get_cfg_option_bool(self, key, default=None):
val = self.config.get(key, default)