~ubuntu-branches/ubuntu/trusty/heat/trusty-security

« back to all changes in this revision

Viewing changes to heat/engine/resources/autoscaling.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-10-03 09:43:04 UTC
  • mto: This revision was merged to the branch mainline in revision 15.
  • Revision ID: package-import@ubuntu.com-20131003094304-zhhr2brapzlpvjmm
Tags: upstream-2013.2~rc1
ImportĀ upstreamĀ versionĀ 2013.2~rc1

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
                   'Value': {'Type': 'String',
66
66
                             'Required': True}}
67
67
    properties_schema = {
68
 
        'AvailabilityZones': {'Required': True,
69
 
                              'Type': 'List'},
70
 
        'LaunchConfigurationName': {'Required': True,
71
 
                                    'Type': 'String'},
72
 
        'Size': {'Required': True,
73
 
                 'Type': 'Number'},
74
 
        'LoadBalancerNames': {'Type': 'List'},
75
 
        'Tags': {'Type': 'List',
76
 
                 'Schema': {'Type': 'Map',
77
 
                            'Schema': tags_schema}}
 
68
        'AvailabilityZones': {
 
69
            'Required': True,
 
70
            'Type': 'List',
 
71
            'Description': _('Not Implemented.')},
 
72
        'LaunchConfigurationName': {
 
73
            'Required': True,
 
74
            'Type': 'String',
 
75
            'Description': _('Name of LaunchConfiguration resource.')},
 
76
        'Size': {
 
77
            'Required': True,
 
78
            'Type': 'Number',
 
79
            'Description': _('Desired number of instances.')},
 
80
        'LoadBalancerNames': {
 
81
            'Type': 'List',
 
82
            'Description': _('List of LoadBalancer resources.')},
 
83
        'Tags': {
 
84
            'Type': 'List',
 
85
            'Schema': {'Type': 'Map', 'Schema': tags_schema},
 
86
            'Description': _('Tags to attach to this group.')}
78
87
    }
79
88
    update_allowed_keys = ('Properties', 'UpdatePolicy',)
80
89
    update_allowed_properties = ('Size', 'LaunchConfigurationName',)
81
90
    attributes_schema = {
82
 
        "InstanceList": ("A comma-delimited list of server ip addresses. "
83
 
                         "(Heat extension)")
 
91
        "InstanceList": _("A comma-delimited list of server ip addresses. "
 
92
                          "(Heat extension).")
84
93
    }
