java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
| 5 +-
java/code/src/com/redhat/rhn/frontend/xmlrpc/MissingCapabilityException.java
| 10 ++++
java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/ServerConfigHandler.java
| 9 +++-
java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/test/ServerConfigHandlerTest.java
| 21 ++++++++--
4 files changed, 39 insertions(+), 6 deletions(-)
New commits:
commit 3bc4c571c889c85bd038a06f08bed865f3aeff0f
Author: Brad Buckingham <bbuckingham(a)redhat.com>
Date: Fri Jun 26 17:44:11 2009 -0400
508141 - api - system.config.deployAll updated w/ better exception when system not
config capable
Updated the logic of the deployAll api to provide an error message consistent
with what the UI provides when the user attempts to deploy config files
to a system that is not capable of deploying files to. E.g. system
doesn't have tools channel and rhncfg* packages installed.
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
index 8db5c8a..a1d65ac 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
@@ -7676,7 +7676,10 @@ Follow this url to see the full list of inactive systems:
<source>Invalid profile label specified: {0}</source>
</trans-unit>
-
+ <trans-unit id="api.system.missingCapabilities">
+ <source>The server {0} does not have the {1} client capability. Please
enable the capability before proceeding with the operation.</source>
+ </trans-unit>
+
<trans-unit id="api.systemgroup.serverNotInGroup">
<source>The specified server is not a member of the specified
group</source>
</trans-unit>
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/MissingCapabilityException.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/MissingCapabilityException.java
index 78ce5a9..ad7a01a 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/MissingCapabilityException.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/MissingCapabilityException.java
@@ -15,6 +15,7 @@
package com.redhat.rhn.frontend.xmlrpc;
import com.redhat.rhn.FaultException;
+import com.redhat.rhn.domain.server.Server;
/**
* MissingCapabilityException
@@ -40,4 +41,13 @@ public class MissingCapabilityException extends FaultException {
super(2401, "missingCapability" , "Missing capability");
}
+ /**
+ * Constructor for exception on missing capability on a server.
+ * @param missingCapability the missing capability.
+ * @param incapableServer the server missing the capability
+ */
+ public MissingCapabilityException(String missingCapability, Server incapableServer)
{
+ super(2401, "missingCapability",
"api.system.missingCapabilities",
+ new Object[] {incapableServer.getHostname(), missingCapability});
+ }
}
diff --git
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/ServerConfigHandler.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/ServerConfigHandler.java
index 886d8fc..cc738de 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/ServerConfigHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/ServerConfigHandler.java
@@ -37,6 +37,7 @@ import com.redhat.rhn.frontend.xmlrpc.BaseHandler;
import com.redhat.rhn.frontend.xmlrpc.configchannel.XmlRpcConfigChannelHelper;
import com.redhat.rhn.frontend.xmlrpc.serializer.ConfigFileNameDtoSerializer;
import com.redhat.rhn.frontend.xmlrpc.system.XmlRpcSystemHelper;
+import com.redhat.rhn.manager.MissingCapabilityException;
import com.redhat.rhn.manager.configuration.ConfigurationManager;
@@ -318,7 +319,13 @@ public class ServerConfigHandler extends BaseHandler {
servers.add(helper.lookupServer(loggedInUser, sid));
}
ConfigurationManager manager = ConfigurationManager.getInstance();
- manager.deployConfiguration(loggedInUser, servers, date);
+ try {
+ manager.deployConfiguration(loggedInUser, servers, date);
+ }
+ catch (MissingCapabilityException e) {
+ throw new com.redhat.rhn.frontend.xmlrpc.MissingCapabilityException(
+ e.getCapability(), e.getServer());
+ }
return 1;
}
diff --git
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/test/ServerConfigHandlerTest.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/test/ServerConfigHandlerTest.java
index 6559418..5510057 100644
---
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/test/ServerConfigHandlerTest.java
+++
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/test/ServerConfigHandlerTest.java
@@ -73,9 +73,7 @@ public class ServerConfigHandlerTest extends BaseHandlerTestCase {
// gcc1 only
Server srv1 = ServerFactoryTest.createTestServer(regular, true,
ServerConstants.getServerGroupTypeProvisioningEntitled());
- SystemManagerTest.giveCapability(srv1.getId(),
- SystemManager.CAP_CONFIGFILES_DEPLOY, ver);
-
+
srv1.subscribe(gcc1);
srv1.subscribe(gcc2);
@@ -108,7 +106,22 @@ public class ServerConfigHandlerTest extends BaseHandlerTestCase {
// System 1 - both g1f1 and g1f2 should deploy here
List<Number> systems = new ArrayList<Number>();
systems.add(srv1.getId());
- Date date = new Date();
+ Date date = new Date();
+
+ try {
+ // validate that system must have config deployment capability
+ // in order to deploy config files... (e.g. rhncfg* pkgs installed)
+ handler.deployAll(regularKey, systems, date);
+
+ fail("Shouldn't be permitted to deploy without config deploy
capability.");
+ }
+ catch (Exception e) {
+ // Success
+ }
+
+ SystemManagerTest.giveCapability(srv1.getId(),
+ SystemManager.CAP_CONFIGFILES_DEPLOY, ver);
+
handler.deployAll(regularKey, systems, date);
DataResult<ScheduledAction> actions = ActionManager.
Show replies by date