コード例 #1
0
    def fetch_all_groups(self):
        """
        Fetch all the Auto-Scaling Groups

        :rtype: dict
        :return: JSON object for all the Auto-Scaling Groups
        """
        endpoint = {'endpoint': self.endpoint}
        cmd = "DescribeAutoScalingGroups"
        return operate(self.service, cmd, endpoint)
コード例 #2
0
    def modify_group(self, group_config):
        """
        Modify the Auto-Scaling Group

        :type group_config: dict
        :param group_config: auto-scaling group configuration
        """
        group_name = group_config['AutoScalingGroupName']

        endpoint = {'endpoint': self.endpoint}
        cmd = "UpdateAutoScalingGroup"
        params = fetch_used_params(self.name, cmd, group_config)
        params.update(endpoint)
        try:
            self.handle_response(operate(self.service, cmd, params))
        except Exception, e:
            raise IcsASException(e)
コード例 #3
0
    def create_launch_config(self, launch_config):
        """
        Create a new Launch Configuration

        :type launch_config: dict
        :param launch_config: launch configuration
        """
        endpoint = {'endpoint': self.endpoint}
        params = keyname_formatd(launch_config)
        params.update(endpoint)
        cmd = "CreateLaunchConfiguration"
        log.info("create the launch configuration")
        log.info(">> %s" % launch_config['LaunchConfigurationName'])
        try:
            self.handle_response(operate(self.service, cmd, params))
        except Exception, e:
            raise IcsASException(e)
コード例 #4
0
    def create_group(self, group_config):
        """
        Create a new Auto-Scaling Group

        :type group_config: dict
        :param group_config: auto-scaling group configuration
        """
        endpoint = {'endpoint': self.endpoint}
        params = keyname_formatd(group_config)
        params.update(endpoint)
        cmd = "CreateAutoScalingGroup"
        log.info("create the auto-scaling group")
        log.info(">> %s" % group_config['AutoScalingGroupName'])
        try:
            self.handle_response(operate(self.service, cmd, params))
        except Exception, e:
            raise IcsASException(e)
コード例 #5
0
    def delete_launch_config(self, name):
        """
        Delete an existing Launch Configuration

        :type name: string
        :param name: launch configuration name
        """
        endpoint = {'endpoint': self.endpoint}
        cmd = "DeleteLaunchConfiguration"
        key = 'LaunchConfigurationName'
        params = {key: name}
        params = keyname_formatd(params)
        params.update(endpoint)
        log.info("delete the launch configuration")
        log.info(">> %s" % name)
        try:
            self.handle_response(operate(self.service, cmd, params))
        except Exception, e:
            raise IcsASException(e)
コード例 #6
0
    def fetch_launch_config(self, name):
        """
        Fetch an existing Launch Configuration

        :type name: string
        :param name: launch configuration name
        """
        endpoint = {'endpoint': self.endpoint}
        cmd = "DescribeLaunchConfigurations"
        key = 'LaunchConfigurationNames'
        params = {key: [name]}
        params = keyname_formatd(params)
        params.update(endpoint)
        log.info("find the launch configuration")
        log.info(">> %s" % name)
        try:
            response = operate(self.service, cmd, params)
        except Exception, e:
            raise IcsASException(e)
コード例 #7
0
    def fetch_group(self, name):
        """
        Fetch an existing Auto-Scaling Group

        :type name: string
        :param name: auto-scaling group name
        """
        endpoint = {'endpoint': self.endpoint}
        cmd = "DescribeAutoScalingGroups"
        key = 'AutoScalingGroupNames'
        params = {key: [name]}
        params = keyname_formatd(params)
        params.update(endpoint)
        log.info("find the auto-scaling group")
        log.info(">> %s" % name)
        try:
            response = operate(self.service, cmd, params)
        except Exception, e:
            raise IcsASException(e)
コード例 #8
0
    def delete_group(self, name):
        """
        Delete an existing Auto-Scaling Group

        :type name: string
        :param name: auto-scaling group name
        """
        endpoint = {'endpoint': self.endpoint}
        cmd = "DeleteAutoScalingGroup"
        key = 'AutoScalingGroupName'
        params = {key: name}
        params['ForceDelete'] = True
        params = keyname_formatd(params)
        params.update(endpoint)
        log.info("delete the auto-scaling group")
        log.info(">> %s" % name)
        try:
            self.handle_response(operate(self.service, cmd, params))
        except Exception, e:
            raise IcsASException(e)
コード例 #9
0
    def delete_scaling_policy(self, scaling_policy, metric_alarm):
        """
        Delete an existing Scaling Policy

        :type scaling_policy: dict
        :param scaling_policy: scaling policy configuration

        :type metric_alarm: dict
        :param metric_alarm: metric alarm configuration
        """
        result = 0
        endpoint = {'endpoint': self.endpoint}
        cmd = "DeletePolicy"
        params = fetch_used_params(self.name, cmd, scaling_policy)
        params.update(endpoint)
        log.info("delete the scaling policy")
        log.info(">> %s" % scaling_policy["PolicyName"])
        try:
            self.handle_response(operate(self.service, cmd, params))
        except Exception, e:
            log.error(e)
コード例 #10
0
            raise IcsASException(e)
        log.info("OK")

        if "Tags" in group_config:
            log.info("update the tags of this auto-scaling group")
            log.info(">> %s" % group_name)
            cmd = "CreateOrUpdateTags"
            params = {"Tags": group_config["Tags"]}

            for tag in params["Tags"]:
                tag["ResourceType"] = "auto-scaling-group"

            params = fetch_used_params(self.name, cmd, params)
            params.update(endpoint)
            try:
                self.handle_response(operate(self.service, cmd, params))
            except Exception, e:
                raise IcsASException(e)
            log.info("OK")

    def update_group(self, group_config, launch_config):
        """
        Update the Auto-Scaling Group

        :type group_config: dict
        :param group_config: auto-scaling group configuration

        :type launch_config: dict
        :param launch_config: launch configuration
        """
        group_name = group_config['AutoScalingGroupName']