Re: [Spacewalk-devel] Patch: 1058431-sw-remove-channel-does-not-rm-ks-trees

2014-02-03 Thread Michael Mraka
Tomas Lestach wrote:
% What if I created a custom distribution that reuses the kickstart trees of 
rhel-i386-server-5 (according to the BZ)?
% 
% Does my kickstart distribution stays unusable after deleting the channel?

Hi Tomas,

Thanks for pointing it out. I've modified code so files are deleted only
if no other kickstart tree points to them.

%  % Hi all,
%  %
%  %I tried to fix the problem described in bz1058431 -
%  Spacewalk-remove-channel does not remove the kickstart trees.
%  %You can find my patch enclosed.
%  
%  Hi Dimi,
%  
%  Thanks for your patch. I've reviewed and commited it. Actually I've
%  splitted the change into two commits - trailing whitespace removal
%  and
%  the change itself - so it's clear which code really changed.

Regards,

--
Michael Mráka
Satellite Engineering, Red Hat

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Re: [Spacewalk-devel] Patch: 1058431-sw-remove-channel-does-not-rm-ks-trees

2014-01-29 Thread Michael Mraka
Dimitar Yordanov wrote:
% Hi all,
% 
%I tried to fix the problem described in bz1058431 - 
Spacewalk-remove-channel does not remove the kickstart trees.
%You can find my patch enclosed.

Hi Dimi,

Thanks for your patch. I've reviewed and commited it. Actually I've
splitted the change into two commits - trailing whitespace removal and
the change itself - so it's clear which code really changed.


Regards,

--
Michael Mráka
Satellite Engineering, Red Hat

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Re: [Spacewalk-devel] Patch: 1058431-sw-remove-channel-does-not-rm-ks-trees

2014-01-29 Thread Tomas Lestach
What if I created a custom distribution that reuses the kickstart trees of 
rhel-i386-server-5 (according to the BZ)?

Does my kickstart distribution stays unusable after deleting the channel?

Regards,
--
Tomas Lestach
Red Hat Satellite Engineering, Red Hat


- Original Message -
 From: Michael Mraka michael.mr...@redhat.com
 To: spacewalk-devel@redhat.com
 Sent: Wednesday, January 29, 2014 2:55:42 PM
 Subject: Re: [Spacewalk-devel] Patch: 
 1058431-sw-remove-channel-does-not-rm-ks-trees
 
 Dimitar Yordanov wrote:
 % Hi all,
 %
 %I tried to fix the problem described in bz1058431 -
 Spacewalk-remove-channel does not remove the kickstart trees.
 %You can find my patch enclosed.
 
 Hi Dimi,
 
 Thanks for your patch. I've reviewed and commited it. Actually I've
 splitted the change into two commits - trailing whitespace removal
 and
 the change itself - so it's clear which code really changed.
 
 
 Regards,
 
 --
 Michael Mráka
 Satellite Engineering, Red Hat
 
 ___
 Spacewalk-devel mailing list
 Spacewalk-devel@redhat.com
 https://www.redhat.com/mailman/listinfo/spacewalk-devel

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

[Spacewalk-devel] Patch: 1058431-sw-remove-channel-does-not-rm-ks-trees

2014-01-28 Thread Dimitar Yordanov
Hi all,

   I tried to fix the problem described in bz1058431 - Spacewalk-remove-channel 
does not remove the kickstart trees.
   You can find my patch enclosed.

Dimi

-- 
Dimitar Yordanov
Systems Management QA
#satellite-qa
From 50cd79f0607322aab39a3d34e48dd8712c87eadb Mon Sep 17 00:00:00 2001
From: Dimitar Yordanov dyord...@redhat.com
Date: Mon, 27 Jan 2014 20:09:53 +0100
Subject: [PATCH] 1058431 - sw-remove-channel does not rm ks trees.

---
 backend/satellite_tools/spacewalk-remove-channel | 71 
 1 file changed, 47 insertions(+), 24 deletions(-)

