From 0e4be3f8db663f2f976260465b62801b47b44f11 Mon Sep 17 00:00:00 2001 From: Ricardo Mateus Date: Thu, 7 Nov 2024 13:13:13 +0000 Subject: [PATCH 1/2] Remove out of support tools from spacewalk-utils-extra remove tool delete-old-systems-interactive Signed-off-by: Ricardo Mateus remove tool migrate-system-profile Signed-off-by: Ricardo Mateus remove spacewalk-api tool Signed-off-by: Ricardo Mateus removes unnecessary dependency Signed-off-by: Ricardo Mateus remove tool sw-ldap-user-sync Signed-off-by: Ricardo Mateus --- .../testing/automation/spacewalk-pylint.sh | 5 - utils/Makefile | 8 +- utils/delete-old-systems-interactive | 115 ------------- utils/delete-old-systems-interactive.sgml | 91 ---------- utils/migrate-system-profile | 85 --------- utils/migrate-system-profile.sgml | 113 ------------ utils/migrateSystemProfile.py | 161 ------------------ utils/spacewalk-api | 102 ----------- utils/spacewalk-api.sgml | 88 ---------- utils/spacewalk-utils.spec | 22 --- utils/sw-ldap-user-sync | 97 ----------- utils/sw-ldap-user-sync.conf | 10 -- 12 files changed, 3 insertions(+), 894 deletions(-) delete mode 100755 utils/delete-old-systems-interactive delete mode 100644 utils/delete-old-systems-interactive.sgml delete mode 100755 utils/migrate-system-profile delete mode 100644 utils/migrate-system-profile.sgml delete mode 100644 utils/migrateSystemProfile.py delete mode 100755 utils/spacewalk-api delete mode 100644 utils/spacewalk-api.sgml delete mode 100755 utils/sw-ldap-user-sync delete mode 100644 utils/sw-ldap-user-sync.conf diff --git a/susemanager-utils/testing/automation/spacewalk-pylint.sh b/susemanager-utils/testing/automation/spacewalk-pylint.sh index 194c52400100..a654295d8506 100755 --- a/susemanager-utils/testing/automation/spacewalk-pylint.sh +++ b/susemanager-utils/testing/automation/spacewalk-pylint.sh @@ -39,12 +39,8 @@ proxy/proxy/wsgi/xmlrpc.py proxy/proxy/wsgi/xmlrpc_redirect.py reporting/reports.py utils/cloneByDate.py -utils/delete-old-systems-interactive utils/depsolver.py utils/__init__.py -utils/migrate-system-profile -utils/migrateSystemProfile.py -utils/spacewalk-api utils/spacewalk-clone-by-date utils/spacewalk-common-channels utils/spacewalk-dump-schema @@ -52,7 +48,6 @@ utils/spacewalk-hostname-rename utils/spacewalk-manage-channel-lifecycle utils/spacewalk-sync-setup utils/spacewalk-utils.changes -utils/sw-ldap-user-sync utils/systemSnapshot.py utils/taskotop spacewalk/certs-tools/ diff --git a/utils/Makefile b/utils/Makefile index 0d32f8c63af3..d7853ede7290 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -5,13 +5,11 @@ NAME := spacewalk-utils SUBDIR = utils -FILES = __init__ migrateSystemProfile depsolver cloneByDate -SCRIPTS = migrate-system-profile spacewalk-api \ - spacewalk-common-channels delete-old-systems-interactive spacewalk-hostname-rename \ +FILES = __init__ depsolver cloneByDate +SCRIPTS = spacewalk-common-channels spacewalk-hostname-rename \ spacewalk-clone-by-date spacewalk-sync-setup spacewalk-manage-channel-lifecycle \ - sw-ldap-user-sync \ taskotop spacewalk-watch-channel-sync.sh -CONFIGS = spacewalk-common-channels.ini sw-ldap-user-sync.conf +CONFIGS = spacewalk-common-channels.ini DOCBOOK = $(wildcard /usr/bin/docbook2man) diff --git a/utils/delete-old-systems-interactive b/utils/delete-old-systems-interactive deleted file mode 100755 index fa67696cde5d..000000000000 --- a/utils/delete-old-systems-interactive +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/python3 -# -# Copyright (c) 2017 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. -# - -from __future__ import print_function -from datetime import datetime, timedelta -from optparse import Option, OptionParser -import re -import sys - -try: - import xmlrpclib -except ImportError: - import xmlrpc.client as xmlrpclib # pylint: disable=F0401 - -def processCommandline(argv): - optionsTable = [ - Option('--idle', action='store', dest='idle', - help=''), - Option('--host', action='store', dest='host', default='localhost', - help=''), - Option('--username', action='store', dest='username', default='admin', - help=''), - Option('--password', action='store', dest='passwd', - help=''), - Option('--force', action='store_true', dest='force', default=False, - help=''), - ] - optionParser = OptionParser( - usage="Usage: %s --idle= [--host=] [--username=] [--password=] [--force]" % sys.argv[0], - option_list=optionsTable) - - options = optionParser.parse_args(argv)[0] - - if not options.idle: - sys.stderr.write('Need --idle parameter\n') - sys.exit(1) - - if not options.passwd: - passwdfile = '/etc/rhn/%s-password' % options.username - try: - with open(passwdfile, 'r') as f: - options.passwd = f.read().splitlines()[0] - except IOError: - sys.stderr.write('Error reading password file [%s]: %s\n' % (passwdfile, sys.exc_info()[1])) - - try: - t, w = re.compile('^(\d+)(\D)$').search(options.idle).groups() - except AttributeError: - t = options.idle - w = 'd' - - try: - t = int(t) - except ValueError: - sys.stderr.write('Unknown idle parameter [%s]\n' % options.idle) - sys.exit(1) - - if w == 'm': - options.idle = t * 60 - elif w == 'h': - options.idle = t * 60 * 60 - elif w == 'd': - options.idle = t * 60 * 60 * 24 - elif w == 'w': - options.idle = t * 60 * 60 * 24 * 7 - else: - sys.stderr.write('Unknown idle parameter [%s]\n' % options.idle) - sys.exit(1) - - return options - -if __name__ == '__main__': - options = processCommandline(sys.argv) - - not_before = datetime.now() - timedelta(seconds=options.idle) - - print('Lookup on [%s] systems with last checkin before [%s]' % (options.host, not_before)) - - client = xmlrpclib.Server('http://%s/rpc/api' % options.host, verbose=0) - key = client.auth.login(options.username, options.passwd) - - systems = client.system.list_user_systems(key) - to_delete = [] - for system in systems: - print('System [%s] id [%s] last checking [%s]' % (system['name'], system['id'], system['last_checkin']), end='') - if system['last_checkin'] < not_before: - to_delete.append(system['id']) - print(' -> delete', end='') - print() - - if len(to_delete) == 0: - print('Total systems [%s], none idle' % len(systems)) - sys.exit(0) - - if not options.force: - print('Total systems [%s], would delete [%s]' % (len(systems), len(to_delete))) - else: - client.system.delete_systems(key, to_delete) - print('All systems deleted') - - client.auth.logout(key) diff --git a/utils/delete-old-systems-interactive.sgml b/utils/delete-old-systems-interactive.sgml deleted file mode 100644 index cab3e82fbb9d..000000000000 --- a/utils/delete-old-systems-interactive.sgml +++ /dev/null @@ -1,91 +0,0 @@ - - - - -delete-old-systems-interactive8 -Version 1.0 - - - -delete-old-systems-interactive - -delete inactive systems from Spacewalk server. - - - - - - - delete-old-systems-interactive [OPTIONS] --idle time_delta - - - - -Description - delete-old-systems-interactive - will use Spacewalk API to determine when each registred system checked in last time and optionaly will delete systems which have been inactive for time_delta. - This script will list all registred systems and their last check in. And will if none system is idle more than time_delta, it will write summary: - Total systems [127], none idle - If some systems are idle more than time_delta, you will get summary like: - Total systems [127], would delete [51] - None system is deleted by default, unless you specify --force option. - - -Options - - - -h, --help - - Display the help screen with a list of options. - - - - --idle time_delta - - Search for system, which are inactive for more than time_delta. If only number is specified, it is interpreted as days. You can use suffixes m (for minutes), h (hours), d (days) and w (weeks). E.g. "--idle 10" and "--idle 10d" is the same and means ten days, "--idle 2w" means two weeks. - - - - --host host - - Hostname of you Spacewalk server. If not set, localhost is used by default. - - - - --username login - - Your username. By default "admin". - - - - --password pass - - Your password. If not specified on command line, then it is read from /etc/rhn/$username-password - - - - --force - - If specified, then idle systems are deleted. - - - - - -EXAMPLES - delete-old-systems-interactive --server=spacewalk.com --idle 30d - - -Authors - - Miroslav Suchymsuchy@redhat.com - Jan Pazdziorajpazdziora@redhat.com - Tomas Kasparektkasparek@redhat.com - - - -COPYRIGHT AND LICENSE - Copyright (c) 2009--2015 Red Hat, Inc. - Released under GNU General Public License, version 2 (GPLv2). - - - diff --git a/utils/migrate-system-profile b/utils/migrate-system-profile deleted file mode 100755 index b3c2e7dae1d2..000000000000 --- a/utils/migrate-system-profile +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/python3 -# -# wrapper for Script to migrate systems between Orgs. -# -# Copyright (c) 2008--2015 Red Hat, Inc. -# -# Authors: Pradeep Kilambi -# -# 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. -# - - -if __name__ != '__main__': - raise ImportError("module cannot be imported") - -import sys - - -def systemExit(code, msgs=None): - "Exit with a code and optional message(s). Saved a few lines of code." - - if msgs: - if type(msgs) not in [type([]), type(())]: - msgs = (msgs, ) - for msg in msgs: - sys.stderr.write(str(msg) + '\n') - sys.exit(code) - -_LIBPATH = "/usr/share/rhn" -# add to the path if need be -if _LIBPATH not in sys.path: - sys.path.append(_LIBPATH) - -from rhn import rhnLockfile - - -### acquire lock/check for other instances of migrate servers -# i.e., lock against multiple instances of migrate servers -LOCK = None -try: - LOCK = rhnLockfile.Lockfile('/tmp/migrate-server.pid') -except rhnLockfile.LockfileLockedException: - systemExit(1, "ERROR: attempting to run more than one instance of migrate-server. Exiting.") - -try: - # NOTE: importing - from utils import migrateSystemProfile -except KeyboardInterrupt: - systemExit(0, "\nUser interrupted process.") -except ImportError as e: - systemExit(2, "Unable to find migrate server tool.\n" - "Error: %s" % e) - - -def releaseLOCK(): - global LOCK - if LOCK: - LOCK.release() - - -def main(): - # execute - try: - return migrateSystemProfile.main() - except KeyboardInterrupt: - systemExit(0, "\nUser interrupted process.") - - releaseLOCK() - return 0 - - -if __name__ == '__main__': - try: - sys.exit(abs(main() or 0)) - except KeyboardInterrupt: - systemExit(0, "\nUser interrupted process.") diff --git a/utils/migrate-system-profile.sgml b/utils/migrate-system-profile.sgml deleted file mode 100644 index b52eef6afe11..000000000000 --- a/utils/migrate-system-profile.sgml +++ /dev/null @@ -1,113 +0,0 @@ - - - - -migrate-system-profile8 -Version 1.0 - - - -migrate-system-profile - -Migrate a system between organizations on the Red Hat Satellite server . - - - - - - - migrate-system-profile - options ... - - - --satellite=SATELLITE - - - -uUSERNAME - --username=USERNAME - - - -pPASSWORD - --password=PASSWORD - - - --systemId=SYSTEMID - - - --to-org-id=TARGET_ORG_ID - - - --csv=CSV_FILE - - - -v --verbose - - - -h--help - - - - -Description - - migrate-system-profile migrates a system from one org to another. - - - -Options - - - -h, --help - - Display the help screen with a list of options. - - - - --satellite - - Satellite server on which migration needs to run. - - - - -uUSERNAME - --username=USERNAME - - username of user that has administrative access to migrate a system from the source org. - - - - -pPASSWORD - --password=PASSWORD - - >password of user that has administrative access to migrate a system from the source org. - - - - --systemId=SYSTEMID - - client system id to be migrated on the satellite server. - - - - --to-org-id=TARGET_ORG_ID - - Target org id the client system will be migrated to. - - - - --csv=CSV_FILE - - CSV file with data to be migrated. Each line should be of the format: - systemId,to-org-id - - - - - - -Authors - - Pradeep Kilambi pkilambi@redhat.com - - - diff --git a/utils/migrateSystemProfile.py b/utils/migrateSystemProfile.py deleted file mode 100644 index c872eb2d284a..000000000000 --- a/utils/migrateSystemProfile.py +++ /dev/null @@ -1,161 +0,0 @@ -""" -Multi-Org: Script to migrate server from one org to another - -Script that connects to a given satellite db and migrates the -server and its history from source org to the destination org. - -Copyright (c) 2008--2015 Red Hat, Inc. Distributed under GPL. -Author: Pradeep Kilambi - -""" - -import csv -import os -import sys -try: - import xmlrpclib -except ImportError: - import xmlrpc.client as xmlrpclib # pylint: disable=F0401 - -from optparse import OptionParser, Option # pylint: disable=deprecated-module -from uyuni.common.cli import getUsernamePassword, xmlrpc_login, xmlrpc_logout - -_topdir = '/usr/share/rhn' -if _topdir not in sys.path: - sys.path.append(_topdir) - -client = None -DEBUG = 0 - -options_table = [ - Option("-v", "--verbose", action="count", - help="Increase verbosity"), - Option("-u", "--username", action="store", - help="Satellite/Org Admin username"), - Option("-p", "--password", action="store", - help="Satellite/Org Admin password"), - Option("--satellite", action="store", - help="Satellite server to run migration"), - Option("--systemId", action="append", - help="client system to migrate"), - Option("--to-org-id", action="store", - help="Destination Org ID"), - Option("--csv", action="store", - help="CSV File to process"), -] - -_csv_fields = ['systemId', 'to-org-id'] - -def main(): - global client, DEBUG - parser = OptionParser(option_list=options_table) - - (options, _args) = parser.parse_args() - - if options.satellite: - satellite_host = options.satellite - else: - satellite_host = os.uname()[1] - - if options.verbose: - DEBUG = 1 - - satellite_url = "http://%s/rpc/api" % satellite_host - if DEBUG: - print("Connecting to %s" % satellite_url) - - client = xmlrpclib.Server(satellite_url, verbose=0) - - if options.csv: - migrate_data = read_csv_file(options.csv) - else: - migrate_data = [] - - if not options.csv: - if not options.systemId: - print("Missing --systemId") - return 1 - - if not options.to_org_id: - print("Missing Destination org id") - return None - else: - to_org_id = options.to_org_id or None - - migrate_data = [[options.systemId, to_org_id]] - - username, password = getUsernamePassword(options.username, - options.password) - - sessionKey = xmlrpc_login(client, username, password) - - if not migrate_data: - sys.stderr.write("Nothing to migrate. Exiting.. \n") - sys.exit(1) - - for server_id, to_org_id in migrate_data: - if isinstance(server_id, type([])): - server_id = list(map(int, server_id)) - else: - server_id = [int(server_id)] - try: - migrate_system(sessionKey, int(to_org_id), server_id) - except Exception: # pylint: disable=try-except-raise - raise - - if DEBUG: - print("Migration Completed successfully") - xmlrpc_logout(client, sessionKey) - - return None - -def migrate_system(key, newOrgId, server_ids): - """ - Call to migrate given system to new org - """ - if DEBUG: - print("Migrating systemIds %s to Org %s" % (server_ids, newOrgId)) - try: - client.org.migrateSystems(key, newOrgId, server_ids) - except xmlrpclib.Fault as e: - sys.stderr.write("Error: %s\n" % e.faultString) - sys.exit(-1) - - - -def lookup_server(key, from_org_id): - # Get the org id - # TODO: replace with an api call - rows = client.org.listServerByOrg(key, from_org_id) - if not rows: - sys.stderr.write("No Systems registered for Org-ID %s \n" % from_org_id) - sys.exit(1) - print(" ") - print("Available Systems for Org-ID: %s " % from_org_id) - print("------------------------------------") - print(" Server-ID Server-Name ") - print("------------------------------------") - for row in rows: - print(" %s %s " % (row['id'], row['name'])) - print("--------------------------------------------") - - return rows - - -def read_csv_file(csv_file): - """ - Parse the fields in the given csv - """ - csv_data = [] - f_csv = open(csv_file) - reader = csv.reader(f_csv) - for data in reader: - if len(data) != len(_csv_fields): - sys.stderr.write("Invalid Data.Skipping line .. \n" - % data) - continue - csv_data.append(data) - return csv_data - -if __name__ == '__main__': - sys.exit(main() or 0) diff --git a/utils/spacewalk-api b/utils/spacewalk-api deleted file mode 100755 index bd5490f5754d..000000000000 --- a/utils/spacewalk-api +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/python3 -# -# Copyright (c) 2017 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. -# - -from getpass import getpass -from optparse import Option, OptionParser -import io -import re -import sys - -try: - import xmlrpclib -except ImportError: - import xmlrpc.client as xmlrpclib # pylint: disable=F0401 - -def processCommandline(argv): - optionsTable = [ - Option('--server', action='store', dest='server', - help='URL of your Spacewalk server.'), - Option('--user', action='store', dest='username', - help='Name of user to log in.'), - Option('--password', action='store', dest='password', - help='If you do not specify this and unless --nologin is specified, you will be prompted for your password.'), - Option('--login', action='store_true', dest='login', default=True, - help='If we should log in or not. Default is to log in.'), - Option('--nologin', action='store_false', dest='login', - help='If we should log in or not. Default is to log in.'), - ] - optionParser = OptionParser( - usage="Usage: %s --server= [--login] [--user=] [--password=]" % sys.argv[0], - option_list=optionsTable) - - options, unparsed = optionParser.parse_args(argv[1:]) - - if not options.server: - sys.stderr.write('Error: No server specified.\n') - sys.exit(1) - - if not options.username and options.login: - with io.TextIOWrapper(open('/dev/tty', 'r+b', buffering=0)) as tty: - tty.write('Enter username: ') - try: - options.username = tty.readline() - except KeyboardInterrupt: - tty.write("\n") - sys.exit(0) - - if not options.password and options.login: - options.password = getpass('Enter your password: ') - - return options, unparsed - -if __name__ == '__main__': - options, unparsed = processCommandline(sys.argv) - - client = xmlrpclib.Server('http://%s/rpc/api' % options.server, verbose=0) - session = '' - if options.login: - try: - session = client.auth.login(options.username, options.password) - except xmlrpclib.Fault: - sys.stderr.write('Error: %s \n' % str(sys.exc_info()[1])) - sys.exit(1) - - params = [] - for param in unparsed: - if param == '%session%': - param = session - elif re.compile('%file:(.*)%').search(param): - filename = re.compile('%file:(.*)%').search(param).groups()[0] - with open(filename, 'r') as f: - param = f.read() - elif re.compile('%boolean:(.*)%').search(param): - param = bool(re.compile('%boolean:(.*)%').search(param).groups()[0]) - elif re.compile('%integer:(.*)%').search(param): - param = int(re.compile('%integer:(.*)%').search(param).groups()[0]) - elif re.compile('%string:(.*)%').search(param): - param = re.compile('%string:(.*)%').search(param).groups()[0] - params.append(param) - - try: - result = getattr(client, params[0])(*params[1:]) - sys.stdout.write(str(result) + '\n') - except xmlrpclib.Fault: - sys.stderr.write('Fault returned from XML RPC Server: %s\n' % str(sys.exc_info()[1])) - sys.exit(1) - finally: - if options.login: - client.auth.logout(session) diff --git a/utils/spacewalk-api.sgml b/utils/spacewalk-api.sgml deleted file mode 100644 index af8c9c0d0642..000000000000 --- a/utils/spacewalk-api.sgml +++ /dev/null @@ -1,88 +0,0 @@ - - - - -spacewalk-api8 -Version 1.0 - - - -spacewalk-api - -Call Spacawalk API from command line. - - - - - - - spacewalk-api [OPTIONS] --server=spacewalk.domain.com FUNCTION [PARAM1 PARAM2 ...] - - - - -Description - spacewalk-api interact with the Spacewalk server and expose its API layer. - FUNCTION is api method you wish to call and is followed by its parameters. There is few special substitutions available: - %session% - is replaced with sessionid. If you use --nologin option, then it is replaced by empty string. - %file:/some/file% - is replaced by content of given file. - %boolean:value% - is interpreted as a boolean value. Use 0 as false and any other integer as true. - %integer:value% - is interpreted as an integer value. - %string:value% - is interpreted as a string value. - - -Options - - - -h, --help - - Display the help screen with a list of options. - - - - --server - - URL of your Spacewalk server. - - - - --login --nologin - - If we should log in or not. Default is to log in. - - - - --user - - Name of user to log in. - - - - --password - - If you do not specify this and unless --nologin is specified, you will be prompted for your password. - - - - - -EXAMPLES - spacewalk-api --server=spacewalk.com --nologin api.systemVersion - spacewalk-api --server=spacewalk.com --user=foo --password=bar channel.listAllChannels "%session%" - spacewalk-api --server=spacewalk.com --user=foo --password=bar user.setReadOnly "%session%" user "%boolean:1%" - spacewalk-api --server=spacewalk.com --nologin proxy.isProxy '%file:/etc/sysconfig/rhn/systemid%' - - -Authors - - Miroslav Suchýmsuchy@redhat.com - Tomas Kasparektkasparek@redhat.com - - - -COPYRIGHT AND LICENSE - Copyright (c) 2009--2017 Red Hat, Inc. - Released under GNU General Public License, version 2 (GPLv2). - - - diff --git a/utils/spacewalk-utils.spec b/utils/spacewalk-utils.spec index 74eba61ed14d..223d775deba1 100644 --- a/utils/spacewalk-utils.spec +++ b/utils/spacewalk-utils.spec @@ -85,20 +85,8 @@ Summary: Extra utilities that may run against a SUSE Manager/Uyuni server # Required by spacewalk-watch-channel-sync.sh Group: Productivity/Other Requires: bash -# Required by sw-ldap-user-sync -Requires: python3-PyYAML -# Required by sw-ldap-user-sync -Requires: python3-ldap -# Required by migrate-system-profile -Requires: python3-rhnlib >= 2.5.20 -# Required by migrateSystemProfile.py -Requires: python3-uyuni-common-libs -# Required by spacewalk-watch-channel-sync.sh -Requires: spacewalk-backend-tools >= 2.2.27 # As spacewalk-utils owns {python3_sitelib}/utils Requires: spacewalk-utils -# Required by migrate-system-profile, migrateSystemProfile.py -Requires(pre): uyuni-base-common %description extras Extra utilities that may be run against a SUSE Manager server (unsupported) or an Uyuni server @@ -149,16 +137,6 @@ popd %files extras %defattr(-,root,root) %license COPYING.GPLv2 COPYING.GPLv3 -%attr(755,root,root) %{_bindir}/delete-old-systems-interactive -%attr(755,root,root) %{_bindir}/migrate-system-profile -%attr(755,root,root) %{_bindir}/spacewalk-api %attr(755,root,root) %{_bindir}/spacewalk-watch-channel-sync.sh -%attr(755,root,root) %{_bindir}/sw-ldap-user-sync -%{python3_sitelib}/utils/migrateSystemProfile.py* -%{python3_sitelib}/utils/__pycache__/migrateSystemProfile.* -%config(noreplace) %{_sysconfdir}/rhn/sw-ldap-user-sync.conf -%{_mandir}/man8/delete-old-systems-interactive.8%{?ext_man} -%{_mandir}/man8/migrate-system-profile.8%{?ext_man} -%{_mandir}/man8/spacewalk-api.8%{?ext_man} %changelog diff --git a/utils/sw-ldap-user-sync b/utils/sw-ldap-user-sync deleted file mode 100755 index f50e7d45c345..000000000000 --- a/utils/sw-ldap-user-sync +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/python3 - -## purpose: creates new spacewalk accounts for users in a specific LDAP -## group, removes spacewalk accounts after deleting users from a -## specific LDAP group -## copyright: B1 Systems GmbH , 2011. -## license: GPLv3+, http://www.gnu.org/licenses/gpl-3.0.html -## author: Christian Berendt , 2011. - -import logging -import ldap -import yaml -import sys - -try: - import xmlrpclib -except ImportError: - import xmlrpc.client as xmlrpclib # pylint: disable=F0401 - -logging.basicConfig( - filename = "/var/log/sw-ldap-user-sync.log", - filemode = "a", - format = "%(asctime)s [%(levelname)-8s] %(message)s", - level = logging.DEBUG -) - -settings = yaml.load(open("/etc/rhn/sw-ldap-user-sync.conf")) - -try: - directory = ldap.initialize(settings["directory"]["url"]) - directory.simple_bind_s(settings["directory"]["user"], - settings["directory"]["password"]) -except Exception as e: - logging.error("unable to connect to LDAP server: %s" % e) - sys.exit(1) - -try: - spacewalk = xmlrpclib.Server(settings["spacewalk"]["url"], verbose=0) - spacewalk_token = spacewalk.auth.login(settings["spacewalk"]["user"], - settings["spacewalk"]["password"]) -except Exception as e: - logging.error("unable to connect to spacewalk server: %s" % e) - sys.exit(1) - -filter = '(objectclass=groupOfNames)' -attrs = ['member'] - -try: - result = spacewalk.user.list_users(spacewalk_token) -except Exception as e: - logging.error("unable to fetch user accounts from spacewalk server: %s" % e) - sys.exit(1) - -users = {} -for user in result: - detail = spacewalk.user.getDetails(spacewalk_token, user.get('login')) - if user.get('use_pam'): - users[user.get('login')] = 1 - -try: - (dn, data) = directory.search_s(settings["directory"]["group"], ldap.SCOPE_SUBTREE, filter, attrs)[0] -except Exception as e: - logging.error("unable to fetch user entries from LDAP group: %s" % e) - sys.exit(1) - -for uid in data['member']: - filter = "(objectclass=posixAccount)" - attrs = ['givenName', 'sn', 'mail', 'uid'] - - try: - (userdn, userdata) = directory.search_s(uid, ldap.SCOPE_SUBTREE, filter, attrs)[0] - if userdata["uid"][0] in users: - del users[userdata["uid"][0]] - else: - logging.info("creating new user account for ldap user %s" % userdata["uid"][0]) - - try: - spacewalk.user.create(spacewalk_token, userdata["uid"][0], "", - userdata["givenName"][0], userdata["sn"][0], userdata["mail"][0], 1) - except Exception as e: - logging.error("unable to create new user account %s on spacewalk server: %s" % (userdata["uid"], e)) - except Exception as e: - logging.error("unable to fetch user details for user %s from LDAP server: %s" % (uid, e)) - - -for user in list(users.keys()): - logging.info("deleting user %s" % user) - - try: - spacewalk.user.delete(spacewalk_token, user) - except Exception as e: - logging.error("unable to remove user account %s from spacewalk: %s" - % (user, e)) - -directory.unbind() -spacewalk.auth.logout(spacewalk_token) - diff --git a/utils/sw-ldap-user-sync.conf b/utils/sw-ldap-user-sync.conf deleted file mode 100644 index 84d251b5d821..000000000000 --- a/utils/sw-ldap-user-sync.conf +++ /dev/null @@ -1,10 +0,0 @@ -directory: - user: uid=xyz,dc=example,dc=com - password: xxx - url: ldaps://ldap.example.com:636 - group: cn=admin,ou=groups,dc=example,dc=com - users: ou=people,dc=example,dc=com -spacewalk: - url: http://localhost/rpc/api - user: spacewalk - password: xxx From 8fbc7bcf2f74caa88ad9a392c9fa168c3f80f38f Mon Sep 17 00:00:00 2001 From: Ricardo Mateus Date: Fri, 8 Nov 2024 15:43:26 +0000 Subject: [PATCH 2/2] move watch channel sync and remove utils extras Signed-off-by: Ricardo Mateus --- ...rmateus.uyuni_remove_spacewalk-utils-extras | 2 ++ utils/spacewalk-utils.spec | 18 ++---------------- 2 files changed, 4 insertions(+), 16 deletions(-) create mode 100644 utils/spacewalk-utils.changes.rmateus.uyuni_remove_spacewalk-utils-extras diff --git a/utils/spacewalk-utils.changes.rmateus.uyuni_remove_spacewalk-utils-extras b/utils/spacewalk-utils.changes.rmateus.uyuni_remove_spacewalk-utils-extras new file mode 100644 index 000000000000..7f9cd73614e7 --- /dev/null +++ b/utils/spacewalk-utils.changes.rmateus.uyuni_remove_spacewalk-utils-extras @@ -0,0 +1,2 @@ +- Remove tools from spacewalk-utils-extra and moved them to uyuni + contrib repository diff --git a/utils/spacewalk-utils.spec b/utils/spacewalk-utils.spec index 223d775deba1..504035438109 100644 --- a/utils/spacewalk-utils.spec +++ b/utils/spacewalk-utils.spec @@ -33,7 +33,7 @@ BuildRequires: python3-rpm-macros BuildRequires: uyuni-base-common # Required by depsolver.py Requires: (python3-PyYAML or python3-pyyaml) -# Required by spacewalk-hostname-rename +# Required by spacewalk-hostname-rename, spacewalk-watch-channel-sync.sh Requires: bash # Required by spacewalk-hostname-rename Requires: cobbler @@ -80,17 +80,6 @@ Requires: perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version)) %description Utilities that may be run against a SUSE Manager server (supported) or an Uyuni server -%package extras -Summary: Extra utilities that may run against a SUSE Manager/Uyuni server -# Required by spacewalk-watch-channel-sync.sh -Group: Productivity/Other -Requires: bash -# As spacewalk-utils owns {python3_sitelib}/utils -Requires: spacewalk-utils - -%description extras -Extra utilities that may be run against a SUSE Manager server (unsupported) or an Uyuni server - %prep %setup -q @@ -120,6 +109,7 @@ popd %attr(755,root,root) %{_bindir}/spacewalk-manage-channel-lifecycle %attr(755,root,root) %{_bindir}/spacewalk-sync-setup %attr(755,root,root) %{_bindir}/taskotop +%attr(755,root,root) %{_bindir}/spacewalk-watch-channel-sync.sh %config %{_sysconfdir}/rhn/spacewalk-common-channels.ini %dir %{python3_sitelib}/utils %{python3_sitelib}/utils/__init__.py* @@ -134,9 +124,5 @@ popd %{_mandir}/man8/spacewalk-sync-setup.8%{?ext_man} %{_mandir}/man8/taskotop.8%{?ext_man} -%files extras -%defattr(-,root,root) -%license COPYING.GPLv2 COPYING.GPLv3 -%attr(755,root,root) %{_bindir}/spacewalk-watch-channel-sync.sh %changelog