Skip to content

Commit

Permalink
#63: deployment (execution) using new code works
Browse files Browse the repository at this point in the history
  • Loading branch information
ypujante committed Jun 12, 2011
1 parent b42d4f8 commit 067cacc
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,34 +202,35 @@ class SystemController extends ControllerBase
args.fabric = request.fabric
args.name = params.title

Plan plan = deploymentService.computeDeploymentPlan(args)

def plans =
deploymentService.groupByInstance(plan, [type: 'deploy', name: args.name])
deploymentService.computeDeploymentPlans(params,
[type: 'deploy',
name: args.name])

session.delta.addAll(plans)
if(plans)
session.delta.addAll(plans)

def bouncePlans
def bouncePlans = null

def bouncePlan = deploymentService.computeBouncePlan(args) { true }
if(bouncePlan)
{
bouncePlan.name = "Bounce ${params.title}"
bouncePlans =
deploymentService.groupByInstance(bouncePlan, [type: 'bounce', name: args.name])
session.delta.addAll(bouncePlans)
}
// def bouncePlan = deploymentService.computeBouncePlan(args) { true }
// if(bouncePlan)
// {
// bouncePlan.name = "Bounce ${params.title}"
// bouncePlans =
// deploymentService.groupByInstance(bouncePlan, [type: 'bounce', name: args.name])
// session.delta.addAll(bouncePlans)
// }

def redeployPlans
def redeployPlans = null

def redeployPlan = deploymentService.computeRedeployPlan(args) { true }
if(redeployPlan)
{
redeployPlan.name = "Redeploy ${params.title}"
redeployPlans =
deploymentService.groupByInstance(redeployPlan, [type: 'redeploy', name: args.name])
session.delta.addAll(redeployPlans)
}
// def redeployPlan = deploymentService.computeRedeployPlan(args) { true }
// if(redeployPlan)
// {
// redeployPlan.name = "Redeploy ${params.title}"
// redeployPlans =
// deploymentService.groupByInstance(redeployPlan, [type: 'redeploy', name: args.name])
// session.delta.addAll(redeployPlans)
// }

[
delta: plans,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public class ActionExecutionFactoryImpl implements ActionExecutionFactory
@Override
<V> ActionExecution<V> createAction(ActionDescriptor actionDescriptor)
{
Closure actionClosure = this."${actionDescriptor.class.name}_execution"
Closure actionClosure = this."${actionDescriptor.class.simpleName}_execution"

return new ClosureActionExecution<V>(actionDescriptor: actionDescriptor,
actionClosure: actionClosure)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class DeploymentServiceImpl implements DeploymentService

SystemModelDelta delta = deltaMgr.computeDelta(expectedModel, currentModel)

if(!delta)
if(!delta.hasDelta())
return []

Collection<Type> types = []
Expand All @@ -110,6 +110,17 @@ class DeploymentServiceImpl implements DeploymentService
plan.setMetadata('fabric', expectedModel.fabric)
plan.setMetadata('systemId', expectedModel.id)
plan.setMetadata(metadata)

plan.step?.metadata?.putAll(metadata)

def name = params.name ?: metadata.name
if(!name)
{
name = metadata.collect { k,v -> "${k}=$v"}.join(' - ')
}
name = "${name} - ${type}".toString()
plan.name = name

return plan
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
public interface ActionDescriptor
{
String getDescription();
String getName();

Map<String, Object> toMetadata();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public class AgentActionDescriptor extends BaseActionDescriptor
/**
* Constructor
*/
public AgentActionDescriptor(String description, String fabric, String agent)
public AgentActionDescriptor(String name, String fabric, String agent)
{
super(description);
super(name);
_fabric = fabric;
_agent = agent;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@
*/
public class BaseActionDescriptor implements ActionDescriptor
{
private final String _description;
private final String _name;

/**
* Constructor
*/
public BaseActionDescriptor(String description)
public BaseActionDescriptor(String name)
{
_description = description;
_name = name;
}

@Override
public String getDescription()
public String getName()
{
return _description;
return _name;
}

@Override
Expand All @@ -51,6 +51,6 @@ public Map<String, Object> toMetadata()
@Override
public void toMetadata(Map<String, Object> metadata)
{
metadata.put("description", _description);
metadata.put("name", _name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ public class MountPointActionDescriptor extends AgentActionDescriptor
/**
* Constructor
*/
public MountPointActionDescriptor(String description,
public MountPointActionDescriptor(String name,
String fabric,
String agent,
String mountPoint)
{
super(description, fabric, agent);
super(name, fabric, agent);
_mountPoint = mountPoint;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public class NoOpActionDescriptor extends BaseActionDescriptor
/**
* Constructor
*/
public NoOpActionDescriptor(String description, Map<String, Object> details)
public NoOpActionDescriptor(String name, Map<String, Object> details)
{
super(description);
super(name);
_details = details;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ public class ScriptLifecycleInstallActionDescriptor extends MountPointActionDesc
/**
* Constructor
*/
public ScriptLifecycleInstallActionDescriptor(String description,
public ScriptLifecycleInstallActionDescriptor(String name,
String fabric,
String agent,
String mountPoint,
String parent,
Object script,
Map initParameters)
{
super(description, fabric, agent, mountPoint);
super(name, fabric, agent, mountPoint);
_parent = parent;
_script = script;
_initParameters = initParameters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public class ScriptLifecycleUninstallActionDescriptor extends MountPointActionDe
/**
* Constructor
*/
public ScriptLifecycleUninstallActionDescriptor(String description,
public ScriptLifecycleUninstallActionDescriptor(String name,
String fabric,
String agent,
String mountPoint)
{
super(description, fabric, agent, mountPoint);
super(name, fabric, agent, mountPoint);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ public class ScriptTransitionActionDescriptor extends MountPointActionDescriptor
/**
* Constructor
*/
public ScriptTransitionActionDescriptor(String description,
public ScriptTransitionActionDescriptor(String name,
String fabric,
String agent,
String mountPoint,
String action,
String endState,
Map actionArgs)
{
super(description, fabric, agent, mountPoint);
super(name, fabric, agent, mountPoint);
_action = action;
_endState = endState;
_actionArgs = actionArgs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public String getAgent()
@Override
public String getMountPoint()
{
return _expectedEntry == null ? _currentEntry.getMountPoint() : _expectedEntry.getAgent();
return _expectedEntry == null ? _currentEntry.getMountPoint() : _expectedEntry.getMountPoint();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,13 @@ protected void processEntryDelta(ICompositeStepBuilder<ActionDescriptor> stepBui
// not deployed => need to deploy it or deployed but not expected => need to undeploy
if(entryDelta.getCurrentEntry() == null || entryDelta.getExpectedEntry() == null)
{
processEntryStateMismatch(stepBuilder.addCompositeSteps(IStep.Type.SEQUENTIAL),
ICompositeStepBuilder<ActionDescriptor> entryStepsBuilder =
stepBuilder.addCompositeSteps(IStep.Type.SEQUENTIAL);

entryStepsBuilder.setMetadata("agent", entryDelta.getAgent());
entryStepsBuilder.setMetadata("mountPoint", entryDelta.getMountPoint());

processEntryStateMismatch(entryStepsBuilder,
systemModelDelta,
entryDelta);
return;
Expand Down Expand Up @@ -255,8 +261,7 @@ protected void addTransitionStep(ICompositeStepBuilder<ActionDescriptor> stepBui
entryDelta.getMountPoint(),
action,
endState,
actionArgs
);
actionArgs);

addLeafStep(stepBuilder, actionDescriptor);
}
Expand Down

0 comments on commit 067cacc

Please sign in to comment.