client/rhel
by Justin Sherrill
client/rhel/rhnsd/rhnsd.c | 118 +++++++++++++++++++++++++++++++++++++++++--
client/rhel/rhnsd/rhnsd.init | 2
2 files changed, 115 insertions(+), 5 deletions(-)
New commits:
commit 941dce7fb5b2c544e2a93de9d63e207038d20f8f
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Nov 30 17:35:02 2009 -0500
502234 - fixing issue where the rhnsd init script would fail to reload the configuration, a forward port of a patch from rhel 4
diff --git a/client/rhel/rhnsd/rhnsd.c b/client/rhel/rhnsd/rhnsd.c
index d41f7a0..c2d0583 100644
--- a/client/rhel/rhnsd/rhnsd.c
+++ b/client/rhel/rhnsd/rhnsd.c
@@ -26,10 +26,12 @@
#include <sys/wait.h>
#include <sys/time.h>
#include <time.h>
+#include <limits.h>
#include <regex.h>
#define RHN_CHECK "/usr/sbin/rhn_check" /* XXX: fix me */
#define RHN_UP2DATE "/etc/sysconfig/rhn/up2date"
+#define RHNSD_CONFIG_FILE "/etc/sysconfig/rhn/rhnsd"
#define MAX_PATH_SIZE 512
@@ -64,6 +66,16 @@ static const char doc[] = N_("Red Hat Network Services Daemon");
#define PROGRAM "rhnsd"
#define VERSION "1.0.2"
+/* Configuration parameters */
+static const char* param_name_interval = "interval";
+
+typedef struct _config_param
+{
+ char *key;
+ char *data;
+} config_param;
+
+
/* Prototype for option handler. */
static error_t parse_opt __P ((int key, char *arg, struct argp_state *state));
@@ -76,10 +88,14 @@ static struct argp argp = {
static void termination_handler (int);
static int rhn_init(void);
static int rhn_do_action(void);
+static void read_configuration();
+static void setInterval(char *arg);
+
static int parse_systemid_path(char* systemid_path, int systemid_path_length);
static void set_signal_handlers (void);
static void unset_signal_handlers (void);
+static void SIGHUP_handler(int);
/* Arguments */
#define MIN_INTERVAL 1 /* minimal sane interval; RHN will blacklist
@@ -109,6 +125,11 @@ int main (int argc, char **argv)
bindtextdomain(PROGRAM, "/usr/share/locale");
textdomain(PROGRAM);
+ /* Read default configuration file and allow command line
+ * options to override initial configuration file entries
+ **/
+ read_configuration();
+
/* Parse and process arguments. */
argp_parse(&argp, argc, argv, 0, &remaining, NULL);
@@ -191,6 +212,8 @@ int main (int argc, char **argv)
}
}
+
+
/* Handle program arguments. */
static error_t
parse_opt (int key, char *arg, struct argp_state *state)
@@ -203,11 +226,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
case 'i':
/* --interval */
- interval = atoi(arg);
- if (interval < MIN_INTERVAL) {
- interval = MIN_INTERVAL;
- syslog(LOG_WARNING, "you cannot specify a minimum interval less than %d, interval adjusted.", MIN_INTERVAL);
- }
+ setInterval(arg);
break;
case 'v':
@@ -293,6 +312,7 @@ set_signal_handlers (void)
signal (SIGQUIT, termination_handler);
signal (SIGTERM, termination_handler);
signal (SIGPIPE, SIG_IGN);
+ signal (SIGHUP, SIGHUP_handler);
}
static void
@@ -302,6 +322,7 @@ unset_signal_handlers (void)
signal (SIGQUIT, SIG_DFL);
signal (SIGTERM, SIG_DFL);
signal (SIGPIPE, SIG_DFL);
+ signal (SIGHUP, SIG_DFL);
}
/* XXX: fix me up */
@@ -472,6 +493,93 @@ static int rhn_do_action(void)
return 0;
}
+
+
+static void setInterval(char *arg)
+{
+ interval = atoi(arg);
+ if (interval < MIN_INTERVAL) {
+ interval = MIN_INTERVAL;
+ syslog(LOG_WARNING, "you cannot specify a minimum interval less than %d, interval adjusted.", MIN_INTERVAL);
+ }
+ syslog(LOG_NOTICE, "%s running with check_in interval set to %d seconds.", doc, interval);
+}
+
+static int skipLine(char *line)
+{
+ if (line == NULL) {
+ return 1;
+ }
+ // Detect a Comment
+ if (line[0] == '#') {
+ return 1;
+ }
+ return 0;
+}
+
+/*
+ * Returns a key/value pair of a configuration item, or NULL.
+ * Expected format of config entries is:
+ * KEY=VALUE
+ */
+static config_param *parseLine(char *line)
+{
+ if (skipLine(line)) {
+ return NULL;
+ }
+
+ config_param *cp = malloc(sizeof(config_param));
+ char delim[] = "=";
+ char *dup = strdup(line);
+ cp->key = strsep(&dup, delim);
+ if (cp->key == NULL) {
+ free(dup);
+ return NULL;
+ }
+ int index;
+ // Cast all keys to lowercase
+ for (index = 0; index < strlen(cp->key); index++) {
+ cp->key[index] = tolower(cp->key[index]);
+ }
+
+ cp->data = strsep(&dup, delim);
+ if (cp->data == NULL) {
+ free(dup);
+ return NULL;
+ }
+ free(dup);
+ return cp;
+}
+
+static void read_configuration()
+{
+ FILE *config = fopen(RHNSD_CONFIG_FILE, "r");
+ if (config == NULL) {
+ syslog(LOG_ERR, "Error reading configuraton file, %s", RHNSD_CONFIG_FILE);
+ syslog(LOG_ERR, "%s", strerror(errno));
+ return;
+ }
+ char line[LINE_MAX];
+ while (fgets(line, LINE_MAX, config) != NULL) {
+ config_param *cp = parseLine(line);
+ if (cp == NULL) {
+ continue;
+ }
+ if (strncmp(param_name_interval, cp->key, strlen(param_name_interval)) == 0) {
+ setInterval(cp->data);
+ }
+ free(cp);
+ }
+ fclose(config);
+}
+
+static void SIGHUP_handler(int signum)
+{
+ read_configuration();
+}
+
+
+
#define MAX_CONFIG_LINE_SIZE (2*MAX_PATH_SIZE)
#define SYSTEMID_NMATCH 2
/* parse systemIdPath from the up2date configuration file */
diff --git a/client/rhel/rhnsd/rhnsd.init b/client/rhel/rhnsd/rhnsd.init
index 19dbc7d..31e6d3f 100644
--- a/client/rhel/rhnsd/rhnsd.init
+++ b/client/rhel/rhnsd/rhnsd.init
@@ -91,8 +91,10 @@ case "$1" in
fi
;;
reload)
+ echo -n $"Reloading Red Hat Network Daemon: "
killproc rhnsd -HUP
RETVAL=$?
+ echo
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload}"
13 years, 6 months
java/code
by Justin Sherrill
java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java | 8 ++--
java/code/src/com/redhat/rhn/manager/system/SystemManager.java | 17 ++++++++++
2 files changed, 22 insertions(+), 3 deletions(-)
New commits:
commit 83f534f7dac8430e19c846cbaa698a49b379e848
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Nov 30 17:01:21 2009 -0500
542830 - fixing three api calls that were using very inefficient queries to use the same queries that were used in sat 5.2
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 d8b2ca6..7c15aec 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
@@ -521,7 +521,7 @@ public class SystemHandler extends BaseHandler {
*/
public Object[] listSystems(String sessionKey) throws FaultException {
User loggedInUser = getLoggedInUser(sessionKey);
- DataResult<SystemOverview> dr = SystemManager.systemList(loggedInUser, null);
+ DataResult<SystemOverview> dr = SystemManager.systemListShort(loggedInUser, null);
dr.elaborate();
return dr.toArray();
}
@@ -1323,7 +1323,7 @@ public class SystemHandler extends BaseHandler {
// Get the logged in user
User loggedInUser = getLoggedInUser(sessionKey);
User target = XmlRpcUserHelper.getInstance().lookupTargetUser(loggedInUser, login);
- return getUserSystemsList(target);
+ return SystemManager.systemListShort(target, null);
}
/**
@@ -1341,11 +1341,13 @@ public class SystemHandler extends BaseHandler {
public List listUserSystems(String sessionKey) {
// Get the logged in user
User loggedInUser = getLoggedInUser(sessionKey);
- return getUserSystemsList(loggedInUser);
+ return SystemManager.systemListShort(loggedInUser, null);
}
/**
* Private helper method to get a list of systems for a particular user
+ * The query used is very inefficient. Only use it when you need a lot
+ * of information about the systems.
* @param user The user to lookup
* @return An array of SystemOverview objects representing a system
*/
diff --git a/java/code/src/com/redhat/rhn/manager/system/SystemManager.java b/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
index 8f2bc99..74a3b2c 100644
--- a/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
+++ b/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
@@ -287,6 +287,23 @@ public class SystemManager extends BaseManager {
Map elabParams = new HashMap();
return makeDataResult(params, elabParams, pc, m);
}
+
+ /**
+ * Returns list of all systems visible to user.
+ * This is meant to be fast and only gets the id, name, and last checkin
+ * @param user Currently logged in user.
+ * @param pc PageControl
+ * @return list of SystemOverviews.
+ */
+ public static DataResult systemListShort(User user, PageControl pc) {
+ SelectMode m = ModeFactory.getMode("System_queries", "xmlrpc_visible_to_user",
+ SystemOverview.class);
+ Map params = new HashMap();
+ params.put("user_id", user.getId());
+ Map elabParams = new HashMap();
+
+ return makeDataResult(params, elabParams, pc, m);
+ }
/**
* Returns a list of all systems
13 years, 6 months
4 commits - java/code scripts/channel-to-update-level
by Justin Sherrill
java/code/src/com/redhat/rhn/common/hibernate/HibernateFactory.java | 48 ++++++
java/code/src/com/redhat/rhn/domain/errata/ErrataFactory.java | 12 +
java/code/src/com/redhat/rhn/domain/errata/impl/PublishedErrata.hbm.xml | 5
java/code/src/com/redhat/rhn/domain/server/ServerFactory.java | 33 ----
java/code/src/com/redhat/rhn/frontend/action/systems/ErrataConfirmSetupAction.java | 73 ++++------
java/code/src/com/redhat/rhn/manager/system/SystemManager.java | 4
java/code/webapp/WEB-INF/pages/systems/errataconfirm.jsp | 8 -
scripts/channel-to-update-level/create-channel-update | 2
8 files changed, 112 insertions(+), 73 deletions(-)
New commits:
commit 2e303d0f35bd3dd2b6b7551f79a5bade8ce87e3c
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Nov 30 13:40:40 2009 -0500
converting old hibernate max in clause limit fix to use new fix
diff --git a/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java b/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
index 2e5b87f..efbe49b 100644
--- a/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
@@ -29,8 +29,6 @@ import com.redhat.rhn.frontend.xmlrpc.ChannelSubscriptionException;
import com.redhat.rhn.manager.rhnset.RhnSetDecl;
import com.redhat.rhn.manager.system.UpdateBaseChannelCommand;
-import java.util.LinkedList;
-
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.hibernate.Query;
@@ -39,10 +37,10 @@ import org.hibernate.Session;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -748,30 +746,8 @@ public class ServerFactory extends HibernateFactory {
* @return list of system ids that are solaris systems
*/
public static List<Long> listSolarisSystems(Collection<Long> systemIds) {
- return listGenericSystems(systemIds, "Server.listSolarisSystems");
- }
-
-
-
- private static List<Long> listGenericSystems(Collection<Long> systemIds, String query) {
- //Hibernate can't handle empty lists for in clauses, silly hibernate
- if (systemIds.isEmpty()) {
- return Collections.EMPTY_LIST;
- }
- ArrayList<Long> tmpList = new ArrayList<Long>();
- List<Long> toRet = new ArrayList<Long>();
- tmpList.addAll(systemIds);
-
- for (int i = 0; i < systemIds.size();) {
- int initial = i;
- int fin = i + 500 < systemIds.size() ? i + 500 : systemIds.size();
- List<Long> sublist = tmpList.subList(i, fin);
- toRet.addAll(ServerFactory.getSession().getNamedQuery(query).
- setParameterList("sids", sublist).list());
- i = fin;
- }
-
- return toRet;
+ return singleton.listObjectsByNamedQuery("Server.listSolarisSystems",
+ new HashMap(), systemIds, "sids");
}
/**
@@ -781,7 +757,8 @@ public class ServerFactory extends HibernateFactory {
* @return list of system ids that are linux systems
*/
public static List<Long> listLinuxSystems(Collection<Long> systemIds) {
- return listGenericSystems(systemIds, "Server.listRedHatSystems");
+ return singleton.listObjectsByNamedQuery("Server.listRedHatSystems",
+ new HashMap(), systemIds, "sids");
}
}
commit 9f4dbe3d7e6224218a2cbfe5895fec100840c5e7
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Nov 30 13:40:01 2009 -0500
538559 - fixing issue where about 300 errata could not be applied to a system due to inefficient hibernate usage
diff --git a/java/code/src/com/redhat/rhn/common/hibernate/HibernateFactory.java b/java/code/src/com/redhat/rhn/common/hibernate/HibernateFactory.java
index 71dd50d..4a9b190 100644
--- a/java/code/src/com/redhat/rhn/common/hibernate/HibernateFactory.java
+++ b/java/code/src/com/redhat/rhn/common/hibernate/HibernateFactory.java
@@ -36,6 +36,9 @@ import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.sql.Blob;
import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -117,8 +120,12 @@ public abstract class HibernateFactory {
Set entrySet = parameters.entrySet();
for (Iterator itr = entrySet.iterator(); itr.hasNext();) {
Map.Entry entry = (Map.Entry) itr.next();
- if (entry.getValue() instanceof List) {
- query.setParameterList((String) entry.getKey(), (List) entry.getValue());
+ if (entry.getValue() instanceof Collection) {
+ Collection c = (Collection) entry.getValue();
+ if (c.size() > 100) {
+ LOG.error("Query exectued with Collection larger than 1000");
+ }
+ query.setParameterList((String) entry.getKey(), c);
}
else {
query.setParameter((String) entry.getKey(), entry.getValue());
@@ -196,6 +203,43 @@ public abstract class HibernateFactory {
* @param qryName Named query to use to find a list of objects.
* @param qryParams Map of named bind parameters whose keys are Strings. The
* map can also be null.
+ * @param col the collection to use as an inclause
+ * @param colLabel the label the collection will have
+ * @return List of objects returned by named query, or null if nothing
+ * found.
+ */
+ protected List listObjectsByNamedQuery(String qryName, Map qryParams,
+ Collection col, String colLabel) {
+
+ if (col.isEmpty()) {
+ return Collections.EMPTY_LIST;
+ }
+
+ ArrayList<Long> tmpList = new ArrayList<Long>();
+ List<Long> toRet = new ArrayList<Long>();
+ tmpList.addAll(col);
+
+ for (int i = 0; i < col.size();) {
+ int initial = i;
+ int fin = i + 500 < col.size() ? i + 500 : col.size();
+ List<Long> sublist = tmpList.subList(i, fin);
+
+ qryParams.put(colLabel, sublist);
+ toRet.addAll(listObjectsByNamedQuery(qryName, qryParams, false));
+ i = fin;
+ }
+ return toRet;
+ }
+
+
+
+ /**
+ * Using a named query, find all the objects matching the criteria within.
+ * Warning: This can be very expensive if the returned list is large. Use
+ * only for small tables with static data
+ * @param qryName Named query to use to find a list of objects.
+ * @param qryParams Map of named bind parameters whose keys are Strings. The
+ * map can also be null.
* @param cacheable if we should cache the results of this query
* @return List of objects returned by named query, or null if nothing
* found.
diff --git a/java/code/src/com/redhat/rhn/domain/errata/ErrataFactory.java b/java/code/src/com/redhat/rhn/domain/errata/ErrataFactory.java
index 08136ff..8482beb 100644
--- a/java/code/src/com/redhat/rhn/domain/errata/ErrataFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/errata/ErrataFactory.java
@@ -47,6 +47,7 @@ import org.hibernate.Query;
import org.hibernate.Session;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@@ -1030,5 +1031,16 @@ public class ErrataFactory extends HibernateFactory {
copyDetails(cloned, cloned.getOriginal(), true);
}
+ /**
+ * List errata objects by ID
+ * @param ids list of ids
+ * @return List of Errata Objects
+ */
+ public static List<Errata> listErrata(Collection<Long> ids) {
+ return singleton.listObjectsByNamedQuery("PublishedErrata.listByIds",
+ new HashMap(), ids, "list");
+ }
+
+
}
diff --git a/java/code/src/com/redhat/rhn/domain/errata/impl/PublishedErrata.hbm.xml b/java/code/src/com/redhat/rhn/domain/errata/impl/PublishedErrata.hbm.xml
index 70ccc7a..ddf7c66 100644
--- a/java/code/src/com/redhat/rhn/domain/errata/impl/PublishedErrata.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/errata/impl/PublishedErrata.hbm.xml
@@ -89,6 +89,11 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<![CDATA[from com.redhat.rhn.domain.errata.impl.PublishedErrata as e
where e.id = :id]]>
</query>
+ <query name="PublishedErrata.listByIds">
+ <![CDATA[from com.redhat.rhn.domain.errata.impl.PublishedErrata as e
+ where e.id in (:list)]]>
+ </query>
+
<query name="PublishedErrata.findByAdvisoryName">
<![CDATA[from com.redhat.rhn.domain.errata.impl.PublishedErrata as e
where e.advisoryName = :advisory]]>
diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/ErrataConfirmSetupAction.java b/java/code/src/com/redhat/rhn/frontend/action/systems/ErrataConfirmSetupAction.java
index 1c31544..4bf16b9 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/systems/ErrataConfirmSetupAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/systems/ErrataConfirmSetupAction.java
@@ -14,22 +14,20 @@
*/
package com.redhat.rhn.frontend.action.systems;
-import com.redhat.rhn.common.db.datasource.DataResult;
import com.redhat.rhn.common.util.DatePicker;
import com.redhat.rhn.domain.action.Action;
+import com.redhat.rhn.domain.errata.Errata;
+import com.redhat.rhn.domain.errata.ErrataFactory;
import com.redhat.rhn.domain.rhnset.RhnSet;
import com.redhat.rhn.domain.server.Server;
import com.redhat.rhn.domain.user.User;
-import com.redhat.rhn.frontend.dto.ErrataOverview;
-import com.redhat.rhn.frontend.listview.PageControl;
import com.redhat.rhn.frontend.struts.RequestContext;
+import com.redhat.rhn.frontend.struts.RhnAction;
import com.redhat.rhn.frontend.struts.RhnHelper;
-import com.redhat.rhn.frontend.struts.RhnListAction;
-import com.redhat.rhn.frontend.struts.RhnListSetHelper;
import com.redhat.rhn.frontend.struts.StrutsDelegate;
-import com.redhat.rhn.frontend.taglibs.list.ListTagHelper;
+import com.redhat.rhn.frontend.taglibs.list.helper.ListRhnSetHelper;
+import com.redhat.rhn.frontend.taglibs.list.helper.Listable;
import com.redhat.rhn.manager.action.ActionManager;
-import com.redhat.rhn.manager.errata.ErrataManager;
import com.redhat.rhn.manager.system.SystemManager;
import org.apache.struts.action.ActionForm;
@@ -39,8 +37,8 @@ import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.action.DynaActionForm;
-import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
@@ -50,9 +48,8 @@ import javax.servlet.http.HttpServletResponse;
* ErrataConfirmSetupAction
* @version $Rev$
*/
-public class ErrataConfirmSetupAction extends RhnListAction {
- public static final String DISPATCH = "dispatch";
- public static final String LIST_NAME = "errataConfirmList";
+public class ErrataConfirmSetupAction extends RhnAction implements Listable {
+
/** {@inheritDoc} */
public ActionForward execute(ActionMapping mapping,
@@ -62,13 +59,18 @@ public class ErrataConfirmSetupAction extends RhnListAction {
RequestContext requestContext = new RequestContext(request);
User user = requestContext.getLoggedInUser();
- RhnListSetHelper helper = new RhnListSetHelper(request);
+
+
Long sid = requestContext.getRequiredParam("sid");
RhnSet set = ErrataSetupAction.getSetDecl(sid).get(user);
+ Server server = SystemManager.lookupByIdAndUser(sid, user);
+
+ ListRhnSetHelper helper = new ListRhnSetHelper(this, request,
+ ErrataSetupAction.getSetDecl(sid));
+ helper.setWillClearSet(false);
+ helper.execute();
- if (request.getParameter(DISPATCH) != null) {
- // if its one of the Dispatch actions handle it..
- helper.updateSet(set, LIST_NAME);
+ if (helper.isDispatched()) {
if (!set.isEmpty()) {
return confirmErrata(mapping, formIn, request, response);
}
@@ -76,26 +78,12 @@ public class ErrataConfirmSetupAction extends RhnListAction {
RhnHelper.handleEmptySelection(request);
}
}
-
-
-
- PageControl pc = new PageControl();
- clampListBounds(pc, request, user);
- pc.setPageSize(set.size());
-
- Server server = SystemManager.lookupByIdAndUser(sid, user);
- DataResult dr = SystemManager.errataInSet(user,
- ErrataSetupAction.getSetDecl(sid).getLabel(), pc);
- dr.setElaborationParams(Collections.EMPTY_MAP);
//Setup the datepicker widget
DatePicker picker = getStrutsDelegate().prepopulateDatePicker(request,
(DynaActionForm)formIn, "date", DatePicker.YEAR_RANGE_POSITIVE);
request.setAttribute("date", picker);
-
- request.setAttribute("pageList", dr);
request.setAttribute("system", server);
- request.setAttribute(ListTagHelper.PARENT_URL, request.getRequestURI());
return getStrutsDelegate().forwardParams(mapping.findForward("default"),
request.getParameterMap());
@@ -125,15 +113,13 @@ public class ErrataConfirmSetupAction extends RhnListAction {
Map hparams = new HashMap();
Server server = SystemManager.lookupByIdAndUser(sid, user);
- DataResult errata = SystemManager.errataInSet(user,
- ErrataSetupAction.getSetDecl(sid) .getLabel(), null);
+ RhnSet set = ErrataSetupAction.getSetDecl(sid).get(user);
+ List<Errata> errataList = ErrataFactory.listErrata(set.getElementValues());
- if (server != null && !errata.isEmpty()) {
- for (int i = 0; i < errata.size(); i++) {
- Action update = ActionManager.createErrataAction(user, ErrataManager
- .lookupErrata(new Long(((ErrataOverview)errata.get(i))
- .getId().longValue()), user));
+ if (server != null && !errataList.isEmpty()) {
+ for (Errata e : errataList) {
+ Action update = ActionManager.createErrataAction(user, e);
ActionManager.addServerToAction(server.getId(), update);
update.setEarliestAction(getStrutsDelegate().readDatePicker(form, "date",
DatePicker.YEAR_RANGE_POSITIVE));
@@ -142,12 +128,12 @@ public class ErrataConfirmSetupAction extends RhnListAction {
ActionMessages msg = new ActionMessages();
Object[] args = new Object[3];
- args[0] = new Long(errata.size());
+ args[0] = new Long(errataList.size());
args[1] = server.getName();
args[2] = server.getId().toString();
StringBuffer messageKey = new StringBuffer("errata.schedule");
- if (errata.size() != 1) {
+ if (errataList.size() != 1) {
messageKey = messageKey.append(".plural");
}
@@ -185,5 +171,16 @@ public class ErrataConfirmSetupAction extends RhnListAction {
}
return params;
}
+
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public List getResult(RequestContext context) {
+ Long sid = context.getParamAsLong("sid");
+ return SystemManager.errataInSet(context.getLoggedInUser(),
+ ErrataSetupAction.getSetDecl(sid).getLabel(), null);
+ }
}
diff --git a/java/code/src/com/redhat/rhn/manager/system/SystemManager.java b/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
index 6e1221c..8f2bc99 100644
--- a/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
+++ b/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
@@ -849,7 +849,9 @@ public class SystemManager extends BaseManager {
Map elabParams = new HashMap();
elabParams.put("user_id", user.getId());
- return makeDataResult(params, elabParams, pc, m);
+ DataResult dr = m.execute(params);
+ dr.setElaborationParams(elabParams);
+ return dr;
}
/**
diff --git a/java/code/webapp/WEB-INF/pages/systems/errataconfirm.jsp b/java/code/webapp/WEB-INF/pages/systems/errataconfirm.jsp
index 91742b4..f6348c7 100644
--- a/java/code/webapp/WEB-INF/pages/systems/errataconfirm.jsp
+++ b/java/code/webapp/WEB-INF/pages/systems/errataconfirm.jsp
@@ -19,13 +19,13 @@
<rl:listset name="erratConfirmListSet">
- <rl:list dataset="pageList"
+ <rl:list
width="100%"
- name="errataConfirmList"
styleclass="list"
emptykey="erratalist.jsp.noerrata">
<rl:decorator name="PageSizeDecorator"/>
+ <rl:decorator name="ElaborationDecorator"/>
<rl:column headerkey="erratalist.jsp.type" styleclass="first-column text-align: center;">
<c:if test="${current.securityAdvisory}">
commit 2fcc1109fa8d197f8820f6155f722b0381518b78
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Tue Nov 24 18:57:11 2009 -0500
fixing list borders on errata apply confirm page
diff --git a/java/code/webapp/WEB-INF/pages/systems/errataconfirm.jsp b/java/code/webapp/WEB-INF/pages/systems/errataconfirm.jsp
index 162a0aa..91742b4 100644
--- a/java/code/webapp/WEB-INF/pages/systems/errataconfirm.jsp
+++ b/java/code/webapp/WEB-INF/pages/systems/errataconfirm.jsp
@@ -27,7 +27,7 @@
<rl:decorator name="PageSizeDecorator"/>
- <rl:column headerkey="erratalist.jsp.type" styleclass="text-align: center;">
+ <rl:column headerkey="erratalist.jsp.type" styleclass="first-column text-align: center;">
<c:if test="${current.securityAdvisory}">
<img src="/img/wrh-security.gif"
title="<bean:message key="erratalist.jsp.securityadvisory"/>" />
@@ -51,7 +51,7 @@
${current.advisorySynopsis}
</rl:column>
- <rl:column headerkey="erratalist.jsp.updated">
+ <rl:column headerkey="erratalist.jsp.updated" styleclass="last-column">
${current.updateDate}
</rl:column>
</rl:list>
commit 9e170616b0d7da97f5a29313cd8298e24ed41a0d
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Tue Nov 24 18:52:01 2009 -0500
fixing cluster-storage src channel search
diff --git a/scripts/channel-to-update-level/create-channel-update b/scripts/channel-to-update-level/create-channel-update
index 9c16ca1..a64c1ca 100755
--- a/scripts/channel-to-update-level/create-channel-update
+++ b/scripts/channel-to-update-level/create-channel-update
@@ -343,6 +343,8 @@ def findSrcChan(version, release, arch, extra = None):
return "rhel-%s-%s-%s" % (arch, low_release, version)
else: #else we do, so lets process that
low_extra = extra.lower()
+ if low_extra == "clusterstorage":
+ low_extra = "cluster-storage"
if low_extra == "extra":
return "rhel-%s-%s-%s-%s" % (arch, low_release, version, low_extra)
else:
13 years, 6 months
Changes to 'refs/tags/spacewalk-schema-0.7.7-1'
by Milan Zazrivec
Tag 'spacewalk-schema-0.7.7-1' created by Milan Zazrivec <mzazrivec(a)redhat.com> at 2009-11-30 16:22 +0000
Tagging package [spacewalk-schema] version [0.7.7-1] in directory [schema/spacewalk/].
Changes since SatConfig-cluster-1.54.8-1:
Milan Zazrivec (6):
Revert "Fix numeric/smallint incompatible types in PostgreSQL."
476851 - drop unneeded synonyms during schema upgrade
rename schema upgrade script to use uniform .sql extension
add missing relationship
add missing package body upgrade scripts
Automatic commit of package [spacewalk-schema] release [0.7.7-1].
---
rel-eng/packages/spacewalk-schema | 2
schema/spacewalk/common/tables/rhn_contact_group_members.sql | 6
schema/spacewalk/common/tables/rhn_ll_netsaint.sql | 2
schema/spacewalk/common/tables/rhn_probe_param_value.sql | 4
schema/spacewalk/postgres/procs/rhn_prepare_install.sql | 2
schema/spacewalk/spacewalk-schema.spec | 5
schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/001-numeric-12-columns.sql | 8
schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/002-rhn_db_environment-rhn_environment-drop.sql | 3
schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/160-rhn_cache.pkb | 102
schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/160-rhn_cache.pkb.sql | 103
schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/161-rhn_server.pkb.sql | 735 +++++
schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/162-rhn_channel.pkb.sql | 1229 ++++++++++
12 files changed, 2082 insertions(+), 119 deletions(-)
---
13 years, 6 months
rel-eng/packages schema/spacewalk
by Milan Zazrivec
rel-eng/packages/spacewalk-schema | 2 +-
schema/spacewalk/spacewalk-schema.spec | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
New commits:
commit b3d5dbc873e24b7e2f0fdce8d9c13c3b255f38d8
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Mon Nov 30 17:22:27 2009 +0100
Automatic commit of package [spacewalk-schema] release [0.7.7-1].
diff --git a/rel-eng/packages/spacewalk-schema b/rel-eng/packages/spacewalk-schema
index 1ad2c7d..84fe8b4 100644
--- a/rel-eng/packages/spacewalk-schema
+++ b/rel-eng/packages/spacewalk-schema
@@ -1 +1 @@
-0.7.6-1 schema/spacewalk/
+0.7.7-1 schema/spacewalk/
diff --git a/schema/spacewalk/spacewalk-schema.spec b/schema/spacewalk/spacewalk-schema.spec
index c981165..749ce86 100644
--- a/schema/spacewalk/spacewalk-schema.spec
+++ b/schema/spacewalk/spacewalk-schema.spec
@@ -2,7 +2,7 @@ Name: spacewalk-schema
Group: Applications/Internet
Summary: Oracle SQL schema for Spacewalk server
-Version: 0.7.6
+Version: 0.7.7
Release: 1%{?dist}
Source0: %{name}-%{version}.tar.gz
@@ -58,6 +58,9 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man1/spacewalk-schema-upgrade*
%changelog
+* Mon Nov 30 2009 Milan Zazrivec <mzazrivec(a)redhat.com> 0.7.7-1
+- schema upgrade fixes for Spacewalk 0.7
+
* Thu Nov 19 2009 Michael Mraka <michael.mraka(a)redhat.com> 0.7.6-1
- replaced cursors + for loops with already written bulk procedure
- removed cartesian join
13 years, 6 months
3 commits - schema/spacewalk
by Milan Zazrivec
schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/160-rhn_cache.pkb | 102
schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/160-rhn_cache.pkb.sql | 103
schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/161-rhn_server.pkb.sql | 735 +++++
schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/162-rhn_channel.pkb.sql | 1229 ++++++++++
4 files changed, 2067 insertions(+), 102 deletions(-)
New commits:
commit e0b600c88bfe448868e2a7d5db38ef72b59c7adf
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Mon Nov 30 16:22:33 2009 +0100
add missing package body upgrade scripts
What we were missing were upgrades for following two package bodies:
- rhn_server
- rhn_channel
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/161-rhn_server.pkb.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/161-rhn_server.pkb.sql
new file mode 100644
index 0000000..293bf8b
--- /dev/null
+++ b/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/161-rhn_server.pkb.sql
@@ -0,0 +1,735 @@
+--
+-- Copyright (c) 2008 Red Hat, Inc.
+--
+-- This software is licensed to you under the GNU General Public License,
+-- version 2 (GPLv2). There is NO WARRANTY for this software, express or
+-- implied, including the implied warranties of MERCHANTABILITY or FITNESS
+-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+-- along with this software; if not, see
+-- http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+--
+-- Red Hat trademarks are not licensed under GPLv2. No permission is
+-- granted to use or replicate Red Hat trademarks that are incorporated
+-- in this software or its documentation.
+--
+--
+--
+--
+
+create or replace
+package body rhn_server
+is
+ function system_service_level(
+ server_id_in in number,
+ service_level_in in varchar2
+ ) return number is
+
+ cursor ents is
+ select label from rhnServerEntitlementView
+ where server_id = server_id_in;
+
+ retval number := 0;
+
+ begin
+ for ent in ents loop
+ retval := rhn_entitlements.entitlement_grants_service (ent.label, service_level_in);
+ if retval = 1 then
+ return retval;
+ end if;
+ end loop;
+
+ return retval;
+
+ end system_service_level;
+
+
+ function can_change_base_channel(server_id_in IN NUMBER)
+ return number
+ is
+ throwaway number;
+ begin
+ -- the idea: if we get past this query, the server is
+ -- neither sat nor proxy, so base channel is changeable
+
+ select 1 into throwaway
+ from rhnServer S
+ where S.id = server_id_in
+ and not exists (select 1 from rhnSatelliteInfo SI where SI.server_id = S.id)
+ and not exists (select 1 from rhnProxyInfo PI where PI.server_id = S.id);
+
+ return 1;
+ exception
+ when no_data_found
+ then
+ return 0;
+ end can_change_base_channel;
+
+ procedure set_custom_value(
+ server_id_in in number,
+ user_id_in in number,
+ key_label_in in varchar2,
+ value_in in varchar2
+ ) is
+ key_id_val number;
+ begin
+ select CDK.id into key_id_val
+ from rhnCustomDataKey CDK,
+ rhnServer S
+ where S.id = server_id_in
+ and S.org_id = CDK.org_id
+ and CDK.label = key_label_in;
+
+ begin
+ insert into rhnServerCustomDataValue (server_id, key_id, value, created_by, last_modified_by)
+ values (server_id_in, key_id_val, value_in, user_id_in, user_id_in);
+ exception
+ when DUP_VAL_ON_INDEX
+ then
+ update rhnServerCustomDataValue
+ set value = value_in,
+ last_modified_by = user_id_in
+ where server_id = server_id_in
+ and key_id = key_id_val;
+ end;
+
+ end set_custom_value;
+
+ function bulk_set_custom_value(
+ key_label_in in varchar2,
+ value_in in varchar2,
+ set_label_in in varchar2,
+ set_uid_in in number
+ )
+ return integer
+ is
+ i integer := 0;
+ begin
+ i := 0;
+ for server in rhn_set.set_iterator(set_label_in, set_uid_in)
+ loop
+ if rhn_server.system_service_level(server.element, 'provisioning') = 1 then
+ rhn_server.set_custom_value(server.element, set_uid_in, key_label_in, value_in);
+ i := i + 1;
+ end if;
+ end loop server;
+ return i;
+ end bulk_set_custom_value;
+
+ procedure bulk_snapshot_tag(
+ org_id_in in number,
+ tagname_in in varchar2,
+ set_label_in in varchar2,
+ set_uid_in in number
+ ) is
+ snapshot_id number;
+ begin
+ for server in rhn_set.set_iterator(set_label_in, set_uid_in)
+ loop
+ if rhn_server.system_service_level(server.element, 'provisioning') = 1 then
+ begin
+ select max(id) into snapshot_id
+ from rhnSnapshot
+ where server_id = server.element;
+ exception
+ when NO_DATA_FOUND then
+ rhn_server.snapshot_server(server.element, 'tagging system: ' || tagname_in);
+
+ select max(id) into snapshot_id
+ from rhnSnapshot
+ where server_id = server.element;
+ end;
+
+ -- now have a snapshot_id to work with...
+ begin
+ rhn_server.tag_snapshot(snapshot_id, org_id_in, tagname_in);
+ exception
+ when DUP_VAL_ON_INDEX
+ then
+ -- do nothing, be forgiving...
+ null;
+ end;
+ end if;
+ end loop server;
+ end bulk_snapshot_tag;
+
+ procedure tag_delete(
+ server_id_in in number,
+ tag_id_in in number
+ ) is
+ cursor snapshots is
+ select snapshot_id
+ from rhnSnapshotTag
+ where tag_id = tag_id_in;
+ tag_id_tmp number;
+ begin
+ select id into tag_id_tmp
+ from rhnTag
+ where id = tag_id_in
+ for update;
+
+ delete
+ from rhnSnapshotTag
+ where server_id = server_id_in
+ and tag_id = tag_id_in;
+ for snapshot in snapshots loop
+ return;
+ end loop;
+ delete
+ from rhnTag
+ where id = tag_id_in;
+ end tag_delete;
+
+ procedure tag_snapshot(
+ snapshot_id_in in number,
+ org_id_in in number,
+ tagname_in in varchar2
+ ) is
+ begin
+ insert into rhnSnapshotTag (snapshot_id, server_id, tag_id)
+ select snapshot_id_in, server_id, lookup_tag(org_id_in, tagname_in)
+ from rhnSnapshot
+ where id = snapshot_id_in;
+ end tag_snapshot;
+
+ procedure bulk_snapshot(
+ reason_in in varchar2,
+ set_label_in in varchar2,
+ set_uid_in in number
+ ) is
+ begin
+ for server in rhn_set.set_iterator(set_label_in, set_uid_in)
+ loop
+ if rhn_server.system_service_level(server.element, 'provisioning') = 1 then
+ rhn_server.snapshot_server(server.element, reason_in);
+ end if;
+ end loop server;
+ end bulk_snapshot;
+
+ procedure snapshot_server(
+ server_id_in in number,
+ reason_in in varchar2
+ ) is
+ snapshot_id number;
+ cursor revisions is
+ select distinct
+ cr.id
+ from rhnConfigRevision cr,
+ rhnConfigFileName cfn,
+ rhnConfigFile cf,
+ rhnConfigChannel cc,
+ rhnServerConfigChannel scc
+ where 1=1
+ and scc.server_id = server_id_in
+ and scc.config_channel_id = cc.id
+ and cc.id = cf.config_channel_id
+ and cf.id = cr.config_file_id
+ and cr.id = cf.latest_config_revision_id
+ and cf.config_file_name_id = cfn.id
+ and cf.id = lookup_first_matching_cf(scc.server_id, cfn.path);
+ locked integer;
+ begin
+ select rhn_snapshot_id_seq.nextval into snapshot_id from dual;
+
+ insert into rhnSnapshot (id, org_id, server_id, reason) (
+ select snapshot_id,
+ s.org_id,
+ server_id_in,
+ reason_in
+ from rhnServer s
+ where s.id = server_id_in
+ );
+ insert into rhnSnapshotChannel (snapshot_id, channel_id) (
+ select snapshot_id, sc.channel_id
+ from rhnServerChannel sc
+ where sc.server_id = server_id_in
+ );
+ insert into rhnSnapshotServerGroup (snapshot_id, server_group_id) (
+ select snapshot_id, sgm.server_group_id
+ from rhnServerGroupMembers sgm
+ where sgm.server_id = server_id_in
+ );
+ locked := 0;
+ while true loop
+ begin
+ insert into rhnPackageNEVRA (id, name_id, evr_id, package_arch_id)
+ select rhn_pkgnevra_id_seq.nextval, sp.name_id, sp.evr_id, sp.package_arch_id
+ from rhnServerPackage sp
+ where sp.server_id = server_id_in
+ and not exists
+ (select 1
+ from rhnPackageNEVRA nevra
+ where nevra.name_id = sp.name_id
+ and nevra.evr_id = sp.evr_id
+ and (nevra.package_arch_id = sp.package_arch_id
+ or (nevra.package_arch_id is null
+ and sp.package_arch_id is null)));
+ exit;
+ exception when dup_val_on_index then
+ if locked = 1 then
+ raise;
+ else
+ lock table rhnPackageNEVRA in exclusive mode;
+ locked := 1;
+ end if;
+ end;
+ end loop;
+ insert into rhnSnapshotPackage (snapshot_id, nevra_id) (
+ select distinct snapshot_id, nevra.id
+ from rhnServerPackage sp, rhnPackageNEVRA nevra
+ where sp.server_id = server_id_in
+ and nevra.name_id = sp.name_id
+ and nevra.evr_id = sp.evr_id
+ and (nevra.package_arch_id = sp.package_arch_id
+ or (nevra.package_arch_id is null
+ and sp.package_arch_id is null))
+ );
+
+ insert into rhnSnapshotConfigChannel ( snapshot_id, config_channel_id ) (
+ select snapshot_id, scc.config_channel_id
+ from rhnServerConfigChannel scc
+ where server_id = server_id_in
+ );
+
+ for revision in revisions loop
+ insert into rhnSnapshotConfigRevision (
+ snapshot_id, config_revision_id
+ ) values (
+ snapshot_id, revision.id
+ );
+ end loop;
+ end snapshot_server;
+
+ procedure remove_action(
+ server_id_in in number,
+ action_id_in in number
+ ) is
+ -- this really wants "nulls last", but 8.1.7.3.0 sucks ass.
+ -- instead, we make a local table that holds our
+ -- list of ids with null prereqs. There's surely a better way
+ -- (an array instead of a table maybe? who knows...)
+ -- but I've got code to do this handy that I can look at ;)
+ cursor chained_actions is
+ select id, prerequisite
+ from rhnAction
+ start with id = action_id_in
+ connect by prior id = prerequisite
+ order by prerequisite desc;
+ cursor sessions is
+ select s.id
+ from rhnKickstartSession s
+ where server_id_in in (s.old_server_id, s.new_server_id)
+ and s.action_id = action_id_in
+ and not exists (
+ select 1
+ from rhnKickstartSessionState ss
+ where ss.id = s.state_id
+ and ss.label in ('failed','complete')
+ );
+ type chain_end_type is table of number index by binary_integer;
+ chain_ends chain_end_type;
+ i number;
+ prereq number := 1;
+ begin
+ select prerequisite
+ into prereq
+ from rhnAction
+ where id = action_id_in;
+
+ if prereq is not null then
+ rhn_exception.raise_exception('action_is_child');
+ end if;
+
+ i := 0;
+ for action in chained_actions loop
+ if action.prerequisite is null then
+ chain_ends(i) := action.id;
+ i := i + 1;
+ else
+ delete from rhnServerAction
+ where server_id = server_id_in
+ and action_id = action.id;
+ end if;
+ end loop;
+ i := chain_ends.first;
+ while i is not null loop
+ delete from rhnServerAction
+ where server_id = server_id_in
+ and action_id = chain_ends(i);
+ i := chain_ends.next(i);
+ end loop;
+ for s in sessions loop
+ update rhnKickstartSession
+ set state_id = (
+ select id
+ from rhnKickstartSessionState
+ where label = 'failed'
+ ),
+ action_id = null
+ where id = s.id;
+ set_ks_session_history_message(s.id, 'failed', 'Kickstart cancelled due to action removal');
+ end loop;
+ end remove_action;
+
+ function check_user_access(server_id_in in number, user_id_in in number)
+ return number
+ is
+ has_access number;
+ begin
+ -- first check; if this returns no rows, then the server/user are in different orgs, and we bail
+ select 1 into has_access
+ from rhnServer S,
+ web_contact wc
+ where wc.org_id = s.org_id
+ and s.id = server_id_in
+ and wc.id = user_id_in;
+
+ -- okay, so they're in the same org. if we have an org admin, they get a free pass
+ if rhn_user.check_role(user_id_in, 'org_admin') = 1
+ then
+ return 1;
+ end if;
+
+ select 1 into has_access
+ from rhnServerGroupMembers SGM,
+ rhnUserServerGroupPerms USG
+ where SGM.server_group_id = USG.server_group_id
+ and SGM.server_id = server_id_in
+ and USG.user_id = user_id_in
+ and rownum = 1;
+
+ return 1;
+ exception
+ when no_data_found
+ then
+ return 0;
+ end check_user_access;
+
+ -- *******************************************************************
+ -- FUNCTION: can_server_consume_virt_slot
+ -- Returns 1 if the server id is eligible to consume a virtual slot,
+ -- else returns 0.
+ -- Called by: insert_into_servergroup, delete_from_servergroup
+ -- *******************************************************************
+ function can_server_consume_virt_slot(server_id_in in number,
+ group_type_in in
+ rhnServerGroupType.label%TYPE)
+ return number
+ is
+
+ cursor server_virt_slots is
+ select vi.VIRTUAL_SYSTEM_ID
+ from
+ rhnVirtualInstance vi
+ where
+ -- server id is a virtual instance
+ vi.VIRTUAL_SYSTEM_ID = server_id_in
+ -- server id's host is virt entitled
+ and exists ( select 1
+ from rhnServerEntitlementView sev
+ where vi.HOST_SYSTEM_ID = sev.server_id
+ and sev.label in ('virtualization_host',
+ 'virtualization_host_platform') )
+ -- server id's host also has the ent we want
+ and exists ( select 1
+ from rhnServerEntitlementView sev2
+ where vi.HOST_SYSTEM_ID = sev2.server_id
+ and sev2.label = group_type_in );
+
+ begin
+ for server_virt_slot in server_virt_slots loop
+ return 1;
+ end loop;
+ return 0;
+ end can_server_consume_virt_slot;
+
+
+ procedure insert_into_servergroup (
+ server_id_in in number,
+ server_group_id_in in number
+ ) is
+ used_slots number;
+ max_slots number;
+ org_id number;
+ mgmt_available number;
+ mgmt_upgrade number;
+ mgmt_sgid number;
+ prov_available number;
+ prov_upgrade number;
+ prov_sgid number;
+ group_label rhnServerGroupType.label%TYPE;
+ group_type number;
+ begin
+ -- frist, group_type = null, because it's easy...
+
+ -- this will rowlock the servergroup we're trying to change;
+ -- we probably need to lock the other one, but I think the chances
+ -- of it being a real issue are very small for now...
+ select sg.group_type, sg.org_id, sg.current_members, sg.max_members
+ into group_type, org_id, used_slots, max_slots
+ from rhnServerGroup sg
+ where sg.id = server_group_id_in
+ for update of sg.current_members;
+
+ if group_type is null then
+ if used_slots >= max_slots then
+ rhn_exception.raise_exception('servergroup_max_members');
+ end if;
+
+ insert into rhnServerGroupMembers(
+ server_id, server_group_id
+ ) values (
+ server_id_in, server_group_id_in
+ );
+ update rhnServerGroup
+ set current_members = current_members + 1
+ where id = server_group_id_in;
+
+ rhn_cache.update_perms_for_server_group(server_group_id_in);
+ return;
+ end if;
+
+ -- now for group_type != null
+ --
+ select label
+ into group_label
+ from rhnServerGroupType sgt
+ where sgt.id = group_type;
+
+ -- the naive easy path that gets hit most often and has to be quickest.
+ if group_label in ('sw_mgr_entitled',
+ 'enterprise_entitled',
+ 'monitoring_entitled',
+ 'provisioning_entitled',
+ 'virtualization_host',
+ 'virtualization_host_platform') then
+ if used_slots >= max_slots and
+ (can_server_consume_virt_slot(server_id_in, group_label) != 1)
+ then
+ rhn_exception.raise_exception('servergroup_max_members');
+ end if;
+
+ insert into rhnServerGroupMembers(
+ server_id, server_group_id
+ ) values (
+ server_id_in, server_group_id_in
+ );
+
+ -- Only update current members if the system in consuming a
+ -- physical slot.
+ if can_server_consume_virt_slot(server_id_in, group_label) = 0 then
+ update rhnServerGroup
+ set current_members = current_members + 1
+ where id = server_group_id_in;
+ end if;
+
+ return;
+ end if;
+ end;
+
+ function insert_into_servergroup_maybe (
+ server_id_in in number,
+ server_group_id_in in number
+ ) return number is
+ retval number := 0;
+ cursor servergroups is
+ select s.id server_id,
+ sg.id server_group_id
+ from rhnServerGroup sg,
+ rhnServer s
+ where s.id = server_id_in
+ and sg.id = server_group_id_in
+ and s.org_id = sg.org_id
+ and not exists (
+ select 1
+ from rhnServerGroupMembers sgm
+ where sgm.server_id = s.id
+ and sgm.server_group_id = sg.id
+ );
+ begin
+ for sgm in servergroups loop
+ rhn_server.insert_into_servergroup(sgm.server_id, sgm.server_group_id);
+ retval := retval + 1;
+ end loop;
+ return retval;
+ end insert_into_servergroup_maybe;
+
+ procedure insert_set_into_servergroup (
+ server_group_id_in in number,
+ user_id_in in number,
+ set_label_in in varchar2
+ ) is
+ cursor servers is
+ select st.element id
+ from rhnSet st
+ where st.user_id = user_id_in
+ and st.label = set_label_in
+ and exists (
+ select 1
+ from rhnUserManagedServerGroups umsg
+ where umsg.server_group_id = server_group_id_in
+ and umsg.user_id = user_id_in
+ )
+ and not exists (
+ select 1
+ from rhnServerGroupMembers sgm
+ where sgm.server_id = st.element
+ and sgm.server_group_id = server_group_id_in
+ );
+ begin
+ for s in servers loop
+ rhn_server.insert_into_servergroup(s.id, server_group_id_in);
+ end loop;
+ end insert_set_into_servergroup;
+
+ procedure delete_from_servergroup (
+ server_id_in in number,
+ server_group_id_in in number
+ ) is
+ cursor server_virt_groups is
+ select 1
+ from rhnServerEntitlementVirtual sev
+ where sev.server_id = server_id_in
+ and sev.server_group_id = server_group_id_in;
+
+ oid number;
+ mgmt_sgid number;
+ label rhnServerGroupType.label%TYPE;
+ group_type number;
+ begin
+ begin
+ select sg.group_type, sg.org_id
+ into group_type, oid
+ from rhnServerGroupMembers sgm,
+ rhnServerGroup sg
+ where sg.id = server_group_id_in
+ and sg.id = sgm.server_group_id
+ and sgm.server_id = server_id_in
+ for update of sg.current_members;
+ exception
+ when no_data_found then
+ rhn_exception.raise_exception('server_not_in_group');
+ end;
+
+ -- do group_type is null first
+ if group_type is null then
+ delete from rhnServerGroupMembers
+ where server_group_id = server_group_id_in
+ and server_id = server_id_in;
+ update rhnServerGroup
+ set current_members = current_members - 1
+ where id = server_group_id_in;
+ rhn_cache.update_perms_for_server_group(server_group_id_in);
+ return;
+ end if;
+
+ select sgt.label
+ into label
+ from rhnServerGroupType sgt
+ where sgt.id = group_type;
+
+ if label in ('sw_mgr_entitled',
+ 'enterprise_entitled',
+ 'provisioning_entitled',
+ 'monitoring_entitled',
+ 'virtualization_host',
+ 'virtualization_host_platform') then
+
+ -- Only update current members if the system is consuming
+ -- a physical slot.
+ for server_virt_group in server_virt_groups loop
+ delete from rhnServerGroupMembers
+ where server_group_id = server_group_id_in
+ and server_id = server_id_in;
+ return;
+ end loop;
+
+ delete from rhnServerGroupMembers
+ where server_group_id = server_group_id_in
+ and server_id = server_id_in;
+
+ update rhnServerGroup
+ set current_members = current_members - 1
+ where id = server_group_id_in;
+
+ end if;
+ end;
+
+ procedure delete_set_from_servergroup (
+ server_group_id_in in number,
+ user_id_in in number,
+ set_label_in in varchar2
+ ) is
+ cursor servergroups is
+ select sgm.server_id, sgm.server_group_id
+ from rhnSet st,
+ rhnServerGroupMembers sgm
+ where sgm.server_group_id = server_group_id_in
+ and st.user_id = user_id_in
+ and st.label = set_label_in
+ and sgm.server_id = st.element
+ and exists (
+ select 1
+ from rhnUserManagedServerGroups usgp
+ where usgp.server_group_id = server_group_id_in
+ and usgp.user_id = user_id_in
+ );
+ begin
+ for sgm in servergroups loop
+ rhn_server.delete_from_servergroup(sgm.server_id, server_group_id_in);
+ end loop;
+ end delete_set_from_servergroup;
+
+ procedure clear_servergroup (
+ server_group_id_in in number
+ ) is
+ cursor servers is
+ select sgm.server_id id
+ from rhnServerGroupMembers sgm
+ where sgm.server_group_id = server_group_id_in;
+ begin
+ for s in servers loop
+ rhn_server.delete_from_servergroup(s.id, server_group_id_in);
+ end loop;
+ end clear_servergroup;
+
+ procedure delete_from_org_servergroups (
+ server_id_in in number
+ ) is
+ cursor servergroups is
+ select sgm.server_group_id id
+ from rhnServerGroup sg,
+ rhnServerGroupMembers sgm
+ where sgm.server_id = server_id_in
+ and sgm.server_group_id = sg.id
+ and sg.group_type is null;
+ begin
+ for sg in servergroups loop
+ rhn_server.delete_from_servergroup(server_id_in, sg.id);
+ end loop;
+ end delete_from_org_servergroups;
+
+ function get_ip_address (
+ server_id_in in number
+ ) return varchar2 is
+ cursor interfaces is
+ select name, ip_addr
+ from rhnServerNetInterface
+ where server_id = server_id_in
+ and ip_addr != '127.0.0.1';
+ cursor addresses is
+ select ipaddr ip_addr
+ from rhnServerNetwork
+ where server_id = server_id_in
+ and ipaddr != '127.0.0.1';
+ begin
+ for addr in addresses loop
+ return addr.ip_addr;
+ end loop;
+ for iface in interfaces loop
+ return iface.ip_addr;
+ end loop;
+ return NULL;
+ end get_ip_address;
+end rhn_server;
+/
+SHOW ERRORS
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/162-rhn_channel.pkb.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/162-rhn_channel.pkb.sql
new file mode 100644
index 0000000..028a8e9
--- /dev/null
+++ b/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/162-rhn_channel.pkb.sql
@@ -0,0 +1,1229 @@
+--
+-- Copyright (c) 2008 Red Hat, Inc.
+--
+-- This software is licensed to you under the GNU General Public License,
+-- version 2 (GPLv2). There is NO WARRANTY for this software, express or
+-- implied, including the implied warranties of MERCHANTABILITY or FITNESS
+-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+-- along with this software; if not, see
+-- http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+--
+-- Red Hat trademarks are not licensed under GPLv2. No permission is
+-- granted to use or replicate Red Hat trademarks that are incorporated
+-- in this software or its documentation.
+--
+--
+--
+--
+
+CREATE OR REPLACE
+PACKAGE BODY rhn_channel
+IS
+ body_version varchar2(100) := '';
+
+ -- Cursor that fetches all the possible base channels for a
+ -- (server_arch_id, release, org_id) combination
+ cursor base_channel_cursor(
+ release_in in varchar2,
+ server_arch_id_in in number,
+ org_id_in in number
+ ) return rhnChannel%ROWTYPE is
+ select distinct c.*
+ from rhnDistChannelMap dcm,
+ rhnServerChannelArchCompat scac,
+ rhnChannel c,
+ rhnChannelPermissions cp
+ where cp.org_id = org_id_in
+ and cp.channel_id = c.id
+ and c.parent_channel is null
+ and c.id = dcm.channel_id
+ and c.channel_arch_id = dcm.channel_arch_id
+ and dcm.release = release_in
+ and scac.server_arch_id = server_arch_id_in
+ and scac.channel_arch_id = c.channel_arch_id;
+
+ FUNCTION get_license_path(channel_id_in IN NUMBER)
+ RETURN VARCHAR2
+ IS
+ license_val VARCHAR2(1000);
+ BEGIN
+ SELECT CFL.license_path INTO license_val
+ FROM rhnChannelFamilyLicense CFL, rhnChannelFamilyMembers CFM
+ WHERE CFM.channel_id = channel_id_in
+ AND CFM.channel_family_id = CFL.channel_family_id;
+
+ RETURN license_val;
+
+ EXCEPTION
+ WHEN NO_DATA_FOUND
+ THEN
+ RETURN NULL;
+ END get_license_path;
+
+
+ PROCEDURE license_consent(channel_id_in IN NUMBER, user_id_in IN NUMBER, server_id_in IN NUMBER)
+ IS
+ channel_family_id_val NUMBER;
+ BEGIN
+ channel_family_id_val := rhn_channel.family_for_channel(channel_id_in);
+ IF channel_family_id_val IS NULL
+ THEN
+ rhn_exception.raise_exception('channel_subscribe_no_family');
+ END IF;
+
+ IF rhn_channel.get_license_path(channel_id_in) IS NULL
+ THEN
+ rhn_exception.raise_exception('channel_consent_no_license');
+ END IF;
+
+ INSERT INTO rhnChannelFamilyLicenseConsent (channel_family_id, user_id, server_id)
+ VALUES (channel_family_id_val, user_id_in, server_id_in);
+ END license_consent;
+
+ PROCEDURE subscribe_server(server_id_in IN NUMBER, channel_id_in NUMBER, immediate_in NUMBER := 1, user_id_in in number := null, recalcfamily_in NUMBER := 1)
+ IS
+ channel_parent_val rhnChannel.parent_channel%TYPE;
+ parent_subscribed BOOLEAN;
+ server_has_base_chan BOOLEAN;
+ server_already_in_chan BOOLEAN;
+ channel_family_id_val NUMBER;
+ server_org_id_val NUMBER;
+ available_subscriptions NUMBER;
+ consenting_user NUMBER;
+ allowed number := 0;
+ current_members_val number;
+ BEGIN
+ if user_id_in is not null then
+ allowed := rhn_channel.user_role_check(channel_id_in, user_id_in, 'subscribe');
+ else
+ allowed := 1;
+ end if;
+
+ if allowed = 0 then
+ rhn_exception.raise_exception('no_subscribe_permissions');
+ end if;
+
+
+ SELECT parent_channel INTO channel_parent_val FROM rhnChannel WHERE id = channel_id_in;
+
+ IF channel_parent_val IS NOT NULL
+ THEN
+ -- child channel; if attempting to cross-subscribe a child to the wrong base, silently ignore
+ parent_subscribed := FALSE;
+
+ FOR check_subscription IN check_server_subscription(server_id_in, channel_parent_val)
+ LOOP
+ parent_subscribed := TRUE;
+ END LOOP check_subscription;
+
+ IF NOT parent_subscribed
+ THEN
+ RETURN;
+ END IF;
+ ELSE
+ -- base channel
+ server_has_base_chan := FALSE;
+ FOR base IN server_base_subscriptions(server_id_in)
+ LOOP
+ server_has_base_chan := TRUE;
+ END LOOP base;
+
+ IF server_has_base_chan
+ THEN
+ rhn_exception.raise_exception('channel_server_one_base');
+ END IF;
+ END IF;
+
+ FOR check_subscription IN check_server_subscription(server_id_in, channel_id_in)
+ LOOP
+ server_already_in_chan := TRUE;
+ END LOOP check_subscription;
+
+ IF server_already_in_chan
+ THEN
+ RETURN;
+ END IF;
+
+ channel_family_id_val := rhn_channel.family_for_channel(channel_id_in);
+ IF channel_family_id_val IS NULL
+ THEN
+ rhn_exception.raise_exception('channel_subscribe_no_family');
+ END IF;
+
+ --
+ -- Use the org_id of the server only if the org_id of the channel = NULL.
+ -- This is required for subscribing to shared channels.
+ --
+ SELECT NVL(org_id, (SELECT org_id FROM rhnServer WHERE id = server_id_in))
+ INTO server_org_id_val
+ FROM rhnChannel
+ WHERE id = channel_id_in;
+
+ select current_members
+ into current_members_val
+ from rhnPrivateChannelFamily
+ where org_id = server_org_id_val and channel_family_id = channel_family_id_val
+ for update of current_members;
+
+ available_subscriptions := rhn_channel.available_family_subscriptions(channel_family_id_val, server_org_id_val);
+
+ IF available_subscriptions IS NULL OR
+ available_subscriptions > 0 or
+ can_server_consume_virt_channl(server_id_in, channel_family_id_val) = 1
+ THEN
+
+ IF rhn_channel.get_license_path(channel_id_in) IS NOT NULL
+ THEN
+ BEGIN
+
+ SELECT user_id INTO consenting_user
+ FROM rhnChannelFamilyLicenseConsent
+ WHERE channel_family_id = channel_family_id_val
+ AND server_id = server_id_in;
+
+ EXCEPTION
+ WHEN NO_DATA_FOUND THEN
+ rhn_exception.raise_exception('channel_subscribe_no_consent');
+ END;
+ END IF;
+
+ insert into rhnServerHistory (id,server_id,summary,details) (
+ select rhn_event_id_seq.nextval,
+ server_id_in,
+ 'subscribed to channel ' || SUBSTR(c.label, 0, 106),
+ c.label
+ from rhnChannel c
+ where c.id = channel_id_in
+ );
+ UPDATE rhnServer SET channels_changed = sysdate WHERE id = server_id_in;
+ INSERT INTO rhnServerChannel (server_id, channel_id) VALUES (server_id_in, channel_id_in);
+ IF recalcfamily_in > 0
+ THEN
+ rhn_channel.update_family_counts(channel_family_id_val, server_org_id_val);
+ END IF;
+ queue_server(server_id_in, immediate_in);
+ ELSE
+ rhn_exception.raise_exception('channel_family_no_subscriptions');
+ END IF;
+
+ END subscribe_server;
+
+ function can_server_consume_virt_channl(
+ server_id_in in number,
+ family_id_in in number )
+ return number
+ is
+
+ cursor server_virt_families is
+ select vi.virtual_system_id, cfvsl.channel_family_id
+ from
+ rhnChannelFamilyVirtSubLevel cfvsl,
+ rhnSGTypeVirtSubLevel sgtvsl,
+ rhnVirtualInstance vi
+ where
+ vi.virtual_system_id = server_id_in
+ and sgtvsl.virt_sub_level_id = cfvsl.virt_sub_level_id
+ and cfvsl.channel_family_id = family_id_in
+ and exists (
+ select 1
+ from rhnServerEntitlementView sev
+ where vi.host_system_id = sev.server_id
+ and sev.server_group_type_id = sgtvsl.server_group_type_id );
+ begin
+
+ for server_virt_family in server_virt_families loop
+ return 1;
+ end loop;
+
+ return 0;
+
+ end;
+
+
+ PROCEDURE bulk_subscribe_server(channel_id_in IN NUMBER, set_label_in IN VARCHAR2, set_uid_in IN NUMBER)
+ IS
+ BEGIN
+ FOR server IN rhn_set.set_iterator(set_label_in, set_uid_in)
+ LOOP
+ rhn_channel.subscribe_server(server.element, channel_id_in, 0, set_uid_in);
+ END LOOP server;
+ END bulk_subscribe_server;
+
+ PROCEDURE bulk_server_base_change(channel_id_in IN NUMBER, set_label_in IN VARCHAR2, set_uid_in IN NUMBER)
+ IS
+ BEGIN
+ FOR server IN rhn_set.set_iterator(set_label_in, set_uid_in)
+ LOOP
+ IF rhn_server.can_change_base_channel(server.element) = 1
+ THEN
+ rhn_channel.clear_subscriptions(TO_NUMBER(server.element));
+ rhn_channel.subscribe_server(server.element, channel_id_in, 0, set_uid_in);
+ END IF;
+ END LOOP server;
+ END bulk_server_base_change;
+
+ procedure bulk_server_basechange_from(
+ set_label_in in varchar2,
+ set_uid_in in number,
+ old_channel_id_in in number,
+ new_channel_id_in in number
+ ) is
+ cursor servers is
+ select sc.server_id id
+ from rhnChannel nc,
+ rhnServerChannelArchCompat scac,
+ rhnServer s,
+ rhnChannel oc,
+ rhnServerChannel sc,
+ rhnSet st
+ where 1=1
+ -- first, find the servers we're looking for.
+ and st.label = set_label_in
+ and st.user_id = set_uid_in
+ and st.element = sc.server_id
+ -- now, filter out anything that's not in the
+ -- old base channel.
+ and sc.channel_id = old_channel_id_in
+ and sc.channel_id = oc.id
+ and oc.parent_channel is null
+ -- now, see if it's compatible with the new base channel
+ and nc.id = new_channel_id_in
+ and nc.parent_channel is null
+ and sc.server_id = s.id
+ and s.server_arch_id = scac.server_arch_id
+ and scac.channel_arch_id = nc.channel_arch_id;
+ begin
+ for s in servers loop
+ insert into rhnSet (
+ user_id, label, element
+ ) values (
+ set_uid_in,
+ set_label_in || 'basechange',
+ s.id
+ );
+ end loop channel;
+ bulk_server_base_change(new_channel_id_in,
+ set_label_in || 'basechange',
+ set_uid_in);
+ delete from rhnSet
+ where label = set_label_in||'basechange'
+ and user_id = set_uid_in;
+ end bulk_server_basechange_from;
+
+ procedure bulk_guess_server_base(
+ set_label_in in varchar2,
+ set_uid_in in number
+ ) is
+ channel_id number;
+ begin
+ for server in rhn_set.set_iterator(set_label_in, set_uid_in)
+ loop
+ -- anything that doesn't work, we just ignore
+ begin
+ if rhn_server.can_change_base_channel(server.element) = 1
+ then
+ channel_id := guess_server_base(TO_NUMBER(server.element));
+ rhn_channel.clear_subscriptions(TO_NUMBER(server.element));
+ rhn_channel.subscribe_server(TO_NUMBER(server.element), channel_id, 0, set_uid_in);
+ end if;
+ exception when others then
+ null;
+ end;
+ end loop server;
+ end;
+
+ function guess_server_base(
+ server_id_in in number
+ ) RETURN number is
+ cursor server_cursor is
+ select s.server_arch_id, s.release, s.org_id
+ from rhnServer s
+ where s.id = server_id_in;
+ begin
+ for s in server_cursor loop
+ for channel in base_channel_cursor(s.release,
+ s.server_arch_id, s.org_id)
+ loop
+ return channel.id;
+ end loop base_channel_cursor;
+ end loop server_cursor;
+ -- Server not found, or no base channel applies to it
+ return null;
+ end;
+
+ -- Private function
+ function normalize_server_arch(server_arch_in in varchar2)
+ return varchar2
+ deterministic
+ is
+ suffix VARCHAR2(128) := '-redhat-linux';
+ suffix_len NUMBER := length(suffix);
+ begin
+ if server_arch_in is NULL then
+ return NULL;
+ end if;
+ if instr(server_arch_in, '-') > 0
+ then
+ -- Suffix already present
+ return server_arch_in;
+ end if;
+ return server_arch_in || suffix;
+ end normalize_server_arch;
+
+ --
+ --
+ -- Raises:
+ -- server_arch_not_found
+ -- no_subscribe_permissions
+ function base_channel_for_release_arch(
+ release_in in varchar2,
+ server_arch_in in varchar2,
+ org_id_in in number := -1,
+ user_id_in in number := null
+ ) return number is
+ server_arch varchar2(256) := normalize_server_arch(server_arch_in);
+ server_arch_id number;
+ begin
+ -- Look up the server arch
+ begin
+ select id
+ into server_arch_id
+ from rhnServerArch
+ where label = server_arch;
+ exception
+ when no_data_found then
+ rhn_exception.raise_exception('server_arch_not_found');
+ end;
+ return base_channel_rel_archid(release_in, server_arch_id,
+ org_id_in, user_id_in);
+ end base_channel_for_release_arch;
+
+ function base_channel_rel_archid(
+ release_in in varchar2,
+ server_arch_id_in in number,
+ org_id_in in number := -1,
+ user_id_in in number := null
+ ) return number is
+ denied_channel_id number := null;
+ valid_org_id number := org_id_in;
+ valid_user_id number := user_id_in;
+ channel_subscribable number;
+ begin
+ if org_id_in = -1 and user_id_in is not null then
+ -- Get the org id from the user id
+ begin
+ select org_id
+ into valid_org_id
+ from web_contact
+ where id = user_id_in;
+ exception
+ when no_data_found then
+ -- User doesn't exist
+ -- XXX Only list public stuff for now
+ valid_user_id := null;
+ valid_org_id := -1;
+ end;
+ end if;
+
+ for c in base_channel_cursor(release_in, server_arch_id_in, valid_org_id)
+ loop
+ -- This row is a possible match
+ if valid_user_id is null then
+ -- User ID not specified, so no user to channel permissions to
+ -- check
+ return c.id;
+ end if;
+
+ -- Check user to channel permissions
+ select loose_user_role_check(c.id, user_id_in, 'subscribe')
+ into channel_subscribable
+ from dual;
+
+ if channel_subscribable = 1 then
+ return c.id;
+ end if;
+
+ -- Base channel exists, but is not subscribable; keep trying
+ denied_channel_id := c.id;
+ end loop base_channel_fetch;
+
+ if denied_channel_id is not null then
+ rhn_exception.raise_exception('no_subscribe_permissions');
+ end if;
+ -- No base channel applies
+ return NULL;
+ end base_channel_rel_archid;
+
+ procedure bulk_guess_server_base_from(
+ set_label_in in varchar2,
+ set_uid_in in number,
+ channel_id_in in number
+ ) is
+ cursor channels(server_id_in in number) is
+ select rsc.channel_id
+ from rhnServerChannel rsc,
+ rhnChannel rc
+ where server_id_in = rsc.server_id
+ and rsc.channel_id = rc.id
+ and rc.parent_channel is null;
+ begin
+ for server in rhn_set.set_iterator(set_label_in, set_uid_in)
+ loop
+ for channel in channels(server.element)
+ loop
+ if channel.channel_id = channel_id_in
+ then
+ insert into rhnSet (user_id, label, element) values (set_uid_in, set_label_in || 'baseguess', server.element);
+ end if;
+ end loop channel;
+ end loop server;
+ bulk_guess_server_base(set_label_in||'baseguess',set_uid_in);
+ delete from rhnSet where label = set_label_in||'baseguess' and user_id = set_uid_in;
+ end;
+
+
+ PROCEDURE clear_subscriptions(server_id_in IN NUMBER, deleting_server IN NUMBER := 0 )
+ IS
+ cursor server_channels(server_id_in in number) is
+ select s.org_id, sc.channel_id, cfm.channel_family_id
+ from rhnServer s,
+ rhnServerChannel sc,
+ rhnChannelFamilyMembers cfm
+ where s.id = server_id_in
+ and s.id = sc.server_id
+ and sc.channel_id = cfm.channel_id;
+ BEGIN
+ for channel in server_channels(server_id_in)
+ loop
+ unsubscribe_server(server_id_in, channel.channel_id, 1, 1, deleting_server);
+ rhn_channel.update_family_counts(channel.channel_family_id, channel.org_id);
+ end loop channel;
+ END clear_subscriptions;
+
+ PROCEDURE unsubscribe_server(server_id_in IN NUMBER, channel_id_in NUMBER, immediate_in NUMBER := 1, unsubscribe_children_in number := 0,
+ deleting_server IN NUMBER := 0 )
+ IS
+ channel_family_id_val NUMBER;
+ server_org_id_val NUMBER;
+ available_subscriptions NUMBER;
+ server_already_in_chan BOOLEAN;
+ cursor channel_family_is_proxy(channel_family_id_in in number) is
+ select 1
+ from rhnChannelFamily
+ where id = channel_family_id_in
+ and label = 'rhn-proxy';
+ cursor channel_family_is_satellite(channel_family_id_in in number) is
+ select 1
+ from rhnChannelFamily
+ where id = channel_family_id_in
+ and label = 'rhn-satellite';
+ -- this is *EXACTLY* like check_server_parent_membership, but if we recurse
+ -- with the package-level one, we get a "cursor already open", so we need a
+ -- copy on our call stack instead. GROAN.
+ cursor local_chk_server_parent_memb (
+ server_id_in number,
+ channel_id_in number ) is
+ select c.id
+ from rhnChannel c,
+ rhnServerChannel sc
+ where 1=1
+ and c.parent_channel = channel_id_in
+ and c.id = sc.channel_id
+ and sc.server_id = server_id_in;
+ BEGIN
+ FOR child IN local_chk_server_parent_memb(server_id_in, channel_id_in)
+ LOOP
+ if unsubscribe_children_in = 1 then
+ unsubscribe_server(server_id_in => server_id_in,
+ channel_id_in => child.id,
+ immediate_in => immediate_in,
+ unsubscribe_children_in => unsubscribe_children_in,
+ deleting_server => deleting_server);
+ else
+ rhn_exception.raise_exception('channel_unsubscribe_child_exists');
+ end if;
+ END LOOP child;
+
+ server_already_in_chan := FALSE;
+
+ FOR check_subscription IN check_server_subscription(server_id_in, channel_id_in)
+ LOOP
+ server_already_in_chan := TRUE;
+ END LOOP check_subscription;
+
+ IF NOT server_already_in_chan
+ THEN
+ RETURN;
+ END IF;
+
+ if deleting_server = 0 then
+
+ insert into rhnServerHistory (id,server_id,summary,details) (
+ select rhn_event_id_seq.nextval,
+ server_id_in,
+ 'unsubscribed from channel ' || SUBSTR(c.label, 0, 106),
+ c.label
+ from rhnChannel c
+ where c.id = channel_id_in
+ );
+
+ UPDATE rhnServer SET channels_changed = sysdate WHERE id = server_id_in;
+ end if;
+
+ DELETE FROM rhnServerChannel WHERE server_id = server_id_in AND channel_id = channel_id_in;
+
+ if deleting_server = 0 then
+ queue_server(server_id_in, immediate_in);
+ end if;
+
+ channel_family_id_val := rhn_channel.family_for_channel(channel_id_in);
+ IF channel_family_id_val IS NULL
+ THEN
+ rhn_exception.raise_exception('channel_unsubscribe_no_family');
+ END IF;
+
+ for ignore in channel_family_is_satellite(channel_family_id_val) loop
+ delete from rhnSatelliteInfo where server_id = server_id_in;
+ delete from rhnSatelliteChannelFamily where server_id = server_id_in;
+ end loop;
+
+ for ignore in channel_family_is_proxy(channel_family_id_val) loop
+ delete from rhnProxyInfo where server_id = server_id_in;
+ end loop;
+
+ DELETE FROM rhnChannelFamilyLicenseConsent
+ WHERE channel_family_id = channel_family_id_val
+ AND server_id = server_id_in;
+
+ SELECT org_id INTO server_org_id_val
+ FROM rhnServer
+ WHERE id = server_id_in;
+
+ rhn_channel.update_family_counts(channel_family_id_val, server_org_id_val);
+ END unsubscribe_server;
+
+ PROCEDURE bulk_unsubscribe_server(channel_id_in IN NUMBER, set_label_in IN VARCHAR2, set_uid_in IN NUMBER)
+ IS
+ BEGIN
+ FOR server IN rhn_set.set_iterator(set_label_in, set_uid_in)
+ LOOP
+ rhn_channel.unsubscribe_server(server.element, channel_id_in, 0);
+ END LOOP server;
+ END bulk_unsubscribe_server;
+
+ FUNCTION family_for_channel(channel_id_in IN NUMBER)
+ RETURN NUMBER
+ IS
+ channel_family_id_val NUMBER;
+ BEGIN
+ SELECT channel_family_id INTO channel_family_id_val
+ FROM rhnChannelFamilyMembers
+ WHERE channel_id = channel_id_in;
+
+ RETURN channel_family_id_val;
+ EXCEPTION
+ WHEN NO_DATA_FOUND
+ THEN
+ RETURN NULL;
+ END family_for_channel;
+
+ FUNCTION available_family_subscriptions(channel_family_id_in IN NUMBER, org_id_in IN NUMBER)
+ RETURN NUMBER
+ IS
+ cfp channel_family_perm_cursor%ROWTYPE;
+ current_members_val NUMBER;
+ max_members_val NUMBER;
+ found NUMBER;
+ BEGIN
+ IF NOT channel_family_perm_cursor%ISOPEN
+ THEN
+ OPEN channel_family_perm_cursor(channel_family_id_in, org_id_in);
+ END IF;
+
+ FETCH channel_family_perm_cursor INTO cfp;
+
+ WHILE channel_family_perm_cursor%FOUND
+ LOOP
+ found := 1;
+
+ current_members_val := cfp.current_members;
+ max_members_val := cfp.max_members;
+
+ FETCH channel_family_perm_cursor INTO cfp;
+ END LOOP;
+
+ IF channel_family_perm_cursor%ISOPEN
+ THEN
+ CLOSE channel_family_perm_cursor;
+ END IF;
+
+ -- not found: either the channel fam doesn't have an entry in cfp, or the org doesn't have access to it.
+ -- either way, there are no available subscriptions
+
+ IF found IS NULL
+ THEN
+ RETURN 0;
+ END IF;
+
+ -- null max members? in that case, pass it on; NULL means infinite
+ IF max_members_val IS NULL
+ THEN
+ RETURN NULL;
+ END IF;
+
+ -- otherwise, return the delta
+ RETURN max_members_val - current_members_val;
+ END available_family_subscriptions;
+
+ -- *******************************************************************
+ -- FUNCTION: channel_family_current_members
+ -- Calculates and returns the actual count of systems consuming
+ -- physical channel subscriptions.
+ -- Called by: update_family_counts
+ -- rhn_entitlements.repoll_virt_guest_entitlements
+ -- *******************************************************************
+ function channel_family_current_members(channel_family_id_in IN NUMBER,
+ org_id_in IN NUMBER)
+ return number
+ is
+ current_members_count number := 0;
+ begin
+ select count(distinct server_id)
+ into current_members_count
+ from rhnChannelFamilyServerPhysical cfsp
+ where cfsp.channel_family_id = channel_family_id_in
+ and cfsp.customer_id = org_id_in;
+ return current_members_count;
+ end;
+
+ PROCEDURE update_family_counts(channel_family_id_in IN NUMBER,
+ org_id_in IN NUMBER)
+ IS
+ BEGIN
+ update rhnPrivateChannelFamily
+ set current_members = (
+ channel_family_current_members(channel_family_id_in, org_id_in)
+ )
+ where org_id = org_id_in
+ and channel_family_id = channel_family_id_in;
+
+ END update_family_counts;
+
+ FUNCTION available_chan_subscriptions(channel_id_in IN NUMBER,
+ org_id_in IN NUMBER)
+ RETURN NUMBER
+ IS
+ channel_family_id_val NUMBER;
+ BEGIN
+ SELECT channel_family_id INTO channel_family_id_val
+ FROM rhnChannelFamilyMembers
+ WHERE channel_id = channel_id_in;
+
+ RETURN rhn_channel.available_family_subscriptions(
+ channel_family_id_val, org_id_in);
+ END available_chan_subscriptions;
+
+ -- *******************************************************************
+ -- PROCEDURE: entitle_customer
+ -- Creates a chan fam bucket, or sets max_members for an existing bucket
+ -- Called by: rhn_ep.poll_customer_internal
+ -- Calls: set_family_maxmembers + update_family_counts if the row
+ -- already exists, else it creates it in rhnPrivateChannelFamily.
+ -- *******************************************************************
+ procedure entitle_customer(customer_id_in in number,
+ channel_family_id_in in number,
+ quantity_in in number)
+ is
+ cursor permissions is
+ select 1
+ from rhnPrivateChannelFamily pcf
+ where pcf.org_id = customer_id_in
+ and pcf.channel_family_id = channel_family_id_in;
+ begin
+ for perm in permissions loop
+ set_family_maxmembers(
+ customer_id_in,
+ channel_family_id_in,
+ quantity_in
+ );
+ rhn_channel.update_family_counts(
+ channel_family_id_in,
+ customer_id_in
+ );
+ return;
+ end loop;
+
+ insert into rhnPrivateChannelFamily pcf (
+ channel_family_id, org_id, max_members, current_members
+ ) values (
+ channel_family_id_in, customer_id_in, quantity_in, 0
+ );
+ end;
+
+ -- *******************************************************************
+ -- PROCEDURE: set_family_maxmembers
+ -- Prunes an existing channel family bucket by unsubscribing the
+ -- necessary servers and sets max_members.
+ -- Called by: rhn_channel.entitle_customer
+ -- Calls: unsubscribe_server_from_family
+ -- *******************************************************************
+ procedure set_family_maxmembers(customer_id_in in number,
+ channel_family_id_in in number,
+ quantity_in in number)
+ is
+ cursor servers is
+ select server_id from (
+ select rownum row_number, server_id, modified from (
+ select rcfsp.server_id,
+ rcfsp.modified
+ from rhnChannelFamilyServerPhysical rcfsp
+ where rcfsp.customer_id = customer_id_in
+ and rcfsp.channel_family_id = channel_family_id_in
+ order by modified
+ )
+ where rownum > quantity_in
+ );
+ begin
+ -- prune subscribed servers
+ for server in servers loop
+ rhn_channel.unsubscribe_server_from_family(server.server_id,
+ channel_family_id_in);
+ end loop;
+
+ update rhnPrivateChannelFamily pcf
+ set pcf.max_members = quantity_in
+ where pcf.org_id = customer_id_in
+ and pcf.channel_family_id = channel_family_id_in;
+ end;
+
+ procedure unsubscribe_server_from_family(server_id_in in number,
+ channel_family_id_in in number)
+ is
+ begin
+ delete
+ from rhnServerChannel rsc
+ where rsc.server_id = server_id_in
+ and channel_id in (
+ select rcfm.channel_id
+ from rhnChannelFamilyMembers rcfm
+ where rcfm.channel_family_id = channel_family_id_in);
+ end;
+
+ function get_org_id(channel_id_in in number)
+ return number
+ is
+ org_id_out number;
+ begin
+ select org_id into org_id_out
+ from rhnChannel
+ where id = channel_id_in;
+
+ return org_id_out;
+ end get_org_id;
+
+ function get_cfam_org_access(cfam_id_in in number, org_id_in in number)
+ return number
+ is
+ cursor families is
+ select 1
+ from rhnOrgChannelFamilyPermissions cfp
+ where cfp.org_id = org_id_in;
+ begin
+ -- the idea: if we get past this query,
+ -- the user has the role, else catch the exception and return 0
+ for family in families loop
+ return 1;
+ end loop;
+ return 0;
+ end;
+
+ function get_org_access(channel_id_in in number, org_id_in in number)
+ return number
+ is
+ throwaway number;
+ begin
+ -- the idea: if we get past this query,
+ -- the org has access to the channel, else catch the exception and return 0
+ select distinct 1 into throwaway
+ from rhnChannelFamilyMembers CFM,
+ rhnOrgChannelFamilyPermissions CFP
+ where cfp.org_id = org_id_in
+ and CFM.channel_family_id = CFP.channel_family_id
+ and CFM.channel_id = channel_id_in
+ and (CFP.max_members > 0 or CFP.max_members is null or CFP.org_id = 1);
+
+ return 1;
+ exception
+ when no_data_found
+ then
+ return 0;
+ end;
+
+ -- check if a user has a given role, or if such a role is inferrable
+ function user_role_check_debug(channel_id_in in number,
+ user_id_in in number,
+ role_in in varchar2,
+ reason_out out varchar2)
+ return number
+ is
+ org_id number;
+ begin
+ org_id := rhn_user.get_org_id(user_id_in);
+
+ -- channel might be shared
+ if role_in = 'subscribe' and
+ rhn_channel.shared_user_role_check(channel_id_in, user_id_in, role_in) = 1 then
+ return 1;
+ end if;
+
+ if role_in = 'manage' and
+ NVL(rhn_channel.get_org_id(channel_id_in), -1) <> org_id then
+ reason_out := 'channel_not_owned';
+ return 0;
+ end if;
+
+ if role_in = 'subscribe' and
+ rhn_channel.get_org_access(channel_id_in, org_id) = 0 then
+ reason_out := 'channel_not_available';
+ return 0;
+ end if;
+
+ -- channel admins have all roles
+ if rhn_user.check_role_implied(user_id_in, 'channel_admin') = 1 then
+ reason_out := 'channel_admin';
+ return 1;
+ end if;
+
+ -- the subscribe permission is inferred
+ -- UNLESS the not_globally_subscribable flag is set
+ if role_in = 'subscribe'
+ then
+ if rhn_channel.org_channel_setting(channel_id_in,
+ org_id,
+ 'not_globally_subscribable') = 0 then
+ reason_out := 'globally_subscribable';
+ return 1;
+ end if;
+ end if;
+
+ -- all other roles (manage right now) are explicitly granted
+ reason_out := 'direct_permission';
+ return rhn_channel.direct_user_role_check(channel_id_in,
+ user_id_in, role_in);
+ end;
+
+ -- same as above, but with no OUT param; useful in views, etc
+ function user_role_check(channel_id_in in number, user_id_in in number, role_in in varchar2)
+ return number
+ is
+ throwaway varchar2(256);
+ begin
+ return rhn_channel.user_role_check_debug(channel_id_in, user_id_in, role_in, throwaway);
+ end;
+
+ --
+ -- For multiorg phase II, this function simply checks to see if the user's
+ -- has a trust relationship that includes this channel by id.
+ --
+ function shared_user_role_check(channel_id in number, user_id in number, role in varchar2)
+ return number
+ is
+ n number;
+ oid number;
+ begin
+ oid := rhn_user.get_org_id(user_id);
+ select 1 into n
+ from rhnSharedChannelView s
+ where s.id = channel_id and s.org_trust_id = oid;
+ return 1;
+ exception
+ when no_data_found then
+ return 0;
+ end;
+
+ -- same as above, but returns 1 if user_id_in is null
+ -- This is useful in queries where user_id is not specified
+ function loose_user_role_check(channel_id_in in number, user_id_in in number, role_in in varchar2)
+ return number
+ is
+ begin
+ if user_id_in is null then
+ return 1;
+ end if;
+ return user_role_check(channel_id_in, user_id_in, role_in);
+ end loose_user_role_check;
+
+ -- directly checks the table, no inferred permissions
+ function direct_user_role_check(channel_id_in in number, user_id_in in number, role_in in varchar2)
+ return number
+ is
+ throwaway number;
+ begin
+ -- the idea: if we get past this query, the user has the role, else catch the exception and return 0
+ select 1 into throwaway
+ from rhnChannelPermissionRole CPR,
+ rhnChannelPermission CP
+ where CP.user_id = user_id_in
+ and CP.channel_id = channel_id_in
+ and CPR.label = role_in
+ and CP.role_id = CPR.id;
+
+ return 1;
+ exception
+ when no_data_found
+ then
+ return 0;
+ end;
+
+ -- check if an org has a certain setting
+ function org_channel_setting(channel_id_in in number, org_id_in in number, setting_in in varchar2)
+ return number
+ is
+ throwaway number;
+ begin
+ -- the idea: if we get past this query, the org has the setting, else catch the exception and return 0
+ select 1 into throwaway
+ from rhnOrgChannelSettingsType OCST,
+ rhnOrgChannelSettings OCS
+ where OCS.org_id = org_id_in
+ and OCS.channel_id = channel_id_in
+ and OCST.label = setting_in
+ and OCS.setting_id = OCST.id;
+
+ return 1;
+ exception
+ when no_data_found
+ then
+ return 0;
+ end;
+
+ FUNCTION channel_priority(channel_id_in IN number)
+ RETURN number
+ IS
+ channel_name varchar2(256);
+ priority number;
+ end_of_life_val date;
+ org_id_val number;
+ BEGIN
+
+ select name, end_of_life, org_id
+ into channel_name, end_of_life_val, org_id_val
+ from rhnChannel
+ where id = channel_id_in;
+
+ if end_of_life_val is not null then
+ return -400;
+ end if;
+
+ if channel_name like 'Red Hat Enterprise Linux%' or channel_name like 'RHEL%' then
+ priority := 1000;
+ if channel_name not like '%Beta%' then
+ priority := priority + 1000;
+ end if;
+
+ priority := priority +
+ case
+ when channel_name like '%v. 5%' then 600
+ when channel_name like '%v. 4%' then 500
+ when channel_name like '%v. 3%' then 400
+ when channel_name like '%v. 2%' then 300
+ when channel_name like '%v. 1%' then 200
+ else 0
+ end;
+
+ priority := priority +
+ case
+ when channel_name like 'Red Hat Enterprise Linux (v. 5%' then 60
+ when (channel_name like '%AS%' and channel_name not like '%Extras%') then 50
+ when (channel_name like '%ES%' and channel_name not like '%Extras%') then 40
+ when (channel_name like '%WS%' and channel_name not like '%Extras%') then 30
+ when (channel_name like '%Desktop%' and channel_name not like '%Extras%') then 20
+ when channel_name like '%Extras%' then 10
+ else 0
+ end;
+
+ priority := priority +
+ case
+ when channel_name like '%)' then 5
+ else 0
+ end;
+
+ priority := priority +
+ case
+ when channel_name like '%32-bit x86%' then 4
+ when channel_name like '%64-bit Intel Itanium%' then 3
+ when channel_name like '%64-bit AMD64/Intel EM64T%' then 2
+ else 0
+ end;
+ elsif channel_name like 'Red Hat Desktop%' then
+ priority := 900;
+
+ if channel_name not like '%Beta%' then
+ priority := priority + 50;
+ end if;
+
+ priority := priority +
+ case
+ when channel_name like '%v. 4%' then 40
+ when channel_name like '%v. 3%' then 30
+ when channel_name like '%v. 2%' then 20
+ when channel_name like '%v. 1%' then 10
+ else 0
+ end;
+
+ priority := priority +
+ case
+ when channel_name like '%32-bit x86%' then 4
+ when channel_name like '%64-bit Intel Itanium%' then 3
+ when channel_name like '%64-bit AMD64/Intel EM64T%' then 2
+ else 0
+ end;
+
+ elsif org_id_val is not null then
+ priority := 600;
+ else
+ priority := 500;
+ end if;
+
+ return -priority;
+
+ end channel_priority;
+
+ -- right now this only does the accounting changes; the cascade
+ -- actually does the rhnServerChannel delete.
+ procedure delete_server_channels(server_id_in in number)
+ is
+ begin
+ update rhnPrivateChannelFamily
+ set current_members = current_members -1
+ where org_id in (
+ select org_id
+ from rhnServer
+ where id = server_id_in
+ )
+ and channel_family_id in (
+ select rcfm.channel_family_id
+ from rhnChannelFamilyMembers rcfm,
+ rhnServerChannel rsc
+ where rsc.server_id = server_id_in
+ and rsc.channel_id = rcfm.channel_id
+ and not exists (
+ select 1
+ from
+ rhnChannelFamilyVirtSubLevel cfvsl,
+ rhnSGTypeVirtSubLevel sgtvsl,
+ rhnServerEntitlementView sev,
+ rhnVirtualInstance vi
+ where
+ -- system is a virtual instance
+ vi.virtual_system_id = server_id_in
+ and vi.host_system_id = sev.server_id
+ -- system's host has a virt ent
+ and sev.label in ('virtualization_host',
+ 'virtualization_host_platform')
+ and sev.server_group_type_id =
+ sgtvsl.server_group_type_id
+ -- the host's virt ent grants a cf virt sub level
+ and sgtvsl.virt_sub_level_id = cfvsl.virt_sub_level_id
+ -- the cf is in that virt sub level
+ and cfvsl.channel_family_id = rcfm.channel_family_id
+ )
+ );
+ end;
+
+ -- this could certainly be optimized to do updates if needs be
+ procedure refresh_newest_package(channel_id_in in number, caller_in in varchar2 := '(unknown)')
+ is
+ begin
+ delete from rhnChannelNewestPackage where channel_id = channel_id_in;
+ insert into rhnChannelNewestPackage
+ ( channel_id, name_id, evr_id, package_id, package_arch_id )
+ ( select channel_id,
+ name_id, evr_id,
+ package_id, package_arch_id
+ from rhnChannelNewestPackageView
+ where channel_id = channel_id_in
+ );
+ insert into rhnChannelNewestPackageAudit (channel_id, caller)
+ values (channel_id_in, caller_in);
+ update rhnChannel
+ set last_modified = greatest(sysdate, last_modified + 1/86400)
+ where id = channel_id_in;
+ end;
+
+ procedure update_channel ( channel_id_in in number, invalidate_ss in number := 0,
+ date_to_use in date := sysdate )
+ is
+
+ channel_last_modified date;
+ last_modified_value date;
+
+ cursor snapshots is
+ select snapshot_id id
+ from rhnSnapshotChannel
+ where channel_id = channel_id_in;
+
+ begin
+
+ select last_modified
+ into channel_last_modified
+ from rhnChannel
+ where id = channel_id_in;
+
+ last_modified_value := date_to_use;
+
+ if last_modified_value <= channel_last_modified then
+ last_modified_value := last_modified_value + 1/86400;
+ end if;
+
+ update rhnChannel set last_modified = last_modified_value
+ where id = channel_id_in;
+
+ if invalidate_ss = 1 then
+ for snapshot in snapshots loop
+ update rhnSnapshot
+ set invalid = lookup_snapshot_invalid_reason('channel_modified')
+ where id = snapshot.id;
+ end loop;
+ end if;
+
+ end update_channel;
+
+ procedure update_channels_by_package ( package_id_in in number, date_to_use in date := sysdate )
+ is
+
+ cursor channels is
+ select channel_id
+ from rhnChannelPackage
+ where package_id = package_id_in
+ order by channel_id;
+
+ begin
+ for channel in channels loop
+ -- we want to invalidate the snapshot assocated with the channel when we
+ -- do this b/c we know we've added or removed or packages
+ rhn_channel.update_channel ( channel.channel_id, 1, date_to_use );
+ end loop;
+ end update_channels_by_package;
+
+
+ procedure update_channels_by_errata ( errata_id_in number, date_to_use in date := sysdate )
+ is
+
+ cursor channels is
+ select channel_id
+ from rhnChannelErrata
+ where errata_id = errata_id_in
+ order by channel_id;
+
+ begin
+ for channel in channels loop
+ -- we won't invalidate snapshots, b/c just changing the errata associated with
+ -- a channel shouldn't invalidate snapshots
+ rhn_channel.update_channel ( channel.channel_id, 0, date_to_use );
+ end loop;
+ end update_channels_by_errata;
+
+END rhn_channel;
+/
+SHOW ERRORS
commit f942de95d9fe259e09ea809f61af9ab95769f015
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Mon Nov 30 16:19:21 2009 +0100
add missing relationship
From commit 9615725006221e9feb74bf827f7a15c363fe2cc6
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/160-rhn_cache.pkb.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/160-rhn_cache.pkb.sql
index 7c895db..9c1dcf1 100644
--- a/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/160-rhn_cache.pkb.sql
+++ b/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/160-rhn_cache.pkb.sql
@@ -87,6 +87,7 @@ is
rhnServerGroup sg,
rhnUserGroupType ugt
where ugt.label = 'org_admin'
+ and ugt.id = ug.group_type
and sg.id = server_group_id_in
and ugm.user_id = usgp.user_id
and ug.org_id = sg.org_id
commit c31883ad2159a806c3b6ac27fcb88c94c3fc1737
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Mon Nov 30 16:16:22 2009 +0100
rename schema upgrade script to use uniform .sql extension
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/160-rhn_cache.pkb b/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/160-rhn_cache.pkb
deleted file mode 100644
index 7c895db..0000000
--- a/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/160-rhn_cache.pkb
+++ /dev/null
@@ -1,102 +0,0 @@
---
--- Copyright (c) 2008 Red Hat, Inc.
---
--- This software is licensed to you under the GNU General Public License,
--- version 2 (GPLv2). There is NO WARRANTY for this software, express or
--- implied, including the implied warranties of MERCHANTABILITY or FITNESS
--- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
--- along with this software; if not, see
--- http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
---
--- Red Hat trademarks are not licensed under GPLv2. No permission is
--- granted to use or replicate Red Hat trademarks that are incorporated
--- in this software or its documentation.
---
---
---
---
-
-create or replace package body
-rhn_cache
-is
- body_version varchar2(100) := '';
-
- -- this searches out all users who get perms...
- procedure update_perms_for_server(
- server_id_in in number
- ) is
- begin
- -- delete rows which are no more valid
- delete from rhnUserServerPerms p
- where server_id = server_id_in
- and user_id not in (select user_id
- from rhnUserServerPermsDupes d
- where p.server_id = d.server_id);
- -- insert newly added rows
- insert into rhnUserServerPerms(user_id, server_id) (
- select distinct user_id, server_id_in
- from rhnUserServerPermsDupes d
- where server_id = server_id_in
- and user_id not in (
- select user_id
- from rhnUserServerPerms p
- where p.server_id = d.server_id)
- );
- end update_perms_for_server;
-
- -- update rhnUserServerPerms cache from rhnUserServerPermsDupes
- procedure update_perms_for_user(
- user_id_in in number
- ) is
- begin
- -- first delete rows which are not in rhnUserServerPermsDupes
- delete from rhnUserServerPerms up
- where user_id = user_id_in
- and not exists (
- select 1
- from rhnUserServerPermsDupes uspd
- where uspd.user_id = up.user_id
- and uspd.server_id = up.server_id);
-
- -- then insert rest of rows from rhnUserServerPermsDupes
- insert into rhnUserServerPerms (user_id, server_id)
- select distinct user_id_in, server_id
- from rhnUserServerPermsDupes uspd
- where uspd.user_id = user_id_in
- and not exists (
- select 1
- from rhnUserServerPerms usp
- where usp.user_id = user_id_in
- and usp.server_id = uspd.server_id);
- end update_perms_for_user;
-
- -- this means a server got added or removed, so we
- -- can't key off of a server anywhere.
- procedure update_perms_for_server_group(
- server_group_id_in in number
- ) is
- cursor users is
- -- org admins aren't affected, so don't test for them
- select usgp.user_id id
- from rhnUserServerGroupPerms usgp
- where usgp.server_group_id = server_group_id_in
- and not exists (
- select 1
- from rhnUserGroup ug,
- rhnUserGroupMembers ugm,
- rhnServerGroup sg,
- rhnUserGroupType ugt
- where ugt.label = 'org_admin'
- and sg.id = server_group_id_in
- and ugm.user_id = usgp.user_id
- and ug.org_id = sg.org_id
- and ugm.user_group_id = ug.id
- );
- begin
- for u in users loop
- update_perms_for_user(u.id);
- end loop;
- end update_perms_for_server_group;
-end rhn_cache;
-/
-show errors
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/160-rhn_cache.pkb.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/160-rhn_cache.pkb.sql
new file mode 100644
index 0000000..7c895db
--- /dev/null
+++ b/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/160-rhn_cache.pkb.sql
@@ -0,0 +1,102 @@
+--
+-- Copyright (c) 2008 Red Hat, Inc.
+--
+-- This software is licensed to you under the GNU General Public License,
+-- version 2 (GPLv2). There is NO WARRANTY for this software, express or
+-- implied, including the implied warranties of MERCHANTABILITY or FITNESS
+-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+-- along with this software; if not, see
+-- http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+--
+-- Red Hat trademarks are not licensed under GPLv2. No permission is
+-- granted to use or replicate Red Hat trademarks that are incorporated
+-- in this software or its documentation.
+--
+--
+--
+--
+
+create or replace package body
+rhn_cache
+is
+ body_version varchar2(100) := '';
+
+ -- this searches out all users who get perms...
+ procedure update_perms_for_server(
+ server_id_in in number
+ ) is
+ begin
+ -- delete rows which are no more valid
+ delete from rhnUserServerPerms p
+ where server_id = server_id_in
+ and user_id not in (select user_id
+ from rhnUserServerPermsDupes d
+ where p.server_id = d.server_id);
+ -- insert newly added rows
+ insert into rhnUserServerPerms(user_id, server_id) (
+ select distinct user_id, server_id_in
+ from rhnUserServerPermsDupes d
+ where server_id = server_id_in
+ and user_id not in (
+ select user_id
+ from rhnUserServerPerms p
+ where p.server_id = d.server_id)
+ );
+ end update_perms_for_server;
+
+ -- update rhnUserServerPerms cache from rhnUserServerPermsDupes
+ procedure update_perms_for_user(
+ user_id_in in number
+ ) is
+ begin
+ -- first delete rows which are not in rhnUserServerPermsDupes
+ delete from rhnUserServerPerms up
+ where user_id = user_id_in
+ and not exists (
+ select 1
+ from rhnUserServerPermsDupes uspd
+ where uspd.user_id = up.user_id
+ and uspd.server_id = up.server_id);
+
+ -- then insert rest of rows from rhnUserServerPermsDupes
+ insert into rhnUserServerPerms (user_id, server_id)
+ select distinct user_id_in, server_id
+ from rhnUserServerPermsDupes uspd
+ where uspd.user_id = user_id_in
+ and not exists (
+ select 1
+ from rhnUserServerPerms usp
+ where usp.user_id = user_id_in
+ and usp.server_id = uspd.server_id);
+ end update_perms_for_user;
+
+ -- this means a server got added or removed, so we
+ -- can't key off of a server anywhere.
+ procedure update_perms_for_server_group(
+ server_group_id_in in number
+ ) is
+ cursor users is
+ -- org admins aren't affected, so don't test for them
+ select usgp.user_id id
+ from rhnUserServerGroupPerms usgp
+ where usgp.server_group_id = server_group_id_in
+ and not exists (
+ select 1
+ from rhnUserGroup ug,
+ rhnUserGroupMembers ugm,
+ rhnServerGroup sg,
+ rhnUserGroupType ugt
+ where ugt.label = 'org_admin'
+ and sg.id = server_group_id_in
+ and ugm.user_id = usgp.user_id
+ and ug.org_id = sg.org_id
+ and ugm.user_group_id = ug.id
+ );
+ begin
+ for u in users loop
+ update_perms_for_user(u.id);
+ end loop;
+ end update_perms_for_server_group;
+end rhn_cache;
+/
+show errors
13 years, 6 months
schema/spacewalk
by Milan Zazrivec
schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/002-rhn_db_environment-rhn_environment-drop.sql | 3 +++
1 file changed, 3 insertions(+)
New commits:
commit cf64dd8d756aa1797618eb6f2c7cd8dade60d96f
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Mon Nov 30 15:52:13 2009 +0100
476851 - drop unneeded synonyms during schema upgrade
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/002-rhn_db_environment-rhn_environment-drop.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/002-rhn_db_environment-rhn_environment-drop.sql
index 489d2f4..54d2952 100644
--- a/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/002-rhn_db_environment-rhn_environment-drop.sql
+++ b/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/002-rhn_db_environment-rhn_environment-drop.sql
@@ -11,3 +11,6 @@ alter table rhn_config_macro drop column environment;
drop table rhn_db_environment;
drop table rhn_environment;
+
+drop synonym db_environment;
+drop synonym environment;
13 years, 6 months
schema/spacewalk
by Milan Zazrivec
schema/spacewalk/common/tables/rhn_contact_group_members.sql | 6 +++---
schema/spacewalk/common/tables/rhn_ll_netsaint.sql | 2 +-
schema/spacewalk/common/tables/rhn_probe_param_value.sql | 4 ++--
schema/spacewalk/postgres/procs/rhn_prepare_install.sql | 2 +-
schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/001-numeric-12-columns.sql | 8 --------
5 files changed, 7 insertions(+), 15 deletions(-)
New commits:
commit aee6131d9f6f2a9df2b5ed737e3fbaa04e8690eb
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Mon Nov 30 14:12:59 2009 +0100
Revert "Fix numeric/smallint incompatible types in PostgreSQL."
This reverts commit 9bfcee416f62ec342d249c51b8edc64d57b67ef6.
There are two reasons for the revert:
1) the schema upgrade script won't work. Oracle will throw
"ORA-01440: column to be modified must be empty to decrease precision or scale"
in most of the upgrade situations (i.e. with filled tables)
2) it would be more desirable to change the type of referenced columns
from NUMBER(12) to NUMBER to stay consistent. The upgrade script modifying
NUMBER(12) to NUMBER would work without any problems then.
There's bug #542662 tracking efforts leading to an alternative
solution for the problem addressed by the original commit.
diff --git a/schema/spacewalk/common/tables/rhn_contact_group_members.sql b/schema/spacewalk/common/tables/rhn_contact_group_members.sql
index 952265b..25b67aa 100644
--- a/schema/spacewalk/common/tables/rhn_contact_group_members.sql
+++ b/schema/spacewalk/common/tables/rhn_contact_group_members.sql
@@ -16,16 +16,16 @@
CREATE TABLE rhn_contact_group_members
(
- contact_group_id NUMBER(12) NOT NULL
+ contact_group_id NUMBER NOT NULL
CONSTRAINT rhn_cntgm_cgid_fk
REFERENCES rhn_contact_groups (recid)
ON DELETE CASCADE,
order_number NUMBER NOT NULL,
- member_contact_method_id NUMBER(12)
+ member_contact_method_id NUMBER
CONSTRAINT rhn_cntgm_mcmid_fk
REFERENCES rhn_contact_methods (recid)
ON DELETE CASCADE,
- member_contact_group_id NUMBER(12)
+ member_contact_group_id NUMBER
CONSTRAINT rhn_cntgm_mcgid_fk
REFERENCES rhn_contact_groups (recid)
ON DELETE CASCADE,
diff --git a/schema/spacewalk/common/tables/rhn_ll_netsaint.sql b/schema/spacewalk/common/tables/rhn_ll_netsaint.sql
index eda6c67..eaf4553 100644
--- a/schema/spacewalk/common/tables/rhn_ll_netsaint.sql
+++ b/schema/spacewalk/common/tables/rhn_ll_netsaint.sql
@@ -16,7 +16,7 @@
CREATE TABLE rhn_ll_netsaint
(
- netsaint_id NUMBER(12) NOT NULL,
+ netsaint_id NUMBER NOT NULL,
city VARCHAR2(255)
)
ENABLE ROW MOVEMENT
diff --git a/schema/spacewalk/common/tables/rhn_probe_param_value.sql b/schema/spacewalk/common/tables/rhn_probe_param_value.sql
index ded05e1..e2f606b 100644
--- a/schema/spacewalk/common/tables/rhn_probe_param_value.sql
+++ b/schema/spacewalk/common/tables/rhn_probe_param_value.sql
@@ -16,8 +16,8 @@
CREATE TABLE rhn_probe_param_value
(
- probe_id NUMBER(12) NOT NULL,
- command_id NUMBER(12) NOT NULL,
+ probe_id NUMBER NOT NULL,
+ command_id NUMBER NOT NULL,
param_name VARCHAR2(40) NOT NULL,
value VARCHAR2(1024),
last_update_user VARCHAR2(40),
diff --git a/schema/spacewalk/postgres/procs/rhn_prepare_install.sql b/schema/spacewalk/postgres/procs/rhn_prepare_install.sql
index 5ebb34b..05e51a6 100644
--- a/schema/spacewalk/postgres/procs/rhn_prepare_install.sql
+++ b/schema/spacewalk/postgres/procs/rhn_prepare_install.sql
@@ -26,7 +26,7 @@ rhn_prepare_install
command_instance_id in out rhn_command_queue_instances.recid%type,
install_command in rhn_command_queue_instances.command_id%type
)
-returns smallint
+returns numeric
as $$
declare
/* ignore this command if it has not been run after five minutes */
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/001-numeric-12-columns.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/001-numeric-12-columns.sql
deleted file mode 100644
index c5ec175..0000000
--- a/schema/spacewalk/upgrade/spacewalk-schema-0.6-to-spacewalk-schema-0.7/001-numeric-12-columns.sql
+++ /dev/null
@@ -1,8 +0,0 @@
--- Change columns to numeric 12 to match the columns of their foreign keys.
-alter table rhn_contact_group_members modify(contact_group_id NUMBER(12));
-alter table rhn_contact_group_members modify(member_contact_method_id NUMBER(12));
-alter table rhn_contact_group_members modify(member_contact_group_id NUMBER(12));
-alter table rhn_ll_netsaint modify(netsaint_id NUMBER(12));
-alter table rhn_probe_param_value modify(probe_id NUMBER(12));
-alter table rhn_probe_param_value modify(command_id NUMBER(12));
-
13 years, 6 months
Changes to 'refs/tags/SatConfig-cluster-1.54.8-1'
by Miroslav Suchý
Tag 'SatConfig-cluster-1.54.8-1' created by Miroslav Suchý <msuchy(a)redhat.com> at 2009-11-30 13:43 +0000
Tagging package [SatConfig-cluster] version [1.54.8-1] in directory [monitoring/SatConfig/cluster/].
Changes since spacewalk-java-0.7.21-1:
Miroslav Suchý (2):
name space Validator conflicts with older version of perl-IO-Compress-Base
Automatic commit of package [SatConfig-cluster] release [1.54.8-1].
---
monitoring/SatConfig/cluster/ApacheServer.pm | 6 +-
monitoring/SatConfig/cluster/ConfigObject.pm | 2
monitoring/SatConfig/cluster/HostsAccess.pm | 2
monitoring/SatConfig/cluster/IpAddr.pm | 18 +++----
monitoring/SatConfig/cluster/LocalConfig.pm | 10 ++--
monitoring/SatConfig/cluster/ModJK2.pm | 8 +--
monitoring/SatConfig/cluster/NetworkFilesystem.pm | 2
monitoring/SatConfig/cluster/OffnetRoute.pm | 10 ++--
monitoring/SatConfig/cluster/PhysCluster.pm | 48 +++++++++----------
monitoring/SatConfig/cluster/PhysNode.pm | 8 +--
monitoring/SatConfig/cluster/PrivateIpAddr.pm | 2
monitoring/SatConfig/cluster/RemoteConfig.pm | 6 +-
monitoring/SatConfig/cluster/SatConfig-cluster.spec | 5 +-
monitoring/SatConfig/cluster/TomcatBinding.pm | 6 +-
monitoring/SatConfig/cluster/TomcatServer.pm | 50 ++++++++++----------
monitoring/SatConfig/cluster/VIP.pm | 2
rel-eng/packages/SatConfig-cluster | 2
17 files changed, 95 insertions(+), 92 deletions(-)
---
13 years, 6 months
2 commits - monitoring/SatConfig rel-eng/packages
by Miroslav Suchý
monitoring/SatConfig/cluster/ApacheServer.pm | 6 +-
monitoring/SatConfig/cluster/ConfigObject.pm | 2
monitoring/SatConfig/cluster/HostsAccess.pm | 2
monitoring/SatConfig/cluster/IpAddr.pm | 18 +++----
monitoring/SatConfig/cluster/LocalConfig.pm | 10 ++--
monitoring/SatConfig/cluster/ModJK2.pm | 8 +--
monitoring/SatConfig/cluster/NetworkFilesystem.pm | 2
monitoring/SatConfig/cluster/OffnetRoute.pm | 10 ++--
monitoring/SatConfig/cluster/PhysCluster.pm | 48 +++++++++----------
monitoring/SatConfig/cluster/PhysNode.pm | 8 +--
monitoring/SatConfig/cluster/PrivateIpAddr.pm | 2
monitoring/SatConfig/cluster/RemoteConfig.pm | 6 +-
monitoring/SatConfig/cluster/SatConfig-cluster.spec | 5 +-
monitoring/SatConfig/cluster/TomcatBinding.pm | 6 +-
monitoring/SatConfig/cluster/TomcatServer.pm | 50 ++++++++++----------
monitoring/SatConfig/cluster/VIP.pm | 2
rel-eng/packages/SatConfig-cluster | 2
17 files changed, 95 insertions(+), 92 deletions(-)
New commits:
commit 662544755c534462b18e5eeaa528b608243b5ad0
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Mon Nov 30 14:43:07 2009 +0100
Automatic commit of package [SatConfig-cluster] release [1.54.8-1].
diff --git a/monitoring/SatConfig/cluster/SatConfig-cluster.spec b/monitoring/SatConfig/cluster/SatConfig-cluster.spec
index 6fdc5b7..7f2b298 100644
--- a/monitoring/SatConfig/cluster/SatConfig-cluster.spec
+++ b/monitoring/SatConfig/cluster/SatConfig-cluster.spec
@@ -1,6 +1,6 @@
%define sysv_dir %{_sysconfdir}/rc.d/np.d
Name: SatConfig-cluster
-Version: 1.54.7
+Version: 1.54.8
Release: 1%{?dist}
Summary: Satellite Configuration System - cluster information
URL: https://fedorahosted.org/spacewalk
@@ -57,6 +57,9 @@ install -m 644 SatCluster.pm $RPM_BUILD_ROOT%{perl_vendorlib}/NOCpulse/
rm -rf $RPM_BUILD_ROOT
%changelog
+* Mon Nov 30 2009 Miroslav Suchý <msuchy(a)redhat.com> 1.54.8-1
+- name space Validator conflicts with older version of perl-IO-Compress-Base
+
* Mon Jul 27 2009 John Matthews <jmatthew(a)redhat.com> 1.54.7-1
- remove warning when run as perl -w (msuchy(a)redhat.com)
diff --git a/rel-eng/packages/SatConfig-cluster b/rel-eng/packages/SatConfig-cluster
index ab988af..c4b5e77 100644
--- a/rel-eng/packages/SatConfig-cluster
+++ b/rel-eng/packages/SatConfig-cluster
@@ -1 +1 @@
-1.54.7-1 monitoring/SatConfig/cluster/
+1.54.8-1 monitoring/SatConfig/cluster/
commit 09512ad3f4717c8cc8f1d2a0aa7804334097c241
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Mon Nov 30 14:41:21 2009 +0100
name space Validator conflicts with older version of perl-IO-Compress-Base
See https://bugzilla.redhat.com/show_bug.cgi?id=542645 for more details
Since Validator:: is quite generic namespace, it is high probability of
such conflict in future. Therefore I changed the namespace to
SatConfig::cluster::Validator
diff --git a/monitoring/SatConfig/cluster/ApacheServer.pm b/monitoring/SatConfig/cluster/ApacheServer.pm
index b9af38d..35ebd01 100644
--- a/monitoring/SatConfig/cluster/ApacheServer.pm
+++ b/monitoring/SatConfig/cluster/ApacheServer.pm
@@ -18,21 +18,21 @@ sub initialize
my ($self,@params) = @_;
$self->SUPER::initialize(@params);
$self->addValidators(
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'serverName',
description=>'Fully qualified host+domain name of the server in question',
required=>0,
optional=>1,
format=>'string'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'serverAlias',
description=>'Short name (i.e. host name) of the server',
required=>0,
optional=>1,
format=>'string'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'allowedClients',
description=>'Space separated list of IP addresses that clients can connect from (if none, all are allowed)',
required=>0,
diff --git a/monitoring/SatConfig/cluster/ConfigObject.pm b/monitoring/SatConfig/cluster/ConfigObject.pm
index 8fa8f59..b395768 100644
--- a/monitoring/SatConfig/cluster/ConfigObject.pm
+++ b/monitoring/SatConfig/cluster/ConfigObject.pm
@@ -200,7 +200,7 @@ sub describe
return $result;
}
-package Validator;
+package SatConfig::cluster::Validator;
use NOCpulse::Object;
@ISA=qw(NOCpulse::Object);
diff --git a/monitoring/SatConfig/cluster/HostsAccess.pm b/monitoring/SatConfig/cluster/HostsAccess.pm
index 034642a..7759890 100644
--- a/monitoring/SatConfig/cluster/HostsAccess.pm
+++ b/monitoring/SatConfig/cluster/HostsAccess.pm
@@ -16,7 +16,7 @@ sub initialize
my ($self,@params) = @_;
$self->SUPER::initialize(@params);
$self->addValidators(
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'allow',
description=>'Comma separated list of hosts (per hosts_access(5)) allowed access to this daemon',
required=>0,
diff --git a/monitoring/SatConfig/cluster/IpAddr.pm b/monitoring/SatConfig/cluster/IpAddr.pm
index 83edba3..4912b9c 100644
--- a/monitoring/SatConfig/cluster/IpAddr.pm
+++ b/monitoring/SatConfig/cluster/IpAddr.pm
@@ -24,63 +24,63 @@ sub initialize
{
my ($self,@params) = @_;
$self->addValidators(
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'dev',
description=>'A device name (e.g. eth0)',
required=>1,
optional=>0,
format=>'deviceName'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'speed',
description=>'Force link speed (100baseT4, 100baseTx, 100baseTx-FD, 100baseTx-HD, 10baseT, 10baseT-FD, 10baseT-HD)',
required=>0,
optional=>1,
format=>'string'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'mtu',
description=>'Force link mtu size',
required=>0,
optional=>1,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'mac',
description=>'A MAC address (e.g. 00:D0:11:22:33:44)',
required=>0,
optional=>0,
format=>'macAddress'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'addr',
description=>'An IP address',
required=>1,
optional=>0,
format=>'ipAddress'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'mask',
description=>'A CIDR netmask (e.g. 24)',
required=>1,
optional=>0,
format=>'cidrMask'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'gate',
description=>'IP address of gateway',
required=>0,
optional=>1,
format=>'ipAddress'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'fqdn',
description=>'Fully qualified domain name for this address',
required=>0,
optional=>1,
format=>'string'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'TomcatBinding',
description=>'Tomcat App Server Binding',
required=>0,
diff --git a/monitoring/SatConfig/cluster/LocalConfig.pm b/monitoring/SatConfig/cluster/LocalConfig.pm
index 2d2208f..1409710 100644
--- a/monitoring/SatConfig/cluster/LocalConfig.pm
+++ b/monitoring/SatConfig/cluster/LocalConfig.pm
@@ -20,35 +20,35 @@ sub initialize
my ($self,@params) = @_;
$self->SUPER::initialize(@params);
$self->addValidators(
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'dbd',
description=>'Database driver (usually Oracle)',
required=>1,
optional=>0,
format=>'string'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'dbname',
description=>'Database name (usually licensed01)',
required=>1,
optional=>0,
format=>'string'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'orahome',
description=>'Path to Oracle home (/home/oracle/OraHome1)',
required=>1,
optional=>0,
format=>'string'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'username',
description=>'User to log in to database as (web)',
required=>1,
optional=>0,
format=>'string'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'username',
description=>'Passwod to log into database with',
required=>1,
diff --git a/monitoring/SatConfig/cluster/ModJK2.pm b/monitoring/SatConfig/cluster/ModJK2.pm
index 688f5df..2b2f2bf 100644
--- a/monitoring/SatConfig/cluster/ModJK2.pm
+++ b/monitoring/SatConfig/cluster/ModJK2.pm
@@ -21,28 +21,28 @@ sub initialize
my ($self,@params) = @_;
$self->SUPER::initialize(@params);
$self->addValidators(
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'jkshmSize',
description=>'dykeman fix',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'webapps',
description=>'dykeman fix',
required=>1,
optional=>0,
format=>'string'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'serverClusterFilename',
description=>'Configuration filename (on this machine) of the J2K server cluster',
required=>1,
optional=>0,
format=>'string'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'debugLevel',
description=>'dykeman fix',
required=>1,
diff --git a/monitoring/SatConfig/cluster/NetworkFilesystem.pm b/monitoring/SatConfig/cluster/NetworkFilesystem.pm
index f707e45..222fe4d 100644
--- a/monitoring/SatConfig/cluster/NetworkFilesystem.pm
+++ b/monitoring/SatConfig/cluster/NetworkFilesystem.pm
@@ -16,7 +16,7 @@ sub initialize
my ($self,@params) = @_;
$self->SUPER::initialize(@params);
$self->addValidators(
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'source',
description=>'<servername>:</path/to/mount>',
required=>1,
diff --git a/monitoring/SatConfig/cluster/OffnetRoute.pm b/monitoring/SatConfig/cluster/OffnetRoute.pm
index 9a71dee..928dddb 100644
--- a/monitoring/SatConfig/cluster/OffnetRoute.pm
+++ b/monitoring/SatConfig/cluster/OffnetRoute.pm
@@ -18,35 +18,35 @@ sub initialize
{
my ($self,@params) = @_;
$self->addValidators(
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'net',
description=>'A network address',
required=>1,
optional=>0,
format=>'ipAddress'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'mask',
description=>'A CIDR mask (e.g. 24)',
required=>0,
optional=>0,
format=>'cidrMask'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'dev',
description=>'A device name (e.g. eth0)',
required=>1,
optional=>0,
format=>'deviceName'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'gate',
description=>'IP address of a gateway',
required=>1,
optional=>0,
format=>'ipAddress'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'vip',
description=>'Virtual IP address',
required=>0,
diff --git a/monitoring/SatConfig/cluster/PhysCluster.pm b/monitoring/SatConfig/cluster/PhysCluster.pm
index 3f59404..e90ec1f 100644
--- a/monitoring/SatConfig/cluster/PhysCluster.pm
+++ b/monitoring/SatConfig/cluster/PhysCluster.pm
@@ -53,168 +53,168 @@ sub initialize
$self->SUPER::initialize();
$self->readFromFile($filename);
$self->addValidators(
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'satNumber',
description=>'Node number within the cluster (e.g. 1,2)',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'nameservers',
description=>'List of nameserver ip addresses separated by spaces',
required=>1,
optional=>0,
format=>'string'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'nssearchpath',
description=>'List of domain names to search separated by spaces',
required=>1,
optional=>0,
format=>'string'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'smonaddr',
description=>'IP address of smon',
required=>1,
optional=>0,
format=>'ipAddress'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'smonfqdn',
description=>'Fully qualified domain name of smon',
required=>1,
optional=>0,
format=>'fqdn'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'smontestaddr',
description=>'IP address of smon-test',
required=>1,
optional=>0,
format=>'ipAddress'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'smontestfqdn',
description=>'Fully qualified domain name of smon-test',
required=>1,
optional=>0,
format=>'fqdn'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'sshaddr',
description=>'IP Address of host from which SSH connects will come',
required=>1,
optional=>0,
format=>'ipAddress'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'sshmask',
description=>'Dotted-quad mask for sshaddr',
required=>1,
optional=>0,
format=>'ipAddress'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'sshfqdn',
description=>'Fully qualified domain name of host from which ssh connects will com',
required=>1,
optional=>0,
format=>'fqdn'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'otherHosts',
description=>'List of static host entries separated by spaces',
required=>0,
optional=>1,
format=>'string'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'ntpservers',
description=>'List of ntp server IP addresses separated by spaces',
required=>0,
optional=>1,
format=>'string'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'superSputEnabled',
description=>'1 or 0, depending on whether SuperSput should be enabled or not',
required=>1,
optional=>0,
format=>'boolean'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'haFailoverEnabled',
description=>'1 or 0, depending on whether HA should be enabled or not',
required=>1,
optional=>0,
format=>'boolean'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'portalAddress',
description=>'IP address of the portal/DB machine',
required=>0,
optional=>1,
format=>'ipAddress'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'VIP',
description=>'Virtual IP Address definition',
required=>0,
optional=>1,
format=>'VIP'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'OffnetRoute',
description=>'Off net route definition',
required=>0,
optional=>0,
format=>'OffnetRoute'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'PhysNode',
description=>'Node definition',
required=>1,
optional=>0,
format=>'PhysNode'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'ApacheServer',
description=>'Apache server definition',
required=>0,
optional=>-1,
format=>'ApacheServer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'NetworkFilesystem',
description=>'An NFS mounted filesystem',
required=>0,
optional=>-1,
format=>'NetworkFilesystem'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'LocalConfig',
description=>'Local configuration server access info',
required=>0,
optional=>1,
format=>'LocalConfig'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'RemoteConfig',
description=>'Remote configuration server access info',
required=>0,
optional=>1,
format=>'RemoteConfig'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'TomcatServer',
description=>'System wide parameters for a Tomcat app server',
required=>0,
optional=>1,
format=>'TomcatServer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'ModJK2',
description=>'Parameters for JK2 clients under Apache',
required=>0,
diff --git a/monitoring/SatConfig/cluster/PhysNode.pm b/monitoring/SatConfig/cluster/PhysNode.pm
index 8e0059f..4a633f9 100644
--- a/monitoring/SatConfig/cluster/PhysNode.pm
+++ b/monitoring/SatConfig/cluster/PhysNode.pm
@@ -22,28 +22,28 @@ sub initialize
my ($self,@params) = @_;
$self->SUPER::initialize(@params);
$self->addValidators(
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'IpAddr',
description=>'An IP Address definition',
required=>1,
optional=>-1,
format=>'IpAddr'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'PrivateIpAddr',
description=>'A private IP Address definition',
required=>1,
optional=>0,
format=>'PrivateIpAddr'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'HostsAccess',
description=>'Hosts allowed to access a daemons services',
required=>0,
optional=>-1,
format=>'HostsAccess'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'hostname',
description=>'Host Name',
required=>0,
diff --git a/monitoring/SatConfig/cluster/PrivateIpAddr.pm b/monitoring/SatConfig/cluster/PrivateIpAddr.pm
index fdc9435..4dc533d 100644
--- a/monitoring/SatConfig/cluster/PrivateIpAddr.pm
+++ b/monitoring/SatConfig/cluster/PrivateIpAddr.pm
@@ -45,7 +45,7 @@ sub initialize
$self->SUPER::initialize(@params);
$self->set_validators([]);
$self->addValidators(
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'dev',
description=>'A device name (e.g. eth0 or lo)',
required=>1,
diff --git a/monitoring/SatConfig/cluster/RemoteConfig.pm b/monitoring/SatConfig/cluster/RemoteConfig.pm
index 765c75c..01d506e 100644
--- a/monitoring/SatConfig/cluster/RemoteConfig.pm
+++ b/monitoring/SatConfig/cluster/RemoteConfig.pm
@@ -18,21 +18,21 @@ sub initialize
my ($self,@params) = @_;
$self->SUPER::initialize(@params);
$self->addValidators(
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'protocol',
description=>'Protocol to access configuration server with (http/https)',
required=>1,
optional=>0,
format=>'string'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'host',
description=>'Host to connect to (defaults to smon address)',
required=>0,
optional=>1,
format=>'string'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'path',
description=>'Path to configuration program (/cgi-bin/fetch_nocpulse_ini.cgi)',
required=>1,
diff --git a/monitoring/SatConfig/cluster/TomcatBinding.pm b/monitoring/SatConfig/cluster/TomcatBinding.pm
index 7ea5f1c..dd80bdc 100644
--- a/monitoring/SatConfig/cluster/TomcatBinding.pm
+++ b/monitoring/SatConfig/cluster/TomcatBinding.pm
@@ -18,21 +18,21 @@ sub initialize
my ($self,@params) = @_;
$self->SUPER::initialize(@params);
$self->addValidators(
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'shutdownPort',
description=>'Port on which Tomcat should listen for a shutdown message',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'httpPort',
description=>'Server HTTP server port',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'ajpPort',
description=>'Port on which AJP content is served (a highly-optimized transaction protocol)',
required=>1,
diff --git a/monitoring/SatConfig/cluster/TomcatServer.pm b/monitoring/SatConfig/cluster/TomcatServer.pm
index bc4abd5..bb7fce6 100644
--- a/monitoring/SatConfig/cluster/TomcatServer.pm
+++ b/monitoring/SatConfig/cluster/TomcatServer.pm
@@ -41,175 +41,175 @@ sub initialize
my ($self,@params) = @_;
$self->SUPER::initialize(@params);
$self->addValidators(
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'csdb_connpool_min_limit',
description=>'The Minimum number of physical connections maintained by the current state connection pool',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'csdb_connpool_max_limit',
description=>'The Maximum number of physical connections maintained by the current state connection pool',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'csdb_connpool_increment',
description=>'Incremental number of physical current state connections to be opened when all the existing ones are busy and a new connection is requested.',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'csdb_connpool_active_size',
description=>'kdykeman fix',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'csdb_connpool_pool_size',
description=>'kdykeman fix',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'csdb_connpool_timeout',
description=>'Specifies how much time must pass before an idle physical current state connection is disconnected',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'csdb_connpool_nowait',
description=>'Specifies whether to wait or return an error if the maximum number of connections are in the pool and busy.',
required=>1,
optional=>0,
format=>'boolean'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'cfdb_connpool_min_limit',
description=>'The Minimum number of physical connections maintained by the configuration connection pool',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'cfdb_connpool_max_limit',
description=>'The Maximum number of physical connections maintained by the configuration connection pool',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'cfdb_connpool_increment',
description=>'Incremental number of physical current state connections to be opened when all the existing ones are busy and a new connection is requested.',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'cfdb_connpool_active_size',
description=>'kdykeman fix',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'cfdb_connpool_pool_size',
description=>'kdykeman fix',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'cfdb_connpool_timeout',
description=>'Specifies how much time must pass before an idle physical current state connection is disconnected',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'cfdb_connpool_nowait',
description=>'Specifies whether to wait or return an error if the maximum number of connections are in the pool and busy.',
required=>1,
optional=>0,
format=>'boolean'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'http_minProcessors',
description=>'The number of http request processing threads that will be created on startup. The default value is 5.',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'http_maxProcessors',
description=>'The maximum number of simultaneous requests that can be handled on the http port. The default value is 20.',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'http_enableLookups',
description=>'Whether or not to perform DNS lookups to return the actual host name of the remote client',
required=>1,
optional=>0,
format=>'boolean'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'http_redirectPort',
description=>'The ssl port if being used',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'http_acceptCount',
description=>'The maximum queue length for incoming http connection requests when all possible request processing threads are in use. Any requests received when the queue is full will be refused.',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'http_connectionTimeout',
description=>'The number of milliseconds to wait, after accepting a connection, for the request URI line to be presented.',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'ajp_minProcessors',
description=>'The number of ajp request processing threads that will be created on startup. The default value is 5.',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'ajp_maxProcessors',
description=>'The maximum number of simultaneous requests that can be handled on the ajp port. The default value is 20.',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'ajp_acceptCount',
description=>'The maximum queue length for incoming ajp connection requests when all possible request processing threads are in use. Any requests received when the queue is full will be refused.',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'debugLevel',
description=>'The debugging detail level of log messages generated, with higher numbers creating more detailed output.',
required=>1,
optional=>0,
format=>'integer'
),
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'javaOpts',
description=>'Java runtime options passed on invocation of the java process',
required=>0,
diff --git a/monitoring/SatConfig/cluster/VIP.pm b/monitoring/SatConfig/cluster/VIP.pm
index ba6306d..9bb3aa7 100644
--- a/monitoring/SatConfig/cluster/VIP.pm
+++ b/monitoring/SatConfig/cluster/VIP.pm
@@ -15,7 +15,7 @@ sub initialize
my ($self,@params) = @_;
$self->SUPER::initialize(@params);
$self->addValidators(
- Validator->newInitialized(
+ SatConfig::cluster::Validator->newInitialized(
name=>'network',
description=>'A network address',
required=>1,
13 years, 6 months