diff --git a/backend/satellite_tools/spacewalk-remove-channel b/backend/satellite_tools/spacewalk-remove-channel
index f3b5d2e..1b9216c 100755
--- a/backend/satellite_tools/spacewalk-remove-channel
+++ b/backend/satellite_tools/spacewalk-remove-channel
@@ -11,10 +11,10 @@
 # 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. 
+# in this software or its documentation.
 #
 
 import sys
@@ -35,11 +35,11 @@ from spacewalk.server import rhnSQL
 from spacewalk.server.rhnPackage import unlink_package_file
 
 options_table = [
-Option(-v, --verbose,   action=count, 
+Option(-v, --verbose,   action=count,
help=Increase verbosity),
 Option(-l, --list,  action=store_true,
help=List defined channels and exit),
-Option(-c, --channel,   action=append, 
+Option(-c, --channel,   action=append,
help=Delete this channel (can be present multiple times)),
 Option(-u, --unsubscribe,   action=store_true,
help=Unsubscribe systems registered to the specified channels),
@@ -157,7 +157,7 @@ def main():
 def __serverCheck(labels, unsubscribe):
 sql = 
 select distinct S.org_id, S.id, S.name
-from rhnChannel c inner join 
+from rhnChannel c inner join
  rhnServerChannel sc on c.id = sc.channel_id inner join
  rhnServer s on s.id = sc.server_id
 where c.label in (%s)
@@ -187,13 +187,13 @@ def __serverCheck(labels, unsubscribe):
 print str(map['id']).ljust(14),
 print(map['name'])
 
-return len(list) 
+return len(list)
 
 
 def __unsubscribeServers(labels):
 sql = 
 select distinct sc.server_id as server_id, C.id as channel_id, c.parent_channel, c.label
-from rhnChannel c inner join 
+from rhnChannel c inner join
  rhnServerChannel sc on c.id = sc.channel_id
 where c.label in (%s) order by C.parent_channel
 
@@ -231,7 +231,7 @@ def __unsubscribeServers(labels):
 def __kickstartCheck(labels):
 sql = 
 select K.org_id, K.label
-from rhnKSData K inner join 
+from rhnKSData K inner join
  rhnKickstartDefaults KD on KD.kickstart_id = K.id inner join
  rhnKickstartableTree KT on KT.id = KD.kstree_id inner join
  rhnChannel c on c.id = KT.channel_id
@@ -250,7 +250,7 @@ def __kickstartCheck(labels):
   Please remove these or change their associated base channel.\n)
 print('org_id'.ljust(8)),
 print('label')
-print(-*20) 
+print(-*20)
 for map in list:
 print str(map['org_id']).ljust(8),
 print(map['label'])
@@ -260,7 +260,7 @@ def __kickstartCheck(labels):
 
 def __listChannels():
 sql = 
-select c1.label, c2.label parent_channel 
+select c1.label, c2.label parent_channel
 from rhnChannel c1 left outer join rhnChannel c2 on c1.parent_channel = c2.id
 order by c2.label desc, c1.label asc
 
@@ -286,7 +286,7 @@ def __listChannels():
 def delete_channels(channelLabels, force=0, justdb=0, skip_packages=0, skip_channels=0):
 # Get the package ids
 if not channelLabels:
-return 
+return
 
 rpms_ids = list_packages(channelLabels, force=force, sources=0)
 rpms_paths = _get_package_paths(rpms_ids, sources=0)
@@ -297,14 +297,17 @@ def delete_channels(channelLabels, force=0, justdb=0, skip_packages=0, skip_chan
 _delete_srpms(srpms_ids)
 _delete_rpms(rpms_ids)
 
+_delete_ks_files(channelLabels)
+
 if not justdb and not skip_packages:
 _delete_files(rpms_paths + srpms_paths)
 
+
 # Get the channel ids
 h = rhnSQL.prepare(
-select id, parent_channel 
-from rhnChannel 
-where label = :label 
+select id, parent_channel
+from rhnChannel
+where label = :label
 order by parent_channel)
 channel_ids = []
 for label in channelLabels:
@@ -327,7 +330,7 @@ def delete_channels(channelLabels, force=0, justdb=0, skip_packages=0, skip_chan
 ]
 query = 
 delete from %(table_2)s