2014-03-23 23:12:07 +01:00
|
|
|
from bootstrapvz.base import Task
|
|
|
|
from bootstrapvz.common import phases
|
|
|
|
from bootstrapvz.common.tasks import host
|
2013-12-29 16:09:47 +01:00
|
|
|
|
|
|
|
|
2014-02-23 21:51:28 +01:00
|
|
|
class AddExternalCommands(Task):
|
|
|
|
description = 'Determining required external commands for EC2 bootstrapping'
|
2013-12-29 16:09:47 +01:00
|
|
|
phase = phases.preparation
|
2014-02-23 21:51:28 +01:00
|
|
|
successors = [host.CheckExternalCommands]
|
2013-12-29 16:09:47 +01:00
|
|
|
|
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':
|
2014-02-23 21:51:28 +01:00
|
|
|
info.host_dependencies['euca-bundle-image'] = 'euca2ools'
|
|
|
|
info.host_dependencies['euca-upload-bundle'] = '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
|