diff options
author | Chuck Short <zulcss@ubuntu.com> | 2009-05-05 09:59:54 +0200 |
---|---|---|
committer | Chuck Short <zulcss@ubuntu.com> | 2009-05-05 09:59:54 +0200 |
commit | 322bf4c779a378f113e6bf60714c66298aba876d (patch) | |
tree | 839d46c3211c2724ecafa32beaeac0cf0ab4519f /ec2-set-apt-sources.py | |
parent | ac53fe3d7599356b1f8c9851113212b68a5ab667 (diff) | |
download | vyos-cloud-init-322bf4c779a378f113e6bf60714c66298aba876d.tar.gz vyos-cloud-init-322bf4c779a378f113e6bf60714c66298aba876d.zip |
* Add more smarts to ec2 instance bring up. (LP: #371936)
Diffstat (limited to 'ec2-set-apt-sources.py')
-rwxr-xr-x | ec2-set-apt-sources.py | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/ec2-set-apt-sources.py b/ec2-set-apt-sources.py index 46ca0a48..8efb5896 100755 --- a/ec2-set-apt-sources.py +++ b/ec2-set-apt-sources.py @@ -37,8 +37,7 @@ def checkServer(): sys.exit(0) def detectZone(): - api_ver = '2008-02-01' - metadat = None + api_ver = '2008-02-01' base_url = 'http://169.254.169.254/%s/meta-data' % api_ver zone = urllib.urlopen('%s/placement/availability-zone' % base_url).read() @@ -49,7 +48,7 @@ def detectZone(): return(archive) -def updateList(): +def updateList(filename): mirror = detectZone() if not os.path.exists("/var/run/ec2/sources.lists"): t = os.popen("lsb_release -c").read() @@ -69,5 +68,22 @@ def updateList(): prog = apt.progress.FetchProgress() cache.update(prog) + os.system('touch %s' %(filename)) + +def get_ami_id(): + api_ver = '2008-02-01' + + url = 'http://169.254.169.254/%s/meta-data' % api_ver + ami_id = urllib.urlopen('%s/ami-id/' %url).read() + return ami_id + + checkServer() -updateList() + +ami_id = get_ami_id() +filename = '/var/ec2/.apt-already-ran.%s' %ami_id + +if os.path.exists(filename): + print "ec2-set-apt-sources already ran....skipping." +else: + updateList(filename) |