def create_group()

in footmark/ess/connection.py [0:0]


    def create_group(self, max_size, min_size, name=None, default_cooldown=None, removal_policies=None,
                     load_balancer_ids=None, db_instance_ids=None, vswitch_ids=None):
        """
        A scaling group is a collection of ECS instances with the same application scenarios.
        It defines the maximum and minimum numbers of ECS instances in the group, 
        and their associated Server Load Balancer instances, RDS instances, and other attributes.

        :type int
        :param max_size: Maximum number of ECS instances in the scaling group. Value range: [0, 100].
        :type int
        :param min_size: Minimum number of ECS instances in the scaling group. Value range: [0, 100].
        :type str
        :param name: Name shown for the scaling group, which must contain 2-40 characters (English or Chinese).
            The name must begin with a number, an upper/lower-case letter or a Chinese character and may contain numbers, “_“, “-“ or “.”. 
            The account name is unique in the same region.
            If this parameter is not specified, the default value is its ID.
        :type int
        :param default_cooldown: Default cool-down time (in seconds) of the scaling group. Value range: [0, 86400]. Default to is 300.
        :type list
        :param removal_policies: Policy for removing ECS instances from the scaling group.
            Optional values:
                OldestInstance: removes the first ECS instance attached to the scaling group.
                NewestInstance: removes the first ECS instance attached to the scaling group.
                OldestScalingConfiguration: removes the ECS instance with the oldest scaling configuration.
            Default values: OldestScalingConfiguration and OldestInstance.
            At most 2 policies can be entered.
        :type list
        :param load_balancer_ids: ID list of a Server Load Balancer instance.
        :type list
        :param db_instance_ids: ID list of an RDS instance.
        :type list
        :param vswitch_ids: ID list of a VSwitch. It is used to create instance in multiple zones.
            At most 5 VSwitches in a VPC can be specified.
            The priority of VSwitches descends from 1 to 5, and 1 indicates the highest priority.
            When you fail to create an instance in the zone to which a specified VSwitch belongs, 
            another VSwitch with less priority replaces the specified one automatically. 
        
        :rtype: object
        :return: Returns a <footmark.ess.Group> object.

        """

        params = {}

        self.build_list_params(params, max_size, 'MaxSize')
        if min_size > max_size:
            self.build_list_params(params, max_size, 'MinSize')
        else:
            self.build_list_params(params, min_size, 'MinSize')

        if name:
            self.build_list_params(params, name, 'ScalingGroupName')
        if default_cooldown:
            self.build_list_params(params, default_cooldown, 'DefaultCooldown')
        if removal_policies:
            for i in range(len(removal_policies)):
                if i < 2 and removal_policies[i]:
                    self.build_list_params(params, removal_policies[i], 'RemovalPolicy' + bytes(i + 1));
        if load_balancer_ids:
            self.build_list_params(params, json.dumps(load_balancer_ids), 'LoadBalancerIds')

        if db_instance_ids:
            self.build_list_params(params, json.dumps(db_instance_ids), 'DBInstanceIds')

        if vswitch_ids:
            self.build_list_params(params, vswitch_ids, 'VSwitchIds')

        result = self.get_object('CreateScalingGroup', params, ResultSet)
        return self.describe_groups(scaling_group_ids=[result.scaling_group_id])[0]