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):
|
2016-06-04 11:35:59 +02:00
|
|
|
description = 'Determining required external commands for EC2 bootstrapping'
|
2016-09-12 01:12:19 +02:00
|
|
|
phase = phases.validation
|
2016-06-04 11:35:59 +02:00
|
|
|
successors = [host.CheckExternalCommands]
|
2013-12-29 16:09:47 +01:00
|
|
|
|
2016-06-04 11:35:59 +02:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
|
|
|
if info.manifest.volume['backing'] == 's3':
|
|
|
|
info.host_dependencies['euca-bundle-image'] = 'euca2ools'
|
|
|
|
info.host_dependencies['euca-upload-bundle'] = 'euca2ools'
|
2013-05-02 19:13:35 +02:00
|
|
|
|
|
|
|
|
2014-05-03 10:43:14 +02:00
|
|
|
class GetInstanceMetadata(Task):
|
2016-06-04 11:35:59 +02:00
|
|
|
description = 'Retrieving instance metadata'
|
|
|
|
phase = phases.preparation
|
2013-06-09 20:29:54 +02:00
|
|
|
|
2016-06-04 11:35:59 +02:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
|
|
|
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._ec2['host'] = json.load(response)
|
|
|
|
info._ec2['region'] = info._ec2['host']['region']
|
2014-05-03 10:43:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
class SetRegion(Task):
|
2016-06-04 11:35:59 +02:00
|
|
|
description = 'Setting the AWS region'
|
|
|
|
phase = phases.preparation
|
2014-05-03 10:43:14 +02:00
|
|
|
|
2016-06-04 11:35:59 +02:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
|
|
|
info._ec2['region'] = info.manifest.provider['region']
|