in footmark/ess/connection.py [0:0]
def create_configuration(self, scaling_group_id, image_id, instance_type, security_group_id, name=None,
internet_charge_type=None, max_bandwidth_in=None, max_bandwidth_out=None,
system_disk_category='cloud_efficiency', system_disk_size=40, data_disks=None,
tags=None, key_pair_name=None, ram_role_name=None, user_data=None):
"""
create an scaling configuration in ess
:type str
:param scaling_group_id: ID of the scaling group of a scaling configuration.
:type str
:param image_id: ID of an ECS instance image, indicating an image selected
:type str
:param instance_type: Resource type of an ECS instance.
:type str
:param security_group_id: ID of the security group to which a newly created instance belongs.
:type str
:param name: Name shown for the scheduled task.
The name must contain 2-40 English or Chinese characters, and start with a number,
a letter in upper or lower case or a Chinese character.
The name can contain numbers, “_“, “-“ or “.”.
The account name in the same scaling group is unique in the same region.
If this parameter value is not specified, the default value is ScalingConfigurationId.
:type str
:param internet_charge_type: Network billing type, Values: PayByBandwidth or PayByTraffic. Default to PayByBandwidth.
:type str
:param max_bandwidth_out: Maximum outgoing bandwidth from the public network, measured in Mbps (Mega bit per second). Default to 0.
:type str
:param max_bandwidth_in: Maximum incoming bandwidth from the public network, measured in Mbps (Mega bit per second). Default to 200.
:type str
:param system_disk_category: Category of the system disk. Values: cloud_efficiency or cloud_ssd. Default to cloud_efficiency.
:type int
:param system_disk_size: Size of the system disk. Values: 40~500. Default to 40.
:type list
:param data_disks: A list of hash/dictionaries of data disks. A maximum of four values can be entered.
'[{size:"value", category:"value", snapshot_id:"value", delete_with_instance:"value"}]',
size: Size of data disk. Values: 20 ~ 32768.
category: Category of the data disk. Values: cloud_efficiency or cloud_ssd. Default to cloud_efficiency.
snapshot_id: Snapshot used for creating the data disk. If it is specified, the size parameter is neglected, and the size of the created disk is the size of the snapshot.
delete_with_instance: Whether the data disk will be released along with the instance. Default to true.
:type list
:param tags: A list of hash/dictionaries of instance
tags, '[{tag_key:"value", tag_value:"value"}]', tag_key
must be not null when tag_value isn't null
:type str
:param key_pair_name: Key pair name.
:type str
:param ram_role_name: The name of the instance RAM role.
:type str
:param user_data: The user-defined data of the instance.
:rtype: object
:return: Returns a <footmark.ess.Configuration> object.
"""
params = {}
self.build_list_params(params, scaling_group_id, 'ScalingGroupId')
self.build_list_params(params, image_id, 'ImageId')
self.build_list_params(params, instance_type, 'InstanceType')
self.build_list_params(params, security_group_id, 'SecurityGroupId')
if name:
self.build_list_params(params, name, 'ScalingConfigurationName')
if internet_charge_type:
self.build_list_params(params, internet_charge_type, 'InternetChargeType')
if max_bandwidth_in:
self.build_list_params(params, max_bandwidth_in, 'InternetMaxBandwidthIn')
if max_bandwidth_out:
self.build_list_params(params, max_bandwidth_out, 'InternetMaxBandwidthOut')
if system_disk_category:
self.build_list_params(params, system_disk_category, 'SystemDisk.Category')
if system_disk_size:
self.build_list_params(params, system_disk_size, 'SystemDisk.Size')
# Disks Details
if data_disks:
for i in range(len(data_disks)):
if i > 3:
break
disk = data_disks[i]
if disk:
if 'size' in disk:
self.build_list_params(params, disk['size'], 'DataDisk' + bytes(i+1) + 'Size')
if 'category' in disk:
self.build_list_params(params, disk['category'], 'DataDisk' + bytes(i+1) + 'Category')
if 'snapshot_id' in disk:
self.build_list_params(params, disk['snapshot_id'], 'DataDisk' + bytes(i+1) + 'SnapshotId')
if 'delete_with_instance' in disk:
self.build_list_params(params, disk['delete_with_instance'],
'DataDisk' + bytes(i+1) + 'DeleteWithInstance')
self.build_tags_params(params, tags, max_tag_number=5)
if key_pair_name:
self.build_list_params(params, key_pair_name, 'KeyPairName')
if user_data:
self.build_list_params(params, base64.b64encode(user_data), 'UserData')
if ram_role_name:
self.build_list_params(params, ram_role_name, 'RamRoleName')
instances = []
result = self.get_object('CreateScalingConfiguration', params, ResultSet)
return self.describe_configurations(scaling_group_id=scaling_group_id, scaling_configuration_ids=[result.scaling_configuration_id])[0]