diff --git a/moto/ec2/models.py b/moto/ec2/models.py index 368d27bb6..978f5cf80 100644 --- a/moto/ec2/models.py +++ b/moto/ec2/models.py @@ -16,30 +16,35 @@ from .utils import ( ) +class InstanceState(object): + def __init__(self, name='pending', code=0): + self.name = name + self.code = code + + class Instance(BotoInstance): def __init__(self, image_id, user_data): super(Instance, self).__init__() self.id = random_instance_id() self.image_id = image_id - self._state_name = "pending" - self._state_code = 0 + self._state = InstanceState() self.user_data = user_data def start(self): - self._state_name = "pending" - self._state_code = 0 + self._state.name = "pending" + self._state.code = 0 def stop(self): - self._state_name = "stopping" - self._state_code = 64 + self._state.name = "stopping" + self._state.code = 64 def terminate(self): - self._state_name = "shutting-down" - self._state_code = 32 + self._state.name = "shutting-down" + self._state.code = 32 def reboot(self): - self._state_name = "pending" - self._state_code = 0 + self._state.name = "pending" + self._state.code = 0 class InstanceBackend(object): diff --git a/moto/ec2/responses/instances.py b/moto/ec2/responses/instances.py index d0f044e50..ef7f53fb8 100644 --- a/moto/ec2/responses/instances.py +++ b/moto/ec2/responses/instances.py @@ -86,8 +86,8 @@ EC2_RUN_INSTANCES = """