Beispiel #1
0
 def get_instance(self, region, uuid, get_metadata=False):
     results = self._do_query(region, GET_INSTANCE_QUERY % uuid)['result']
     if len(results) > 0:
         metadata = None
         if get_metadata:
             metadata = self._get_instance_meta(region, uuid)
         return self._to_reconciler_instance(results[0], metadata=metadata)
     else:
         msg = "Couldn't find instance (%s) using JSON Bridge in region (%s)"
         raise exceptions.NotFound(msg % (uuid, region))
Beispiel #2
0
 def test_failed_validation_region_not_found(self):
     beginning_d = utils.decimal_utc()
     exists = self.mox.CreateMockAnything()
     exists.instance = INSTANCE_ID_1
     launched_at = beginning_d - (60 * 60)
     exists.launched_at = launched_at
     exists.instance_flavor_id = INSTANCE_FLAVOR_ID_1
     exists.deleted_at = None
     exists.deployment().AndReturn(None)
     ex = exceptions.NotFound()
     self.mox.ReplayAll()
     result = self.reconciler.failed_validation(exists)
     self.assertFalse(result)
     self.mox.VerifyAll()
Beispiel #3
0
 def test_failed_validation_not_found(self):
     beginning_d = utils.decimal_utc()
     exists = self.mox.CreateMockAnything()
     exists.instance = INSTANCE_ID_1
     launched_at = beginning_d - (60 * 60)
     exists.launched_at = launched_at
     exists.instance_flavor_id = INSTANCE_FLAVOR_ID_1
     exists.deleted_at = None
     deployment = self.mox.CreateMockAnything()
     exists.deployment().AndReturn(deployment)
     deployment.name = 'RegionOne.prod.cell1'
     ex = exceptions.NotFound()
     self.client.get_instance('RegionOne', INSTANCE_ID_1,
                              get_metadata=True).AndRaise(ex)
     self.mox.ReplayAll()
     result = self.reconciler.failed_validation(exists)
     self.assertFalse(result)
     self.mox.VerifyAll()
Beispiel #4
0
 def test_missing_exists_for_instance_not_found(self):
     launch_id = 1
     beginning_d = utils.decimal_utc()
     launch = self.mox.CreateMockAnything()
     launch.instance = INSTANCE_ID_1
     launch.launched_at = beginning_d - (60 * 60)
     launch.instance_flavor_id = INSTANCE_FLAVOR_ID_1
     models.InstanceUsage.objects.get(id=launch_id).AndReturn(launch)
     deployment = self.mox.CreateMockAnything()
     launch.deployment().AndReturn(deployment)
     deployment.name = 'RegionOne.prod.cell1'
     ex = exceptions.NotFound()
     self.client.get_instance('RegionOne', INSTANCE_ID_1).AndRaise(ex)
     self.mox.ReplayAll()
     result = self.reconciler.missing_exists_for_instance(
         launch_id, beginning_d)
     self.assertFalse(result)
     self.mox.VerifyAll()