summaryrefslogtreecommitdiff
path: root/ec2-run-user-data.py
diff options
context:
space:
mode:
authorChuck Short <zulcss@ubuntu.com>2009-04-06 23:04:49 +0100
committerBazaar Package Importer <jamesw@ubuntu.com>2009-04-06 23:04:49 +0100
commitc3ba031b7feb74bfbaf54fd73b599c95ed0df765 (patch)
treedb1dafc0bbb13a0efe1ec3f8c46220d5937aea4f /ec2-run-user-data.py
parent6dddf16cb8dea2e1a96b3d613b81087df247fd3d (diff)
downloadvyos-cloud-init-c3ba031b7feb74bfbaf54fd73b599c95ed0df765.tar.gz
vyos-cloud-init-c3ba031b7feb74bfbaf54fd73b599c95ed0df765.zip
* debian/control:
- Add python-cheetah and python-apt as a dependency. * debian/ec2-config.cfg: - Remove distro due to the change in ec2-set-apt-sources.py * debian/inistall - Install the templates in the right place. * ec2-set-apt-sources.py: - Use python-apt to update the sources.list.
Diffstat (limited to 'ec2-run-user-data.py')
-rwxr-xr-xec2-run-user-data.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/ec2-run-user-data.py b/ec2-run-user-data.py
index 56e5e538..ef3b86b1 100755
--- a/ec2-run-user-data.py
+++ b/ec2-run-user-data.py
@@ -23,11 +23,22 @@ import os
import sys
import tempfile
import urllib
+import socket
from time import gmtime, strftime
api_ver = '2008-02-01'
metadata = None
+def checkServer():
+ s = socket.socket()
+ try:
+ address = '169.254.169.254'
+ port = 80
+ s.connect((address,port))
+ except socket.error, 0:
+ print "!!!! Unable to connect to %s" % address
+ sys.exit(0)
+
def get_user_data():
url = 'http://169.254.169.254/%s/user-data' % api_ver
fp = urllib.urlopen(url)
@@ -40,6 +51,7 @@ def get_ami_id():
ami_id = urllib.urlopen('%s/ami-id/' %url).read()
return ami_id
+checkServer()
user_data = get_user_data()
amiId = get_ami_id()
filename = '/var/ec2/.already-ran.%s' % amiId