Skip to content

Commit

Permalink
Customize User Request Log messages
Browse files Browse the repository at this point in the history
Signed-off-by: Lucio Correia <[email protected]>
  • Loading branch information
Lucio Correia authored and danielhb committed Feb 25, 2016
1 parent 0ff1cba commit 1d97430
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
12 changes: 12 additions & 0 deletions control/debugreports.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,24 @@
from wok.control.utils import UrlSubNode


DEBUGREPORTS_ACTIVITY = {
'POST': {'default': "Create host debug report '%(name)s'"},
}

DEBUGREPORT_ACTIVITY = {
'PUT': {'default': "Update host debug report '%(name)s'"},
'DELETE': {'default': "Delete host debug report '%(ident)s'"},
}


@UrlSubNode('debugreports', True)
class DebugReports(AsyncCollection):
def __init__(self, model):
super(DebugReports, self).__init__(model)
self.resource = DebugReport
self.role_key = 'dashboard'
self.admin_methods = ['GET', 'POST']
self.log_map = DEBUGREPORTS_ACTIVITY

def _get_resources(self, filter_params):
res_list = super(DebugReports, self)._get_resources(filter_params)
Expand All @@ -44,6 +55,7 @@ def __init__(self, model, ident):
self.admin_methods = ['GET', 'PUT', 'POST']
self.uri_fmt = '/debugreports/%s'
self.content = DebugReportContent(model, ident)
self.log_map = DEBUGREPORT_ACTIVITY

@property
def data(self):
Expand Down
25 changes: 25 additions & 0 deletions control/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,28 @@
from wok.plugins.gingerbase.control.cpuinfo import CPUInfo


HOST_ACTIVITY = {
'POST': {
'reboot': "Host reboot",
'shutdown': "Host shutdown",
'swupdate': "Host software update",
},
}

REPOSITORIES_ACTIVITY = {
'POST': {'default': "Add host software repository '%(repo_id)s'"},
}

REPOSITORY_ACTIVITY = {
'PUT': {'default': "Update host software repository '%(repo_id)s'"},
'DELETE': {'default': "Remove host software repository '%(ident)s'"},
'POST': {
'enable': "Enable host software repository '%(ident)s'",
'disable': "Disable host software repository '%(ident)s'",
},
}


@UrlSubNode('host', True)
class Host(Resource):
def __init__(self, model, id=None):
Expand All @@ -42,6 +64,7 @@ def __init__(self, model, id=None):
self.swupdateprogress = SoftwareUpdateProgress(self.model)
self.cpuinfo = CPUInfo(self.model)
self.capabilities = Capabilities(self.model)
self.log_map = HOST_ACTIVITY

@property
def data(self):
Expand Down Expand Up @@ -111,6 +134,7 @@ def __init__(self, model):
self.role_key = 'updates'
self.admin_methods = ['GET', 'POST']
self.resource = Repository
self.log_map = REPOSITORIES_ACTIVITY


class Repository(Resource):
Expand All @@ -121,6 +145,7 @@ def __init__(self, model, id):
self.uri_fmt = "/host/repositories/%s"
self.enable = self.generate_action_handler('enable')
self.disable = self.generate_action_handler('disable')
self.log_map = REPOSITORY_ACTIVITY

@property
def data(self):
Expand Down

0 comments on commit 1d97430

Please sign in to comment.