From 76ea9172da56816ed6faa9bad6babc18fc060f3a Mon Sep 17 00:00:00 2001 From: Steve Pulec Date: Mon, 8 Jul 2013 20:29:13 -0400 Subject: [PATCH] Clean up ec2 instance state --- moto/ec2/models.py | 25 +++++++++++++++---------- moto/ec2/responses/instances.py | 20 ++++++++++---------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/moto/ec2/models.py b/moto/ec2/models.py index 368d27bb..978f5cf8 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 d0f044e5..ef7f53fb 100644 --- a/moto/ec2/responses/instances.py +++ b/moto/ec2/responses/instances.py @@ -86,8 +86,8 @@ EC2_RUN_INSTANCES = """