summaryrefslogtreecommitdiff
path: root/ec2init/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'ec2init/__init__.py')
-rw-r--r--ec2init/__init__.py20
1 files changed, 4 insertions, 16 deletions
diff --git a/ec2init/__init__.py b/ec2init/__init__.py
index 80203c80..cfd54e8d 100644
--- a/ec2init/__init__.py
+++ b/ec2init/__init__.py
@@ -143,8 +143,8 @@ class EC2Init:
self.store_userdata()
def store_userdata(self):
- write_file(userdata_raw, self.datasource.get_userdata_raw(), 0644)
- write_file(userdata, self.datasource.get_userdata(), 0644)
+ util.write_file(userdata_raw, self.datasource.get_userdata_raw(), 0644)
+ util.write_file(userdata, self.datasource.get_userdata(), 0644)
def initctl_emit(self):
subprocess.Popen(['initctl', 'emit', 'cloud-config',
@@ -240,14 +240,14 @@ class EC2Init:
return
filename=filename.replace(os.sep,'_')
- write_file("%s/%s" % (user_scripts_dir,filename), payload, 0700)
+ util.write_file("%s/%s" % (user_scripts_dir,filename), payload, 0700)
def handle_upstart_job(self,data,ctype,filename,payload):
if ctype == "__end__" or ctype == "__begin__": return
if not filename.endswith(".conf"):
filename=filename+".conf"
- write_file("%s/%s" % ("/etc/init",filename), payload, 0644)
+ util.write_file("%s/%s" % ("/etc/init",filename), payload, 0644)
def handle_cloud_config(self,data,ctype,filename,payload):
if ctype == "__begin__":
@@ -313,15 +313,3 @@ class EC2Init:
subprocess.Popen(['swapon', '-a']).communicate()
-def write_file(file,content,mode=0644):
- try:
- os.makedirs(os.path.dirname(file))
- except OSError as e:
- if e.errno != errno.EEXIST:
- raise e
-
- f=open(file,"wb")
- f.write(content)
- f.close()
- os.chmod(file,mode)
-