Merge pull request #1188 from lleontop/layer_per_stack

Layer per stack
This commit is contained in:
Jack Danger 2017-09-25 13:58:39 -07:00 committed by GitHub
commit 4ca76ae1b0
2 changed files with 18 additions and 2 deletions

View File

@ -422,11 +422,11 @@ class OpsWorksBackend(BaseBackend):
stackid = kwargs['stack_id'] stackid = kwargs['stack_id']
if stackid not in self.stacks: if stackid not in self.stacks:
raise ResourceNotFoundException(stackid) raise ResourceNotFoundException(stackid)
if name in [l.name for l in self.layers.values()]: if name in [l.name for l in self.stacks[stackid].layers]:
raise ValidationException( raise ValidationException(
'There is already a layer named "{0}" ' 'There is already a layer named "{0}" '
'for this stack'.format(name)) 'for this stack'.format(name))
if shortname in [l.shortname for l in self.layers.values()]: if shortname in [l.shortname for l in self.stacks[stackid].layers]:
raise ValidationException( raise ValidationException(
'There is already a layer with shortname "{0}" ' 'There is already a layer with shortname "{0}" '
'for this stack'.format(shortname)) 'for this stack'.format(shortname))

View File

@ -27,6 +27,22 @@ def test_create_layer_response():
response.should.contain("LayerId") response.should.contain("LayerId")
second_stack_id = client.create_stack(
Name="test_stack_2",
Region="us-east-1",
ServiceRoleArn="service_arn",
DefaultInstanceProfileArn="profile_arn"
)['StackId']
response = client.create_layer(
StackId=second_stack_id,
Type="custom",
Name="TestLayer",
Shortname="TestLayerShortName"
)
response.should.contain("LayerId")
# ClientError # ClientError
client.create_layer.when.called_with( client.create_layer.when.called_with(
StackId=stack_id, StackId=stack_id,