Skip to content

Commit

Permalink
Merge pull request #5007 from rundeck/enh/plugin-control-optimized
Browse files Browse the repository at this point in the history
more optimized use of pluginControlService
  • Loading branch information
gschueler committed Jun 27, 2019
2 parents 1f340b4 + 63712c3 commit 262f335
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.dtolabs.rundeck.core.authorization.UserAndRolesAuthContext
import com.dtolabs.rundeck.core.common.Framework
import com.dtolabs.rundeck.core.common.INodeEntry
import com.dtolabs.rundeck.core.common.NodeSetImpl
import com.dtolabs.rundeck.core.common.PluginControlService
import com.dtolabs.rundeck.core.utils.NodeSet
import com.dtolabs.rundeck.core.utils.OptsUtil
import com.dtolabs.rundeck.plugins.logging.LogFilterPlugin
Expand Down Expand Up @@ -1862,20 +1863,22 @@ class ScheduledExecutionController extends ControllerBase{
params[it]='false'
}
}
def pluginControlService = frameworkService.getPluginControlService(params.project)
def nodeStepTypes = frameworkService.getNodeStepPluginDescriptions()?.findAll{
!frameworkService.getPluginControlService(params.project)?.isDisabledPlugin(it.name,'WorkflowNodeStep')
!pluginControlService?.isDisabledPlugin(it.name, 'WorkflowNodeStep')
}
def stepTypes = frameworkService.getStepPluginDescriptions()?.findAll{
!frameworkService.getPluginControlService(params.project)?.isDisabledPlugin(it.name,'WorkflowStep')
!pluginControlService?.isDisabledPlugin(it.name, 'WorkflowStep')
}
def strategyPlugins = scheduledExecutionService.getWorkflowStrategyPluginDescriptions()
def globals=frameworkService.getProjectGlobals(scheduledExecution.project).keySet()
def logFilterPlugins = pluginService.listPlugins(LogFilterPlugin).findAll{k,v->
!frameworkService.getPluginControlService(params.project)?.isDisabledPlugin(k,'LogFilter')
!pluginControlService?.isDisabledPlugin(k, 'LogFilter')
}
def notificationPlugins = notificationService.listNotificationPlugins().findAll{k,v->
!frameworkService.getPluginControlService(params.project)?.isDisabledPlugin(k,'Notification')
!pluginControlService?.isDisabledPlugin(k, 'Notification')
}

