Beispiel #1
0
    def test_group_create(self):
        """
        Creating a group passes all the correct arguments to pyrax and saves
        the group ID as the resource ID.
        """
        self._setup_test_stack()
        self.assertEqual(1, len(self.fake_auto_scale.groups))
        self.assertEqual(
            {
                'cooldown': 60,
                'config_drive': False,
                'user_data': None,
                'disk_config': None,
                'flavor': 'flavor-ref',
                'image': 'image-ref',
                'launch_config_type': 'launch_server',
                'load_balancers': None,
                'key_name': "my-key",
                'max_entities': 25,
                'group_metadata': {'group': 'metadata'},
                'metadata': {'server': 'metadata'},
                'min_entities': 1,
                'name': 'My Group',
                'networks': [{'uuid': '00000000-0000-0000-0000-000000000000'},
                             {'uuid': '11111111-1111-1111-1111-111111111111'}],
                'personality': [{
                        'path': u'/tmp/testfile',
                        'contents': u'dGVzdCBjb250ZW50'}],
                'server_name': u'autoscaled-server'},
            self.fake_auto_scale.groups['0'].kwargs)

        resource = self.stack['my_group']
        self.assertEqual('0', resource.FnGetRefId())
Beispiel #2
0
 def test_group_create(self):
     """
     Creating a group passes all the correct arguments to pyrax and saves
     the group ID as the resource ID.
     """
     self._setup_test_stack()
     self.assertEqual(len(self.fake_auto_scale.groups), 1)
     self.assertEqual(
         self.fake_auto_scale.groups['0'].kwargs, {
             'cooldown': 60,
             'disk_config': None,
             'flavor': 'flavor-ref',
             'image': 'image-ref',
             'launch_config_type': 'launch_server',
             'load_balancers': None,
             'key_name': "my-key",
             'max_entities': 25,
             'group_metadata': {
                 'group': 'metadata'
             },
             'metadata': {
                 'server': 'metadata'
             },
             'min_entities': 1,
             'name': 'My Group',
             'networks': None,
             'personality': None,
             'server_name': u'autoscaled-server'
         })
     resource = self.stack['my_group']
     self.assertEqual(resource.FnGetRefId(), '0')
Beispiel #3
0
    def test_group_create_stack(self):
        """Creating a group passes all the correct arguments to pyrax.

        Also saves the group ID as the resource ID.
        """
        self._setup_test_stack(self.stack_template)
        self.assertEqual(1, len(self.fake_auto_scale.groups))
        self.assertEqual(
            {
                'cooldown': 60,
                'min_entities': 1,
                'max_entities': 25,
                'group_metadata': {'group': 'metadata'},
                'name': 'My Group',
                'launch_config_type': u'launch_stack',
                'template': (
                    '''heat_template_version: 2015-10-15
description: This is a Heat template
parameters:
  image:
    default: cirros-0.3.4-x86_64-uec
    type: string
  flavor:
    default: m1.tiny
    type: string
resources:
  rand:
    type: OS::Heat::RandomString
'''),
                'template_url': None,
                'disable_rollback': False,
                'environment': {
                    'parameters': {
                        'image':
                        'Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)',
                    },
                    'resource_registry': {
                        'Heat::InstallConfigAgent': ('https://myhost.com/'
                                                     'bootconfig.yaml')
                    }
                },
                'files': {
                    'fileA.yaml': 'Contents of the file',
                    'file:///usr/fileB.template': 'Contents of the file'
                },
                'parameters': {
                    'flavor': '4 GB Performance',
                },
                'timeout_mins': 30,
            },
            self.fake_auto_scale.groups['0'].kwargs
        )

        resource = self.stack['my_group']
        self.assertEqual('0', resource.FnGetRefId())
Beispiel #4
0
 def test_create_webhook_change(self):
     """
     Creating the resource creates the scaling policy with pyrax,
     and sets the resource's ID to {group_id}:{policy_id}
     """
     self._setup_test_stack(self.policy_template)
     resource = self.stack['my_policy']
     self.assertEqual('my-group-id:0', resource.FnGetRefId())
     self.assertEqual(
         {
             'name': '+10 on webhook',
             'scaling_group': 'my-group-id',
             'change': 10,
             'cooldown': 0,
             'policy_type': 'webhook'
         }, self.fake_auto_scale.policies['0'].kwargs)
Beispiel #5
0
 def assertResourceState(self, resource, ref_id):
     self.assertIsNone(resource.validate())
     self.assertEqual((resource.CREATE, resource.COMPLETE), resource.state)
     self.assertEqual(ref_id, resource.FnGetRefId())
Beispiel #6
0
    def test_group_create_no_personality(self):

        template = template_format.parse('''
HeatTemplateFormatVersion: "2012-12-12"
Description: "Rackspace Auto Scale"
Parameters: {}
Resources:
    my_group:
        Type: Rackspace::AutoScale::Group
        Properties:
            groupConfiguration:
                name: "My Group"
                cooldown: 60
                minEntities: 1
                maxEntities: 25
                metadata:
                    group: metadata
            launchConfiguration:
                type: "launch_server"
                args:
                    server:
                        name: autoscaled-server
                        flavorRef: flavor-ref
                        imageRef: image-ref
                        key_name: my-key
                        metadata:
                            server: metadata
                        networks:
                            - uuid: "00000000-0000-0000-0000-000000000000"
                            - uuid: "11111111-1111-1111-1111-111111111111"
''')

        self.stack = utils.parse_stack(template)
        self.stack.create()
        self.assertEqual(('CREATE', 'COMPLETE'), self.stack.state,
                         self.stack.status_reason)

        self.assertEqual(1, len(self.fake_auto_scale.groups))
        self.assertEqual(
            {
                'cooldown':
                60,
                'config_drive':
                False,
                'user_data':
                None,
                'disk_config':
                None,
                'flavor':
                'flavor-ref',
                'image':
                'image-ref',
                'launch_config_type':
                'launch_server',
                'load_balancers':
                None,
                'key_name':
                "my-key",
                'max_entities':
                25,
                'group_metadata': {
                    'group': 'metadata'
                },
                'metadata': {
                    'server': 'metadata'
                },
                'min_entities':
                1,
                'name':
                'My Group',
                'networks': [{
                    'uuid': '00000000-0000-0000-0000-000000000000'
                }, {
                    'uuid': '11111111-1111-1111-1111-111111111111'
                }],
                'personality':
                None,
                'server_name':
                u'autoscaled-server'
            }, self.fake_auto_scale.groups['0'].kwargs)

        resource = self.stack['my_group']
        self.assertEqual('0', resource.FnGetRefId())