def _dummy_event(self, event_id): resource = self.stack['generic1'] return Event(utils.dummy_context(), self.stack, 'CREATE', 'COMPLETE', 'state changed', 'z3455xyc-9f88-404d-a85b-5315293e67de', resource.properties, resource.name, resource.type(), uuid='abc123yc-9f88-404d-a85b-531529456xyz', id=event_id)
def _dummy_event(self, event_id): resource = self.stack["generic1"] return Event( utils.dummy_context(), self.stack, "CREATE", "COMPLETE", "state changed", "z3455xyc-9f88-404d-a85b-5315293e67de", resource.properties, resource.name, resource.type(), uuid="abc123yc-9f88-404d-a85b-531529456xyz", id=event_id, )
def test_update_group_config(self): """ Updating the groupConfiguration section in a template results in a pyrax call to update the group configuration. """ self._setup_test_stack() resource = self.stack['my_group'] uprops = copy.deepcopy(dict(resource.properties.data)) uprops['groupConfiguration']['minEntities'] = 5 new_template = rsrc_defn.ResourceDefinition(resource.name, resource.type(), uprops) scheduler.TaskRunner(resource.update, new_template)() self.assertEqual(1, len(self.fake_auto_scale.groups)) self.assertEqual( 5, self.fake_auto_scale.groups['0'].kwargs['min_entities'])
def test_update_launch_config_stack(self): self._setup_test_stack(self.stack_template) resource = self.stack['my_group'] uprops = copy.deepcopy(dict(resource.properties.data)) lcargs = uprops['launchConfiguration']['args'] lcargs['stack']['timeout_mins'] = 60 new_template = rsrc_defn.ResourceDefinition(resource.name, resource.type(), uprops) scheduler.TaskRunner(resource.update, new_template)() self.assertEqual(1, len(self.fake_auto_scale.groups)) self.assertEqual( 60, self.fake_auto_scale.groups['0'].kwargs['timeout_mins'])
def test_update(self): self._setup_test_stack(self.webhook_template) resource = self.stack['my_webhook'] uprops = copy.deepcopy(dict(resource.properties.data)) uprops['metadata']['a'] = 'different!' uprops['name'] = 'newhook' template = rsrc_defn.ResourceDefinition(resource.name, resource.type(), uprops) scheduler.TaskRunner(resource.update, template)() self.assertEqual( { 'name': 'newhook', 'scaling_group': 'my-group-id', 'policy': 'my-policy-id', 'metadata': {'a': 'different!'}}, self.fake_auto_scale.webhooks['0'].kwargs)
def test_update(self): """Updating the resource calls appropriate update method with pyrax.""" self._setup_test_stack(self.policy_template) resource = self.stack['my_policy'] uprops = copy.deepcopy(dict(resource.properties.data)) uprops['changePercent'] = 50 del uprops['change'] template = rsrc_defn.ResourceDefinition(resource.name, resource.type(), uprops) scheduler.TaskRunner(resource.update, template)() self.assertEqual( { 'name': '+10 on webhook', 'scaling_group': 'my-group-id', 'change': 50, 'is_percent': True, 'cooldown': 0, 'policy_type': 'webhook' }, self.fake_auto_scale.policies['0'].kwargs)
def test_update(self): """Updating the resource calls appropriate update method with pyrax.""" self._setup_test_stack(self.policy_template) resource = self.stack['my_policy'] uprops = copy.deepcopy(dict(resource.properties.data)) uprops['changePercent'] = 50 del uprops['change'] template = rsrc_defn.ResourceDefinition(resource.name, resource.type(), uprops) scheduler.TaskRunner(resource.update, template)() self.assertEqual( { 'name': '+10 on webhook', 'scaling_group': 'my-group-id', 'change': 50, 'is_percent': True, 'cooldown': 0, 'policy_type': 'webhook'}, self.fake_auto_scale.policies['0'].kwargs)
def test_update_launch_config(self): """ Updating the launchConfigresults section in a template results in a pyrax call to update the launch configuration. """ self._setup_test_stack() resource = self.stack['my_group'] uprops = copy.deepcopy(dict(resource.properties.data)) lcargs = uprops['launchConfiguration']['args'] lcargs['loadBalancers'] = [{'loadBalancerId': '1', 'port': 80}] new_template = rsrc_defn.ResourceDefinition(resource.name, resource.type(), uprops) scheduler.TaskRunner(resource.update, new_template)() self.assertEqual(1, len(self.fake_auto_scale.groups)) self.assertEqual([{ 'loadBalancerId': 1, 'port': 80 }], self.fake_auto_scale.groups['0'].kwargs['load_balancers'])
def test_update_launch_config(self): """ Updating the launchConfigresults section in a template results in a pyrax call to update the launch configuration. """ self._setup_test_stack() resource = self.stack['my_group'] uprops = copy.deepcopy(dict(resource.properties.data)) lcargs = uprops['launchConfiguration']['args'] lcargs['loadBalancers'] = [{'loadBalancerId': '1', 'port': 80}] new_template = rsrc_defn.ResourceDefinition(resource.name, resource.type(), uprops) scheduler.TaskRunner(resource.update, new_template)() self.assertEqual(1, len(self.fake_auto_scale.groups)) self.assertEqual( [{'loadBalancerId': 1, 'port': 80}], self.fake_auto_scale.groups['0'].kwargs['load_balancers'])
def _vpc_route_tables(self): for resource in self.stack.resources.itervalues(): if (resource.type() == 'AWS::EC2::RouteTable' and resource.properties.get('VpcId') == self.properties.get('VpcId')): yield resource