Refactoring repair api
This commit is contained in:
parent
143500dbc7
commit
a45a11e2f7
@ -36,7 +36,6 @@ from stacktach import datetime_to_decimal as dt
|
||||
from stacktach import models
|
||||
from stacktach import stacklog
|
||||
from stacktach import utils
|
||||
from stacktach.models import InstanceExists, ImageExists
|
||||
|
||||
DEFAULT_LIMIT = 50
|
||||
HARD_LIMIT = 1000
|
||||
@ -454,19 +453,13 @@ def get_verified_count(request):
|
||||
"format should be %YYYY-%mm-%dd)")
|
||||
|
||||
|
||||
def exists_factory(service):
|
||||
model = InstanceExists
|
||||
if service == 'glance':
|
||||
model = ImageExists
|
||||
return model
|
||||
|
||||
|
||||
def repair_stacktach_down(request):
|
||||
post_dict = dict((request.POST._iterlists()))
|
||||
message_ids = post_dict.get('message_ids')
|
||||
service = post_dict.get('service', ['nova'])
|
||||
klass = _exists_model_factory(service[0])['klass']
|
||||
absent_exists, exists_not_pending = \
|
||||
exists_factory(service[0]).mark_exists_as_sent_unverified(message_ids)
|
||||
klass.mark_exists_as_sent_unverified(message_ids)
|
||||
response_data = {'absent_exists': absent_exists,
|
||||
'exists_not_pending': exists_not_pending}
|
||||
response = HttpResponse(json.dumps(response_data),
|
||||
|
@ -72,7 +72,7 @@ urlpatterns = patterns('',
|
||||
url(r'db/confirm/usage/exists/(?P<message_id>[\w\-]+)/$',
|
||||
'stacktach.dbapi.exists_send_status'),
|
||||
url(r'db/count/verified', 'stacktach.dbapi.get_verified_count'),
|
||||
url(r'repair/', 'stacktach.dbapi.repair_stacktach_down'),
|
||||
url(r'db/repair/', 'stacktach.dbapi.repair_stacktach_down'),
|
||||
|
||||
url(r'^(?P<deployment_id>\d+)/$', 'stacktach.views.home', name='home'),
|
||||
url(r'^(?P<deployment_id>\d+)/details/(?P<column>\w+)/(?P<row_id>\d+)/$',
|
||||
|
@ -1009,7 +1009,7 @@ class StacktachRepairScenarioApi(StacktachBaseTestCase):
|
||||
message_ids = ["04fd94b5-64dd-4559-83b7-981d9d4f7a5a",
|
||||
"14fd94b5-64dd-4559-83b7-981d9d4f7a5a",
|
||||
"24fd94b5-64dd-4559-83b7-981d9d4f7a5a"]
|
||||
request.POST._iterlists().AndReturn([('service', 'nova'),
|
||||
request.POST._iterlists().AndReturn([('service', ['nova']),
|
||||
('message_ids', message_ids)])
|
||||
self.mox.StubOutWithMock(models.InstanceExists,
|
||||
'mark_exists_as_sent_unverified')
|
||||
|
Loading…
x
Reference in New Issue
Block a user