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

Commit 8316cdc

Browse files
mabuaishaEarthmanT
authored andcommitted
Cy 837 update sdk library versions (#171)
* CY-837 Update Cloudify AWSSDK Plugin SDK Library Versions * CY-837 Update rds cloudformation exmaple * Route53 example updated * CY-865: Remove references to old aws plugin from blueprint examples * CY-865: Update elb blueprint examples * CY-865: Update natgateway blueprint example * CY-865: Update lambda example * CY-865: Update kms example * CY-865: Update ecs example * CY-865: fix issue with autoscaling group * CY-865: Update ecs example * CY-865: Update ec2 examples * CY-865: Update ec2 examples * CY-865: Update blueprint example and use the latest version for cloudify * CY-865: Update plugin to add support for backward compatibility with old aws plugin * Temporary change to rerun integration tests on CI (all tests) * CY-892: Add cloudify manager integration tests * CY-837: Update awssdk test * CY-837: Update awssdk plugin to verion 2.8.0
1 parent 889db2e commit 8316cdc

File tree

61 files changed

+1866
-1314
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1866
-1314
lines changed

.circleci/config.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ jobs:
107107
command: pip install -e .
108108
- run:
109109
name: install test requirements
110-
command: pip install awscli nose testtools https://github.com/cloudify-cosmo/cloudify-fabric-plugin/archive/1.5.1.zip https://github.com/cloudify-incubator/cloudify-utilities-plugin/archive/1.7.1.zip https://github.com/cloudify-incubator/cloudify-ecosystem-test/archive/2.0.zip
110+
command: pip install awscli nose testtools https://github.com/cloudify-cosmo/cloudify-fabric-plugin/archive/1.5.1.zip https://github.com/cloudify-incubator/cloudify-utilities-plugin/archive/1.7.1.zip https://github.com/cloudify-incubator/cloudify-ecosystem-test/archive/2.1.2.zip
111111
- run:
112112
name: execute test
113-
command: nosetests -s integration_tests/test_awssdk.py
113+
command: nosetests -s integration_tesing/test_awssdk.py
114114

115115
workflows:
116116
version: 2
@@ -125,7 +125,6 @@ workflows:
125125
context: ecosystem
126126
requires:
127127
- wagon
128-
- unittests
129128
filters:
130129
branches:
131130
only: /([0-9\.]*\-build|master|dev)/

cloudify_awssdk/autoscaling/resources/autoscaling_group.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
Autoscaling.Group
1717
~~~~~~~~~~~~~~
1818
AWS Autoscaling Group interface
19+
1920
"""
21+
# Standard imports
22+
from re import sub
23+
2024
# Cloudify
2125
from cloudify.exceptions import OperationRetry
2226
from cloudify_awssdk.common import decorators, utils
@@ -155,7 +159,7 @@ def create(ctx, iface, resource_config, **_):
155159

156160
subnet_list_string = params.get(SUBNET_LIST)
157161
subnet_list = \
158-
subnet_list_string.split(', ') if \
162+
sub("[^\w]", " ", subnet_list_string).split() if \
159163
subnet_list_string else []
160164

161165
subnet_list = \
@@ -168,7 +172,10 @@ def create(ctx, iface, resource_config, **_):
168172
ctx.instance,
169173
SUBNET_TYPE_DEPRECATED,
170174
subnet_list)
175+
171176
if subnet_list:
177+
# Remove any duplicate items from subnet list
178+
subnet_list = list(set(subnet_list))
172179
params[SUBNET_LIST] = ', '.join(subnet_list)
173180

174181
# Actually create the resource

cloudify_awssdk/autoscaling/resources/launch_configuration.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@
2020
# Cloudify
2121
from cloudify_awssdk.common import decorators, utils
2222
from cloudify_awssdk.autoscaling import AutoscalingBase
23+
from cloudify.exceptions import NonRecoverableError
2324
# Boto
2425
from botocore.exceptions import ClientError
2526

2627
RESOURCE_TYPE = 'Autoscaling Launch Configuration'
2728
LCS = 'LaunchConfigurations'
2829
RESOURCE_NAMES = 'LaunchConfigurationNames'
2930
RESOURCE_NAME = 'LaunchConfigurationName'
31+
IAM_INSTANCE_PROFILE = 'IamInstanceProfile'
3032
LC_ARN = 'LaunchConfigurationARN'
3133
IMAGEID = 'ImageId'
3234
INSTANCEID = 'InstanceId'
@@ -106,6 +108,17 @@ def create(ctx, iface, resource_config, **_):
106108
params[RESOURCE_NAME] = resource_id
107109
utils.update_resource_id(ctx.instance, resource_id)
108110

111+
# Check if the "IamInstanceProfile" is passed or not and then update it
112+
iam_instance_profile = params.get(IAM_INSTANCE_PROFILE)
113+
if iam_instance_profile:
114+
if isinstance(iam_instance_profile, basestring):
115+
iam_instance_profile = iam_instance_profile.strip()
116+
params[IAM_INSTANCE_PROFILE] = str(iam_instance_profile)
117+
else:
118+
raise NonRecoverableError(
119+
'Invalid {0} data type for {1}'
120+
''.format(type(iam_instance_profile), IAM_INSTANCE_PROFILE))
121+
109122
# Add Security Groups
110123
secgroups_list = params.get(SECGROUPS, [])
111124
params[SECGROUPS] = \

cloudify_awssdk/cloudformation/tests/test_stack.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# * See the License for the specific language governing permissions and
1313
# * limitations under the License.
1414
import unittest
15+
import copy
1516
from mock import patch, MagicMock
1617

1718
from cloudify.state import current_ctx
@@ -73,10 +74,11 @@ def test_prepare(self):
7374
type_class=stack)
7475

7576
def test_create(self):
76-
_ctx = self.get_mock_ctx('test_create',
77-
test_properties=NODE_PROPERTIES,
78-
test_runtime_properties=RUNTIME_PROPERTIES,
79-
type_hierarchy=STACK_TH)
77+
_ctx = self.get_mock_ctx(
78+
'test_create', test_properties=NODE_PROPERTIES,
79+
test_runtime_properties=RUNTIME_PROPERTIES,
80+
type_hierarchy=STACK_TH,
81+
ctx_operation_name='cloudify.interfaces.lifecycle.configure')
8082

8183
current_ctx.set(_ctx)
8284
self.fake_client.describe_stacks = MagicMock(return_value={
@@ -106,8 +108,13 @@ def test_create(self):
106108
except AssertionError as e:
107109
raise e
108110

111+
updated_runtime_prop = copy.deepcopy(RUNTIMEPROP_AFTER_CREATE)
112+
updated_runtime_prop['create_response'] = {
113+
'StackName': 'Stack',
114+
'StackStatus': 'CREATE_COMPLETE'
115+
}
109116
self.assertEqual(_ctx.instance.runtime_properties,
110-
RUNTIMEPROP_AFTER_CREATE)
117+
updated_runtime_prop)
111118

112119
def test_delete(self):
113120
_ctx = \

cloudify_awssdk/common/decorators.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ def wrapper_outer(function):
217217
def wrapper_inner(**kwargs):
218218
'''Inner, worker function'''
219219
ctx = kwargs['ctx']
220+
_, _, _, operation_name = ctx.operation.name.split('.')
220221
resource_type = kwargs.get('resource_type', 'AWS Resource')
221222
iface = kwargs['iface']
222223
# Run the operation if this is the first pass
@@ -251,6 +252,12 @@ def wrapper_inner(**kwargs):
251252
raise OperationRetry(
252253
'%s ID# "%s" is still in a pending state.'
253254
% (resource_type, iface.resource_id))
255+
256+
elif status_good and status in status_good:
257+
if operation_name in ['create', 'configure']:
258+
ctx.instance.runtime_properties['create_response'] = \
259+
utils.JsonCleanuper(iface.properties).to_dict()
260+
254261
elif not status and fail_on_missing:
255262
raise NonRecoverableError(
256263
'%s ID# "%s" no longer exists but "fail_on_missing" set'

cloudify_awssdk/common/tests/test_decorators.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ def test_delete(*agrs, **kwargs):
7777

7878
def test_wait_for_status(self):
7979

80-
_ctx = self._gen_decorators_context('test_wait_for_status')
80+
_ctx = self._gen_decorators_context(
81+
'test_wait_for_status',
82+
op_name='cloudify.interfaces.lifecycle.create')
8183

8284
@decorators.wait_for_status(status_good=['ok'],
8385
status_pending=['pending'])
@@ -87,37 +89,43 @@ def test_ok(*agrs, **kwargs):
8789
# ok
8890
mock_interface = MagicMock()
8991
mock_interface.status = 'ok'
92+
mock_interface.properties = {'status': 'ok'}
9093

9194
test_ok(ctx=_ctx, iface=mock_interface)
9295

9396
self.assertEqual(_ctx.instance.runtime_properties, {
94-
'resource_config': {}
97+
'resource_config': {},
98+
'create_response': {'status': 'ok'},
9599
})
96100

97101
# pending
98102
mock_interface = MagicMock()
99103
mock_interface.status = 'pending'
104+
mock_interface.properties = {'status': 'pending'}
100105

101106
with self.assertRaises(OperationRetry):
102107
test_ok(ctx=_ctx, iface=mock_interface)
103108

104109
# unknow
105110
mock_interface = MagicMock()
106-
mock_interface.status = 'unknow'
111+
mock_interface.status = 'unknown'
112+
mock_interface.properties = {'status': 'unknown'}
107113

108114
with self.assertRaises(NonRecoverableError):
109115
test_ok(ctx=_ctx, iface=mock_interface)
110116

111117
# empty status
112118
mock_interface = MagicMock()
113119
mock_interface.status = None
120+
mock_interface.properties = {'status': None}
114121

115122
with self.assertRaises(NonRecoverableError):
116123
test_ok(ctx=_ctx, iface=mock_interface)
117124

118125
# empty status but ignore
119126
mock_interface = MagicMock()
120127
mock_interface.status = None
128+
mock_interface.properties = {'status': None}
121129

122130
@decorators.wait_for_status(status_pending=['pending'],
123131
fail_on_missing=False)

cloudify_awssdk/dynamodb/tests/test_table.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from mock import patch, MagicMock
1616
import unittest
17+
import copy
1718
from cloudify.state import current_ctx
1819
from cloudify_awssdk.common.tests.test_base import TestBase, CLIENT_CONFIG
1920
from cloudify_awssdk.common.tests.test_base import DELETE_RESPONSE
@@ -67,7 +68,8 @@ def test_create(self):
6768
'test_create',
6869
test_properties=NODE_PROPERTIES,
6970
test_runtime_properties=DEFAULT_RUNTIME_PROPERTIES,
70-
type_hierarchy=TABLE_TH
71+
type_hierarchy=TABLE_TH,
72+
ctx_operation_name='cloudify.interfaces.lifecycle.create',
7173
)
7274

7375
current_ctx.set(_ctx)
@@ -123,10 +125,11 @@ def test_create(self):
123125
TableName='aws_table_name'
124126
)
125127

126-
self.assertEqual(
127-
_ctx.instance.runtime_properties,
128-
RUNTIME_PROPERTIES_AFTER_CREATE
129-
)
128+
updated_runtime_prop = copy.deepcopy(RUNTIME_PROPERTIES_AFTER_CREATE)
129+
updated_runtime_prop['create_response'] = {'TableStatus': 'ACTIVE'}
130+
131+
self.assertEqual(_ctx.instance.runtime_properties,
132+
updated_runtime_prop)
130133

131134
def test_delete(self):
132135
_ctx = self.get_mock_ctx(

cloudify_awssdk/ec2/resources/elasticip.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ def detach(ctx, iface, resource_config, **_):
238238
if not elasticip_id:
239239
elasticip_id = iface.resource_id
240240
params[ELASTICIP_ID] = elasticip_id
241-
elif not association_id:
241+
242+
if not association_id:
242243
return
243244

244245
if association_id and elasticip_id:

cloudify_awssdk/ec2/resources/subnet.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
SUBNET_ID = 'SubnetId'
3232
SUBNET_IDS = 'SubnetIds'
3333
CIDR_BLOCK = 'CidrBlock'
34+
IPV6_CIDR_BLOCK = 'Ipv6CidrBlock'
3435
VPC_ID = 'VpcId'
3536
VPC_TYPE = 'cloudify.nodes.aws.ec2.Vpc'
3637
VPC_TYPE_DEPRECATED = 'cloudify.aws.nodes.Vpc'
@@ -81,14 +82,14 @@ def delete(self, params=None):
8182
self.logger.debug('Response: %s' % res)
8283
return res
8384

84-
def modify_instance_attribute(self, params=None):
85+
def modify_subnet_attribute(self, params=None):
8586
'''
8687
Modifies an existing AWS EC2 Subnet Attribute.
8788
'''
8889
self.logger.debug(
8990
'Modifying {0} attribute with parameters: {1}'.format(
9091
self.type_name, params))
91-
res = self.client.modify_instance_attribute(**params)
92+
res = self.client.modify_subnet_attribute(**params)
9293
self.logger.debug('Response: %s' % res)
9394
return res
9495

@@ -110,6 +111,7 @@ def create(ctx, iface, resource_config, **_):
110111

111112
vpc_id = params.get(VPC_ID)
112113
cidr_block = params.get(CIDR_BLOCK)
114+
ipv6_cidr_block = params.get(IPV6_CIDR_BLOCK)
113115

114116
# If either of these values is missing,
115117
# they must be filled from a connected VPC.
@@ -134,6 +136,12 @@ def create(ctx, iface, resource_config, **_):
134136
targ.instance.runtime_properties.get(
135137
'resource_config', {}).get(CIDR_BLOCK)
136138

139+
# If ipv6 cidr block is provided by user, then we need to make sure that
140+
# The subnet size must use a /64 prefix length
141+
if ipv6_cidr_block:
142+
ipv6_cidr_block = ipv6_cidr_block[:-2] + '64'
143+
params[IPV6_CIDR_BLOCK] = ipv6_cidr_block
144+
137145
# Actually create the resource
138146
create_response = iface.create(params)[SUBNET]
139147
ctx.instance.runtime_properties['create_response'] = \

cloudify_awssdk/ec2/resources/vpc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ def create(ctx, iface, resource_config, **_):
109109
create_response = iface.create(params)[VPC]
110110
ctx.instance.runtime_properties['create_response'] = \
111111
utils.JsonCleanuper(create_response).to_dict()
112+
112113
vpc_id = create_response.get(VPC_ID, '')
113114
iface.update_resource_id(vpc_id)
114115
utils.update_resource_id(

0 commit comments

Comments
 (0)