Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example of a glu plugin to customize a plan
* Copyright (c) 2012 Yan Pujante
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
package com.pongasoft.glu.plugins
* Example of a plugin which adds the username as part of the metadata sent to the agents.
* Configured in glu-console-webapp.groovy this way:
* // define the plugins as a Map, or a class name or an array of class names
* orchestration.engine.plugins = [
* 'org.linkedin.glu.orchestration.engine.plugins.builtin.StreamFileContentPlugin',
* 'com.pongasoft.glu.plugins.CustomizePlanPlugin'
* ]
* @author */
public class CustomizePlanPlugin
def authorizationService
* Called on initialization
def PluginService_initialize = { args ->
authorizationService = args.applicationContext['authorizationService']
* Called after computing the plans which allows you to tweak the plan or add some metadata
* @param args.params.planType the type of plan to create (ex: bounce, deploy, transition, etc...)
* @param args.params.stepType the type of steps to create (ex: sequential or parallel)
* @param (optional) the name of the plan if provided
* @param args.params.* any other params needed by the plan creation (provided in the "plans"
* and "mountPointActions" configuration parameters)
* @param args.metadata metadata to use for the plan
* @param args.serviceResult the collection of plans
* @return a collection of plans (depending on <code>args.params.stepType</code>)
def PlannerService_post_computePlans = { args ->
args.serviceResult?.each { plan ->
plan.leafSteps?.each { leafStep ->
def initParameters = leafStep.metadata?.initParameters
initParameters.username = authorizationService.executingPrincipal
return null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment