Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Addition of ability to shutdown vms added to nimbus-admin

  • Loading branch information...
commit 112fe1a257754f68bae1d3dc988889775ffc1fb8 1 parent 9f5a2fa
@rrusnak1 rrusnak1 authored oldpatricka committed
View
53 authzdb/src/org/nimbus/authz/AuthzDBAdapter.java
@@ -22,6 +22,7 @@
private static final String FIND_OBJECT_BY_NAME = "Select id from objects where name = ? and parent_id = ? and object_type = ?";
private static final String FIND_OBJECT_BY_DATA_KEY = "Select id from objects where data_key = ?";
private static final String FIND_USER_BY_ALIAS = "Select user_id from user_alias where alias_name = ? and alias_type = ?";
+ private static final String FIND_USER_BY_FRIENDLY = "Select user_id from user_alias where friendly_name = ? and alias_type = ?";
private static final String CHECK_PERMISSIONS = "Select access_type_id from object_acl where object_id = ? and user_id = ?";
private static final String GET_DATA_KEY = "select data_key from objects where id = ?";
private static final String GET_CKSUM = "select md5sum from objects where id = ?";
@@ -63,6 +64,7 @@ public String getCumulusPublicUser()
return cumulusPublicUser;
}
+
public void setCumulusPublicUser(
String pubUser)
{
@@ -84,6 +86,10 @@ public String getCanonicalUserIdFromDn(
return getCanonicalUserIdFromAlias(name, ALIAS_TYPE_DN);
}
+ public String getCanonicalUserIdFromFriendlyName(String name) throws AuthzDBException {
+ return getCanonicalUserIdFromFriendly(name, ALIAS_TYPE_DN);
+ }
+
public List<UserAlias> getUserAliases(String userId)
throws AuthzDBException
{
@@ -886,6 +892,53 @@ public String getCanonicalUserIdFromAlias(
}
}
+ public String getCanonicalUserIdFromFriendly(String name, int type) throws AuthzDBException {
+ Connection c = null;
+ PreparedStatement pstmt = null;
+
+ try
+ {
+ c = getConnection();
+ pstmt = c.prepareStatement(FIND_USER_BY_FRIENDLY);
+ pstmt.setString(1, name);
+ pstmt.setInt(2, type);
+ logger.debug("getting user " + pstmt.toString());
+ ResultSet rs = pstmt.executeQuery();
+
+ if(!rs.next())
+ {
+ throw new AuthzDBException("no such user found " + name);
+ }
+ String canUserId = rs.getString(1);
+
+ return canUserId;
+
+ }
+ catch(SQLException e)
+ {
+ logger.error("",e);
+ throw new AuthzDBException(e);
+ }
+ finally
+ {
+ try
+ {
+ if (pstmt != null)
+ {
+ pstmt.close();
+ }
+ if (c != null)
+ {
+ returnConnection(c);
+ }
+ }
+ catch (SQLException sql)
+ {
+ logger.error("SQLException in finally cleanup", sql);
+ }
+ }
+ }
+
private Connection getConnection() throws SQLException
{
return this.dataSource.getConnection();
View
5 ...ce-api/java/source/src/org/nimbustools/api/services/admin/RemoteAdminToolsManagement.java
@@ -25,5 +25,8 @@
public interface RemoteAdminToolsManagement extends Remote {
public Hashtable getAllRunningVMs() throws RemoteException;
-
+ public Hashtable getVMsByUser(String user) throws RemoteException;
+ public String shutdownVM(String id, String seconds) throws RemoteException;
+ public String shutdownAllVMs(String seconds) throws RemoteException;
+ public String test(String user) throws RemoteException;
}
View
13 service/service/java/source/src/org/globus/workspace/remoting/admin/client/AdminClient.java
@@ -21,24 +21,19 @@
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.*;
import org.apache.log4j.varia.NullAppender;
-import org.globus.workspace.remoting.RemotingClient;
import org.globus.workspace.remoting.admin.NodeReport;
import org.globus.workspace.remoting.admin.VmmNode;
import org.nimbustools.api.services.admin.RemoteNodeManagement;
-import org.nimbustools.api.brain.NimbusHomePathResolver;
import java.io.*;
-import java.rmi.NotBoundException;
-import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.*;
-import java.util.concurrent.ExecutionException;
public class AdminClient extends RMIConfig {
private static final Log logger =
- LogFactory.getLog(AdminClient.class.getName());
+ LogFactory.getLog(RMIConfig.class.getName());
public static final int EXIT_OK = 0;
public static final int EXIT_PARAMETER_PROBLEM = 1;
@@ -91,7 +86,6 @@
public static void main(String args[]) {
- // early check for debug options
boolean isDebug = false;
final String debugFlag = "--" + Opts.DEBUG_LONG;
for (String arg : args) {
@@ -108,7 +102,8 @@ public static void main(String args[]) {
BasicConfigurator.configure(consoleAppender);
logger.info("Debug mode enabled");
- } else {
+ }
+ else {
BasicConfigurator.configure(new NullAppender());
}
@@ -407,7 +402,7 @@ private void loadArgs(String[] args) throws ParameterProblem {
if (config == null || config.trim().length() == 0) {
throw new ParameterProblem("Config file path is invalid");
}
- this.configPath = config.trim();
+ super.configPath = config.trim();
final boolean batchMode = line.hasOption(Opts.BATCH);
final boolean json = line.hasOption(Opts.JSON);
View
37 service/service/java/source/src/org/globus/workspace/remoting/admin/client/Opts.java
@@ -133,11 +133,46 @@ public Options getOptions() {
OptionBuilder.withLongOpt(POOL_LONG).hasArg().create(POOL);
+ //*************************************************************************
+ // NIMBUS-ADMIN
+ //*************************************************************************
+
+ public static final String LIST_VMS = "l";
+ public static final String LIST_VMS_LONG = "list";
+ public final Option LIST_VMS_OPT =
+ OptionBuilder.withLongOpt(LIST_VMS_LONG).hasOptionalArg().create(LIST_VMS);
+
+ public static final String SHUTDOWN_VMS = "s";
+ public static final String SHUTDOWN_VMS_LONG = "shutdown";
+ public final Option SHUTDOWN_VMS_OPT =
+ OptionBuilder.withLongOpt(SHUTDOWN_VMS_LONG).hasOptionalArg().create(SHUTDOWN_VMS);
+
+ public static final String ALL_VMS = "a";
+ public static final String ALL_VMS_LONG = "all";
+ public final Option ALL_VMS_OPT =
+ OptionBuilder.withLongOpt(ALL_VMS_LONG).hasOptionalArg().create(ALL_VMS);
+
+ public static final String USER = "u";
+ public static final String USER_LONG = "user";
+ public final Option USER_OPT =
+ OptionBuilder.withLongOpt(USER_LONG).hasOptionalArg().create(USER);
+
+ public static final String ID = "i";
+ public static final String ID_LONG = "id";
+ public final Option ID_OPT =
+ OptionBuilder.withLongOpt(ID_LONG).hasOptionalArg().create(ID);
+
+ public static final String SECONDS = "n";
+ public static final String SECONDS_LONG = "seconds";
+ public final Option SECONDS_OPT =
+ OptionBuilder.withLongOpt(SECONDS_LONG).hasOptionalArg().create(SECONDS);
+
public final Option[] ALL_ENABLED_OPTIONS = {
HELP_OPT, DEBUG_OPT, CONFIG_OPT, BATCH_OPT, DELIMITER_OPT,
REPORT_OPT, JSON_OPT, OUTPUT_OPT, ADD_NODES_OPT, LIST_NODES_OPT,
REMOVE_NODES_OPT, UPDATE_NODES_OPT, NETWORKS_OPT, MEMORY_OPT, POOL_OPT,
- ACTIVE_OPT, INACTIVE_OPT,
+ ACTIVE_OPT, INACTIVE_OPT, LIST_VMS_OPT, SHUTDOWN_VMS_OPT, USER_OPT, ID_OPT,
+ SECONDS_OPT, ALL_VMS_OPT
};
}
View
4 service/service/java/source/src/org/globus/workspace/remoting/admin/client/RMIConfig.java
@@ -2,6 +2,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.PatternLayout;
+import org.apache.log4j.varia.NullAppender;
import org.globus.workspace.remoting.RemotingClient;
import org.nimbustools.api.brain.NimbusHomePathResolver;
View
223 ...vice/java/source/src/org/globus/workspace/remoting/admin/client/RemoteAdminToolsMain.java
@@ -1,19 +1,4 @@
-package org.globus.workspace.remoting.admin.client;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.ParseException;
-import org.apache.commons.cli.PosixParser;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nimbustools.api.services.admin.RemoteAdminToolsManagement;
-
-import java.rmi.RemoteException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-/**
+/*
* Copyright 1999-2010 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -27,30 +12,44 @@
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
- *
- * User: rrusnak
*/
+package org.globus.workspace.remoting.admin.client;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.PosixParser;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.*;
+import org.apache.log4j.varia.NullAppender;
+import org.nimbustools.api.services.admin.RemoteAdminToolsManagement;
+
+import java.rmi.RemoteException;
+import java.util.*;
+
-/**
- * Main class for nimbus-admin tool in /bin
- */
public class RemoteAdminToolsMain extends RMIConfig {
private static final Log logger =
- LogFactory.getLog(RemoteAdminToolsMain.class.getName());
-
- private static final String PROP_RMI_BINDING_ADMINTOOLS_DIR = "rmi.binding.admintools";
+ LogFactory.getLog(RMIConfig.class.getName());
public static final int EXIT_OK = 0;
public static final int EXIT_PARAMETER_PROBLEM = 1;
public static final int EXIT_EXECUTION_PROBLEM = 2;
public static final int EXIT_UNKNOWN_PROBLEM = 3;
+ private static final String PROP_RMI_BINDING_ADMINTOOLS_DIR = "rmi.binding.admintools";
+
+ private ToolAction action;
private RemoteAdminToolsManagement remoteAdminToolsManagement;
+ private String user;
+ private String vmID;
+ private String seconds;
+ private boolean allVMs = false;
public static void main(String args[]) {
- // early check for debug options
boolean isDebug = false;
final String debugFlag = "--" + Opts.DEBUG_LONG;
for (String arg : args) {
@@ -60,35 +59,80 @@ public static void main(String args[]) {
}
}
+ if (isDebug) {
+
+ final PatternLayout layout = new PatternLayout("%C{1}:%L - %m%n");
+ final ConsoleAppender consoleAppender = new ConsoleAppender(layout, "System.err");
+ BasicConfigurator.configure(consoleAppender);
+
+ logger.info("Debug mode enabled");
+ }
+ else {
+ BasicConfigurator.configure(new NullAppender());
+ }
+
Throwable anyError = null;
ParameterProblem paramError = null;
ExecutionProblem execError = null;
int ret = EXIT_OK;
-
try {
final RemoteAdminToolsMain ratm = new RemoteAdminToolsMain();
ratm.run(args);
- }
- catch (ParameterProblem e) {
+
+ } catch (ParameterProblem e) {
paramError = e;
anyError = e;
ret = EXIT_PARAMETER_PROBLEM;
- }
- catch (ExecutionProblem e) {
+ } catch (ExecutionProblem e) {
execError = e;
anyError = e;
ret = EXIT_EXECUTION_PROBLEM;
+ } catch (Throwable t) {
+ anyError = t;
+ ret = EXIT_UNKNOWN_PROBLEM;
+ }
+
+ if (anyError == null) {
+ System.exit(ret);
+ } else {
+ logger.debug("Got error", anyError);
+ }
+
+ if (paramError != null) {
+ System.err.println("Parameter Problem:\n\n" + paramError.getMessage());
+ System.err.println("See --help");
+
+ } else if (execError != null) {
+ System.err.println(execError.getMessage());
+ } else {
+ System.err.println("An unexpected error was encountered. Please report this!");
+ System.err.println(anyError.getMessage());
+ System.err.println();
+ System.err.println("Stack trace:");
+ anyError.printStackTrace(System.err);
}
+
+ System.exit(ret);
+
}
- public void run(String[] args) throws ParameterProblem, ExecutionProblem {
+ public void run(String[] args)
+ throws ExecutionProblem, ParameterProblem {
+
this.loadArgs(args);
super.loadConfig(PROP_RMI_BINDING_ADMINTOOLS_DIR);
this.remoteAdminToolsManagement = (RemoteAdminToolsManagement) super.setupRemoting();
- this.listRunningVMs();
+ switch (this.action) {
+ case ListVMs:
+ listVMs();
+ break;
+ case ShutdownVMs:
+ shutdownVM(vmID, seconds);
+ }
}
private void loadArgs(String[] args) throws ParameterProblem {
+
logger.debug("Parsing command line arguments");
final CommandLineParser parser = new PosixParser();
@@ -96,11 +140,58 @@ private void loadArgs(String[] args) throws ParameterProblem {
final CommandLine line;
try {
line = parser.parse(opts.getOptions(), args);
- }
- catch (ParseException e) {
+ } catch (ParseException e) {
throw new ParameterProblem(e.getMessage(), e);
}
+ // figure action first
+ ToolAction tAction = null;
+ for (ToolAction t : ToolAction.values()) {
+ if (line.hasOption(t.option())) {
+ if (tAction == null) {
+ tAction = t;
+ } else {
+ System.out.println("parameter problem");
+ throw new ParameterProblem("You may only specify a single action");
+ }
+ }
+ }
+
+ if (tAction == null) {
+ throw new ParameterProblem("You must specify an action");
+ }
+
+ this.action = tAction;
+ logger.debug("Action: " + tAction);
+
+ if(this.action == ToolAction.ListVMs) {
+ if(line.hasOption(Opts.USER)) {
+ final String user = line.getOptionValue(Opts.USER);
+ if(user == null || user.trim().length() == 0) {
+ throw new ParameterProblem("User value is empty");
+ }
+ this.user = user;
+ }
+ }
+ else if(this.action == ToolAction.ShutdownVMs) {
+ if(line.hasOption(Opts.ALL_VMS))
+ allVMs = true;
+ if(line.hasOption(Opts.ID) && !allVMs) {
+ final String id = line.getOptionValue(Opts.ID);
+ if(id == null || id.trim().length() == 0) {
+ throw new ParameterProblem("VM ID value is empty");
+ }
+ this.vmID = id;
+ }
+ if(line.hasOption(Opts.SECONDS)) {
+ final String seconds = line.getOptionValue(Opts.SECONDS);
+ if(seconds == null || seconds.trim().length() == 0) {
+ throw new ParameterProblem("Seconds value is empty");
+ }
+ this.seconds = seconds;
+ }
+ }
+
//finally everything else
if (!line.hasOption(Opts.CONFIG)) {
@@ -111,11 +202,28 @@ private void loadArgs(String[] args) throws ParameterProblem {
throw new ParameterProblem("Config file path is invalid");
}
super.configPath = config.trim();
+
+ 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());
+ }
+
}
- private void listRunningVMs() throws ExecutionProblem {
+ private void listVMs() throws ExecutionProblem {
try {
- Hashtable vms = this.remoteAdminToolsManagement.getAllRunningVMs();
+ Hashtable vms;
+ if(this.user == null) {
+ vms = this.remoteAdminToolsManagement.getAllRunningVMs();
+ }
+ else {
+ vms = this.remoteAdminToolsManagement.getVMsByUser(user);
+ }
+ if(vms == null) {
+ System.out.println("No Running vms found");
+ return;
+ }
for(Enumeration<String> vmIds = vms.keys(); vmIds.hasMoreElements();) {
int i = 0;
@@ -124,7 +232,24 @@ private void listRunningVMs() throws ExecutionProblem {
System.out.println("ID: " + id);
System.out.println("Group ID: " + al.get(i++));
System.out.println("Creator: " + al.get(i++));
- System.out.println("State: " + al.get(i++));
+ System.out.println("State: " + al.get(i));
+ }
+ }
+ catch (RemoteException e) {
+ super.handleRemoteException(e);
+ }
+ }
+
+ private void shutdownVM(String id, String seconds) throws ExecutionProblem {
+ try {
+ String result;
+ if(allVMs) {
+ result = this.remoteAdminToolsManagement.shutdownAllVMs(seconds);
+ System.out.println(result);
+ }
+ else {
+ result = this.remoteAdminToolsManagement.shutdownVM(id, seconds);
+ System.out.println(result);
}
}
catch (RemoteException e) {
@@ -132,3 +257,27 @@ private void listRunningVMs() throws ExecutionProblem {
}
}
}
+
+enum ToolAction {
+ ListVMs(Opts.LIST_VMS, null),
+ ShutdownVMs(Opts.SHUTDOWN_VMS, null);
+
+
+ private final String option;
+ private final String[] fields;
+
+ ToolAction(String option, String[] fields) {
+ this.option = option;
+ this.fields = fields;
+ }
+
+ public String option() {
+ return option;
+ }
+
+ public String[] fields() {
+ return fields;
+ }
+}
+
+
View
201 .../source/src/org/globus/workspace/remoting/admin/defaults/DefaultRemoteAdminToolsMgmt.java
@@ -1,15 +1,25 @@
package org.globus.workspace.remoting.admin.defaults;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nimbus.authz.AuthzDBException;
+import org.nimbus.authz.UserAlias;
+import org.nimbustools.api._repr._Caller;
import org.nimbustools.api.repr.Caller;
import org.nimbustools.api.repr.ReprFactory;
import org.nimbustools.api.repr.vm.VM;
import org.nimbustools.api.services.admin.RemoteAdminToolsManagement;
+import org.nimbustools.api.services.rm.DoesNotExistException;
import org.nimbustools.api.services.rm.ManageException;
import org.nimbustools.api.services.rm.Manager;
+import org.nimbus.authz.AuthzDBAdapter;
+import org.nimbustools.api.services.rm.OperationDisabledException;
+import javax.sql.DataSource;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.Hashtable;
+import java.util.List;
/**
* Copyright 1999-2010 University of Chicago
@@ -29,9 +39,13 @@
* User: rrusnak
*/
public class DefaultRemoteAdminToolsMgmt implements RemoteAdminToolsManagement {
+ private static final Log logger =
+ LogFactory.getLog(DefaultRemoteAdminToolsMgmt.class.getName());
protected Manager manager;
protected ReprFactory reprFactory;
+ protected DataSource authzDataSource;
+ private AuthzDBAdapter authz;
public void initialize() throws Exception {
@@ -40,29 +54,186 @@ public void initialize() throws Exception {
public Hashtable getAllRunningVMs() throws RemoteException {
try {
VM[] allRunningVms = manager.getGlobalAll();
- int vmSize = allRunningVms.length;
- Hashtable ht = new Hashtable(vmSize);
+ return returnVMs(allRunningVms);
+ }
+ catch (ManageException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
- for(int i = 0; i < vmSize; i++) {
- ArrayList al = new ArrayList();
- String id = allRunningVms[i].getID();
- Caller caller = allRunningVms[i].getCreator();
+ public Hashtable getVMsByUser(String user) throws RemoteException {
+ try {
+ authz = new AuthzDBAdapter(authzDataSource);
+ String userId = authz.getCanonicalUserIdFromFriendlyName(user);
- al.add(allRunningVms[i].getGroupID());
- al.add(allRunningVms[i].getCreator().getIdentity());
- al.add(allRunningVms[i].getState().getState());
- ht.put(id, al);
+ List<UserAlias> userAlias;
+ userAlias = authz.getUserAliases(userId);
+ if(userAlias.size() == 0)
+ return null;
+
+ Hashtable returnedVMs = new Hashtable(userAlias.size());
+ for(int i = 0; i < userAlias.size(); i++) {
+ String aliasDN = userAlias.get(i).getAliasName();
+ final _Caller caller = this.reprFactory._newCaller();
+ caller.setIdentity(aliasDN);
+ VM[] vmsByCaller = manager.getAllByCaller(caller);
+ returnedVMs.putAll(returnVMs(vmsByCaller));
}
- return ht;
+ return returnedVMs;
+ }
+ catch (AuthzDBException e) {
+ e.printStackTrace();
+ return null;
+ }
+ catch (ManageException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public String shutdownAllVMs(String seconds) throws RemoteException {
+ try {
+ VM[] allRunning = manager.getGlobalAll();
+ for(int i = 0; i < allRunning.length; i++) {
+ String id = allRunning[i].getID();
+ Caller caller = allRunning[i].getCreator();
+ manager.shutdown(id, manager.INSTANCE, null, caller);
+ }
+
+ if(seconds == null) {
+ for(int i = 0; i <= 10; i++) {
+ Thread.sleep(3000);
+ allRunning = manager.getGlobalAll();
+ if(allRunning[0].getState().getState().equals("Propagated"))
+ break;
+ }
+ }
+ else {
+ int mill = (Integer.parseInt(seconds)) * 1000;
+ for(int i = 0; i <= mill; i += 3000) {
+ Thread.sleep(3000);
+ allRunning = manager.getGlobalAll();
+ if(allRunning[0].getState().getState().equals("Propagated"))
+ break;
+ }
+ }
+
+ allRunning = manager.getGlobalAll();
+ for(int i = 0; i < allRunning.length; i++) {
+ String id = allRunning[i].getID();
+ Caller caller = allRunning[i].getCreator();
+ manager.trash(id, manager.INSTANCE, caller);
+ }
+ return "All VMs successfully shut down";
+ }
+ catch (DoesNotExistException d) {
+ d.printStackTrace();
+ return null;
+ }
+ catch (ManageException e) {
+ e.printStackTrace();
+ return null;
+ }
+ catch (OperationDisabledException e) {
+ e.printStackTrace();
+ return null;
+ }
+ catch (InterruptedException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public String shutdownVM(String id, String seconds) throws RemoteException {
+ try {
+ VM instance = manager.getInstance(id);
+ Caller caller = instance.getCreator();
+ manager.shutdown(id, manager.INSTANCE, null, caller);
+
+ if(seconds == null) {
+ for(int i = 0; i <= 10; i++) {
+ Thread.sleep(3000);
+ instance = manager.getInstance(id);
+ if(instance.getState().getState().equals("Propagated")) {
+ manager.trash(id, manager.INSTANCE, caller);
+ return "VM " + id + " shutdown";
+ }
+ }
+ manager.trash(id, manager.INSTANCE, caller);
+ return "VM " + id + " shutdown";
+ }
+ else {
+ int mill = (Integer.parseInt(seconds)) * 1000;
+ for(int i = 0; i <= mill; i += 3000) {
+ Thread.sleep(3000);
+ instance = manager.getInstance(id);
+ if(instance.getState().getState().equals("Propagated")) {
+ manager.trash(id, manager.INSTANCE, caller);
+ return "VM " + id + " shutdown";
+ }
+ }
+ manager.trash(id, manager.INSTANCE, caller);
+ return "VM " + id + " shutdown";
+ }
+ }
+ catch (DoesNotExistException d) {
+ return "VM " + id + " does not exist";
}
catch (ManageException e) {
e.printStackTrace();
+ return "ManageException thrown";
+ }
+ catch (OperationDisabledException e) {
+ e.printStackTrace();
+ return "OperationDisabledException thrown";
+ }
+ catch (InterruptedException e) {
+ e.printStackTrace();
+ return "InterruptedException thrown";
+ }
+ }
+
+ public String test(String user) throws RemoteException {
+ try {
+ authz = new AuthzDBAdapter(authzDataSource);
+ String userId = authz.getCanonicalUserIdFromFriendlyName(user);
+
+ List<UserAlias> userAlias;
+ userAlias = authz.getUserAliases(userId);
+ if(userAlias.size() == 0)
+ return null;
+
+ String aliasDN = userAlias.get(0).getAliasName();
+ final _Caller caller = this.reprFactory._newCaller();
+ caller.setIdentity(aliasDN);
+ return caller.getIdentity();
+ }
+ catch (AuthzDBException e) {
+ e.printStackTrace();
return null;
}
+ //catch (ManageException e) {
+ //e.printStackTrace();
+ // return null;
+ //}
}
- public void createVM() {
- //final Caller caller = this.populator().getCaller();
+ private Hashtable returnVMs(VM[] vms) {
+ int vmSize = vms.length;
+ Hashtable ht = new Hashtable(vmSize);
+
+ for(int i = 0; i < vmSize; i++) {
+ ArrayList al = new ArrayList();
+ String id = vms[i].getID();
+ Caller caller = vms[i].getCreator();
+
+ al.add(vms[i].getGroupID());
+ al.add(vms[i].getCreator().getIdentity());
+ al.add(vms[i].getState().getState());
+ ht.put(id, al);
+ }
+ return ht;
}
public void setManager(Manager manager) {
@@ -73,5 +244,7 @@ public void setReprFactory(ReprFactory reprFactory) {
this.reprFactory = reprFactory;
}
-
+ public void setAuthzDataSource(DataSource authzDataSource) {
+ this.authzDataSource = authzDataSource;
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.