convert ugly camelcase methods to nice, clean underscores
This commit is contained in:
		
							parent
							
								
									f824110ceb
								
							
						
					
					
						commit
						0df2864f99
					
				| @ -1,6 +1,6 @@ | ||||
| from urlparse import parse_qs | ||||
| 
 | ||||
| from moto.ec2.utils import method_namess_from_class | ||||
| from moto.ec2.utils import camelcase_to_underscores, method_namess_from_class | ||||
| 
 | ||||
| from .instances import InstanceResponse | ||||
| from .tags import TagResponse | ||||
| @ -17,6 +17,7 @@ class EC2Response(object): | ||||
|             querystring = parse_qs(headers) | ||||
| 
 | ||||
|         action = querystring['Action'][0] | ||||
|         action = camelcase_to_underscores(action) | ||||
| 
 | ||||
|         for sub_response in self.sub_responses: | ||||
|             method_names = method_namess_from_class(sub_response) | ||||
|  | ||||
| @ -9,37 +9,37 @@ class InstanceResponse(object): | ||||
|         self.querystring = querystring | ||||
|         self.instance_ids = instance_ids_from_querystring(querystring) | ||||
| 
 | ||||
|     def DescribeInstances(self): | ||||
|     def describe_instances(self): | ||||
|         template = Template(EC2_DESCRIBE_INSTANCES) | ||||
|         return template.render(reservations=ec2_backend.all_reservations()) | ||||
| 
 | ||||
|     def RunInstances(self): | ||||
|     def run_instances(self): | ||||
|         min_count = int(self.querystring.get('MinCount', ['1'])[0]) | ||||
|         new_reservation = ec2_backend.add_instances(min_count) | ||||
|         template = Template(EC2_RUN_INSTANCES) | ||||
|         return template.render(reservation=new_reservation) | ||||
| 
 | ||||
|     def TerminateInstances(self): | ||||
|     def terminate_instances(self): | ||||
|         instances = ec2_backend.terminate_instances(self.instance_ids) | ||||
|         template = Template(EC2_TERMINATE_INSTANCES) | ||||
|         return template.render(instances=instances) | ||||
| 
 | ||||
|     def RebootInstances(self): | ||||
|     def reboot_instances(self): | ||||
|         instances = ec2_backend.reboot_instances(self.instance_ids) | ||||
|         template = Template(EC2_REBOOT_INSTANCES) | ||||
|         return template.render(instances=instances) | ||||
| 
 | ||||
|     def StopInstances(self): | ||||
|     def stop_instances(self): | ||||
|         instances = ec2_backend.stop_instances(self.instance_ids) | ||||
|         template = Template(EC2_STOP_INSTANCES) | ||||
|         return template.render(instances=instances) | ||||
| 
 | ||||
|     def StartInstances(self): | ||||
|     def start_instances(self): | ||||
|         instances = ec2_backend.start_instances(self.instance_ids) | ||||
|         template = Template(EC2_START_INSTANCES) | ||||
|         return template.render(instances=instances) | ||||
| 
 | ||||
|     def DescribeInstanceAttribute(self): | ||||
|     def describe_instance_attribute(self): | ||||
|         # TODO this and modify below should raise IncorrectInstanceState if instance not in stopped state | ||||
|         attribute = self.querystring.get("Attribute")[0] | ||||
|         normalized_attribute = camelcase_to_underscores(attribute) | ||||
| @ -49,7 +49,7 @@ class InstanceResponse(object): | ||||
|         template = Template(EC2_DESCRIBE_INSTANCE_ATTRIBUTE) | ||||
|         return template.render(instance=instance, attribute=attribute, value=value) | ||||
| 
 | ||||
|     def ModifyInstanceAttribute(self): | ||||
|     def modify_instance_attribute(self): | ||||
|         for key, value in self.querystring.iteritems(): | ||||
|             if '.Value' in key: | ||||
|                 break | ||||
|  | ||||
| @ -9,17 +9,17 @@ class TagResponse(object): | ||||
|         self.querystring = querystring | ||||
|         self.resource_ids = resource_ids_from_querystring(querystring) | ||||
| 
 | ||||
|     def CreateTags(self): | ||||
|     def create_tags(self): | ||||
|         for resource_id, tag in self.resource_ids.iteritems(): | ||||
|             ec2_backend.create_tag(resource_id, tag[0], tag[1]) | ||||
|         return CREATE_RESPONSE | ||||
| 
 | ||||
|     def DeleteTags(self): | ||||
|     def delete_tags(self): | ||||
|         ec2_backend.delete_tag() | ||||
|         template = Template(DELETE_RESPONSE) | ||||
|         return template.render(reservations=ec2_backend.all_reservations()) | ||||
| 
 | ||||
|     def DescribeTags(self): | ||||
|     def describe_tags(self): | ||||
|         tags = ec2_backend.describe_tags() | ||||
|         template = Template(DESCRIBE_RESPONSE) | ||||
|         return template.render(tags=tags) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user