def globals = frameworkService.getProjectGlobals(scheduledExecution.project).keySet()
return render(view:'edit', model: [scheduledExecution:scheduledExecution,
nextExecutionTime:scheduledExecutionService.nextExecutionTime(scheduledExecution),
notificationValidation: params['notificationValidation'],
Expand Down Expand Up @@ -2121,25 +2124,27 @@ class ScheduledExecutionController extends ControllerBase{
session.removeAttribute('undoOPTS');
session.removeAttribute('redoOPTS');
}
def pluginControlService = frameworkService.getPluginControlService(params.project)

def nodeStepTypes = frameworkService.getNodeStepPluginDescriptions()?.findAll{
!frameworkService.getPluginControlService(params.project)?.isDisabledPlugin(it.name,'WorkflowNodeStep')
!pluginControlService?.isDisabledPlugin(it.name, 'WorkflowNodeStep')
}
def stepTypes = frameworkService.getStepPluginDescriptions()?.findAll{
!frameworkService.getPluginControlService(params.project)?.isDisabledPlugin(it.name,'WorkflowStep')
!pluginControlService?.isDisabledPlugin(it.name, 'WorkflowStep')
}
def logFilterPlugins = pluginService.listPlugins(LogFilterPlugin).findAll { k, v ->
!pluginControlService?.isDisabledPlugin(k, 'LogFilter')
}
def notificationPlugins = notificationService.listNotificationPlugins().findAll { k, v ->
!pluginControlService?.isDisabledPlugin(k, 'Notification')
}
log.debug("ScheduledExecutionController: create : now returning model data to view...")

def strategyPlugins = scheduledExecutionService.getWorkflowStrategyPluginDescriptions()
def globals=frameworkService.getProjectGlobals(scheduledExecution.project).keySet()

def globals=frameworkService.getProjectGlobals(scheduledExecution.project).keySet()
def timeZones = scheduledExecutionService.getTimeZones()
def logFilterPlugins = pluginService.listPlugins(LogFilterPlugin).findAll{k,v->
!frameworkService.getPluginControlService(params.project)?.isDisabledPlugin(k,'LogFilter')
}
def fprojects = frameworkService.projectNames(authContext)
def notificationPlugins = notificationService.listNotificationPlugins().findAll{k,v->
!frameworkService.getPluginControlService(params.project)?.isDisabledPlugin(k,'Notification')
}

return ['scheduledExecution':scheduledExecution, params:params, crontab:[:],
nodeStepDescriptions: nodeStepTypes, stepDescriptions: stepTypes,
notificationPlugins : notificationPlugins,
Expand Down Expand Up @@ -2344,21 +2349,22 @@ class ScheduledExecutionController extends ControllerBase{
request.message=g.message(code:'ScheduledExecutionController.save.failed')
}
}

def pluginControlService = frameworkService.getPluginControlService(params.project)
def nodeStepTypes = frameworkService.getNodeStepPluginDescriptions()?.findAll{
!frameworkService.getPluginControlService(params.project)?.isDisabledPlugin(it.name,'WorkflowNodeStep')
!pluginControlService?.isDisabledPlugin(it.name,'WorkflowNodeStep')
}
def stepTypes = frameworkService.getStepPluginDescriptions()?.findAll{
!frameworkService.getPluginControlService(params.project)?.isDisabledPlugin(it.name,'WorkflowStep')
!pluginControlService?.isDisabledPlugin(it.name,'WorkflowStep')
}
def strategyPlugins = scheduledExecutionService.getWorkflowStrategyPluginDescriptions()

def logFilterPlugins = pluginService.listPlugins(LogFilterPlugin).findAll{k,v->
!frameworkService.getPluginControlService(params.project)?.isDisabledPlugin(k,'LogFilter')
!pluginControlService?.isDisabledPlugin(k,'LogFilter')
}
def notificationPlugins = notificationService.listNotificationPlugins().findAll{k,v->
!frameworkService.getPluginControlService(params.project)?.isDisabledPlugin(k,'Notification')
!pluginControlService?.isDisabledPlugin(k,'Notification')
}

render(view: 'create', model: [scheduledExecution: scheduledExecution, params: params,
nodeStepDescriptions: nodeStepTypes,
stepDescriptions: stepTypes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ class ScheduledExecutionControllerTests {
//try to do update of the ScheduledExecution
def fwkControl = new MockFor(FrameworkService, true)
fwkControl.demand.getAuthContextForSubjectAndProject { subject,proj -> testUserAndRolesContext() }
fwkControl.demand.getPluginControlService { }
fwkControl.demand.getNodeStepPluginDescriptions { [] }
fwkControl.demand.getStepPluginDescriptions { [] }
fwkControl.demand.getRundeckFramework {-> return null }
Expand Down Expand Up @@ -534,6 +535,7 @@ class ScheduledExecutionControllerTests {
//try to do update of the ScheduledExecution
def fwkControl = new MockFor(FrameworkService, true)
fwkControl.demand.getAuthContextForSubjectAndProject { subject,proj -> testUserAndRolesContext() }
fwkControl.demand.getPluginControlService { }
fwkControl.demand.getNodeStepPluginDescriptions { [] }
fwkControl.demand.getStepPluginDescriptions { [] }
fwkControl.demand.getRundeckFramework {-> return null }
Expand Down Expand Up @@ -3353,9 +3355,8 @@ class ScheduledExecutionControllerTests {
def fwkControl = new MockFor(FrameworkService, true)
fwkControl.demand.getAuthContextForSubjectAndProject { subject,proj -> testUserAndRolesContext() }
fwkControl.demand.authorizeProjectResourceAll { framework, resource, actions, project -> return true }
fwkControl.demand.getNodeStepPluginDescriptions { [[name:'test'],[name:'test2']] }
fwkControl.demand.getPluginControlService{proj->plgControlSrv.proxyInstance()}
fwkControl.demand.getPluginControlService{proj->plgControlSrv.proxyInstance()}
fwkControl.demand.getNodeStepPluginDescriptions { [[name:'test'],[name:'test2']] }
fwkControl.demand.getStepPluginDescriptions { [] }
fwkControl.demand.getProjectGlobals { [:] }
fwkControl.demand.projectNames { [] }
Expand Down

0 comments on commit 262f335

Please sign in to comment.