Skip to content

Commit

Permalink
refactored SUCCESS and FAILURE into Bastion.CARP module
Browse files Browse the repository at this point in the history
  • Loading branch information
ndenny committed Oct 28, 2024
1 parent aedf1fb commit 2e75d38
Showing 1 changed file with 1 addition and 29 deletions.
30 changes: 1 addition & 29 deletions bin/bastion.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from Bastion.Condo import *
from Bastion.Actions import *
from Bastion.Model import ARK
from Bastion.CARP import SUCCESS, FAILURE, CRASH, SUCCEEDED, FAILED, CRASHED
import Bastion.Vaults.HPSS
import Bastion.Vaults.BFD

Expand All @@ -43,35 +44,6 @@
a. differential if drift < policy
b. anchor (full) if drift >= policy
"""
def CARP(code, msg, doc, obj = None, **kwargs):
answer = {
'reply': {
'status': code,
'message': msg
},
'context': {},
'report': doc,
'data': obj
}

if 'context' in kwargs:
for k, v in kwargs['context'].items():
answer['context'][k] = v

return answer


def SUCCESS(doc, obj = None, **kwargs):
return CARP('200', 'Ok', doc, obj, **kwargs)


def FAILED(doc, obj = None, **kwargs):
return CARP('400', 'Bad Request', doc, obj, **kwargs)


def CRASHED(doc, obj = None, **kwargs):
return CARP('500', 'Internal Application Error (crash!)', doc, obj, **kwargs)


class App:
CONF_SEARCH_ORDER = [
Expand Down

0 comments on commit 2e75d38

Please sign in to comment.