diff --git a/moto/ec2/models.py b/moto/ec2/models.py index 1bcdbe5d..ccde643e 100644 --- a/moto/ec2/models.py +++ b/moto/ec2/models.py @@ -29,24 +29,24 @@ class Instance(BotoInstance): super(Instance, self).__init__() self.id = random_instance_id() self.image_id = image_id - self._state = InstanceState() + self._state = InstanceState("running", 16) self.user_data = user_data def start(self): - self._state.name = "pending" - self._state.code = 0 + self._state.name = "running" + self._state.code = 16 def stop(self): - self._state.name = "stopping" - self._state.code = 64 + self._state.name = "stopped" + self._state.code = 80 def terminate(self): - self._state.name = "shutting-down" - self._state.code = 32 + self._state.name = "terminated" + self._state.code = 48 def reboot(self): - self._state.name = "pending" - self._state.code = 0 + self._state.name = "running" + self._state.code = 16 def get_tags(self): tags = ec2_backend.describe_tags(self.id) diff --git a/moto/ec2/responses/amis.py b/moto/ec2/responses/amis.py index b95fbfab..b6e85638 100644 --- a/moto/ec2/responses/amis.py +++ b/moto/ec2/responses/amis.py @@ -7,7 +7,10 @@ from moto.ec2.utils import instance_ids_from_querystring class AmisResponse(object): def create_image(self): name = self.querystring.get('Name')[0] - description = self.querystring.get('Description')[0] + if "Description" in self.querystring: + description = self.querystring.get('Description')[0] + else: + description = "" instance_ids = instance_ids_from_querystring(self.querystring) instance_id = instance_ids[0] image = ec2_backend.create_image(instance_id, name, description) diff --git a/moto/ec2/responses/instances.py b/moto/ec2/responses/instances.py index 68be9daf..f230dcf4 100644 --- a/moto/ec2/responses/instances.py +++ b/moto/ec2/responses/instances.py @@ -95,8 +95,8 @@ EC2_RUN_INSTANCES = """