java/code/src/com/redhat/rhn/common/db/datasource/xml/Errata_queries.xml
| 33 +++
java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
| 99 ++++++++++
java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
| 22 ++
java/spacewalk-java.spec
| 10 -
rel-eng/packages/spacewalk-java
| 2
rel-eng/packages/spacewalk-utils
| 2
utils/cloneByDate.py
| 26 ++
utils/spacewalk-clone-by-date
| 4
utils/spacewalk-clone-by-date.sgml
| 12 +
utils/spacewalk-utils.spec
| 5
10 files changed, 204 insertions(+), 11 deletions(-)
New commits:
commit 0aa2ed99cc98f183ae558cb13c3e44a368c931e3
Author: Stephen Herr <sherr(a)redhat.com>
Date: Thu Jan 30 17:51:02 2014 -0500
Automatic commit of package [spacewalk-java] release [2.1.137-1].
diff --git a/java/spacewalk-java.spec b/java/spacewalk-java.spec
index 48d4757..fc43375 100644
--- a/java/spacewalk-java.spec
+++ b/java/spacewalk-java.spec
@@ -28,7 +28,7 @@ Name: spacewalk-java
Summary: Spacewalk Java site packages
Group: Applications/Internet
License: GPLv2
-Version: 2.1.136
+Version: 2.1.137
Release: 1%{?dist}
URL:
https://fedorahosted.org/spacewalk
Source0:
https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
@@ -801,6 +801,14 @@ fi
%{jardir}/postgresql-jdbc.jar
%changelog
+* Thu Jan 30 2014 Stephen Herr <sherr(a)redhat.com> 2.1.137-1
+- 1059910 - create api for channel errata syncing, have clone-by-date call it
+- fix style on kickstart profile creation wizard + use rhn:toolbar
+- use rhn:toolbar for page headers
+- update copyright year in page footer in java
+- Removing unaesthetic spaces around dots in IPv4 address
+- Small code cleanup
+
* Thu Jan 30 2014 Matej Kollar <mkollar(a)redhat.com> 2.1.136-1
- Fixed ssm reboot scheduling.
- Sometimes we don't want "add to ssm" option...
diff --git a/rel-eng/packages/spacewalk-java b/rel-eng/packages/spacewalk-java
index 1c41b95..bf1e5c2 100644
--- a/rel-eng/packages/spacewalk-java
+++ b/rel-eng/packages/spacewalk-java
@@ -1 +1 @@
-2.1.136-1 java/
+2.1.137-1 java/
commit 27a394670e132cc1282baecc936d5bad3bf76933
Author: Stephen Herr <sherr(a)redhat.com>
Date: Thu Jan 30 17:50:11 2014 -0500
Automatic commit of package [spacewalk-utils] release [2.1.27-1].
diff --git a/rel-eng/packages/spacewalk-utils b/rel-eng/packages/spacewalk-utils
index c38810d..d98be26 100644
--- a/rel-eng/packages/spacewalk-utils
+++ b/rel-eng/packages/spacewalk-utils
@@ -1 +1 @@
-2.1.26-1 utils/
+2.1.27-1 utils/
diff --git a/utils/spacewalk-utils.spec b/utils/spacewalk-utils.spec
index 678837b..88bb248 100644
--- a/utils/spacewalk-utils.spec
+++ b/utils/spacewalk-utils.spec
@@ -1,7 +1,7 @@
%define rhnroot %{_prefix}/share/rhn
Name: spacewalk-utils
-Version: 2.1.26
+Version: 2.1.27
Release: 1%{?dist}
Summary: Utilities that may be run against a Spacewalk server.
@@ -91,6 +91,9 @@ spacewalk-pylint $RPM_BUILD_ROOT%{rhnroot}
%changelog
+* Thu Jan 30 2014 Stephen Herr <sherr(a)redhat.com> 2.1.27-1
+- 1059910 - create api for channel errata syncing, have clone-by-date call it
+
* Wed Jan 29 2014 Tomas Kasparek <tkasparek(a)redhat.com> 2.1.26-1
- adding postgresql92-postgresql to possible db service names
commit f0da6be14e30c2570301c0692217171fad1ac690
Author: Stephen Herr <sherr(a)redhat.com>
Date: Thu Jan 30 17:49:51 2014 -0500
1059910 - create api for channel errata syncing, have clone-by-date call it
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Errata_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Errata_queries.xml
index dc41206..f858e4c 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Errata_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Errata_queries.xml
@@ -1296,6 +1296,39 @@ WHERE C.package_id IS NULL
</query>
</mode>
+<mode name="list_packages_needing_sync"
class="com.redhat.rhn.frontend.dto.PackageOverview">
+ <query params="ocid, cid">
+SELECT p.id, pn.name AS package_name,
+ pn.name || '-' || evr_t_as_vre_simple(pevr.evr) || '.' || pa.label
AS nvrea,
+ p.summary
+FROM
+(
+ SELECT
+ oep.package_id, ec.id AS clone_errata_id
+ FROM rhnChannelPackage ocp
+ JOIN rhnChannelErrata oce ON oce.channel_id = ocp.channel_id
+ JOIN rhnErrataPackage oep ON oep.errata_id = oce.errata_id
+ AND oep.package_id = ocp.package_id
+ JOIN rhnErrataCloned ec ON ec.original_id = oep.errata_id
+WHERE ocp.channel_id = :ocid
+) O
+LEFT JOIN (
+ SELECT
+ cep.package_id, cep.errata_id
+ FROM rhnChannelPackage ccp
+ JOIN rhnChannelErrata cce ON cce.channel_id = ccp.channel_id
+ JOIN rhnErrataPackage cep ON cep.errata_id = cce.errata_id
+ AND cep.package_id = ccp.package_id
+WHERE ccp.channel_id = :cid
+) C ON C.errata_id = O.clone_errata_id AND C.package_id = O.package_id
+JOIN rhnPackage p ON p.id = O.package_id
+JOIN rhnPackageName pn ON pn.id = p.name_id
+JOIN rhnPackageEVR pevr ON pevr.id = p.evr_id
+JOIN rhnPackageArch pa ON pa.id = p.package_arch_id
+WHERE C.package_id IS NULL
+ </query>
+</mode>
+
<mode name="list_packages_needing_sync_from_set"
class="com.redhat.rhn.frontend.dto.PackageOverview">
<query params="set_label, ocid, cid">
SELECT p.id, pn.name AS package_name,
diff --git
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
index abdeb26..b2d5de7 100644
---
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
+++
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
@@ -30,6 +30,7 @@ import com.redhat.rhn.domain.channel.ContentSource;
import com.redhat.rhn.domain.channel.ContentSourceFilter;
import com.redhat.rhn.domain.channel.InvalidChannelRoleException;
import com.redhat.rhn.domain.channel.NewChannelHelper;
+import com.redhat.rhn.domain.errata.impl.PublishedClonedErrata;
import com.redhat.rhn.domain.errata.Errata;
import com.redhat.rhn.domain.errata.ErrataFactory;
import
com.redhat.rhn.domain.org.Org;
@@ -41,6 +42,7 @@ import com.redhat.rhn.domain.server.Server;
import com.redhat.rhn.domain.server.ServerFactory;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.frontend.dto.ErrataOverview;
+import com.redhat.rhn.frontend.dto.PackageOverview;
import com.redhat.rhn.frontend.events.UpdateErrataCacheEvent;
import com.redhat.rhn.frontend.xmlrpc.BaseHandler;
import com.redhat.rhn.frontend.xmlrpc.DuplicateChannelLabelException;
@@ -99,6 +101,103 @@ public class ChannelSoftwareHandler extends BaseHandler {
private static Logger log = Logger.getLogger(ChannelSoftwareHandler.class);
/**
+ * If you have satellite-synced a new channel then Red Hat Errata
+ * will have been updated with the packages that are in the newly synced
+ * channel. A cloned erratum will not have been automatically updated
+ * however. If you cloned a channel that includes those cloned errata and
+ * should include the new packages, they will not be included when they
+ * should. This method lists the errata that will be updated if you run the
+ * syncErrata method.
+ * @param sessionKey WebSession containing User information.
+ * @param channelLabel Label of cloned channel to check
+ * @return List of errata that are missing packages
+ *
+ * @xmlrpc.doc If you have satellite-synced a new channel then Red Hat
+ * Errata will have been updated with the packages that are in the newly
+ * synced channel. A cloned erratum will not have been automatically updated
+ * however. If you cloned a channel that includes those cloned errata and
+ * should include the new packages, they will not be included when they
+ * should. This method lists the errata that will be updated if you run the
+ * syncErrata method.
+ * @xmlrpc.param #session_key()
+ * @xmlrpc.param #param_desc("string", "channelLabel",
"channel to update")
+ * @xmlrpc.returntype
+ * #array()
+ * $ErrataOverviewSerializer
+ * #array_end()
+ */
+ public List<ErrataOverview> listErrataNeedingSync(String sessionKey,
+ String channelLabel) {
+ User user = getLoggedInUser(sessionKey);
+ Channel channel = lookupChannelByLabel(user, channelLabel);
+
+ return ChannelManager.listErrataNeedingResync(channel, user);
+ }
+
+ /**
+ * If you have satellite-synced a new channel then Red Hat Errata
+ * will have been updated with the packages that are in the newly synced
+ * channel. A cloned erratum will not have been automatically updated
+ * however. If you cloned a channel that includes those cloned errata and
+ * should include the new packages, they will not be included when they
+ * should. This method updates all the errata in the given cloned channel
+ * with packages that have recently been added, and ensures that all the
+ * packages you expect are in the channel.
+ * @param sessionKey WebSession containing User information.
+ * @param channelLabel Label of cloned channel to update
+ * @return Returns 1 if successfull, FaultException otherwise
+ * @throws NoSuchChannelException thrown if no channel is found.
+ *
+ * @xmlrpc.doc If you have satellite-synced a new channel then Red Hat
+ * Errata will have been updated with the packages that are in the newly
+ * synced channel. A cloned erratum will not have been automatically updated
+ * however. If you cloned a channel that includes those cloned errata and
+ * should include the new packages, they will not be included when they
+ * should. This method updates all the errata in the given cloned channel
+ * with packages that have recently been added, and ensures that all the
+ * packages you expect are in the channel.
+ * @xmlrpc.param #session_key()
+ * @xmlrpc.param #param_desc("string", "channelLabel",
"channel to update")
+ * @xmlrpc.returntype #return_int_success()
+ */
+ public Integer syncErrata(String sessionKey, String channelLabel) {
+ User user = getLoggedInUser(sessionKey);
+ Channel channel = lookupChannelByLabel(user, channelLabel);
+ //Verify permissions
+ if (!(UserManager.verifyChannelAdmin(user, channel) ||
+ user.hasRole(RoleFactory.CHANNEL_ADMIN))) {
+ throw new PermissionCheckFailureException();
+ }
+
+ List<ErrataOverview> errata =
ChannelManager.listErrataNeedingResync(channel, user);
+ List<Long> eids = new ArrayList<Long>();
+ for (ErrataOverview e : errata) {
+ eids.add(e.getId());
+ }
+
+ List<PackageOverview> packages = ChannelManager
+ .listErrataPackagesForResync(channel, user);
+ List<Long> pids = new ArrayList<Long>();
+ for (PackageOverview p : packages) {
+ pids.add(p.getId());
+ }
+
+ ChannelEditor.getInstance().addPackages(user, channel, pids);
+
+ for (Long eid : eids) {
+ Errata e = ErrataManager.lookupErrata(eid, user);
+ if (e.isPublished() && e.isCloned()) {
+ ErrataFactory.syncErrataDetails((PublishedClonedErrata) e);
+ }
+ else {
+ log.fatal("Tried to sync errata with id " + eid +
+ " But it was not published or was not cloned");
+ }
+ }
+ return 1;
+ }
+
+ /**
* Lists the packages with the latest version (including release and epoch)
* for the unique package names
* @param sessionKey WebSession containing User information.
diff --git a/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
b/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
index 658f41f..025d880 100644
--- a/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
+++ b/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
@@ -2584,6 +2584,28 @@ public class ChannelManager extends BaseManager {
* List errata packages that need to be resynced
* @param c the channel to look for packages in
* @param user the user doing it
+ * @return the list of PackageOverview objects
+ */
+ public static List listErrataPackagesForResync(Channel c, User user) {
+ if (!user.hasRole(RoleFactory.CHANNEL_ADMIN)) {
+ throw new PermissionException(RoleFactory.CHANNEL_ADMIN);
+ }
+
+ if (c.isCloned()) {
+ Map params = new HashMap();
+ params.put("cid", c.getId());
+ params.put("ocid", c.getOriginal().getId());
+ SelectMode m = ModeFactory.getMode("Errata_queries",
+ "list_packages_needing_sync");
+ return m.execute(params);
+ }
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * List errata packages that need to be resynced
+ * @param c the channel to look for packages in
+ * @param user the user doing it
* @param setLabel the set of errata to base the package off of
* @return the list of PackageOverview objects
*/
diff --git a/utils/cloneByDate.py b/utils/cloneByDate.py
index b199a38..588a1da 100644
--- a/utils/cloneByDate.py
+++ b/utils/cloneByDate.py
@@ -145,12 +145,13 @@ def main(options):
options.to_date, options.blacklist,
options.removelist, options.background,
options.security_only,
options.use_update_date,
- options.parents)
+ options.no_errata_sync, options.parents)
else:
tree_cloner = ChannelTreeCloner(channel_list, xmlrpc, db,
options.to_date, options.blacklist,
options.removelist, options.background,
-
options.security_only,options.use_update_date)
+
options.security_only,options.use_update_date,
+ options.no_errata_sync)
cloners.append(tree_cloner)
needed_channels += tree_cloner.needing_create().values()
@@ -202,8 +203,8 @@ class ChannelTreeCloner:
"""
# pylint: disable=R0902
def __init__(self, channels, remote_api, db_api, to_date, blacklist,
- removelist, detached,
- security_only, use_update_date, parents =
None):
+ removelist, detached, security_only, use_update_date,
+ no_errata_sync, parents = None):
self.remote_api = remote_api
self.db_api = db_api
self.channel_map = channels
@@ -223,13 +224,15 @@ class ChannelTreeCloner:
self.detached = detached
self.security_only = security_only
self.use_update_date = use_update_date
+ self.no_errata_sync = no_errata_sync
self.validate_source_channels()
for from_label in self.ordered_labels():
to_label = self.channel_map[from_label]
cloner = ChannelCloner(from_label, to_label, self.to_date,
self.remote_api, self.db_api, self.detached,
- self.security_only,self.use_update_date)
+ self.security_only, self.use_update_date,
+ self.no_errata_sync)
self.cloners.append(cloner)
@@ -427,7 +430,7 @@ class ChannelTreeCloner:
class ChannelCloner:
# pylint: disable=R0902
def __init__(self, from_label, to_label, to_date, remote_api, db_api,
- detached, security_only, use_update_date):
+ detached, security_only, use_update_date, no_errata_sync):
self.remote_api = remote_api
self.db_api = db_api
self.from_label = from_label
@@ -441,6 +444,7 @@ class ChannelCloner:
self.detached = detached
self.security_only = security_only
self.use_update_date = use_update_date
+ self.no_errata_sync = no_errata_sync
def dest_label(self):
@@ -547,6 +551,12 @@ class ChannelCloner:
self.reset_new_pkgs()
pb.printComplete()
+ if not self.no_errata_sync:
+ log_clean(0, "")
+ log_clean(0, "Synchronizing Errata in %s with originals"
+ % self.to_label)
+ self.remote_api.sync_errata(self.to_label)
+
def get_errata(self):
""" Returns tuple of all available for cloning, and what falls in
the date range"""
available_errata = self.db_api.applicable_errata(self.from_label, self.to_label)
@@ -674,6 +684,10 @@ class RemoteApi:
self.auth_check()
self.client.errata.cloneAsOriginalAsync(self.auth_token, to_label, errata_list)
+ def sync_errata(self, to_label):
+ self.auth_check()
+ self.client.channel.software.syncErrata(self.auth_token, to_label)
+
def get_details(self, label):
self.auth_check()
try:
diff --git a/utils/spacewalk-clone-by-date b/utils/spacewalk-clone-by-date
index dd48729..862e9c6 100755
--- a/utils/spacewalk-clone-by-date
+++ b/utils/spacewalk-clone-by-date
@@ -43,6 +43,7 @@ SAMPLE_CONFIG = """
"skip_depsolve":false,
"security_only":false,
"use_update_date":false,
+ "no_errata_sync":false,
"blacklist": {
"ALL":["sendmail"],
"my-rhel5-x86_64-clone":["emacs"],
@@ -87,7 +88,7 @@ def merge_config(options):
# add it to options
overwrite = ["username", "password", "blacklist",
"removelist", "channels",
"server", "assumeyes", "to_date",
"skip_depsolve",
- "security_only", "use_update_date"]
+ "security_only", "use_update_date",
"no_errata_sync"]
for key in overwrite:
if config.has_key(key) and not getattr(options, key):
setattr(options, key, config[key])
@@ -156,6 +157,7 @@ def parse_args():
+ "original parent and destination parent of child "
+ "channels cloned this session.")
parser.add_option("-z", "--use-update-date",
dest="use_update_date", action='store_true', help="While cloning
errata by date, clone all errata that have last been updated on or before the date
provided by to_date. If omitted will use issue date of errata (default).")
+ parser.add_option("-n", "--no-errata-sync",
dest="no_errata_sync", action='store_true', help="Do not
automatically sychronize the package list of cloned errata with their originals. This may
make spacewalk-clone-by-date have unexpected results if the original errata have been
updated (e.g.: syncing another architecture for a channel) since the cloned errata were
created. If omitted we will synchronize the cloned errata with the originals to ensure the
expected packages are included (default).")
(options, args) = parser.parse_args()
diff --git a/utils/spacewalk-clone-by-date.sgml b/utils/spacewalk-clone-by-date.sgml
index f2fbf8f..45452b9 100644
--- a/utils/spacewalk-clone-by-date.sgml
+++ b/utils/spacewalk-clone-by-date.sgml
@@ -71,6 +71,9 @@ Utility for cloning errata by date.
<arg>-g</arg><arg>--background</arg>
</cmdsynopsis>
<cmdsynopsis>
+ <arg>-n</arg><arg>--no-errata-sync</arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
<arg>-h</arg><arg>--help</arg>
</cmdsynopsis>
<cmdsynopsis>
@@ -210,6 +213,15 @@ Utility for cloning errata by date.
</listitem>
</varlistentry>
<varlistentry>
+ <term>-n --no-errata-sync</term>
+ <listitem>
+ <para>Do not automatically sychronize the package list of cloned errata
with their originals. This may make spacewalk-clone-by-date have unexpected results if the
original errata have been updated (e.g.: syncing another architecture for a channel) since
the cloned errata were created. If omitted we will synchronize the cloned errata with the
originals to ensure the expected packages are included (default).
+ </para>
+ <para>Errata clones do not necessarily get out-of-sync by satellite-syncing
new architectures of existing channels. Another example would be if the errata contains
some packages in one channel (say the base channel) and additional packages in another
channel (say a child channel). Or it may be due to simply adding or removing packages from
a custom errata that you have already created a clone of. Since cloned errata are not
automatically updated when the original errata are, over time they may become out-of-sync
are require synchronization in order for associating the cloned errata with a cloned
channel to have the normally expected effect.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term>-a <replaceable>SRC_PARENT DEST_PARENT</replaceable>,
--parents=<replaceable>SRC_PARENT DEST_PARENT</replaceable></term>
<listitem>
<para>Space separated list of source parent channel and destination
parent channel. These channels are used for resolving dependencies and cloning the
children, but will not be cloned themselves. Both channels specified here must already
exist. There is no way to specify this option through the config channel, you must simply
re-list the parent src:dest channels as part of the list to clone.
Spacewalk-clone-by-date will detect that the dest parent channel already exists and will
not try to re-create it.</para>