summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSoren Hansen <soren@canonical.com>2009-08-10 21:07:51 +0200
committerSoren Hansen <soren@canonical.com>2009-08-10 21:07:51 +0200
commit1cac841c3365f31a6021a63407f2001cfc69c04d (patch)
tree877e3ee5566c8bbede3a264cec09f04c7caf91d9
parentfb6561d590b494b25f96489eda89adfad6bd557a (diff)
downloadvyos-cloud-init-1cac841c3365f31a6021a63407f2001cfc69c04d.tar.gz
vyos-cloud-init-1cac841c3365f31a6021a63407f2001cfc69c04d.zip
Stop mangling /etc/hosts. EC2 provides a functional DNS.
Replace use of os.system with a call to subprocess.Popen.
-rwxr-xr-xec2-set-hostname.py20
1 files changed, 6 insertions, 14 deletions
diff --git a/ec2-set-hostname.py b/ec2-set-hostname.py
index 48aad89b..cc22f046 100755
--- a/ec2-set-hostname.py
+++ b/ec2-set-hostname.py
@@ -1,10 +1,11 @@
#!/usr/bin/python
#
-# Fetch login credentials for EC2
+# Set instance hostname to the localhostname defined by the EC2 meta-data
+# service
# Copyright (C) 2008-2009 Canonical Ltd.
#
-# Author: Chuck Short <chuck.short@canonical.com>
-# Soren Hansen <soren@canonical.com>
+# Authors: Chuck Short <chuck.short@canonical.com>
+# Soren Hansen <soren@canonical.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3, as
@@ -18,7 +19,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-from Cheetah.Template import Template
+import subprocess
import ec2init
@@ -26,16 +27,7 @@ def main():
ec2 = ec2init.EC2Init()
hostname = ec2.get_hostname()
-
- subprocess.Popen(['hostname', hostname']).communicate()
-
- # replace the ubuntu hostname in /etc/hosts
- mp = {'hostname': hostname}
- t = Template(file="/etc/ec2-init/templates/hosts.tmpl", searchList=[mp])
-
- f = open("/etc/hosts", "w")
- f.write(t.respond())
- f.close()
+ subprocess.Popen(['hostname', hostname]).communicate()
if __name__ == '__main__':
main()