mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-22 09:50:37 +00:00
Final fix for ec2_launch plugin
This commit is contained in:
parent
ed33a5f067
commit
ef698b06ca
2 changed files with 11 additions and 8 deletions
|
@ -48,20 +48,21 @@ class PrintPublicIPAddress(Task):
|
|||
@classmethod
|
||||
def run(cls, info):
|
||||
ec2 = info._ec2
|
||||
conn = info._ec2['connection']
|
||||
logger = logging.getLogger(__name__)
|
||||
filename = info.manifest.plugins['ec2_launch']['print_public_ip']
|
||||
if not filename:
|
||||
filename = '/dev/null'
|
||||
f = open(filename, 'w')
|
||||
|
||||
def instance_has_ip():
|
||||
ec2['instance'].update()
|
||||
return ec2['instance']['PublicIpAddress']
|
||||
|
||||
if waituntil(instance_has_ip, timeout=120, interval=5):
|
||||
logger.info('******* EC2 IP ADDRESS: %s *******' % ec2['instance']['PublicIpAddress'])
|
||||
f.write(ec2['instance']['PublicIpAddress'])
|
||||
else:
|
||||
try:
|
||||
waiter = conn.get_waiter('instance_status_ok')
|
||||
waiter.wait(InstanceIds=[info._ec2['instance']['InstanceId']],
|
||||
Filters=[{'Name': 'instance-state-name', 'Values': ['running']}])
|
||||
info._ec2['instance'] = conn.describe_instances(InstanceIds=[info._ec2['instance']['InstanceId']])['Reservations'][0]['Instances'][0]
|
||||
logger.info('******* EC2 IP ADDRESS: %s *******' % info._ec2['instance']['PublicIpAddress'] )
|
||||
f.write(info._ec2['instance']['PublicIpAddress'])
|
||||
except:
|
||||
logger.error('Could not get IP address for the instance')
|
||||
f.write('')
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ class GetCredentials(Task):
|
|||
|
||||
def env_key(key):
|
||||
return ('aws-' + key).upper().replace('-', '_')
|
||||
|
||||
if all(getenv(env_key(key)) is not None for key in keys):
|
||||
for key in keys:
|
||||
creds[key] = getenv(env_key(key))
|
||||
|
@ -45,6 +46,7 @@ class GetCredentials(Task):
|
|||
|
||||
def provider_key(key):
|
||||
return key.replace('-', '_')
|
||||
|
||||
import boto.provider
|
||||
provider = boto.provider.Provider('aws')
|
||||
if all(getattr(provider, provider_key(key)) is not None for key in keys):
|
||||
|
|
Loading…
Add table
Reference in a new issue