utils/Makefile | 2
utils/spacewalk-custom-repository | 341 --------------------------------
utils/spacewalk-manage-abrt | 395 --------------------------------------
3 files changed, 1 insertion(+), 737 deletions(-)
New commits:
commit 97106977b879a74fc062983ca105f4da7768b6e3
Author: Dimitar Yordanov <dyordano(a)redhat.com>
Date: Wed Aug 28 21:13:34 2013 +0200
removing, to be implemented in spacecmd
diff --git a/utils/Makefile b/utils/Makefile
index fd9f91c..0096ff8 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -7,7 +7,7 @@ NAME := spacewalk-utils
SUBDIR = utils
FILES = __init__ systemSnapshot migrateSystemProfile depsolver cloneByDate
-SCRIPTS = spacewalk-manage-abrt spacewalk-custom-repository sw-system-snapshot
migrate-system-profile spacewalk-api apply_errata \
+SCRIPTS = sw-system-snapshot migrate-system-profile spacewalk-api apply_errata \
scr.cgi spacewalk-common-channels delete-old-systems-interactive
spacewalk-hostname-rename \
spacewalk-dump-schema spacewalk-clone-by-date spacewalk-sync-setup
spacewalk-archive-audits
CONFIGS = spacewalk-common-channels.ini
diff --git a/utils/spacewalk-custom-repository b/utils/spacewalk-custom-repository
deleted file mode 100755
index 3cffd9b..0000000
--- a/utils/spacewalk-custom-repository
+++ /dev/null
@@ -1,341 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright (c) 2010--2012 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.
-#
-# dyordano(a)redhat.com
-
-import sys
-import xmlrpclib
-import fnmatch
-import ConfigParser
-from optparse import OptionParser, Option
-import re
-from spacewalk.common.cli import getUsernamePassword, xmlrpc_login, xmlrpc_logout
-
-DEFAULT_SERVER = "localhost"
-DEFAULT_USER = "spacewalk"
-DEFAULT_PASSWORD = "spacewalk"
-
-exit_code=0
-
-#mmraka
-CHANNEL_ARCH = {
- 'i386': 'channel-ia32',
- 'ia64': 'channel-ia64',
- 'sparc': 'channel-sparc',
- 'sparc64': 'channel-sparc64',
- 'alpha': 'channel-alpha',
- 's390': 'channel-s390',
- 's390x': 'channel-s390x',
- 'iSeries': 'channel-iSeries',
- 'pSeries': 'channel-pSeries',
- 'x86_64': 'channel-x86_64',
- 'ppc': 'channel-ppc',
- 'ppc64': 'channel-ppc64',
- 'sparc-sun-solaris': 'channel-sparc-sun-solaris',
- 'i386-sun-solaris': 'channel-i386-sun-solaris',
- }
-
-class ExtOptionParser(OptionParser):
-
- """extend OptionParser to print examples"""
- def __init__(self, examples=None, **kwargs):
- self.examples = examples
- OptionParser.__init__(self, **kwargs)
- def print_help(self):
- OptionParser.print_help(self)
- print "\n\n" + self.examples
-
-def connect(user, password, server):
- server_url = "http://%s/rpc/api" % server
-
- if options.verbose > 2:
- client_verbose = options.verbose - 2
- else:
- client_verbose = 0
- if options.verbose:
- sys.stdout.write("Connecting to %s\n" % server_url)
- client = xmlrpclib.Server(server_url, verbose=client_verbose, allow_none=1)
- user, password = getUsernamePassword(user, password)
- key = xmlrpc_login(client, user, password)
- return client, key
-
-def f_print_error(msg):
- global exit_code
- print "ERROR: %s\n" % msg
- exit_code+=1
-
-def f_print_info(msg):
- print "INFO: %s\n" % msg
-
-if __name__ == "__main__":
- # options parsing
- usage = "usage: %prog --action [params]"
- examples = """Examples:
-
- List all available repositoies:
- %(prog)s --list-repos
-
- Create software channel:
- %(prog)s --create-channel --channel-label example_channel --channel-name
example_name --channel-summary example_summary --channel-arch x86_64 --channel-parent
example_parent
-
- %(prog)s --create-channel --channel-label example_channel --channel-name
example_name --channel-summary example_summary --channel-arch x86_64 --channel-parent
example_parent --channel-checksum sha256
-
- %(prog)s --create-channel --channel-label example_channel --channel-name
example_name --channel-summary example_summary --channel-arch x86_64 --channel-parent
example_parent --channel-checksum sha256 --channel-gpgKey-url
http://example.com/gpg_key
--channel-gpgKey-id 069C8460 --channel-gpgKey-fingerprint "25DB B54B DED7 0987 F4C1
0042 B4EB F579 069C 8460"
-
- Create repository:
- %(prog)s --create-repo --repo-label example_repo --repo-url
http://example.redhat.com/example_repo
-
- Update Repository Url:
- %(prog)s --update-repourl --repo-label example_repo --repo-url
http://example.redhat.com/example_repo_updated
-
- Delete repository:
- %(prog)s --delete-repo --repo-label example_repo
-
- Associate repository to a custom software channel:
- %(prog)s --associate-repo --repo-label example_repo --channel-label
example_channel
-
- Disassociate repository to a custom software channel:
- %(prog)s --disassociate-repo --repo-label example_repo --channel-label
example_channel
-
- Add filter to a repository:
- %(prog)s --add-filter --repo-label example_repo --filter-string
example_filter_string* --filter-flag +
-
- Remove filter from a repository:
- %(prog)s --remove-filter --repo-label example_repo --filter-string
example_filter_string* --filter-flag +
-
- Clear filters for a repository:
- %(prog)s --clear-filters --repo-label example_repo
-
- List all filter for a repository:
- %(prog)s --list-filters --repo-label example_repo
-
- List all associated repositories for a custom software channel:
- %(prog)s --list-channels-repos --channel-label example_channel
-
- List all available custom sofware channels:
- %(prog)s --list-channels
-
- Sync custom sofware channel with all associated repositories:
- %(prog)s --sync-now --channel-label example_channel
-
-\n""" % {'prog': sys.argv[0]}
-
- option_list = [
- Option("-u", "--user", help="Spacewalk username",
default=DEFAULT_USER),
- Option("-p", "--password", help="Spacewalk
password", default=DEFAULT_PASSWORD),
- Option("-s", "--server", help="Spacewalk server
Url", default=DEFAULT_SERVER),
- Option("-v", "--verbose", help="verbose",
action="count"),
- Option("", "--channel-label", help="Software channel
label"),
- Option("", "--channel-name", help="Software channel
name"),
- Option("", "--channel-summary", help="Software channel
summary"),
- Option("", "--channel-arch", help="Software channel
architecture"),
- Option("", "--channel-parent", help="Software channel
parent"),
- Option("", "--channel-checksum", help="Software channel
checksum sha1,sha256"),
- Option("", "--channel-gpgKey-url", help="Software
channel gpgKey url"),
- Option("", "--channel-gpgKey-id", help="Software channel
gpgKey id"),
- Option("", "--channel-gpgKey-fingerprint",
help="Software channel gpgKey fingerprint"),
- Option("", "--repo-label", help="Repository
Label"),
- Option("", "--repo-url", help="Repository Url"),
- Option("", "--filter-string", help="filter
string"),
- Option("", "--filter-flag", help="filter flag"),
- Option("", "--list-repos", help="Action: List available
repositories", action="store_true"),
- Option("", "--list-channels", help="Action: List
available software channels", action="store_true"),
- Option("", "--list-channels-repos", help="Action: List
repositories associated with a channel. Requites --channel-label",
action="store_true"),
- Option("", "--list-filters", help="Action: List filtes
for repository. Requites --repo-label", action="store_true"),
- Option("", "--create-channel", help="Action: Create
software channel. Requites label, name, summary, arch",
action="store_true"),
- Option("", "--create-repo", help="Action: Create
repository. Requites --repo-label --repo-url", action="store_true"),
- Option("", "--delete-repo", help="Action: Delete
repository. Requites --repo-label", action="store_true"),
- Option("", "--associate-repo", help="Action: Associate
repository. Requites --repo-label --channel-label", action="store_true"),
- Option("", "--disassociate-repo", help="Action:
Associate repository. Requites --repo-label --channel-label",
action="store_true"),
- Option("", "--add-filter", help="Action: Add filter to
repository. Requites --filter-string --filter-flag --repo-label",
action="store_true"),
- Option("", "--remove-filter", help="Action: Remove
filter from repository. Requites --filter-string --filter-flag --repo-label",
action="store_true"),
- Option("", "--clear-filters", help="Action: Clear
filters for repository. Requites --repo-label", action="store_true"),
- Option("", "--sync-now", help="Action: Sync software
channel with all associated repositories. Requites --channel-label",
action="store_true"),
- Option("", "--update-repourl", help="Action: Update
repsitory Url. Requites --repo-label --repo-url", action="store_true"),
- Option("", "--list_arch", help="Action: List available
architectures.", action="store_true"),
-
- ]
-
- parser = ExtOptionParser(usage=usage, option_list=option_list, examples=examples)
- (options, args) = parser.parse_args()
-
- try:
- client, key = connect(options.user, options.password, options.server)
- except xmlrpclib.Fault, e:
- if e.faultCode == 2950:
- sys.stderr.write("Either the password or username is
incorrect.\n")
- sys.exit(2)
- else:
- raise
-
- try:
- # List Repos
- if options.list_repos:
- l_repo=client.channel.software.listUserRepos(key)
- for repo in l_repo:
- print "| %s | %s | id: %d" %
(repo['label'],repo['sourceUrl'],repo['id'])
-
- # List Channel
- if options.list_channels:
- d_parents={}
- l_ch=client.channel.listSoftwareChannels(key)
- for ch in l_ch:
- if ch['parent_label'] == '':
- if ch['label'] not in d_parents.keys():
- d_parents[ch['label']]=[]
- continue
-
- if ch['parent_label'] not in d_parents.keys():
- d_parents[ch['parent_label']]=[]
-
- d_parents[ch['parent_label']].append(ch['label'])
-
-
- keys = d_parents.keys()
- keys.sort()
- for ch in keys:
- print ch
- for sub in d_parents[ch]:
- print "\t" + sub
-
- # List Channels Repos
- if options.list_channels_repos:
- if options.channel_label != None:
- l_repos=client.channel.software.listChannelRepos(key,
options.channel_label)
- for repo in l_repos:
- print "| %s | %s | id: %d" %
(repo['label'],repo['sourceUrl'],repo['id'])
- else:
- f_print_error("Obligatory param --channel-label is missing.")
-
- # List arch
- if options.list_arch:
- for arch in CHANNEL_ARCH.keys():
- print arch
-
- # Create Channel
- if options.create_channel:
- if options.channel_label != None and \
- options.channel_name != None and \
- options.channel_summary != None and \
- options.channel_arch != None :
- client.channel.software.create(key,options.channel_label,
- options.channel_name,
- options.channel_summary,
- CHANNEL_ARCH[options.channel_arch],
- options.channel_parent,
- options.channel_checksum,
-
{'url':options.channel_gpgKey_url,'id':options.channel_gpgKey_id,'fingerprint':options.channel_gpgKey_fingerprint}
)
- else:
- f_print_error("One or more obligatory params are missing - Label,
Name, Summary or Arch.")
-
- # Create Repo
- if options.create_repo:
- client.channel.software.createRepo(key,
- options.repo_label, 'yum',
- options.repo_url)
-
- # Delete Repo
- if options.delete_repo:
- if options.repo_label != None:
- client.channel.software.removeRepo(key, options.repo_label)
- else:
- f_print_error("Obligatory param --repo_label is missing.")
-
- # Associate Repo to Channel
- if options.associate_repo:
- if options.channel_label != None and options.repo_label != None:
- # check if not alredy associated
- flag=0
- l_repos=client.channel.software.listChannelRepos(key,
options.channel_label)
- for repo in l_repos:
- if repo['label'] == options.repo_label:
- flag=1;break
- if flag == 0:
- client.channel.software.associateRepo(key,
- options.channel_label, options.repo_label)
- else:
- f_print_info("Repo: %s already is associated with the channel: %s.
Nothing to do." % (options.repo_label,options.channel_label))
- else:
- f_print_error("One or more obligatory params are missing:
--channel-label --repo-label.")
-
- # Disassociate Repo to Channel
- if options.disassociate_repo:
- if options.channel_label != None and options.repo_label != None:
- client.channel.software.disassociateRepo(key,
- options.channel_label, options.repo_label)
- else:
- f_print_error("One or more obligatory params are missing:
--channel-label --repo-label.")
-
- # List Filters for Repo
- if options.list_filters:
- if options.repo_label != None:
-
l_filters=client.channel.software.listRepoFilters(key,options.repo_label)
- for filter in l_filters:
- print "| %s | %s | sortOrder: %d" %
(filter['filter'],filter['flag'],filter['sortOrder'])
- else:
- f_print_error("Obligatory param --repo-label is missing.")
-
- # Add Filter to Repo
- if options.add_filter:
- if options.repo_label != None and options.filter_string != None and \
- (options.filter_flag == '-' or options.filter_flag ==
'+'):
-
client.channel.software.addRepoFilter(key,options.repo_label,{'filter':options.filter_string,'flag':options.filter_flag})
- else:
- if options.filter_flag == '-' and options.filter_flag ==
'+':
- f_print_error("One or more obligatory params are missing:
--repo-label --filter-string --filter-flag")
- else:
- f_print_error("Parameter flag accept only values + or -.")
-
- # Remove Filter from Repo
- if options.remove_filter:
- if options.repo_label != None and options.filter_string != None and \
- (options.filter_flag == '-' or options.filter_flag ==
'+'):
-
client.channel.software.removeRepoFilter(key,options.repo_label,{'filter':options.filter_string,'flag':options.filter_flag})
- else:
- if options.filter_flag == '-' and options.filter_flag ==
'+':
- f_print_error("One or more obligatory params are missing:
--repo-label --filter-string --filter-flag")
- else:
- f_print_error("Parameter flag accept only values + or -.")
-
- # Clear Filtes for Repo
- if options.clear_filters:
- if options.repo_label != None:
- client.channel.software.clearRepoFilters(key,options.repo_label)
- else:
- f_print_error("Obligatory param --repo-label is missing.")
-
- # Sync channel with all repos
- if options.sync_now:
- if options.channel_label != None:
- client.channel.software.syncRepo(key,options.channel_label)
- else:
- f_print_error("Obligatory param --channel-label is missing.")
-
- #Update Repo Url
- if options.update_repourl:
- if options.repo_url != None:
-
client.channel.software.updateRepoUrl(key,options.repo_label,options.repo_url)
- else:
- f_print_error("Obligatory param --repo-url is missing.")
-
- except xmlrpclib.Fault, e:
- f_print_error(e.faultString)
-
-
- if client is not None:
- # logout
- xmlrpc_logout(client, key)
-
- sys.exit(exit_code)
diff --git a/utils/spacewalk-manage-abrt b/utils/spacewalk-manage-abrt
deleted file mode 100755
index 0b40733..0000000
--- a/utils/spacewalk-manage-abrt
+++ /dev/null
@@ -1,395 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright (c) 2010--2013 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.
-#
-# dyordano(a)redhat.com
-
-import sys,os
-from optparse import OptionParser
-import xmlrpclib
-import pprint
-import subprocess
-import signal
-
-DEFAULT_SERVER = "localhost"
-DEFAULT_USER = "spacewalk"
-DEFAULT_PASSWORD = "spacewalk"
-
-exit_code=0
-
-#mmraka
-class ExtOptionParser(OptionParser):
-
- """extend OptionParser to print examples"""
- def __init__(self, examples=None, **kwargs):
- self.examples = examples
- OptionParser.__init__(self, **kwargs)
- def print_help(self):
- OptionParser.print_help(self)
- print "\n\n" + self.examples
-
-class ConfigDispatcher:
-
- def __init__(self, username, password, server):
- '''
- @summary: Create XMLRPC client and sign in the user.
- @param username: username
- @param password: password
- @param server: FQDN
- '''
- rhn_server = "https://%s/rpc/api" % server
- self.client = xmlrpclib.Server(rhn_server, verbose=0)
- self.key = self.client.auth.login(username, password)
- self.pp = pprint.PrettyPrinter(indent=4, width=1)
-
- # DISPATCHED METHODS
-----------------------------------------------------------------------------------------------
-
-
- def do_CreateTestCrash(self, kwargs):
- """
- @summary: 'CreateTestCrash' Create a crash note.
- @param sessionKey
- """
- import subprocess
- import signal
- cmd_sleep="sleep 100"
- process = subprocess.Popen(cmd_sleep.split())
- process.send_signal(signal.SIGSEGV)
-
-
- def do_listCrashedSystems(self, kwargs):
- """
- @summary: 'createCrashNote' Create a crash note.
- @param sessionKey
- @param crashId
- @param subject
- @param details
- """
- res=self.client.system.listUserSystems(self.key)
- for sys in res:
-
res_crash=self.client.system.crash.listSystemCrashes(self.key,sys['id'])
- if len(res_crash) != 0:
- print "%d:%s:%s" %
(len(res_crash),sys['id'],sys['name'])
-
- def do_createCrashNote(self, kwargs):
- """
- @summary: 'createCrashNote' Create a crash note.
- @param sessionKey
- @param crashId
- @param subject
- @param details
- """
- print self.client.system.crash.createCrashNote(self.key,
int(kwargs.crashId),kwargs.note_subject,kwargs.note_details)
-
- def do_deleteCrashNote(self, kwargs):
- """
- @summary: 'deleteCrashNote' Delete a crash note.
- @param sessionKey
- @param crashNoteId
-
- """
- print self.client.system.crash.deleteCrashNote(self.key, int(kwargs.noteId))
-
- def do_getCrashNotesForCrash(self, kwargs):
- """
- @summary: 'getCrashNotesForCrash' List crash notes for crash.
- @param sessionKey
- @param crashNoteId
- """
-
- res=self.client.system.crash.getCrashNotesForCrash(self.key,
int(kwargs.crashId))
- self.pritty_print(res,kwargs)
-
-
- def do_isCrashfileUploadEnabled(self, kwargs):
- """
- @summary: 'isCrashfileUploadEnabled' Get the status of crash file upload
settings for the given organization. Returns true if enabled, false otherwise.
- @param sessionKey
- @param orgId
- """
- print self.client.org.isCrashfileUploadEnabled(self.key, int(kwargs.orgId))
-
- def do_isCrashReportingEnabled(self, kwargs):
- """
- @summary: 'isCrashReportingEnabled' Get the status of crash reporting
settings for the given organization. Returns true if enabled, false otherwise.
- @param sessionKey
- @param orgId
- """
- print self.client.org.isCrashReportingEnabled(self.key, int(kwargs.orgId))
-
-
- def do_setCrashfileUpload(self, kwargs):
- """
- @summary: 'setCrashfileUpload' Set the status of crash file upload
settings for the given organization. Modifying the settings is possible as long as crash
reporting is enabled.
- @param sessionKey
- @param orgId
- @boolean enable - Use true/false to enable/disable
- """
- print self.client.org.setCrashfileUpload(self.key,
int(kwargs.orgId),eval(kwargs.bool))
-
- def do_setCrashReporting(self, kwargs):
- """
- @summary: 'setCrashReporting' Set the status of crash reporting settings
for the given organization. Disabling crash reporting will automatically disable crash
file upload.
- @param sessionKey
- @param orgId
- @boolean enable - Use true/false to enable/disable
- """
- print self.client.org.setCrashReporting(self.key,
int(kwargs.orgId),eval(kwargs.bool))
-
- def do_getCrashFileSizeLimit(self, kwargs):
- """
- @summary: 'getCrashFileSizeLimit' action method. Get the organization
wide crash file size limit. The limit value must i a non-negative number, zero means no
limit.
- @param sessionKey
- @param orgId
- """
- print self.client.org.getCrashFileSizeLimit(self.key, int(kwargs.orgId))
-
- def do_setCrashFileSizeLimit(self, kwargs):
- """
- @summary: 'setCrashFileSizeLimit' action method. Set the organization
wide crash file size limit. The limit value must be non-negative, zero means no limit.
- @param sessionKey
- @param orgId
- @param limit
- """
- self.client.org.setCrashFileSizeLimit(self.key, int(kwargs.orgId),
int(kwargs.limit))
-
- def do_deleteCrash(self, kwargs):
- """
- @summary: 'deleteCrash' action method. Delete a crash with given crash
id.
- @param sessionKey
- @param crashId
- """
- self.client.system.crash.deleteCrash(self.key, int(kwargs.crashId))
-
- def do_getCrashFile (self, kwargs):
- """
- @summary: 'getCrashFile' action method. Download a crash file.
- @param sessionKey
- @param crashFileId
- """
- print self.client.system.crash.getCrashFile(self.key, int(kwargs.crashFileId))
-
- def do_getCrashAllFiles(self, kwargs):
-
- s_dest_folder=''
- if kwargs.dest_folder:
- if not os.path.isdir(kwargs.dest_folder):
- print "FAIL: %s is not a folder!" % kwargs.dest_folder
- return 1
- else:
- s_dest_folder="--directory-prefix " + kwargs.dest_folder +
" "
-
- l_res=self.client.system.crash.listSystemCrashFiles(self.key,
int(kwargs.crashId))
- for d_file in l_res:
- s_utl=self.client.system.crash.getCrashFileUrl(self.key, d_file['id'])
- bashCommand = "wget " + s_dest_folder + s_utl + " --tries=1
--no-check-certificate"
- os.system(bashCommand)
-
- def do_getCrashFileUrl(self, kwargs):
- """
- @summary: 'getCrashFileUrl' action method. Get a crash file download
url.
- @param sessionKey
- @param crashFileId
- """
- print self.client.system.crash.getCrashFileUrl(self.key,
int(kwargs.crashFileId))
-
-
- def do_getCrashCountInfo(self, kwargs):
- """
- @summary: 'getCrashCountInfo' action method. Return crash count
information.
- @param sessionKey
- @param serverId
- """
- res=self.client.system.crash.getCrashCountInfo(self.key, int(kwargs.serverId))
- if kwargs.param_key:
- print res[kwargs.param_key]
- else:
- print res
-
- def do_listSystemCrashFiles(self, kwargs):
- """
- @summary: 'listSystemCrashFiles' action method. Return list of crash
files for given crash id.
- @param sessionKey
- @param crashId
- """
- res=self.client.system.crash.listSystemCrashFiles(self.key, int(kwargs.crashId))
- self.pritty_print(res,kwargs)
-
-
- def do_listSystemCrashes(self,kwargs):
- """
- @summary: 'listSystemCrashes' action method. Return list of software
crashes for a system.
- @param sessionKey
- @param serverId
- """
- res=self.client.system.crash.listSystemCrashes(self.key, int(kwargs.serverId))
- self.pritty_print(res,kwargs)
-
- def do_getCrashOverview(self,kwargs):
- res=self.client.system.crash.getCrashOverview(self.key)
- self.pritty_print(res,kwargs)
-
- def do_getCrashesByUuid(self,kwargs):
- if kwargs.uuid:
- res=self.client.system.crash.getCrashesByUuid(self.key,kwargs.uuid)
- self.pritty_print(res,kwargs)
- else:
- res=self.client.system.crash.getCrashOverview(self.key)
- for crash in res:
-
res=self.client.system.crash.getCrashesByUuid(self.key,crash['uuid'])
- self.pritty_print(res,kwargs)
-
-#-----
- def pritty_print(self,res,kwargs):
- if kwargs.param_key:
- l_params=kwargs.param_key.split()
- for i in range(len(res)):
- l_str=[]
- for param in l_params:
- l_str.append(str(res[i][param]))
- self.pp.pprint(l_str)
- else:
- self.pp.pprint(res)
-
- def clean(self):
- """ Cleaning actions like sign out the user. """
- self.client.auth.logout(self.key)
-
- def error(self, message):
- """ Print given message and exit with error code.
"""
- print(message)
- sys.exit(1)
-
- def dispatch(self, options):
- """ Command dispatching method. """
- method_name = 'do_' + options.action
- try:
- method = getattr(self, method_name)
- method(options)
- except AttributeError:
- self.error("Error: unknown action `%s`" % options.action)
-
-
-if __name__ == '__main__':
- usage = "Usage: %prog -a action param1=value1 [param2=value2 ...]"
- examples = """Examples:
-
- List all the systems that have experienced a crash in format ( Number of crashes,
SystemID, Profile Name).
-
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a listCrashedSystems
-
- List craches details
-
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a listSystemCrashes -i
${serverId}
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a listSystemCrashes -i
${serverId} -v 'id'
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a listSystemCrashes -i
${serverId} -v 'id crash'
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a listSystemCrashes -i
${serverId} -v 'id crash executable reason ...'
-
-
- List files from single crash
-
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a listSystemCrashFiles
-c ${crashId}
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a listSystemCrashFiles
-c ${crashId} -v 'id'
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a listSystemCrashFiles
-c ${crashId} -v 'id path filesize ...'
-
- Get crash file
-
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a getCrashFile -f
${crashFileId}
-
- Get all crash files for a single crash
-
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a getCrashAllFiles -c
${crashId}
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a getCrashAllFiles -c
${crashId} -w "dest_folder"
-
- Get crash file Url
-
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a getCrashFileUrl -f
${crashFileId}
-
-
- Get crash info
-
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a getCrashCountInfo -i
${serverId} -v 'total_count'
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a getCrashCountInfo -i
${serverId} -v 'unique_count'
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a getCrashCountInfo -i
${serverId} -v 'last_report'
-
- Delete single crash
-
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a deleteCrash -c
${crashId}
-
-
- Manage crash notes
-
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a createCrashNote -c
${crashId} -j ${note_sunject} -d ${note_details}
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a deleteCrashNote -n
${noteId}
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a getCrashNotesForCrash
-c ${crashId} -v 'id subject details'
-
- Get crash file size limit for certain organization
-
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a getCrashFileSizeLimit
-o ${orgId}
-
- Set crash file size limit for certain organization
-
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a setCrashFileSizeLimit
-o ${orgId} -l 1
-
- Get satellite abrt flags configuration
-
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a
isCrashfileUploadEnabled -o ${orgId}
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a
isCrashReportingEnabled -o ${orgId}
-
- Set satellite abrt flags configuration
-
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a setCrashfileUpload -o
${orgId} -b [True|False]
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a setCrashReporting -o
${orgId} -b [True|False]
-
- Get ABRT Overview
-
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a getCrashOverview
-
- Get Crash by UUID
-
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a getCrashesByUuid -o
${UUID}
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a getCrashesByUuid
-
- Create test crash
-
- %(prog)s -u ${sat_user} -p ${sat_pass} -s ${sat_server} -a CreateTestCrash
-
- \n""" % {'prog': sys.argv[0]}
-
- parser = ExtOptionParser(usage=usage, examples=examples)
- parser.add_option("-u", "--username", dest="username",
metavar="USER", default=DEFAULT_USER)
- parser.add_option("-p", "--password", dest="password",
metavar="PASS", default=DEFAULT_PASSWORD)
- parser.add_option("-s", "--server", dest="server",
metavar="SERVER", help="server's FQDN", default=DEFAULT_SERVER)
- parser.add_option("-a", "--action", dest="action",
metavar="ACTION",
- help="Actions: listCrashedSystems, listSystemCrashes,
listSystemCrashFiles, getCrashFile, getCrashFileUrl, \
- getCrashCountInfo, deleteCrash, createCrashNote, deleteCrashNote,
getCrashNotesForCrash, getCrashFileSizeLimit,\
- setCrashFileSizeLimit, isCrashfileUploadEnabled,
isCrashReportingEnabled, setCrashfileUpload, setCrashReporting, CreateTestCrash,
getCrashOverview, getCrashesByUuid")
- parser.add_option("-i", "--serverId", dest="serverId",
metavar="SERVERID", help="Profile ID on Satellite" )
- parser.add_option("-c", "--crashId", dest="crashId",
metavar="CRASHID")
- parser.add_option("-o", "--orgId", dest="orgId",
metavar="ORGID")
- parser.add_option("-l", "--limit", dest="limit",
metavar="LIMIT", help="Set to 2048 by default.")
- parser.add_option("-f", "--crashFileId",
dest="crashFileId", metavar="CRASHFILEID")
- parser.add_option("-v", "--param_key",
dest="param_key", metavar="PARAM_KEY", help="Space separeted list
of params")
- parser.add_option("-b", "--bool", dest="bool",
metavar="BOOL", help="Posible values: True, False")
- parser.add_option("-j", "--note_subject",
dest="note_subject", metavar="NOTE_SUBJECT")
- parser.add_option("-d", "--note_details",
dest="note_details", metavar="NOTE_DETAILS")
- parser.add_option("-n", "--noteId", dest="noteId",
metavar="NOTEID")
- parser.add_option("-w", "--dest_folder",
dest="dest_folder", metavar="DESTINATION_FOLDER",
help="Distination folder")
- parser.add_option("-m", "--uuid", dest="uuid",
metavar="UUID", help="UUID")
- (options, args) = parser.parse_args()
- assert options.action, "Action must be provided"
-
- dispr = ConfigDispatcher(username=options.username, password=options.password,
server=options.server)
- dispr.dispatch(options)
- dispr.clean()