FirewallManager firewallManager = new FirewallManager(
computeServiceContext, clusterSpec, newCluster);
VelocityEngine velocityEngine = TemplateUtils.newVelocityEngine();
ClusterActionEvent event = new ClusterActionEvent(getAction(), clusterSpec,
instanceTemplate, newCluster, statementBuilder, getCompute(), firewallManager, velocityEngine);
eventMap.put(instanceTemplate, event);
eventSpecificActions(instanceTemplate, event);
for (String role : instanceTemplate.getRoles()) {
if (roleIsInTarget(role)) {
safeGetActionHandler(role).beforeAction(event);
}
}
// cluster may have been updated by handler
newCluster = event.getCluster();
}
doAction(eventMap);
// cluster may have been updated by action
newCluster = Iterables.get(eventMap.values(), 0).getCluster();
for (InstanceTemplate instanceTemplate : clusterSpec.getInstanceTemplates()) {
if (shouldIgnoreInstanceTemplate(instanceTemplate)) {
continue;
}
ClusterActionEvent event = eventMap.get(instanceTemplate);
for (String role : instanceTemplate.getRoles()) {
if (roleIsInTarget(role)) {
event.setCluster(newCluster);
safeGetActionHandler(role).afterAction(event);
// cluster may have been updated by handler
newCluster = event.getCluster();
}
}
}
return newCluster;