}
/*
* Gets the current environment using this cname
*/
EnvironmentDescription curEnv = getEnvironmentFor(applicationName,
cnamePrefix);
/*
* Decides on a cnamePrefix, and launches a new environment
*/
String cnamePrefixToCreate = getCNamePrefixToCreate();
if (getLog().isInfoEnabled())
getLog().info(
"Creating a new environment on " + cnamePrefixToCreate
+ ".elasticbeanstalk.com");
copyOptionSettings(curEnv);
if (! solutionStack.equals(curEnv.getSolutionStackName())) {
if (getLog().isInfoEnabled())
getLog().info(
format("(btw, we're launching with solutionStack/ set to '%s' instead of the default ('%s'). " +
"If this is not the case, then we kindly ask you to file a bug report on the mailing list :)",
curEnv.getSolutionStackName(), solutionStack));
solutionStack = curEnv.getSolutionStackName();
}
String newEnvironmentName = getNewEnvironmentName(this.environmentName);
if (getLog().isInfoEnabled())
getLog().info("And it'll be named " + newEnvironmentName);
CreateEnvironmentResult createEnvResult = createEnvironment(
cnamePrefixToCreate, newEnvironmentName);
/*
* Waits for completion
*/
EnvironmentDescription newEnvDesc = null;
try {
newEnvDesc = waitForEnvironment(createEnvResult.getEnvironmentId());
} catch (Exception exc) {
/*
* Terminates the failed launched environment
*/
terminateAndWaitForEnvironment(createEnvResult.getEnvironmentId());
handleException(exc);
return null;
}
/*
* Swaps
*/
swapEnvironmentCNames(newEnvDesc.getEnvironmentId(),
curEnv.getEnvironmentId(), cnamePrefix);
/*
* Terminates the previous environment - and waits for it
*/