java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java | 45 ++++++++++
1 file changed, 45 insertions(+)
New commits:
commit 385c61bfcd80b4bee37196f6ba0106f9928b034e
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Wed Sep 7 16:45:24 2011 +0200
736381 - New API: system.deleteGuestProfiles()
New API call to delete virt. guest profiles for a given host
The call accepts following arguments:
* hostId: ID of the host system (integer)
* guestNames: list of guest profile names (list of strings)
In case of success, the call returns 1, traceback otherwise.
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
index f941310..9239b56 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
@@ -1211,6 +1211,51 @@ public class SystemHandler extends BaseHandler {
}
/**
+ * Delete the specified list of guest profiles for a given host.
+ * @param sessionKey The sessionKey containing the logged in user.
+ * @param hostId The id of the host system.
+ * @param guestNames List of guest names to delete.
+ * @return 1 in case of success, traceback otherwise.
+ */
+ public Integer deleteGuestProfiles(String sessionKey, Integer hostId,
+ List<String> guestNames) {
+ User loggedInUser = getLoggedInUser(sessionKey);
+ Server server = lookupServer(loggedInUser, hostId);
+
+ if (server != null && !server.isVirtualHost()) {
+ throw new FaultException(1005, "notAHostSystem",
+ "The system ID specified (" + hostId +
+ ") does not represent a host system");
+ }
+
+ List<String> availableGuests = new ArrayList();
+
+ for (VirtualInstance vi : server.getGuests()) {
+ availableGuests.add(vi.getName());
+ }
+
+ for (String gn : guestNames) {
+ if (!availableGuests.contains(gn)) {
+ throw new InvalidSystemException();
+ }
+ }
+
+ for (VirtualInstance vi : server.getGuests()) {
+ if (!guestNames.contains(vi.getName())) {
+ continue;
+ }
+
+ if (vi.isRegisteredGuest()) {
+ throw new SystemsNotDeletedException("Unable to delete guest profile
" +
+ vi.getName() + ": the guest is registered.");
+ }
+ server.removeGuest(vi);
+ }
+
+ return 1;
+ }
+
+ /**
* Delete systems given a list of system ids.
* This call queues the systems for deletion
* @param sessionKey The sessionKey containing the logged in user
Show replies by date