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 create_autoscale_group(self, user_obj, asg): log( logging.DEBUG, "entering create_autoscale_group with %s" % (asg.LaunchConfigurationName)) (definition_name, domain_opts) = tags_to_definition(asg.Tags.type_list) domain_opts['minimum_vms'] = asg.DesiredCapacity dt_name = asg.LaunchConfigurationName site_name = "" if dt_name.find('@') > 0: (dt_name, site_name) = _breakup_name(asg.LaunchConfigurationName) if definition_name == 'sensor_engine': domain_opts['deployable_type'] = dt_name domain_opts['dtname'] = dt_name domain_opts['iaas_site'] = site_name domain_opts['iaas_allocation'] = "m1.small" domain_opts['minimum_vms'] = asg.MinSize domain_opts['maximum_vms'] = asg.MaxSize domain_opts['opentsdb_host'] = self._opentsdb_host domain_opts['opentsdb_port'] = self._opentsdb_port else: domain_opts['dtname'] = dt_name domain_opts['minimum_vms'] = asg.MinSize domain_opts['maximum_vms'] = asg.MaxSize domain_opts['opentsdb_host'] = self._opentsdb_host domain_opts['opentsdb_port'] = self._opentsdb_port #domain_opts['force_site'] = site_name domain_opts['CreatedTime'] = make_time(asg.CreatedTime.date_time) domain_opts['AutoScalingGroupARN'] = asg.AutoScalingGroupARN domain_opts['VPCZoneIdentifier'] = asg.VPCZoneIdentifier domain_opts['HealthCheckType'] = asg.HealthCheckType domain_opts['PlacementGroup'] = asg.PlacementGroup conf = {'engine_conf': domain_opts} log(logging.INFO, "Creating autoscale group with %s" % (conf)) try: self._epum_client.add_domain(asg.AutoScalingGroupName, definition_name, conf, caller=user_obj.access_id) except DashiError, de: if de.exc_type == u'WriteConflictError': raise PhantomAWSException( 'InvalidParameterValue', details="auto scale name already exists") log(logging.ERROR, "An error creating ASG: %s" % (str(de))) raise
def create_autoscale_group(self, user_obj, asg): log(logging.DEBUG, "entering create_autoscale_group with %s" % (asg.LaunchConfigurationName)) (definition_name, domain_opts) = tags_to_definition(asg.Tags.type_list) domain_opts['minimum_vms'] = asg.DesiredCapacity dt_name = asg.LaunchConfigurationName site_name = "" if dt_name.find('@') > 0: (dt_name, site_name) = _breakup_name(asg.LaunchConfigurationName) if definition_name == 'sensor_engine': domain_opts['deployable_type'] = dt_name domain_opts['dtname'] = dt_name domain_opts['iaas_site'] = site_name domain_opts['iaas_allocation'] = "m1.small" domain_opts['minimum_vms'] = asg.MinSize domain_opts['maximum_vms'] = asg.MaxSize domain_opts['opentsdb_host'] = self._opentsdb_host domain_opts['opentsdb_port'] = self._opentsdb_port else: domain_opts['dtname'] = dt_name domain_opts['minimum_vms'] = asg.MinSize domain_opts['maximum_vms'] = asg.MaxSize domain_opts['opentsdb_host'] = self._opentsdb_host domain_opts['opentsdb_port'] = self._opentsdb_port #domain_opts['force_site'] = site_name domain_opts['CreatedTime'] = make_time(asg.CreatedTime.date_time) domain_opts['AutoScalingGroupARN'] = asg.AutoScalingGroupARN domain_opts['VPCZoneIdentifier'] = asg.VPCZoneIdentifier domain_opts['HealthCheckType'] = asg.HealthCheckType domain_opts['PlacementGroup'] = asg.PlacementGroup conf = {'engine_conf': domain_opts} log(logging.INFO, "Creating autoscale group with %s" % (conf)) try: self._epum_client.add_domain(asg.AutoScalingGroupName, definition_name, conf, caller=user_obj.access_id) except DashiError, de: if de.exc_type == u'WriteConflictError': raise PhantomAWSException('InvalidParameterValue', details="auto scale name already exists") log(logging.ERROR, "An error creating ASG: %s" % (str(de))) raise