def __call__(self, req): user_obj = self.get_user_obj(req) log_request(req, user_obj) input = DescribeAutoScalingGroupInput() input.set_from_dict(req.params) names = None if input.AutoScalingGroupNames: names = input.AutoScalingGroupNames (ags_list, next_token) = self._system.get_autoscale_groups(user_obj, names=names, max=input.MaxRecords, startToken=input.NextToken) res = self.get_response() doc = self.get_default_response_body_dom(doc_name="DescribeAutoScalingGroupsResponse") dlcr_el = doc.createElement('DescribeAutoScalingGroupsResult') doc.documentElement.appendChild(dlcr_el) lc_el = doc.createElement('AutoScalingGroups') dlcr_el.appendChild(lc_el) if next_token: nt_el = doc.createElement('NextToken') doc.documentElement.appendChild(nt_el) text_element = doc.createTextNode(next_token) nt_el.appendChild(text_element) ags_list.add_xml(doc, lc_el) res.unicode_body = doc.documentElement.toxml() log_reply(doc, user_obj) return res
def __call__(self, req): user_obj = self.get_user_obj(req) log_request(req, user_obj) input = DescribeAutoScalingInstancesInput() input.set_from_dict(req.params) ids = None if input.InstanceIds: ids = input.InstanceIds (inst_list, next_token) = self._system.get_autoscale_instances(user_obj, instance_id_list=ids, max=input.MaxRecords, startToken=input.NextToken) res = self.get_response() doc = self.get_default_response_body_dom() lc_el = doc.createElement('AutoScalingInstances') doc.documentElement.appendChild(lc_el) if next_token: nt_el = doc.createElement('NextToken') doc.documentElement.appendChild(nt_el) text_element = doc.createTextNode(next_token) nt_el.appendChild(text_element) inst_list.add_xml(doc, lc_el) res.unicode_body = doc.documentElement.toxml() log_reply(doc, user_obj) return res
def __call__(self, req): user_obj = self.get_user_obj(req) log_request(req, user_obj) input = SetDesiredCapacityInput() input.set_from_dict(req.params) force = False if input.HonorCooldown: force = True new_conf = {'desired_capacity': input.DesiredCapacity} self._system.alter_autoscale_group(user_obj, input.AutoScalingGroupName, new_conf, force) res = self.get_response() doc = self.get_default_response_body_dom( doc_name="SetDesiredCapacityResponse") res.unicode_body = doc.documentElement.toprettyxml() log( logging.INFO, "User %s change %s capacity to %d" % (user_obj.access_id, input.AutoScalingGroupName, input.DesiredCapacity)) log_reply(doc, user_obj) return res
def __call__(self, req): user_obj = self.get_user_obj(req) log_request(req, user_obj) input = CreateOrUpdateTagsInput() input.set_from_dict(req.params) # first we need to organize the tags by group association tag_groups = {} for tag in input.Tags: if tag.ResourceId not in tag_groups: tag_groups[tag.ResourceId] = [] l = tag_groups[tag.ResourceId] l.append(tag) for group_name in tag_groups: log(logging.INFO, "Processing tags for the group %s" % (group_name)) tags = tag_groups[group_name] (name, new_conf) = tags_to_definition(tags) self._system.alter_autoscale_group(user_obj, group_name, new_conf, force=True) res = self.get_response() doc = self.get_default_response_body_dom(doc_name="CreateOrUpdateTagsResponse") res.unicode_body = doc.documentElement.toprettyxml() log_reply(doc, user_obj) return res
def __call__(self, req): user_obj = self.get_user_obj(req) log_request(req, user_obj) input = CreateOrUpdateTagsInput() input.set_from_dict(req.params) # first we need to organize the tags by group association tag_groups = {} for tag in input.Tags: if tag.ResourceId not in tag_groups: tag_groups[tag.ResourceId] = [] l = tag_groups[tag.ResourceId] l.append(tag) for group_name in tag_groups: log(logging.INFO, "Processing tags for the group %s" % (group_name)) tags = tag_groups[group_name] (name, new_conf) = tags_to_definition(tags) self._system.alter_autoscale_group(user_obj, group_name, new_conf, force=True) res = self.get_response() doc = self.get_default_response_body_dom( doc_name="CreateOrUpdateTagsResponse") res.unicode_body = doc.documentElement.toprettyxml() log_reply(doc, user_obj) return res
def __call__(self, req): user_obj = self.get_user_obj(req) log_request(req, user_obj) input = DescribeAutoScalingInstancesInput() input.set_from_dict(req.params) ids = None if input.InstanceIds: ids = input.InstanceIds (inst_list, next_token) = self._system.get_autoscale_instances( user_obj, instance_id_list=ids, max=input.MaxRecords, startToken=input.NextToken) res = self.get_response() doc = self.get_default_response_body_dom() lc_el = doc.createElement('AutoScalingInstances') doc.documentElement.appendChild(lc_el) if next_token: nt_el = doc.createElement('NextToken') doc.documentElement.appendChild(nt_el) text_element = doc.createTextNode(next_token) nt_el.appendChild(text_element) inst_list.add_xml(doc, lc_el) res.unicode_body = doc.documentElement.toxml() log_reply(doc, user_obj) return res
def __call__(self, req): user_obj = self.get_user_obj(req) log_request(req, user_obj) input = DescribeLaunchConfigurationsInput() input.set_from_dict(req.params) names = None if input.LaunchConfigurationNames: names = input.LaunchConfigurationNames (lc_list, next_token) = self._system.get_launch_configs(user_obj, names=names, max=input.MaxRecords, startToken=input.NextToken) res = self.get_response() doc = self.get_default_response_body_dom(doc_name='DescribeLaunchConfigurationsResponse') dlcr_el = doc.createElement('DescribeLaunchConfigurationsResult') doc.documentElement.appendChild(dlcr_el) lc_el = doc.createElement('LaunchConfigurations') dlcr_el.appendChild(lc_el) if next_token: nt_el = doc.createElement('NextToken') doc.documentElement.appendChild(nt_el) text_element = doc.createTextNode(next_token) nt_el.appendChild(text_element) lc_list.add_xml(doc, lc_el) res.unicode_body = doc.documentElement.toxml() log_reply(doc, user_obj) return res
def __call__(self, req): user_obj = self.get_user_obj(req) log_request(req, user_obj) input = DeleteLaunchConfigurationInput() input.set_from_dict(req.params) self._system.delete_launch_config(user_obj, input.LaunchConfigurationName) res = self.get_response() doc = self.get_default_response_body_dom(doc_name="DeleteLaunchConfigurationResponse") res.unicode_body = doc.documentElement.toprettyxml() log_reply(doc, user_obj) return res
def __call__(self, req): user_obj = self.get_user_obj(req) log_request(req, user_obj) input = DeleteLaunchConfigurationInput() input.set_from_dict(req.params) self._system.delete_launch_config(user_obj, input.LaunchConfigurationName) res = self.get_response() doc = self.get_default_response_body_dom( doc_name="DeleteLaunchConfigurationResponse") res.unicode_body = doc.documentElement.toprettyxml() log_reply(doc, user_obj) return res
def __call__(self, req): user_obj = self.get_user_obj(req) log_request(req, user_obj) input = TerminateInstanceInAutoScalingGroupInput() input.set_from_dict(req.params) self._system.terminate_instances(user_obj, input.InstanceId, input.ShouldDecrementDesiredCapacity) ############ MUST return an activity type. res = self.get_response() doc = self.get_default_response_body_dom(doc_name="TerminateInstanceInAutoScalingGroupResponse") res.unicode_body = doc.documentElement.toprettyxml() log_reply(doc, user_obj) return res
def __call__(self, req): user_obj = self.get_user_obj(req) log_request(req, user_obj) input = LaunchConfigurationInput() input.set_from_dict(req.params) lc = LaunchConfigurationType('LaunchConfiguration') lc.set_from_intype(input, make_arn(input.LaunchConfigurationName, self.xamznRequestId, 'launchConfigurationName')) self._system.create_launch_config(user_obj, lc) res = self.get_response() doc = self.get_default_response_body_dom(doc_name="CreateLaunchConfigurationResponse") res.unicode_body = doc.documentElement.toprettyxml() log_reply(doc, user_obj) return res
def __call__(self, req): user_obj = self.get_user_obj(req) log_request(req, user_obj) input = DeleteAutoScalingGroupInput() input.set_from_dict(req.params) forceit = False if input.ForceDelete: forceit = True self._system.delete_autoscale_group(user_obj, input.AutoScalingGroupName, forceit) res = self.get_response() doc = self.get_default_response_body_dom(doc_name="DeleteAutoScalingGroupResponse") res.unicode_body = doc.documentElement.toprettyxml() log_reply(doc, user_obj) return res
def __call__(self, req): user_obj = self.get_user_obj(req) log_request(req, user_obj) input = TerminateInstanceInAutoScalingGroupInput() input.set_from_dict(req.params) self._system.terminate_instances(user_obj, input.InstanceId, input.ShouldDecrementDesiredCapacity) ############ MUST return an activity type. res = self.get_response() doc = self.get_default_response_body_dom( doc_name="TerminateInstanceInAutoScalingGroupResponse") res.unicode_body = doc.documentElement.toprettyxml() log_reply(doc, user_obj) return res
def __call__(self, req): user_obj = self.get_user_obj(req) log_request(req, user_obj) input = CreateAutoScalingGroupInput() input.set_from_dict(req.params) arn = make_arn(input.AutoScalingGroupName, self.xamznRequestId, 'autoScalingGroupName') asg = AutoScalingGroupType('AutoScalingGroup') asg.set_from_intype(input, arn) self._system.create_autoscale_group(user_obj, asg) res = self.get_response() doc = self.get_default_response_body_dom(doc_name="CreateAutoScalingGroupResponse") res.unicode_body = doc.documentElement.toprettyxml() log_reply(doc, user_obj) return res
def __call__(self, req): user_obj = self.get_user_obj(req) log_request(req, user_obj) input = LaunchConfigurationInput() input.set_from_dict(req.params) lc = LaunchConfigurationType('LaunchConfiguration') lc.set_from_intype( input, make_arn(input.LaunchConfigurationName, self.xamznRequestId, 'launchConfigurationName')) self._system.create_launch_config(user_obj, lc) res = self.get_response() doc = self.get_default_response_body_dom( doc_name="CreateLaunchConfigurationResponse") res.unicode_body = doc.documentElement.toprettyxml() log_reply(doc, user_obj) return res
def __call__(self, req): user_obj = self.get_user_obj(req) log_request(req, user_obj) input = DeleteAutoScalingGroupInput() input.set_from_dict(req.params) forceit = False if input.ForceDelete: forceit = True self._system.delete_autoscale_group(user_obj, input.AutoScalingGroupName, forceit) res = self.get_response() doc = self.get_default_response_body_dom( doc_name="DeleteAutoScalingGroupResponse") res.unicode_body = doc.documentElement.toprettyxml() log_reply(doc, user_obj) return res
def __call__(self, req): user_obj = self.get_user_obj(req) log_request(req, user_obj) input = CreateAutoScalingGroupInput() input.set_from_dict(req.params) arn = make_arn(input.AutoScalingGroupName, self.xamznRequestId, 'autoScalingGroupName') asg = AutoScalingGroupType('AutoScalingGroup') asg.set_from_intype(input, arn) self._system.create_autoscale_group(user_obj, asg) res = self.get_response() doc = self.get_default_response_body_dom( doc_name="CreateAutoScalingGroupResponse") res.unicode_body = doc.documentElement.toprettyxml() log_reply(doc, user_obj) return res
def __call__(self, req): user_obj = self.get_user_obj(req) log_request(req, user_obj) input = SetDesiredCapacityInput() input.set_from_dict(req.params) force = False if input.HonorCooldown: force = True new_conf = {'desired_capacity': input.DesiredCapacity} self._system.alter_autoscale_group(user_obj, input.AutoScalingGroupName, new_conf, force) res = self.get_response() doc = self.get_default_response_body_dom(doc_name="SetDesiredCapacityResponse") res.unicode_body = doc.documentElement.toprettyxml() log(logging.INFO, "User %s change %s capacity to %d" % (user_obj.access_id, input.AutoScalingGroupName, input.DesiredCapacity)) log_reply(doc, user_obj) return res
def __call__(self, req): user_obj = self.get_user_obj(req) log_request(req, user_obj) input = DescribeLaunchConfigurationsInput() input.set_from_dict(req.params) names = None if input.LaunchConfigurationNames: names = input.LaunchConfigurationNames (lc_list, next_token) = self._system.get_launch_configs( user_obj, names=names, max=input.MaxRecords, startToken=input.NextToken) res = self.get_response() doc = self.get_default_response_body_dom( doc_name='DescribeLaunchConfigurationsResponse') dlcr_el = doc.createElement('DescribeLaunchConfigurationsResult') doc.documentElement.appendChild(dlcr_el) lc_el = doc.createElement('LaunchConfigurations') dlcr_el.appendChild(lc_el) if next_token: nt_el = doc.createElement('NextToken') doc.documentElement.appendChild(nt_el) text_element = doc.createTextNode(next_token) nt_el.appendChild(text_element) lc_list.add_xml(doc, lc_el) res.unicode_body = doc.documentElement.toxml() log_reply(doc, user_obj) return res
def __call__(self, req): user_obj = self.get_user_obj(req) log_request(req, user_obj) input = DescribeAutoScalingGroupInput() input.set_from_dict(req.params) names = None if input.AutoScalingGroupNames: names = input.AutoScalingGroupNames (ags_list, next_token) = self._system.get_autoscale_groups( user_obj, names=names, max=input.MaxRecords, startToken=input.NextToken) res = self.get_response() doc = self.get_default_response_body_dom( doc_name="DescribeAutoScalingGroupsResponse") dlcr_el = doc.createElement('DescribeAutoScalingGroupsResult') doc.documentElement.appendChild(dlcr_el) lc_el = doc.createElement('AutoScalingGroups') dlcr_el.appendChild(lc_el) if next_token: nt_el = doc.createElement('NextToken') doc.documentElement.appendChild(nt_el) text_element = doc.createTextNode(next_token) nt_el.appendChild(text_element) ags_list.add_xml(doc, lc_el) res.unicode_body = doc.documentElement.toxml() log_reply(doc, user_obj) return res