Skip to content
This repository has been archived by the owner on Jan 2, 2019. It is now read-only.

Commit

Permalink
change start operatin handling
Browse files Browse the repository at this point in the history
  • Loading branch information
earthmant committed Feb 20, 2018
1 parent e46be0f commit fd1978d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
25 changes: 18 additions & 7 deletions cloudify_awssdk/ec2/resources/instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# Cloudify
from cloudify import compute
from cloudify import ctx
from cloudify.exceptions import NonRecoverableError
from cloudify.exceptions import NonRecoverableError, OperationRetry
from cloudify_awssdk.common import decorators, utils
from cloudify_awssdk.common.constants import EXTERNAL_RESOURCE_ID
from cloudify_awssdk.ec2 import EC2Base
Expand Down Expand Up @@ -229,15 +229,26 @@ def create(ctx, iface, resource_config, **_):


@decorators.aws_resource(EC2Instances, RESOURCE_TYPE)
@decorators.wait_for_status(
status_good=[RUNNING],
status_pending=[PENDING, STOPPING, SHUTTING_DOWN])
def start(ctx, iface, resource_config, **_):
'''Starts AWS EC2 Instances'''

params = \
dict() if not resource_config else resource_config.copy()
iface.start({INSTANCE_IDS: params.get(INSTANCE_IDS, [iface.resource_id])})
if iface.status in [RUNNING]:
current_properties = iface.properties
ctx.instance.runtime_properties['public_ip_address'] = \
current_properties.get('PublicIpAddress')
ctx.instance.runtime_properties['ip'] = \
current_properties.get('PrivateIpAddress')

elif ctx.operation.retry_number == 0:
params = \
dict() if not resource_config else resource_config.copy()
iface.start(
{INSTANCE_IDS: params.get(
INSTANCE_IDS, [iface.resource_id])})

raise OperationRetry(
'{0} ID# {1} is still in a pending state.'.format(
iface.resource_type, iface.resource_id))


@decorators.aws_resource(EC2Instances, RESOURCE_TYPE)
Expand Down
4 changes: 2 additions & 2 deletions plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ plugins:

awssdk:
executor: central_deployment_agent
source: https://github.com//cloudify-incubator/cloudify-awssdk-plugin/archive/2.0.0.zip
source: https://github.com//cloudify-incubator/cloudify-awssdk-plugin/archive/98-Support-Instance-Keypair.zip
package_name: cloudify-awssdk-plugin
package_version: '2.0.0'
package_version: '2.0.0rc2'

data_types:

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

setup(
name='cloudify-awssdk-plugin',
version='2.0.0',
version='2.0.0rc2',
license='LICENSE',
packages=find_packages(exclude=['tests*']),
description='A Cloudify plugin for AWS',
Expand Down

0 comments on commit fd1978d

Please sign in to comment.