if(vms == null || vms.length == 0)
return errorMsg;
for(int i = 0; i < vms.length; i++) {
String id = vms[i].getID();
Caller caller = vms[i].getCreator();
try {
manager.shutdown(id, manager.INSTANCE, null, caller);
} catch (OperationDisabledException e) {
logger.warn("Shutdown is currently disabled for instance " + id);
if (returnMsg == null) {
returnMsg = "Shutdown is currently disabled for instance " + id;
} else {
returnMsg += "\nShutdown is currently disabled for instance " + id;
}
}
}
//checks every 3 seconds to see if one of the vms has entered propagation mode
//up to a max of 30 seconds before trashing all vms
//I decided against checking every single vm for entering propagation mode since they mostly enter at
//about the same speed
if(seconds == null) {
for(int i = 0; i <= 10; i++) {
Thread.sleep(3000);
vms = typeSet(type, typeID);
if(vms[0].getState().getState().equals("Propagated"))
break;
}
}
//same as above, but max time is the amount of seconds entered by the user
else {
int mill = (Integer.parseInt(seconds)) * 1000;
for(int i = 0; i <= mill; i += 3000) {
Thread.sleep(3000);
vms = typeSet(type, typeID);
if(vms[0].getState().getState().equals("Propagated"))
break;
}
}
//eventually trashes all vms regardless of whether or not they enter propagation mode
vms = typeSet(type, typeID);
for(int i = 0; i < vms.length; i++) {
String id = vms[i].getID();
Caller caller = vms[i].getCreator();
if (force || vms[i].getState().getState().equals("Propagated")) {
manager.trash(id, manager.INSTANCE, caller);
} else {
if (returnMsg == null) {
returnMsg = "Instance " + id + " not trashed because it is was not shut down correctly and --force is off";