2013-06-09 16:25:59 +02:00
|
|
|
from base import Task
|
2013-06-23 15:26:08 +02:00
|
|
|
from common import phases
|
2013-12-29 16:09:47 +01:00
|
|
|
from common.tasks import host
|
|
|
|
|
|
|
|
|
|
|
|
class HostDependencies(Task):
|
2014-01-06 22:57:48 +01:00
|
|
|
description = 'Adding required host packages for EC2 bootstrapping'
|
2013-12-29 16:09:47 +01:00
|
|
|
phase = phases.preparation
|
|
|
|
successors = [host.CheckHostDependencies]
|
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2013-12-29 16:09:47 +01:00
|
|
|
if info.manifest.volume['backing'] == 's3':
|
|
|
|
info.host_dependencies.add('euca2ools')
|
2013-05-02 19:13:35 +02:00
|
|
|
|
|
|
|
|
2013-06-23 12:00:17 +02:00
|
|
|
class GetInfo(Task):
|
|
|
|
description = 'Retrieving instance metadata'
|
2013-06-23 22:12:29 +02:00
|
|
|
phase = phases.preparation
|
2013-06-09 20:29:54 +02:00
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2013-06-23 12:00:17 +02:00
|
|
|
import urllib2
|
|
|
|
import json
|
|
|
|
metadata_url = 'http://169.254.169.254/latest/dynamic/instance-identity/document'
|
|
|
|
response = urllib2.urlopen(url=metadata_url, timeout=5)
|
|
|
|
info.host = json.load(response)
|
|
|
|
return info
|