backend/server/handlers/xmlrpc/registration.py
| 6 ++-
backend/server/rhnChannel.py
| 9 +++-
backend/server/rhnServer/server_class.py
| 9 +++-
java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/internal/ChannelProcedureHandler.java
| 19 +++++++++-
4 files changed, 34 insertions(+), 9 deletions(-)
New commits:
commit d4f157d690ba195211c5123dd71487bfab508ddd
Author: Partha Aji <paji(a)redhat.com>
Date: Thu May 27 13:43:48 2010 -0400
Initial set of changes to get subscribe channel call to work from python backend
diff --git a/backend/server/handlers/xmlrpc/registration.py
b/backend/server/handlers/xmlrpc/registration.py
index 90e5b6f..a6afe24 100644
--- a/backend/server/handlers/xmlrpc/registration.py
+++ b/backend/server/handlers/xmlrpc/registration.py
@@ -347,6 +347,8 @@ class Registration(rhnHandler):
# let the stacked activation keys do their magic
tokens_obj.is_rereg_token = 0
rhnFlags.set("re_registration_token", 0)
+
+ #import epdb; epdb.serve(port=9999)
# now if we have a token, load the extra registration
# information from the token
@@ -369,7 +371,7 @@ class Registration(rhnHandler):
# without a base channel.
try:
# don't commit
- newserv.save(0, channel)
+ newserv.save(0, channel, pre_commit = 1)
except (rhnChannel.SubscriptionCountExceeded,
rhnChannel.NoBaseChannelError), channel_error:
raise rhnFault(70)
@@ -408,7 +410,7 @@ class Registration(rhnHandler):
# |
# +--rhnNoSystemEntitlementsException
try:
- newserv.save(1, channel)
+ newserv.save(1, channel, pre_commit = 1)
except (rhnChannel.SubscriptionCountExceeded,
rhnChannel.NoBaseChannelError), channel_error:
raise rhnFault(70)
diff --git a/backend/server/rhnChannel.py b/backend/server/rhnChannel.py
index dec0ca3..b95d5f5 100644
--- a/backend/server/rhnChannel.py
+++ b/backend/server/rhnChannel.py
@@ -13,7 +13,7 @@
# in this software or its documentation.
#
#
-
+import xmlrpclib
import time
import string
import rpm
@@ -31,6 +31,8 @@ from rhnDependency import MakeEvrError
# local module
import rhnUser, rhnSQL, rhnLib
+XMLRPC = xmlrpclib.Server("http://localhost:8080/rhn/rpc/internal")
+
class NoBaseChannelError(Exception):
pass
@@ -1732,10 +1734,11 @@ def get_obsoletes_blacklist(channel):
# small wrapper around a PL/SQL function
def _subscribe_sql(server_id, channel_id, commit = 1):
log_debug(3, server_id, channel_id, commit)
- subscribe_channel = rhnSQL.Procedure("rhn_channel.subscribe_server")
+
+
try:
# don't run the EC yet
- subscribe_channel(server_id, channel_id, 0)
+ XMLRPC.channel.subscribe_no_user(int(server_id), int(channel_id))
except rhnSQL.SQLSchemaError, e:
if e.errno == 20235: # channel_family_no_subscriptions
raise SubscriptionCountExceeded(channel_id=channel_id)
diff --git a/backend/server/rhnServer/server_class.py
b/backend/server/rhnServer/server_class.py
index b68be4d..b983600 100644
--- a/backend/server/rhnServer/server_class.py
+++ b/backend/server/rhnServer/server_class.py
@@ -492,7 +492,7 @@ class Server(ServerWrapper):
rhnSQL.commit()
# Save this record in the database
- def __save(self, channel):
+ def __save(self, channel, pre_commit = 0):
if self.server.real:
server_id = self.server["id"]
self.server.save()
@@ -534,6 +534,9 @@ class Server(ServerWrapper):
# to allow us to not have to pass in none_ok=1 in any case
#
# This can now throw exceptions which will be caught at a higher level
+ if pre_commit:
+ rhnSQL.commit()
+
if channel is not None:
channel_info = dict(rhnChannel.channel_info(channel))
log_debug(4, "eus channel id %s" % str(channel_info))
@@ -567,13 +570,13 @@ class Server(ServerWrapper):
# This is a wrapper for the above class that allows us to rollback
# any changes in case we don't succeed completely
- def save(self, commit = 1, channel = None):
+ def save(self, commit = 1, channel = None, pre_commit = 0):
log_debug(3)
# attempt to preserve pending changes before we were called,
# so we set up our own transaction checkpoint
rhnSQL.transaction("save_server")
try:
- self.__save(channel)
+ self.__save(channel, pre_commit = pre_commit)
except: # roll back to what we have before and raise again
rhnSQL.rollback("save_server")
# shoot the exception up the chain
diff --git
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/internal/ChannelProcedureHandler.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/internal/ChannelProcedureHandler.java
index 1a25382..9ecbec2 100644
---
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/internal/ChannelProcedureHandler.java
+++
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/internal/ChannelProcedureHandler.java
@@ -15,7 +15,9 @@
package com.redhat.rhn.frontend.xmlrpc.channel.internal;
import com.redhat.rhn.domain.channel.Channel;
+import com.redhat.rhn.domain.channel.ChannelFactory;
import com.redhat.rhn.domain.server.Server;
+import com.redhat.rhn.domain.server.ServerFactory;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.domain.user.UserFactory;
import com.redhat.rhn.frontend.xmlrpc.BaseHandler;
@@ -36,7 +38,7 @@ public class ChannelProcedureHandler extends BaseHandler {
* @param userId the id of the user
* @return 1 on success exception otherwise
*/
- public int subscribeChannelToSystem(Integer serverId,
+ public int subscribe(Integer serverId,
Integer channelId, Integer userId) {
User user = UserFactory.lookupById(userId.longValue());
Channel channel = ChannelManager.lookupByIdAndUser(channelId.longValue(), user);
@@ -52,4 +54,19 @@ public class ChannelProcedureHandler extends BaseHandler {
return 1;
}
+
+ /**
+ * Runs the subscribe channel procedure
+ * @param serverId the id of the server
+ * @param channelId the id of the channel
+ * @return 1 on success exception otherwise
+ */
+ public int subscribeNoUser(Integer serverId,
+ Integer channelId) {
+
+ Channel channel = ChannelFactory.lookupById(channelId.longValue());
+ Server server = ServerFactory.lookupById(serverId.longValue());
+ SystemManager.subscribeServerToChannel(null, server, channel);
+ return 1;
+ }
}