85
94
    rolling_update_schema = {
86
95
        'MinInstancesInService': properties.Schema(properties.NUMBER,
249
258
                scheduler.TaskRunner(lb_resource.update, resolved_snippet)()
250
259
 
251
260
    def FnGetRefId(self):
252
 
        return unicode(self.name)
 
261
        return self.physical_resource_name()
253
262
 
254
263
    def _resolve_attribute(self, name):
255
264
        '''
269
278
                   'Value': {'Type': 'String',
270
279
                             'Required': True}}
271
280
    properties_schema = {
272
 
        'AvailabilityZones': {'Required': True,
273
 
                              'Type': 'List'},
274
 
        'LaunchConfigurationName': {'Required': True,
275
 
                                    'Type': 'String'},
276
 
        'MaxSize': {'Required': True,
277
 
                    'Type': 'String'},
278
 
        'MinSize': {'Required': True,
279
 
                    'Type': 'String'},
280
 
        'Cooldown': {'Type': 'String'},
281
 
        'DesiredCapacity': {'Type': 'Number'},
282
 
        'HealthCheckGracePeriod': {'Type': 'Integer',
283
 
                                   'Implemented': False},
284
 
        'HealthCheckType': {'Type': 'String',
285
 
                            'AllowedValues': ['EC2', 'ELB'],
286
 
                            'Implemented': False},
287
 
        'LoadBalancerNames': {'Type': 'List'},
288
 
        'VPCZoneIdentifier': {'Type': 'List'},
289
 
        'Tags': {'Type': 'List', 'Schema': {'Type': 'Map',
290
 
                                            'Schema': tags_schema}}
 
281
        'AvailabilityZones': {
 
282
            'Required': True,
 
283
            'Type': 'List',
 
284
            'Description': _('Not Implemented.')},
 
285
        'LaunchConfigurationName': {
 
286
            'Required': True,
 
287
            'Type': 'String',
 
288
            'Description': _('Name of LaunchConfiguration resource.')},
 
289
        'MaxSize': {
 
290
            'Required': True,
 
291
            'Type': 'String',
 
292
            'Description': _('Maximum number of instances in the group.')},
 
293
        'MinSize': {
 
294
            'Required': True,
 
295
            'Type': 'String',
 
296
            'Description': _('Minimum number of instances in the group.')},
 
297
        'Cooldown': {
 
298
            'Type': 'String',
 
299
            'Description': _('Cooldown period, in seconds.')},
 
300
        'DesiredCapacity': {
 
301
            'Type': 'Number',
 
302
            'Description': _('Desired initial number of instances.')},
 
303
        'HealthCheckGracePeriod': {
 
304
            'Type': 'Integer',
 
305
            'Implemented': False,
 
306
            'Description': _('Not Implemented.')},
 
307
        'HealthCheckType': {
 
308
            'Type': 'String',
 
309
            'AllowedValues': ['EC2', 'ELB'],
 
310
            'Implemented': False,
 
311
            'Description': _('Not Implemented.')},
 
312
        'LoadBalancerNames': {
 
313
            'Type': 'List',
 
314
            'Description': _('List of LoadBalancer resources.')},
 
315
        'VPCZoneIdentifier': {
 
316
            'Type': 'List',
 
317
            'Description': _('List of VPC subnet identifiers.')},
 
318
        'Tags': {
 
319
            'Type': 'List',
 
320
            'Schema': {'Type': 'Map', 'Schema': tags_schema},
 
321
            'Description': _('Tags to attach to this group.')}
291
322
    }
292
323
    rolling_update_schema = {
293
324
        'MinInstancesInService': properties.Schema(properties.NUMBER,
409
440
                            'Value': self.FnGetRefId()}]
410
441
        return super(AutoScalingGroup, self)._tags() + autoscaling_tag
411
442
 
412
 
    def FnGetRefId(self):
413
 
        return unicode(self.name)
414
 
 
415
443
    def validate(self):
416
444
        res = super(AutoScalingGroup, self).validate()
417
445
        if res:
433
461
                   'Value': {'Type': 'String',
434
462
                             'Required': True}}
435
463
    properties_schema = {
436
 
        'ImageId': {'Type': 'String',
437
 
                    'Required': True},
438
 
        'InstanceType': {'Type': 'String',
439
 
                         'Required': True},
440
 
        'KeyName': {'Type': 'String'},
441
 
        'UserData': {'Type': 'String'},
442
 
        'SecurityGroups': {'Type': 'List'},
443
 
        'KernelId': {'Type': 'String',
444
 
                     'Implemented': False},
445
 
        'RamDiskId': {'Type': 'String',
446
 
                      'Implemented': False},
447
 
        'BlockDeviceMappings': {'Type': 'String',
448
 
                                'Implemented': False},
449
 
        'NovaSchedulerHints': {'Type': 'List',
450
 
                               'Schema': {'Type': 'Map',
451
 
                                          'Schema': tags_schema}},
 
464
        'ImageId': {
 
465
            'Type': 'String',
 
466
            'Required': True,
 
467
            'Description': _('Glance image ID or name.')},
 
468
        'InstanceType': {
 
469
            'Type': 'String',
 
470
            'Required': True,
 
471
            'Description': _('Nova instance type (flavor).')},
 
472
        'KeyName': {
 
473
            'Type': 'String',
 
474
            'Description': _('Optional Nova keypair name.')},
 
475
        'UserData': {
 
476
            'Type': 'String',
 
477
            'Description': _('User data to pass to instance.')},
 
478
        'SecurityGroups': {
 
479
            'Type': 'List',
 
480
            'Description': _('Security group names to assign.')},
 
481
        'KernelId': {
 
482
            'Type': 'String',
 
483
            'Implemented': False,
 
484
            'Description': _('Not Implemented.')},
 
485
        'RamDiskId': {
 
486
            'Type': 'String',
 
487
            'Implemented': False,
 
488
            'Description': _('Not Implemented.')},
 
489
        'BlockDeviceMappings': {
 
490
            'Type': 'String',
 
491
            'Implemented': False,
 
492
            'Description': _('Not Implemented.')},
 
493
        'NovaSchedulerHints': {
 
494
            'Type': 'List',
 
495
            'Schema': {'Type': 'Map', 'Schema': tags_schema},
 
496
            'Description': _('Scheduler hints to pass '
 
497
                             'to Nova (Heat extension).')},
452
498
    }
453
499
 
454
500
    def FnGetRefId(self):
457
503
 
458
504
class ScalingPolicy(signal_responder.SignalResponder, CooldownMixin):
459
505
    properties_schema = {
460
 
        'AutoScalingGroupName': {'Type': 'String',
461
 
                                 'Required': True},
462
 
        'ScalingAdjustment': {'Type': 'Number',
463
 
                              'Required': True},
464
 
        'AdjustmentType': {'Type': 'String',
465
 
                           'AllowedValues': ['ChangeInCapacity',
466
 
                                             'ExactCapacity',
467
 
                                             'PercentChangeInCapacity'],
468
 
                           'Required': True},
469
 
        'Cooldown': {'Type': 'Number'},
 
506
        'AutoScalingGroupName': {
 
507
            'Type': 'String',
 
508
            'Required': True,
 
509
            'Description': _('AutoScaling group name to apply policy to.')},
 
510
        'ScalingAdjustment': {
 
511
            'Type': 'Number',
 
512
            'Required': True,
 
513
            'Description': _('Size of adjustment.')},
 
514
        'AdjustmentType': {
 
515
            'Type': 'String',
 
516
            'AllowedValues': ['ChangeInCapacity',
 
517
                              'ExactCapacity',
 
518
                              'PercentChangeInCapacity'],
 
519
            'Required': True,
 
520
            'Description': _('Type of adjustment (absolute or percentage).')},
 
521
        'Cooldown': {
 
522
            'Type': 'Number',
 
523
            'Description': _('Cooldown period, in seconds.')},
470
524
    }
471
525
 
472
526
    update_allowed_keys = ('Properties',)
473
527
    update_allowed_properties = ('ScalingAdjustment', 'AdjustmentType',
474
528
                                 'Cooldown',)
475
529
    attributes_schema = {
476
 
        "AlarmUrl": ("A signed url to handle the alarm. "
477
 
                     "(Heat extension)")
 
530
        "AlarmUrl": _("A signed url to handle the alarm. "
 
531
                      "(Heat extension).")
478
532
    }
479
533
 
480
534
    def handle_update(self, json_snippet, tmpl_diff, prop_diff):
512
566
                        (self.name, self.properties['Cooldown']))
513
567
            return
514
568
 
515
 
        group = self.stack[self.properties['AutoScalingGroupName']]
 
569
        asgn_id = self.properties['AutoScalingGroupName']
 
570
        group = self.stack.resource_by_refid(asgn_id)
516
571
 
517
572
        logger.info('%s Alarm, adjusting Group %s by %s' %
518
573
                    (self.name, group.name,