Browse files

Try to stop all instances when running nimbus-admin --shutdown --all

Corrupted instances have shutdown capabilities disabled.  When
--shutdown --all is called, it would stop at the first Corrupted
instance with the following message:

    RemoteException occurred in server thread; nested exception is:
    java.rmi.RemoteException: Shutdown is currently disabled

Catch the exception and continue to the next instance.  A warning is
printing in the logs and a message is returned to the user.

Also add a --force argument to nimbus-admin to activate the trash
operation for instances that didn't shut down properly.
  • Loading branch information...
1 parent 898ea3f commit 7b09b7be7110080d474301379a448390efa89686 @priteau priteau committed Aug 22, 2012
View
2 ...ce-api/java/source/src/org/nimbustools/api/services/admin/RemoteAdminToolsManagement.java
@@ -51,6 +51,6 @@
public String getAllVMsByGroupName(String groupName) throws RemoteException;
public String getVMsByState(String state) throws RemoteException;
public Hashtable<String, String[]> showVMsForAllHosts() throws RemoteException;
- public String shutdown(int type, String typeID, String seconds) throws RemoteException;
+ public String shutdown(int type, String typeID, String seconds, boolean force) throws RemoteException;
public String cleanup(int type, String typeID) throws RemoteException;
}
View
7 service/service/java/source/src/org/globus/workspace/remoting/admin/client/Opts.java
@@ -52,6 +52,11 @@ public Options getOptions() {
public final Option CONFIG_OPT =
OptionBuilder.withLongOpt(CONFIG_LONG).hasArg().create(CONFIG);
+ public static final String FORCE = "f";
+ public static final String FORCE_LONG = "force";
+ public final Option FORCE_OPT =
+ OptionBuilder.withLongOpt(FORCE_LONG).create(FORCE);
+
public static final String BATCH = "b";
public static final String BATCH_LONG = "batch";
public final Option BATCH_OPT =
@@ -218,7 +223,7 @@ public Options getOptions() {
OptionBuilder.withLongOpt(STATE_LONG).hasArg().create(STATE);
public final Option[] ALL_ENABLED_OPTIONS = {
- HELP_OPT, DEBUG_OPT, CONFIG_OPT, BATCH_OPT, DELIMITER_OPT,
+ HELP_OPT, DEBUG_OPT, CONFIG_OPT, FORCE_OPT, BATCH_OPT, DELIMITER_OPT,
REPORT_OPT, JSON_OPT, OUTPUT_OPT, ADD_NODES_OPT, LIST_NODES_OPT,
REMOVE_NODES_OPT, UPDATE_NODES_OPT, POOL_AVAILABILITY_OPT, NETWORKS_OPT, MEMORY_OPT, POOL_OPT,
ACTIVE_OPT, INACTIVE_OPT, CLEANUP_VMS_OPT, LIST_VMS_OPT, SHUTDOWN_VMS_OPT, USER_OPT, ID_OPT,
View
24 ...vice/java/source/src/org/globus/workspace/remoting/admin/client/RemoteAdminToolsMain.java
@@ -72,6 +72,7 @@
private List<String> hostList;
private boolean allVMs = false;
private int numOpts = 0;
+ private boolean force = false;
public static void main(String args[]) {
@@ -310,6 +311,7 @@ else if(this.action == ToolAction.ShutdownVMs ||
final boolean batchMode = line.hasOption(Opts.BATCH);
final boolean json = line.hasOption(Opts.JSON);
+ force = line.hasOption(Opts.FORCE);
final Reporter.OutputMode mode;
if (batchMode && json) {
@@ -353,10 +355,10 @@ else if(this.action == ToolAction.ShutdownVMs ||
}
final List leftovers = line.getArgList();
- if (leftovers != null && !leftovers.isEmpty()) {
- throw new ParameterProblem("There are unrecognized arguments, check -h to make " +
- "sure you are doing the intended thing: " + leftovers.toString());
- }
+ if (leftovers != null && !leftovers.isEmpty()) {
+ throw new ParameterProblem("There are unrecognized arguments, check -h to make " +
+ "sure you are doing the intended thing: " + leftovers.toString());
+ }
}
@@ -460,52 +462,52 @@ private void shutdownVM() {
}
if(allVMs) {
result = this.remoteAdminToolsManagement.shutdown(
- RemoteAdminToolsManagement.SHUTDOWN_ALL, null, seconds);
+ RemoteAdminToolsManagement.SHUTDOWN_ALL, null, seconds, force);
}
else if(vmIDs != null) {
for(int i = 0; i < vmIDs.size(); i++) {
feedback = this.remoteAdminToolsManagement.shutdown(
- RemoteAdminToolsManagement.SHUTDOWN_ID, vmIDs.get(i), seconds);
+ RemoteAdminToolsManagement.SHUTDOWN_ID, vmIDs.get(i), seconds, force);
if(feedback != null)
result += feedback + "\n";
}
}
else if(userList != null) {
for(int i = 0; i < userList.size(); i++) {
feedback = this.remoteAdminToolsManagement.shutdown(
- RemoteAdminToolsManagement.SHUTDOWN_UNAME, userList.get(i), seconds);
+ RemoteAdminToolsManagement.SHUTDOWN_UNAME, userList.get(i), seconds, force);
if(feedback != null)
result += feedback + "\n";
}
}
else if(DNList != null) {
for(int i = 0; i < DNList.size(); i++) {
feedback = this.remoteAdminToolsManagement.shutdown(
- RemoteAdminToolsManagement.SHUTDOWN_DN, DNList.get(i), seconds);
+ RemoteAdminToolsManagement.SHUTDOWN_DN, DNList.get(i), seconds, force);
if(feedback != null)
result += feedback + "\n";
}
}
else if(gidList != null) {
for(int i = 0; i < gidList.size(); i++) {
feedback = this.remoteAdminToolsManagement.shutdown(
- RemoteAdminToolsManagement.SHUTDOWN_GID, gidList.get(i), seconds);
+ RemoteAdminToolsManagement.SHUTDOWN_GID, gidList.get(i), seconds, force);
if(feedback != null)
result += feedback + "\n";
}
}
else if(gnameList != null) {
for(int i = 0; i < gnameList.size(); i++) {
feedback = this.remoteAdminToolsManagement.shutdown(
- RemoteAdminToolsManagement.SHUTDOWN_GNAME, gnameList.get(i), seconds);
+ RemoteAdminToolsManagement.SHUTDOWN_GNAME, gnameList.get(i), seconds, force);
if(feedback != null)
result += feedback + "\n";
}
}
else if(hostList != null) {
for(int i = 0; i < hostList.size(); i++) {
feedback = this.remoteAdminToolsManagement.shutdown(
- RemoteAdminToolsManagement.SHUTDOWN_HOST, hostList.get(i), seconds);
+ RemoteAdminToolsManagement.SHUTDOWN_HOST, hostList.get(i), seconds, force);
if(feedback != null)
result += feedback + "\n";
}
View
30 .../source/src/org/globus/workspace/remoting/admin/defaults/DefaultRemoteAdminToolsMgmt.java
@@ -220,9 +220,10 @@ public String getVMsByState(String state) throws RemoteException {
* typeID is either the id or hostname, depending on if shutting down by id or host, or null if shutting down all
* seconds is optional
*/
- public String shutdown(int type, String typeID, String seconds) throws RemoteException {
+ public String shutdown(int type, String typeID, String seconds, boolean force) throws RemoteException {
try {
VM[] vms;
+ String returnMsg = null;
vms = typeSet(type, typeID);
if(vms == null || vms.length == 0)
@@ -231,7 +232,16 @@ public String shutdown(int type, String typeID, String seconds) throws RemoteExc
for(int i = 0; i < vms.length; i++) {
String id = vms[i].getID();
Caller caller = vms[i].getCreator();
- manager.shutdown(id, manager.INSTANCE, null, caller);
+ 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
@@ -263,19 +273,25 @@ public String shutdown(int type, String typeID, String seconds) throws RemoteExc
for(int i = 0; i < vms.length; i++) {
String id = vms[i].getID();
Caller caller = vms[i].getCreator();
- manager.trash(id, manager.INSTANCE, caller);
+ 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";
+ } else {
+ returnMsg += "\nInstance " + id + " not trashed because it is was not shut down correctly and --force is off";
+ }
+ }
}
- return null;
+
+ return returnMsg;
}
catch (ManageException e) {
throw new RemoteException(e.getMessage());
}
catch (DoesNotExistException e) {
throw new RemoteException(e.getMessage());
}
- catch (OperationDisabledException e) {
- throw new RemoteException(e.getMessage());
- }
catch (InterruptedException e) {
throw new RemoteException(e.getMessage());
}

0 comments on commit 7b09b7b

Please sign in to comment.