utils/spacewalk-dump-schema
by Milan Zazrivec
utils/spacewalk-dump-schema | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 3de455555168a00fc07b0853c05c75c31079fee0
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Mon Jul 1 21:29:10 2013 +0200
oracle -> pg migrations: filter plan_table_9i out
diff --git a/utils/spacewalk-dump-schema b/utils/spacewalk-dump-schema
index de3c409..c06865a 100755
--- a/utils/spacewalk-dump-schema
+++ b/utils/spacewalk-dump-schema
@@ -291,7 +291,7 @@ sub process_tables {
my $tables = $dbh->selectall_hashref(q!
select lower(table_name) table_name
from user_tables
- where table_name <> 'PLAN_TABLE' -- plan_table is not part of our schema
+ where table_name not in ('PLAN_TABLE', 'PLAN_TABLE_9I') -- plan_table is not part of our schema
order by table_name
!, 'table_name');
if (not $raw and -d "$DATA_DIR/tables") {
10 years, 10 months
Changes to 'refs/tags/spacewalk-utils-1.10.13-1'
by Grant Gainey
Tag 'spacewalk-utils-1.10.13-1' created by Grant Gainey <ggainey(a)redhat.com> at 2013-07-01 17:48 +0000
Tagging package [spacewalk-utils] version [1.10.13-1] in directory [utils/].
Changes since spacewalk-web-1.10.34-1:
Grant Gainey (3):
977878 - Move sync_setup to somewhere package-able, rename and add license stmt
977878 - Fix create-template to do the right then when re-run, and make --dry-run work
Automatic commit of package [spacewalk-utils] release [1.10.13-1].
---
rel-eng/packages/spacewalk-utils | 2
sync_setup/src/bin/sync_setup | 491 --------------------------------
utils/spacewalk-sync-setup | 591 +++++++++++++++++++++++++++++++++++++++
utils/spacewalk-utils.spec | 9
4 files changed, 600 insertions(+), 493 deletions(-)
---
10 years, 10 months
rel-eng/packages utils/spacewalk-utils.spec
by Grant Gainey
rel-eng/packages/spacewalk-utils | 2 +-
utils/spacewalk-utils.spec | 9 ++++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
New commits:
commit 314fd3aa39969c7f5042332c61636eaf6cbbe2b8
Author: Grant Gainey <ggainey(a)redhat.com>
Date: Mon Jul 1 13:48:08 2013 -0400
Automatic commit of package [spacewalk-utils] release [1.10.13-1].
diff --git a/rel-eng/packages/spacewalk-utils b/rel-eng/packages/spacewalk-utils
index 9a78fc2..065661f7 100644
--- a/rel-eng/packages/spacewalk-utils
+++ b/rel-eng/packages/spacewalk-utils
@@ -1 +1 @@
-1.10.12-1 utils/
+1.10.13-1 utils/
diff --git a/utils/spacewalk-utils.spec b/utils/spacewalk-utils.spec
index fa07512..f64f6fa 100644
--- a/utils/spacewalk-utils.spec
+++ b/utils/spacewalk-utils.spec
@@ -1,7 +1,7 @@
%define rhnroot %{_prefix}/share/rhn
Name: spacewalk-utils
-Version: 1.10.12
+Version: 1.10.13
Release: 1%{?dist}
Summary: Utilities that may be run against a Spacewalk server.
@@ -88,6 +88,13 @@ spacewalk-pylint $RPM_BUILD_ROOT%{rhnroot}
%changelog
+* Mon Jul 01 2013 Grant Gainey <ggainey(a)redhat.com> 1.10.13-1
+- 977878 - spacewalk-sync-setup: Fix create-template to do the right then when re-run, and make
+ --dry-run work
+- 977878 - spacewalk-sync-setup: Move sync_setup to somewhere package-able, rename and add license
+ stmt
+- oracle -> pg migrations: filter plan_table_9i out
+
* Mon Jun 17 2013 Michael Mraka <michael.mraka(a)redhat.com> 1.10.12-1
- removed old CVS/SVN version ids
- branding fixes in man pages
10 years, 10 months
2 commits - sync_setup/src utils/spacewalk-sync-setup
by Grant Gainey
sync_setup/src/bin/sync_setup | 491 ----------------------------------
utils/spacewalk-sync-setup | 591 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 591 insertions(+), 491 deletions(-)
New commits:
commit cf466e39c65a36c32d2d71e1e404a16f3d1b563b
Author: Grant Gainey <ggainey(a)redhat.com>
Date: Mon Jul 1 13:43:05 2013 -0400
977878 - Fix create-template to do the right then when re-run, and make --dry-run work
diff --git a/utils/spacewalk-sync-setup b/utils/spacewalk-sync-setup
index 746a004..5557dd4 100755
--- a/utils/spacewalk-sync-setup
+++ b/utils/spacewalk-sync-setup
@@ -72,12 +72,14 @@ def setupOptions():
help="Password for login master-login on master-server")
parser.add_option_group(cnxGrp)
- tmplGrp = OptionGroup(parser, "Templates", "Options for creating initial versions of setup files")
+ tmplGrp = OptionGroup(parser, "Templates",
+ "Options for creating initial versions of setup files\n"
+ "NOTE: This will replace existing machine-specific stanzas with new content")
tmplGrp.add_option('--cst', '--create-slave-template', action='store_true', dest='slave_template', default=False,
- help="Create a setup file for the slave we're pointed at, "
+ help="Create/update a setup file containing a stanza for the slave we're pointed at, "
"based on information from the master we're pointed at")
tmplGrp.add_option('--cmt', '--create-master-template', action='store_true', dest='master_template', default=False,
- help="Create a setup file for the master we're pointed at, "
+ help="Create/update a setup file stanza for the master we're pointed at, "
"based on information from the slave we're pointed at")
tmplGrp.add_option('--ct', '--create-templates', action='store_true', dest='both_template', default=False,
help="Create both a master and a slave setup file, for the master/slave pair we're pointed at")
@@ -342,8 +344,11 @@ def gen_slave_template(slave_session, master_session, master, filename):
if path.isfile(filename) and access(filename, R_OK):
slave_setup.readfp(open(filename))
- if not slave_setup.has_section(master):
- slave_setup.add_section(master)
+ # Overwrite anything existing for this master - we're starting over
+ if slave_setup.has_section(master):
+ slave_setup.remove_section(master)
+
+ slave_setup.add_section(master)
for org in master_orgs:
if org['name'] in slave_map:
@@ -370,8 +375,11 @@ def gen_master_template(master_session, slave, filename):
if path.isfile(filename) and access(filename, R_OK):
master_setup.readfp(open(filename, 'r'))
- if not master_setup.has_section(slave):
- master_setup.add_section(slave)
+ # Overwrite anything we have for this slave - we're starting over
+ if master_setup.has_section(slave):
+ master_setup.remove_section(slave)
+
+ master_setup.add_section(slave)
if not master_setup.has_option(slave, "isEnabled"):
master_setup.set(slave, 'isEnabled', str(1))
@@ -429,6 +437,31 @@ def apply_slave_template(slave_session, slave_setup_filename):
return
+def describe_slave_template(slave_setup_filename):
+ "Tells us what it _would have_ done to a connected slave with information for "
+ "the master(s) contained in the specified slave-setup-file"
+
+ logging.info("Applying contents of file [" + slave_setup_filename + "] to SLAVE")
+
+ slave_setup = SafeConfigParser()
+ if path.isfile(slave_setup_filename) and access(slave_setup_filename, R_OK):
+ slave_setup.readfp(open(filename))
+ else:
+ fail("Can't find slave-setup file [" + slave_setup_filename + "]")
+
+ fqdns = slave_setup.sections()
+
+ for fqdn in fqdns:
+ logging.info("Updating info for master [" + fqdn + "]")
+ moids = slave_setup.options(fqdn)
+ for moid in moids: # moid|moname|local_oid
+ minfo = slave_setup.get(fqdn, moid)
+ elts = string.split(minfo, '|')
+ logging.info(" Mapping master OrgId [%s], named [%s], to local OrgId [%s]" %
+ (elts[0], elts[1], elts[2]))
+ logging.info("")
+
+ return
def apply_master_template(master_session, master_setup_filename):
"Updates the connected master with information for the slave(s) contained in the specified master-setup-file"
@@ -450,13 +483,59 @@ def apply_master_template(master_session, master_setup_filename):
except Exception, e:
slave = client.sync.slave.create(key, fqdn, True, True)
- client.sync.slave.update(key, slave['id'], fqdn,
- master_setup.getboolean(fqdn, 'isEnabled'),
- master_setup.getboolean(fqdn, 'allowAllOrgs'))
- master_orgs = [int(x) for x in master_setup.get(fqdn, 'allowedOrgs').split(',')]
+ isEnabled = True
+ allowAll = True
+
+ if master_setup.has_option(fqdn, 'isEnabled'):
+ isEnabled = master_setup.getboolean(fqdn, 'isEnabled')
+
+ if master_setup.has_option(fqdn, 'allowAllOrgs'):
+ allowAll = master_setup.getboolean(fqdn, 'allowAllOrgs')
+
+ client.sync.slave.update(key, slave['id'], fqdn, isEnabled, allowAll)
+
+ master_orgs = []
+ if master_setup.has_option(fqdn, 'allowedOrgs'):
+ master_orgs = [int(x) for x in master_setup.get(fqdn, 'allowedOrgs').split(',')]
+
client.sync.slave.setAllowedOrgs(key, slave['id'], master_orgs)
return
+def describe_master_template(master_setup_filename):
+ "Tells us what it _would have_ done to a connected master with information for "
+ "the slave(s) contained in the specified master-setup-file"
+
+ logging.info("Applying contents of file [" + master_setup_filename + "] to MASTER")
+
+ master_setup = SafeConfigParser()
+ if path.isfile(master_setup_filename) and access(master_setup_filename, R_OK):
+ master_setup.readfp(open(filename))
+ else:
+ fail("Can't find master-setup file [" + master_setup_filename + "]")
+
+ fqdns = master_setup.sections()
+
+ for fqdn in fqdns:
+ logging.info("Updating info for slave [" + fqdn + "]")
+
+ if master_setup.has_option(fqdn, 'isEnabled'):
+ logging.info(" isEnabled = %s" % master_setup.getboolean(fqdn, 'isEnabled'))
+ else:
+ logging.info(" isEnabled = 1")
+
+ if master_setup.has_option(fqdn, 'allowAllOrgs'):
+ logging.info(" allowAllOrgs = %s" % master_setup.getboolean(fqdn, 'allowAllOrgs'))
+ else:
+ logging.info(" allowAllOrgs = 1")
+
+ master_orgs = []
+ if master_setup.has_option(fqdn, 'allowedOrgs'):
+ master_orgs = [int(x) for x in master_setup.get(fqdn, 'allowedOrgs').split(',')]
+ logging.info(" allowedOrgs = %s" % master_orgs)
+
+ logging.info("")
+
+ return
def ask(msg):
val = raw_input(msg + " : ")
@@ -495,14 +574,18 @@ if __name__ == '__main__':
filename = determineTemplateFilename('slave', master_info['fqdn'], options, config)
gen_slave_template(slave_cnx, master_cnx, master_info['fqdn'], filename)
- if options.master_file:
+ if (options.master or options.default_ok):
filename = determineTemplateFilename('master', slave_info['fqdn'], options, config)
- if options.apply and (options.master or options.default_ok):
+ if options.apply:
apply_master_template(master_cnx, filename)
+ elif options.dry_run:
+ describe_master_template(filename)
- if options.slave_file:
+ if (options.slave or options.default_ok):
filename = determineTemplateFilename('slave', master_info['fqdn'], options, config)
- if options.apply and (options.slave or options.default_ok):
+ if options.apply:
apply_slave_template(slave_cnx, filename)
+ elif options.dry_run:
+ describe_slave_template(filename)
# vim:ts=4:expandtab:
commit 3a292597c0126ca6ff347fcc10a3ce60f1dd8c9c
Author: Grant Gainey <ggainey(a)redhat.com>
Date: Mon Jul 1 11:06:32 2013 -0400
977878 - Move sync_setup to somewhere package-able, rename and add license stmt
diff --git a/sync_setup/src/bin/sync_setup b/sync_setup/src/bin/sync_setup
deleted file mode 100755
index f230eb0..0000000
--- a/sync_setup/src/bin/sync_setup
+++ /dev/null
@@ -1,491 +0,0 @@
-#!/usr/bin/python
-
-""" iss_setup - a tool for easing the pain of setting up organization-mappings for ISS """
-
-import logging, os, re, sys, xmlrpclib, string
-from ConfigParser import SafeConfigParser, NoOptionError
-from optparse import OptionParser, OptionGroup
-from os import path, access, R_OK
-from os.path import expanduser
-
-home = expanduser("~")
-DEFAULT_MASTER_SETUP_FILENAME = home + '/.spacewalk/master.txt'
-DEFAULT_SLAVE_SETUP_FILENAME = home + '/.spacewalk/slave.txt'
-
-DEFAULT_CONFIG = """
-# Default defines the slave and/or master we should connect to by default
-[Default]
-# Default slave FQDN
-slave.default=SLAVE
-# Default master FQDN
-master.default=MASTER
-"""
-
-DEFAULT_CONFIG_FQDN_STANZA = """
-# Any spacewalk Fully-Qualified-Domain-Name (fqdn) can have a stanza,
-# defining logins and setup files to use
-[FQDN]
-# Login of a sat-admin login for this instance
-login = LOGIN
-# NOTE: Putting passwords in cfg-files is suboptimal. The tool will ask
-# But if you really want to, go ahead
-password = PASSWORD
-# Where's the slave-side setup file for this spacewalk instance?
-slave.setup = SLAVE_FILE
-# Where's the master-side setup file for this spacewalk instance?
-master.setup = MASTER_FILE
-"""
-
-def setupOptions():
- usage = 'usage: %prog [options]'
- parser = OptionParser(usage=usage)
-
- cnxGrp = OptionGroup(parser, "Connections", "Identify the spacewalk instances we're going to connect to");
- cnxGrp.add_option('--ss', '--slave-server', action='store', dest='slave',
- help="name of a slave to connect to.")
- cnxGrp.add_option('--sl', '--slave-login', action='store', dest='slave_login', default="",
- help="A sat-admin login for slave-server")
- cnxGrp.add_option('--sp', '--slave-password', action='store', dest='slave_password', default="",
- help="Password for login slave-login on slave-server")
- cnxGrp.add_option('--ms', '--master-server', action='store', dest='master',
- help="name of a master to connect to.")
- cnxGrp.add_option('--ml', '--master-login', action='store', dest='master_login', default="",
- help="A sat-admin login for master-server")
- cnxGrp.add_option('--mp', '--master-password', action='store', dest='master_password', default="",
- help="Password for login master-login on master-server")
- parser.add_option_group(cnxGrp)
-
- tmplGrp = OptionGroup(parser, "Templates", "Options for creating initial versions of setup files")
- tmplGrp.add_option('--cst', '--create-slave-template', action='store_true', dest='slave_template', default=False,
- help="Create a setup file for the slave we're pointed at, "
- "based on information from the master we're pointed at")
- tmplGrp.add_option('--cmt', '--create-master-template', action='store_true', dest='master_template', default=False,
- help="Create a setup file for the master we're pointed at, "
- "based on information from the slave we're pointed at")
- tmplGrp.add_option('--ct', '--create-templates', action='store_true', dest='both_template', default=False,
- help="Create both a master and a slave setup file, for the master/slave pair we're pointed at")
- parser.add_option_group(tmplGrp)
-
- setupGrp = OptionGroup(parser, "Setup",
- "Specify the setup files we're actually going to apply to a slave/master")
- setupGrp.add_option('--msf', '--master-setup-file', action='store', dest='master_file', metavar='FILE',
- help='Specify the master-setup-file we should use')
- setupGrp.add_option('--ssf', '--slave-setup-file', action='store', dest='slave_file', metavar='FILE',
- help='Specify the slave-setup-file we should use')
- parser.add_option_group(setupGrp)
-
- actionGrp = OptionGroup(parser, "Action", "Should we actually affect the specified spacewalk instances?")
- actionGrp.add_option('--dry-run', action='store_true', dest='dry_run', default=True,
- help="Don't actually change anything, but tell us what you would have done")
- actionGrp.add_option('--apply', action='store_true', dest='apply', default=False,
- help="make the changes specified by the setup files to the specified spacewalk instances")
- actionGrp.add_option('--default-ok', action='store_true', dest='default_ok', default=False,
- help="Even if I don't explicitly tell you about a master or slave on the command-line, it's ok to try to apply changes to them!")
- parser.add_option_group(actionGrp)
-
- utilGrp = OptionGroup(parser, "Utility")
- utilGrp.add_option('-d', '--debug', action='store_true', default=False, dest='debug',
- help='Log debugging output')
- utilGrp.add_option('-q', '--quiet', action='store_true', default=False, dest='quiet',
- help='Log only errors')
- parser.add_option_group(utilGrp)
-
- return parser
-
-
-def setupLogging(opt):
- # determine the logging level
- if opt.debug:
- level = logging.DEBUG
- elif opt.quiet:
- level = logging.ERROR
- else:
- level = logging.INFO
-
- # configure logging
- logging.basicConfig(level=level, format='%(levelname)s: %(message)s')
- return
-
-
-def initializeConfig(opt, handle):
- "We don't have any defaults - create some, using CLI if we have them"
- hdr = DEFAULT_CONFIG
-
- slave_stanza = DEFAULT_CONFIG_FQDN_STANZA
- master_stanza = DEFAULT_CONFIG_FQDN_STANZA
-
- if 'slave' in opt.__dict__:
- hdr = hdr.replace('SLAVE', opt.slave)
- slave_stanza = slave_stanza.replace('FQDN', opt.slave)
-
- if 'slave_login' in opt.__dict__:
- slave_stanza = slave_stanza.replace('LOGIN', opt.slave_login)
-
- if 'slave_password' in opt.__dict__:
- slave_stanza = slave_stanza.replace('PASSWORD', opt.slave_password)
-
- if 'slave_file' in opt.__dict__:
- slave_stanza = slave_stanza.replace('SLAVE_FILE', opt.slave_file)
-
- if 'master' in opt.__dict__:
- hdr = hdr.replace('MASTER', opt.master)
- master_stanza = master_stanza.replace('FQDN', opt.master)
-
- if 'master_login' in opt.__dict__:
- master_stanza = master_stanza.replace('LOGIN', opt.master_login)
-
- if 'master_password' in opt.__dict__:
- master_stanza = master_stanza.replace('PASSWORD', opt.master_password)
-
- if 'master_file' in opt.__dict__:
- master_stanza = master_stanza.replace('MASTER_FILE', opt.master_file)
-
- logging.debug("Header is now " + hdr)
- logging.debug("Slave-stanza is now " + slave_stanza)
- logging.debug("Master-stanza is now " + master_stanza)
-
- handle.write(hdr)
- handle.write(slave_stanza)
- handle.write(master_stanza)
-
- return
-
-
-def setupConfig(opt):
- "The cfg-values we recognize include: \n"
- " * default master \n"
- " * default slave \n"
- " * For specific FQDNs: \n"
- " * login \n"
- " * password \n"
- " * master-setup-file \n"
- " * slave-setup-file \n"
-
- # files are loaded from ~/.spacewalk/
- conf_dir = os.path.expanduser('~/.spacewalk')
- user_conf_file = os.path.join(conf_dir, 'config')
-
- # server-specifics will be loaded from the configuration file later
- config = SafeConfigParser()
-
- # create an empty configuration file if one's not present
- if not os.path.isfile(user_conf_file):
- try:
- # create ~/.spacewalk
- if not os.path.isdir(conf_dir):
- logging.debug('Creating %s' % conf_dir)
- os.mkdir(conf_dir, 0700)
-
- # create a template configuration file
- logging.debug('Creating configuration file: %s' % user_conf_file)
- handle = open(user_conf_file, 'w')
- initializeConfig(opt, handle)
- handle.close()
- except IOError:
- logging.error('Could not create %s' % user_conf_file)
-
- # load options from configuration file
- config.read( [ user_conf_file ] )
-
- return config;
-
-
-def getMasterConnectionInfo(opt, cfg):
- "Make sure we have login, password, and fqdn for MASTER, based on options and config-files"
- info = {}
-
- if 'master' in opt.__dict__:
- info['fqdn'] = opt.master
- elif cfg.has_option('Default', 'master.default'):
- info['fqdn'] = cfg.get('Default', 'master.default')
- else: # No master - skip
- return info
-
- # Now that we have a master fqdn, we can get login info
- if 'master_login' in opt.__dict__:
- info['login'] = opt.master_login
- elif cfg.has_option(info['fqdn'], 'login'):
- info['login'] = cfg.has_option(info['fqdn'], 'login')
- else:
- return info
-
- # And finally pwd
- if 'master_password' in opt.__dict__:
- info['password'] = opt.master_password
- elif cfg.has_option(info['fqdn'], 'password'):
- info['password'] = cfg.has_option(info['fqdn'], 'password')
- else:
- return info;
-
- return info
-
-
-def getSlaveConnectionInfo(opt, cfg):
- "Make sure we have login, password, and fqdn for SLAVE, based on options and config-files"
- info = {}
-
- if 'slave' in opt.__dict__:
- info['fqdn'] = opt.slave
- elif cfg.has_option('Default', 'slave.default'):
- info['fqdn'] = cfg.get('Default', 'slave.default')
- else: # No slave - skip
- return info
-
- # Now that we have a slave fqdn, we can get login info
- if 'slave_login' in opt.__dict__:
- info['login'] = opt.slave_login
- elif cfg.has_option(info['fqdn'], 'login'):
- info['login'] = cfg.has_option(info['fqdn'], 'login')
- else:
- return info
-
- # And finally pwd
- if 'slave_password' in opt.__dict__:
- info['password'] = opt.slave_password
- elif cfg.has_option(info['fqdn'], 'password'):
- info['password'] = cfg.has_option(info['fqdn'], 'password')
- else:
- return info;
-
- return info
-
-
-def validateConnectInfo(info):
- "Something needs to connect - make sure we have fqdn/login/pwd, and ask for "
- " anything missing"
-
- if not 'fqdn' in info or len(info['fqdn']) == 0:
- fail("Can't connect, I don't know what machine you want to go to!")
-
- if not 'login' in info or len(info['login']) == 0:
- info['login'] = ask("Satellite-Admin login for " + info['fqdn'])
- if not 'login' in info:
- fail("Can't connect, I don't have a login to use!")
-
- if not 'password' in info or len(info['password']) == 0:
- info['password'] = ask("Password for " + info['login'] + " on machine " + info['fqdn'])
- # I would love to check for empty-pwd here - but some people use empty passwords :(
-
- return info
-
-
-def connectTo(info):
- logging.debug("Connect-to info = %s" % info)
- logging.info("Connecting to " + info['login'] + "@" + info['fqdn'])
- info = validateConnectInfo(info)
- url = "https://{0}/rpc/api".format(info['fqdn'])
- client = xmlrpclib.Server(url, verbose=0)
- key = client.auth.login(info['login'], info['password'])
- return { "client" : client, "key" : key }
-
-
-def orgByName(orgs):
- org_map = {}
- for org in orgs:
- org_map[org['name']] = org['id']
- return org_map
-
-
-def determineTemplateFilename(kind, fqdn, opt, cfg):
- logging.debug("detTmplFilename kind = %s, fqdn = %s, opt = %s, cfg = %s" % (kind, fqdn, opt, cfg))
-
- if kind == 'master':
- if opt.master_file:
- return opt.master_file
- elif cfg.has_option(fqdn, 'master.setup'):
- return cfg.get(fqdn, 'master.setup')
- else:
- return DEFAULT_MASTER_SETUP_FILENAME
- elif kind == 'slave':
- if opt.slave_file:
- return opt.slave_file
- elif cfg.has_option(fqdn, 'slave.setup') and len(cfg.get(fqdn, 'slave.setup')) != 0:
- return cfg.get(fqdn, 'slave.setup')
- else:
- return DEFAULT_SLAVE_SETUP_FILENAME
- else:
- return None
-
-
-def gen_slave_template(slave_session, master_session, master, filename):
- "Generates a default setup applying to the specified master, for the connected-slave"
- logging.info("Generating slave-setup file " + filename)
-
- master_orgs = master_session['client'].org.listOrgs(master_session['key'])
- master_map = orgByName(master_orgs)
- logging.debug("MASTER ORG MAP %s" % master_map)
-
- slave_orgs = slave_session['client'].org.listOrgs(slave_session['key'])
- slave_map = orgByName(slave_orgs)
- logging.debug("SLAVE ORG MAP %s" % slave_map)
-
- slave_setup = SafeConfigParser()
- slave_setup.optionxform = str
-
- if path.isfile(filename) and access(filename, R_OK):
- slave_setup.readfp(open(filename))
-
- if not slave_setup.has_section(master):
- slave_setup.add_section(master)
-
- for org in master_orgs:
- if org['name'] in slave_map:
- master_org = "%s|%s|%s" % (org['id'], org['name'], slave_map[org['name']])
- slave_setup.set(master, str(org['id']), str(master_org))
- else:
- master_org = "%s|%s|%s" % (org['id'], org['name'], 1)
- slave_setup.set(master, str(org['id']), master_org)
-
- with open(filename, 'w+') as configfile:
- slave_setup.write(configfile)
- configfile.close()
-
- return
-
-
-def gen_master_template(master_session, slave, filename):
- "Generates a default setup applying to the specified slave, for the connected-master"
- logging.info("Generating master-setup file " + filename)
-
- master_setup = SafeConfigParser()
- master_setup.optionxform = str
-
- if path.isfile(filename) and access(filename, R_OK):
- master_setup.readfp(open(filename, 'r'))
-
- if not master_setup.has_section(slave):
- master_setup.add_section(slave)
-
- if not master_setup.has_option(slave, "isEnabled"):
- master_setup.set(slave, 'isEnabled', str(1))
-
- if not master_setup.has_option(slave, "allowAllOrgs"):
- master_setup.set(slave, 'allowAllOrgs', str(1))
-
- if not master_setup.has_option(slave, "allowedOrgs"):
- idlist = []
- for org in master_session['client'].org.listOrgs(master_session['key']):
- idlist.append(org['id'])
- logging.debug("idlist %s" % idlist)
- master_setup.set(slave, 'allowedOrgs', ",".join(str(i) for i in idlist))
-
- with open(filename, 'w+') as mfile:
- master_setup.write(mfile)
- mfile.close()
-
- return
-
-
-def apply_slave_template(slave_session, slave_setup_filename):
- "Updates the connected slave with information for the master(s) contained in the specified slave-setup-file"
- logging.info("Applying slave-setup " + slave_setup_filename)
- client = slave_session['client']
- key = slave_session['key']
-
- slave_setup = SafeConfigParser()
- if path.isfile(slave_setup_filename) and access(slave_setup_filename, R_OK):
- slave_setup.readfp(open(filename))
- else:
- fail("Can't find slave-setup file [" + slave_setup_filename + "]")
-
- fqdns = slave_setup.sections()
-
- for fqdn in fqdns:
- try:
- master = client.sync.master.getMasterByLabel(key, fqdn)
- except Exception, e:
- master = client.sync.master.create(key, fqdn)
-
- master_orgs = []
- moids = slave_setup.options(fqdn)
- for moid in moids: # moid|moname|local_oid
- minfo = slave_setup.get(fqdn, moid)
- elts = string.split(minfo, '|')
- orginfo = {}
- orginfo['masterOrgId'] = int(elts[0])
- orginfo['masterOrgName'] = elts[1]
- if len(elts[2]) > 0:
- orginfo['localOrgId'] = int(elts[2])
- master_orgs.append(orginfo)
-
- client.sync.master.setMasterOrgs(key, master['id'], master_orgs)
-
- return
-
-
-def apply_master_template(master_session, master_setup_filename):
- "Updates the connected master with information for the slave(s) contained in the specified master-setup-file"
- logging.info("Applying master-setup " + master_setup_filename)
- client = master_session['client']
- key = master_session['key']
-
- master_setup = SafeConfigParser()
- if path.isfile(master_setup_filename) and access(master_setup_filename, R_OK):
- master_setup.readfp(open(filename))
- else:
- fail("Can't find master-setup file [" + master_setup_filename + "]")
-
- fqdns = master_setup.sections()
-
- for fqdn in fqdns:
- try:
- slave = client.sync.slave.getSlaveByName(key, fqdn)
- except Exception, e:
- slave = client.sync.slave.create(key, fqdn, True, True)
-
- client.sync.slave.update(key, slave['id'], fqdn,
- master_setup.getboolean(fqdn, 'isEnabled'),
- master_setup.getboolean(fqdn, 'allowAllOrgs'))
- master_orgs = [int(x) for x in master_setup.get(fqdn, 'allowedOrgs').split(',')]
- client.sync.slave.setAllowedOrgs(key, slave['id'], master_orgs)
- return
-
-
-def ask(msg):
- val = raw_input(msg + " : ")
- return val
-
-
-def fail(msg):
- logging.error(msg)
- sys.exit(msg)
-
-
-if __name__ == '__main__':
- parser = setupOptions()
- (options, args) = parser.parse_args()
- setupLogging(options)
- logging.debug("OPTIONS = %s" % options)
-
- config = setupConfig(options)
- logging.debug("CONFIG = %s" % config)
-
- master_info = getMasterConnectionInfo(options, config)
- if options.master_template or options.slave_template or options.both_template or options.master_file:
- master_cnx = connectTo(master_info)
- logging.debug("Master cnx = %s" % master_cnx)
-
- slave_info = getSlaveConnectionInfo(options, config)
- if options.master_template or options.slave_template or options.both_template or options.slave_file:
- slave_cnx = connectTo(slave_info)
- logging.debug("Slave cnx = %s" % slave_cnx)
-
- if options.master_template or options.both_template:
- filename = determineTemplateFilename('master', slave_info['fqdn'], options, config)
- gen_master_template(master_cnx, slave_info['fqdn'], filename)
-
- if options.slave_template or options.both_template:
- filename = determineTemplateFilename('slave', master_info['fqdn'], options, config)
- gen_slave_template(slave_cnx, master_cnx, master_info['fqdn'], filename)
-
- if options.master_file:
- filename = determineTemplateFilename('master', slave_info['fqdn'], options, config)
- if options.apply and (options.master or options.default_ok):
- apply_master_template(master_cnx, filename)
-
- if options.slave_file:
- filename = determineTemplateFilename('slave', master_info['fqdn'], options, config)
- if options.apply and (options.slave or options.default_ok):
- apply_slave_template(slave_cnx, filename)
-
-# vim:ts=4:expandtab:
diff --git a/utils/spacewalk-sync-setup b/utils/spacewalk-sync-setup
new file mode 100755
index 0000000..746a004
--- /dev/null
+++ b/utils/spacewalk-sync-setup
@@ -0,0 +1,508 @@
+#!/usr/bin/python
+#
+# Utility for setting up ISS master/slave org-mappings
+#
+# Copyright (c) 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.
+#
+
+""" iss_setup - a tool for easing the pain of setting up organization-mappings for ISS """
+
+import logging, os, re, sys, xmlrpclib, string
+from ConfigParser import SafeConfigParser, NoOptionError
+from optparse import OptionParser, OptionGroup
+from os import path, access, R_OK
+from os.path import expanduser
+
+home = expanduser("~")
+DEFAULT_MASTER_SETUP_FILENAME = home + '/.spacewalk-sync-setup/master.txt'
+DEFAULT_SLAVE_SETUP_FILENAME = home + '/.spacewalk-sync-setup/slave.txt'
+
+DEFAULT_CONFIG = """
+# Default defines the slave and/or master we should connect to by default
+[Default]
+# Default slave FQDN
+slave.default=SLAVE
+# Default master FQDN
+master.default=MASTER
+"""
+
+DEFAULT_CONFIG_FQDN_STANZA = """
+# Any spacewalk Fully-Qualified-Domain-Name (fqdn) can have a stanza,
+# defining logins and setup files to use
+[FQDN]
+# Login of a sat-admin login for this instance
+login = LOGIN
+# NOTE: Putting passwords in cfg-files is suboptimal. The tool will ask
+# But if you really want to, go ahead
+password = PASSWORD
+# Where's the slave-side setup file for this spacewalk instance?
+slave.setup = SLAVE_FILE
+# Where's the master-side setup file for this spacewalk instance?
+master.setup = MASTER_FILE
+"""
+
+def setupOptions():
+ usage = 'usage: %prog [options]'
+ parser = OptionParser(usage=usage)
+
+ cnxGrp = OptionGroup(parser, "Connections", "Identify the spacewalk instances we're going to connect to");
+ cnxGrp.add_option('--ss', '--slave-server', action='store', dest='slave',
+ help="name of a slave to connect to.")
+ cnxGrp.add_option('--sl', '--slave-login', action='store', dest='slave_login', default="",
+ help="A sat-admin login for slave-server")
+ cnxGrp.add_option('--sp', '--slave-password', action='store', dest='slave_password', default="",
+ help="Password for login slave-login on slave-server")
+ cnxGrp.add_option('--ms', '--master-server', action='store', dest='master',
+ help="name of a master to connect to.")
+ cnxGrp.add_option('--ml', '--master-login', action='store', dest='master_login', default="",
+ help="A sat-admin login for master-server")
+ cnxGrp.add_option('--mp', '--master-password', action='store', dest='master_password', default="",
+ help="Password for login master-login on master-server")
+ parser.add_option_group(cnxGrp)
+
+ tmplGrp = OptionGroup(parser, "Templates", "Options for creating initial versions of setup files")
+ tmplGrp.add_option('--cst', '--create-slave-template', action='store_true', dest='slave_template', default=False,
+ help="Create a setup file for the slave we're pointed at, "
+ "based on information from the master we're pointed at")
+ tmplGrp.add_option('--cmt', '--create-master-template', action='store_true', dest='master_template', default=False,
+ help="Create a setup file for the master we're pointed at, "
+ "based on information from the slave we're pointed at")
+ tmplGrp.add_option('--ct', '--create-templates', action='store_true', dest='both_template', default=False,
+ help="Create both a master and a slave setup file, for the master/slave pair we're pointed at")
+ parser.add_option_group(tmplGrp)
+
+ setupGrp = OptionGroup(parser, "Setup",
+ "Specify the setup files we're actually going to apply to a slave/master")
+ setupGrp.add_option('--msf', '--master-setup-file', action='store', dest='master_file', metavar='FILE',
+ help='Specify the master-setup-file we should use')
+ setupGrp.add_option('--ssf', '--slave-setup-file', action='store', dest='slave_file', metavar='FILE',
+ help='Specify the slave-setup-file we should use')
+ parser.add_option_group(setupGrp)
+
+ actionGrp = OptionGroup(parser, "Action", "Should we actually affect the specified spacewalk instances?")
+ actionGrp.add_option('--dry-run', action='store_true', dest='dry_run', default=True,
+ help="Don't actually change anything, but tell us what you would have done")
+ actionGrp.add_option('--apply', action='store_true', dest='apply', default=False,
+ help="make the changes specified by the setup files to the specified spacewalk instances")
+ actionGrp.add_option('--default-ok', action='store_true', dest='default_ok', default=False,
+ help="Even if I don't explicitly tell you about a master or slave on the command-line, it's ok to try to apply changes to them!")
+ parser.add_option_group(actionGrp)
+
+ utilGrp = OptionGroup(parser, "Utility")
+ utilGrp.add_option('-d', '--debug', action='store_true', default=False, dest='debug',
+ help='Log debugging output')
+ utilGrp.add_option('-q', '--quiet', action='store_true', default=False, dest='quiet',
+ help='Log only errors')
+ parser.add_option_group(utilGrp)
+
+ return parser
+
+
+def setupLogging(opt):
+ # determine the logging level
+ if opt.debug:
+ level = logging.DEBUG
+ elif opt.quiet:
+ level = logging.ERROR
+ else:
+ level = logging.INFO
+
+ # configure logging
+ logging.basicConfig(level=level, format='%(levelname)s: %(message)s')
+ return
+
+
+def initializeConfig(opt, handle):
+ "We don't have any defaults - create some, using CLI if we have them"
+ hdr = DEFAULT_CONFIG
+
+ slave_stanza = DEFAULT_CONFIG_FQDN_STANZA
+ master_stanza = DEFAULT_CONFIG_FQDN_STANZA
+
+ if 'slave' in opt.__dict__:
+ hdr = hdr.replace('SLAVE', opt.slave)
+ slave_stanza = slave_stanza.replace('FQDN', opt.slave)
+
+ if 'slave_login' in opt.__dict__:
+ slave_stanza = slave_stanza.replace('LOGIN', opt.slave_login)
+
+ if 'slave_password' in opt.__dict__:
+ slave_stanza = slave_stanza.replace('PASSWORD', opt.slave_password)
+
+ if 'slave_file' in opt.__dict__:
+ slave_stanza = slave_stanza.replace('SLAVE_FILE', opt.slave_file)
+
+ if 'master' in opt.__dict__:
+ hdr = hdr.replace('MASTER', opt.master)
+ master_stanza = master_stanza.replace('FQDN', opt.master)
+
+ if 'master_login' in opt.__dict__:
+ master_stanza = master_stanza.replace('LOGIN', opt.master_login)
+
+ if 'master_password' in opt.__dict__:
+ master_stanza = master_stanza.replace('PASSWORD', opt.master_password)
+
+ if 'master_file' in opt.__dict__:
+ master_stanza = master_stanza.replace('MASTER_FILE', opt.master_file)
+
+ logging.debug("Header is now " + hdr)
+ logging.debug("Slave-stanza is now " + slave_stanza)
+ logging.debug("Master-stanza is now " + master_stanza)
+
+ handle.write(hdr)
+ handle.write(slave_stanza)
+ handle.write(master_stanza)
+
+ return
+
+
+def setupConfig(opt):
+ "The cfg-values we recognize include: \n"
+ " * default master \n"
+ " * default slave \n"
+ " * For specific FQDNs: \n"
+ " * login \n"
+ " * password \n"
+ " * master-setup-file \n"
+ " * slave-setup-file \n"
+
+ # files are loaded from ~/.spacewalk-sync-setup/
+ conf_dir = os.path.expanduser('~/.spacewalk-sync-setup')
+ user_conf_file = os.path.join(conf_dir, 'config')
+
+ # server-specifics will be loaded from the configuration file later
+ config = SafeConfigParser()
+
+ # create an empty configuration file if one's not present
+ if not os.path.isfile(user_conf_file):
+ try:
+ # create ~/.spacewalk-sync-setup
+ if not os.path.isdir(conf_dir):
+ logging.debug('Creating %s' % conf_dir)
+ os.mkdir(conf_dir, 0700)
+
+ # create a template configuration file
+ logging.debug('Creating configuration file: %s' % user_conf_file)
+ handle = open(user_conf_file, 'w')
+ initializeConfig(opt, handle)
+ handle.close()
+ except IOError:
+ logging.error('Could not create %s' % user_conf_file)
+
+ # load options from configuration file
+ config.read( [ user_conf_file ] )
+
+ return config;
+
+
+def getMasterConnectionInfo(opt, cfg):
+ "Make sure we have login, password, and fqdn for MASTER, based on options and config-files"
+ info = {}
+
+ if 'master' in opt.__dict__:
+ info['fqdn'] = opt.master
+ elif cfg.has_option('Default', 'master.default'):
+ info['fqdn'] = cfg.get('Default', 'master.default')
+ else: # No master - skip
+ return info
+
+ # Now that we have a master fqdn, we can get login info
+ if 'master_login' in opt.__dict__:
+ info['login'] = opt.master_login
+ elif cfg.has_option(info['fqdn'], 'login'):
+ info['login'] = cfg.has_option(info['fqdn'], 'login')
+ else:
+ return info
+
+ # And finally pwd
+ if 'master_password' in opt.__dict__:
+ info['password'] = opt.master_password
+ elif cfg.has_option(info['fqdn'], 'password'):
+ info['password'] = cfg.has_option(info['fqdn'], 'password')
+ else:
+ return info;
+
+ return info
+
+
+def getSlaveConnectionInfo(opt, cfg):
+ "Make sure we have login, password, and fqdn for SLAVE, based on options and config-files"
+ info = {}
+
+ if 'slave' in opt.__dict__:
+ info['fqdn'] = opt.slave
+ elif cfg.has_option('Default', 'slave.default'):
+ info['fqdn'] = cfg.get('Default', 'slave.default')
+ else: # No slave - skip
+ return info
+
+ # Now that we have a slave fqdn, we can get login info
+ if 'slave_login' in opt.__dict__:
+ info['login'] = opt.slave_login
+ elif cfg.has_option(info['fqdn'], 'login'):
+ info['login'] = cfg.has_option(info['fqdn'], 'login')
+ else:
+ return info
+
+ # And finally pwd
+ if 'slave_password' in opt.__dict__:
+ info['password'] = opt.slave_password
+ elif cfg.has_option(info['fqdn'], 'password'):
+ info['password'] = cfg.has_option(info['fqdn'], 'password')
+ else:
+ return info;
+
+ return info
+
+
+def validateConnectInfo(info):
+ "Something needs to connect - make sure we have fqdn/login/pwd, and ask for "
+ " anything missing"
+
+ if not 'fqdn' in info or len(info['fqdn']) == 0:
+ fail("Can't connect, I don't know what machine you want to go to!")
+
+ if not 'login' in info or len(info['login']) == 0:
+ info['login'] = ask("Satellite-Admin login for " + info['fqdn'])
+ if not 'login' in info:
+ fail("Can't connect, I don't have a login to use!")
+
+ if not 'password' in info or len(info['password']) == 0:
+ info['password'] = ask("Password for " + info['login'] + " on machine " + info['fqdn'])
+ # I would love to check for empty-pwd here - but some people use empty passwords :(
+
+ return info
+
+
+def connectTo(info):
+ logging.debug("Connect-to info = %s" % info)
+ logging.info("Connecting to " + info['login'] + "@" + info['fqdn'])
+ info = validateConnectInfo(info)
+ url = "https://{0}/rpc/api".format(info['fqdn'])
+ client = xmlrpclib.Server(url, verbose=0)
+ key = client.auth.login(info['login'], info['password'])
+ return { "client" : client, "key" : key }
+
+
+def orgByName(orgs):
+ org_map = {}
+ for org in orgs:
+ org_map[org['name']] = org['id']
+ return org_map
+
+
+def determineTemplateFilename(kind, fqdn, opt, cfg):
+ logging.debug("detTmplFilename kind = %s, fqdn = %s, opt = %s, cfg = %s" % (kind, fqdn, opt, cfg))
+
+ if kind == 'master':
+ if opt.master_file:
+ return opt.master_file
+ elif cfg.has_option(fqdn, 'master.setup'):
+ return cfg.get(fqdn, 'master.setup')
+ else:
+ return DEFAULT_MASTER_SETUP_FILENAME
+ elif kind == 'slave':
+ if opt.slave_file:
+ return opt.slave_file
+ elif cfg.has_option(fqdn, 'slave.setup') and len(cfg.get(fqdn, 'slave.setup')) != 0:
+ return cfg.get(fqdn, 'slave.setup')
+ else:
+ return DEFAULT_SLAVE_SETUP_FILENAME
+ else:
+ return None
+
+
+def gen_slave_template(slave_session, master_session, master, filename):
+ "Generates a default setup applying to the specified master, for the connected-slave"
+ logging.info("Generating slave-setup file " + filename)
+
+ master_orgs = master_session['client'].org.listOrgs(master_session['key'])
+ master_map = orgByName(master_orgs)
+ logging.debug("MASTER ORG MAP %s" % master_map)
+
+ slave_orgs = slave_session['client'].org.listOrgs(slave_session['key'])
+ slave_map = orgByName(slave_orgs)
+ logging.debug("SLAVE ORG MAP %s" % slave_map)
+
+ slave_setup = SafeConfigParser()
+ slave_setup.optionxform = str
+
+ if path.isfile(filename) and access(filename, R_OK):
+ slave_setup.readfp(open(filename))
+
+ if not slave_setup.has_section(master):
+ slave_setup.add_section(master)
+
+ for org in master_orgs:
+ if org['name'] in slave_map:
+ master_org = "%s|%s|%s" % (org['id'], org['name'], slave_map[org['name']])
+ slave_setup.set(master, str(org['id']), str(master_org))
+ else:
+ master_org = "%s|%s|%s" % (org['id'], org['name'], 1)
+ slave_setup.set(master, str(org['id']), master_org)
+
+ with open(filename, 'w+') as configfile:
+ slave_setup.write(configfile)
+ configfile.close()
+
+ return
+
+
+def gen_master_template(master_session, slave, filename):
+ "Generates a default setup applying to the specified slave, for the connected-master"
+ logging.info("Generating master-setup file " + filename)
+
+ master_setup = SafeConfigParser()
+ master_setup.optionxform = str
+
+ if path.isfile(filename) and access(filename, R_OK):
+ master_setup.readfp(open(filename, 'r'))
+
+ if not master_setup.has_section(slave):
+ master_setup.add_section(slave)
+
+ if not master_setup.has_option(slave, "isEnabled"):
+ master_setup.set(slave, 'isEnabled', str(1))
+
+ if not master_setup.has_option(slave, "allowAllOrgs"):
+ master_setup.set(slave, 'allowAllOrgs', str(1))
+
+ if not master_setup.has_option(slave, "allowedOrgs"):
+ idlist = []
+ for org in master_session['client'].org.listOrgs(master_session['key']):
+ idlist.append(org['id'])
+ logging.debug("idlist %s" % idlist)
+ master_setup.set(slave, 'allowedOrgs', ",".join(str(i) for i in idlist))
+
+ with open(filename, 'w+') as mfile:
+ master_setup.write(mfile)
+ mfile.close()
+
+ return
+
+
+def apply_slave_template(slave_session, slave_setup_filename):
+ "Updates the connected slave with information for the master(s) contained in the specified slave-setup-file"
+ logging.info("Applying slave-setup " + slave_setup_filename)
+ client = slave_session['client']
+ key = slave_session['key']
+
+ slave_setup = SafeConfigParser()
+ if path.isfile(slave_setup_filename) and access(slave_setup_filename, R_OK):
+ slave_setup.readfp(open(filename))
+ else:
+ fail("Can't find slave-setup file [" + slave_setup_filename + "]")
+
+ fqdns = slave_setup.sections()
+
+ for fqdn in fqdns:
+ try:
+ master = client.sync.master.getMasterByLabel(key, fqdn)
+ except Exception, e:
+ master = client.sync.master.create(key, fqdn)
+
+ master_orgs = []
+ moids = slave_setup.options(fqdn)
+ for moid in moids: # moid|moname|local_oid
+ minfo = slave_setup.get(fqdn, moid)
+ elts = string.split(minfo, '|')
+ orginfo = {}
+ orginfo['masterOrgId'] = int(elts[0])
+ orginfo['masterOrgName'] = elts[1]
+ if len(elts[2]) > 0:
+ orginfo['localOrgId'] = int(elts[2])
+ master_orgs.append(orginfo)
+
+ client.sync.master.setMasterOrgs(key, master['id'], master_orgs)
+
+ return
+
+
+def apply_master_template(master_session, master_setup_filename):
+ "Updates the connected master with information for the slave(s) contained in the specified master-setup-file"
+ logging.info("Applying master-setup " + master_setup_filename)
+ client = master_session['client']
+ key = master_session['key']
+
+ master_setup = SafeConfigParser()
+ if path.isfile(master_setup_filename) and access(master_setup_filename, R_OK):
+ master_setup.readfp(open(filename))
+ else:
+ fail("Can't find master-setup file [" + master_setup_filename + "]")
+
+ fqdns = master_setup.sections()
+
+ for fqdn in fqdns:
+ try:
+ slave = client.sync.slave.getSlaveByName(key, fqdn)
+ except Exception, e:
+ slave = client.sync.slave.create(key, fqdn, True, True)
+
+ client.sync.slave.update(key, slave['id'], fqdn,
+ master_setup.getboolean(fqdn, 'isEnabled'),
+ master_setup.getboolean(fqdn, 'allowAllOrgs'))
+ master_orgs = [int(x) for x in master_setup.get(fqdn, 'allowedOrgs').split(',')]
+ client.sync.slave.setAllowedOrgs(key, slave['id'], master_orgs)
+ return
+
+
+def ask(msg):
+ val = raw_input(msg + " : ")
+ return val
+
+
+def fail(msg):
+ logging.error(msg)
+ sys.exit(msg)
+
+
+if __name__ == '__main__':
+ parser = setupOptions()
+ (options, args) = parser.parse_args()
+ setupLogging(options)
+ logging.debug("OPTIONS = %s" % options)
+
+ config = setupConfig(options)
+ logging.debug("CONFIG = %s" % config)
+
+ master_info = getMasterConnectionInfo(options, config)
+ if options.master_template or options.slave_template or options.both_template or options.master_file:
+ master_cnx = connectTo(master_info)
+ logging.debug("Master cnx = %s" % master_cnx)
+
+ slave_info = getSlaveConnectionInfo(options, config)
+ if options.master_template or options.slave_template or options.both_template or options.slave_file:
+ slave_cnx = connectTo(slave_info)
+ logging.debug("Slave cnx = %s" % slave_cnx)
+
+ if options.master_template or options.both_template:
+ filename = determineTemplateFilename('master', slave_info['fqdn'], options, config)
+ gen_master_template(master_cnx, slave_info['fqdn'], filename)
+
+ if options.slave_template or options.both_template:
+ filename = determineTemplateFilename('slave', master_info['fqdn'], options, config)
+ gen_slave_template(slave_cnx, master_cnx, master_info['fqdn'], filename)
+
+ if options.master_file:
+ filename = determineTemplateFilename('master', slave_info['fqdn'], options, config)
+ if options.apply and (options.master or options.default_ok):
+ apply_master_template(master_cnx, filename)
+
+ if options.slave_file:
+ filename = determineTemplateFilename('slave', master_info['fqdn'], options, config)
+ if options.apply and (options.slave or options.default_ok):
+ apply_slave_template(slave_cnx, filename)
+
+# vim:ts=4:expandtab:
10 years, 10 months
Changes to 'refs/tags/spacewalk-web-1.10.34-1'
by Tomáš Kašpárek
Tag 'spacewalk-web-1.10.34-1' created by Tomas Kasparek <tkasparek(a)redhat.com> at 2013-07-01 11:57 +0000
Tagging package [spacewalk-web] version [1.10.34-1] in directory [web/].
Changes since spacewalk-schema-1.10.56-1:
Tomas Kasparek (2):
978288 - lookup for defaults also in /usr/share/rhn/config-defaults/rhn.conf
Automatic commit of package [spacewalk-web] release [1.10.34-1].
---
rel-eng/packages/spacewalk-web | 2 +-
web/modules/pxt/PXT/Config.pm | 2 +-
web/spacewalk-web.spec | 5 ++++-
3 files changed, 6 insertions(+), 3 deletions(-)
---
10 years, 10 months
rel-eng/packages web/spacewalk-web.spec
by Tomáš Kašpárek
rel-eng/packages/spacewalk-web | 2 +-
web/spacewalk-web.spec | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
New commits:
commit a83dd4e472495640a4440e6e19434a3842448646
Author: Tomas Kasparek <tkasparek(a)redhat.com>
Date: Mon Jul 1 13:57:07 2013 +0200
Automatic commit of package [spacewalk-web] release [1.10.34-1].
diff --git a/rel-eng/packages/spacewalk-web b/rel-eng/packages/spacewalk-web
index ca0b4b5..3b4a83a 100644
--- a/rel-eng/packages/spacewalk-web
+++ b/rel-eng/packages/spacewalk-web
@@ -1 +1 @@
-1.10.33-1 web/
+1.10.34-1 web/
diff --git a/web/spacewalk-web.spec b/web/spacewalk-web.spec
index be9aba9..2859d91 100644
--- a/web/spacewalk-web.spec
+++ b/web/spacewalk-web.spec
@@ -4,7 +4,7 @@ Name: spacewalk-web
Summary: Spacewalk Web site - Perl modules
Group: Applications/Internet
License: GPLv2
-Version: 1.10.33
+Version: 1.10.34
Release: 1%{?dist}
URL: https://fedorahosted.org/spacewalk/
Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
@@ -272,6 +272,9 @@ rm -rf $RPM_BUILD_ROOT
# $Id$
%changelog
+* Mon Jul 01 2013 Tomas Kasparek <tkasparek(a)redhat.com> 1.10.34-1
+- 978288 - lookup for defaults also in /usr/share/rhn/config-defaults/rhn.conf
+
* Mon Jul 01 2013 Tomas Kasparek <tkasparek(a)redhat.com> 1.10.33-1
- 979924 - fixing duplicate SSM, System List page
10 years, 10 months
web/modules
by Tomáš Kašpárek
web/modules/pxt/PXT/Config.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit d358dbcd812053f705aa2205033b3bb20861d554
Author: Tomas Kasparek <tkasparek(a)redhat.com>
Date: Mon Jul 1 13:52:54 2013 +0200
978288 - lookup for defaults also in /usr/share/rhn/config-defaults/rhn.conf
diff --git a/web/modules/pxt/PXT/Config.pm b/web/modules/pxt/PXT/Config.pm
index 3974411..501bdd7 100644
--- a/web/modules/pxt/PXT/Config.pm
+++ b/web/modules/pxt/PXT/Config.pm
@@ -211,7 +211,7 @@ sub reset_default {
sub master_configs {
my $self = shift;
- return "/usr/share/rhn/config-defaults/rhn_$self->{domain}.conf";
+ return ("/usr/share/rhn/config-defaults/rhn_$self->{domain}.conf", "/usr/share/rhn/config-defaults/rhn.conf");
}
sub local_configs {
10 years, 10 months
Changes to 'refs/tags/spacewalk-schema-1.10.56-1'
by Milan Zazrivec
Tag 'spacewalk-schema-1.10.56-1' created by Milan Zazrivec <mzazrivec(a)redhat.com> at 2013-07-01 11:36 +0000
Tagging package [spacewalk-schema] version [1.10.56-1] in directory [schema/spacewalk/].
Changes since spacewalk-schema-1.10.55-1:
Milan Zazrivec (2):
PostgreSQL schema upgrade fixes
Automatic commit of package [spacewalk-schema] release [1.10.56-1].
---
rel-eng/packages/spacewalk-schema | 2 +-
schema/spacewalk/spacewalk-schema.spec | 5 ++++-
schema/spacewalk/upgrade/spacewalk-schema-1.5-to-spacewalk-schema-1.6/126-alter-index-rhnCpu.sql.postgresql | 4 +---
schema/spacewalk/upgrade/spacewalk-schema-1.5-to-spacewalk-schema-1.6/127-alter-index-rhnServerDmi.sql.postgresql | 4 +---
4 files changed, 7 insertions(+), 8 deletions(-)
---
10 years, 10 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 b72948c9477de3e3a69316498e00b53e83c1624d
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Mon Jul 1 13:36:46 2013 +0200
Automatic commit of package [spacewalk-schema] release [1.10.56-1].
diff --git a/rel-eng/packages/spacewalk-schema b/rel-eng/packages/spacewalk-schema
index e5115f2..d5ee899 100644
--- a/rel-eng/packages/spacewalk-schema
+++ b/rel-eng/packages/spacewalk-schema
@@ -1 +1 @@
-1.10.55-1 schema/spacewalk/
+1.10.56-1 schema/spacewalk/
diff --git a/schema/spacewalk/spacewalk-schema.spec b/schema/spacewalk/spacewalk-schema.spec
index 254835d..95c29a5 100644
--- a/schema/spacewalk/spacewalk-schema.spec
+++ b/schema/spacewalk/spacewalk-schema.spec
@@ -4,7 +4,7 @@ Name: spacewalk-schema
Group: Applications/Internet
Summary: Oracle SQL schema for Spacewalk server
-Version: 1.10.55
+Version: 1.10.56
Release: 1%{?dist}
Source0: %{name}-%{version}.tar.gz
@@ -71,6 +71,9 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man1/spacewalk-sql*
%changelog
+* Mon Jul 01 2013 Milan Zazrivec <mzazrivec(a)redhat.com> 1.10.56-1
+- PostgreSQL schema upgrade fixes
+
* Mon Jul 01 2013 Michael Mraka <michael.mraka(a)redhat.com> 1.10.55-1
- fixed forgotten end loop
10 years, 10 months
schema/spacewalk
by Milan Zazrivec
schema/spacewalk/upgrade/spacewalk-schema-1.5-to-spacewalk-schema-1.6/126-alter-index-rhnCpu.sql.postgresql | 4 +---
schema/spacewalk/upgrade/spacewalk-schema-1.5-to-spacewalk-schema-1.6/127-alter-index-rhnServerDmi.sql.postgresql | 4 +---
2 files changed, 2 insertions(+), 6 deletions(-)
New commits:
commit f220aeed6a30ea5d8a309ff5550d83c8cd417c1b
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Mon Jul 1 13:35:41 2013 +0200
PostgreSQL schema upgrade fixes
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-1.5-to-spacewalk-schema-1.6/126-alter-index-rhnCpu.sql.postgresql b/schema/spacewalk/upgrade/spacewalk-schema-1.5-to-spacewalk-schema-1.6/126-alter-index-rhnCpu.sql.postgresql
index e933cc0..b0cba77 100644
--- a/schema/spacewalk/upgrade/spacewalk-schema-1.5-to-spacewalk-schema-1.6/126-alter-index-rhnCpu.sql.postgresql
+++ b/schema/spacewalk/upgrade/spacewalk-schema-1.5-to-spacewalk-schema-1.6/126-alter-index-rhnCpu.sql.postgresql
@@ -7,6 +7,4 @@ delete from rhncpu X
DROP INDEX rhn_cpu_server_id_idx;
CREATE UNIQUE INDEX rhn_cpu_server_id_uq
- ON rhnCpu (server_id)
- TABLESPACE [[4m_tbs]]
- NOLOGGING;
+ ON rhnCpu (server_id);
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-1.5-to-spacewalk-schema-1.6/127-alter-index-rhnServerDmi.sql.postgresql b/schema/spacewalk/upgrade/spacewalk-schema-1.5-to-spacewalk-schema-1.6/127-alter-index-rhnServerDmi.sql.postgresql
index 13ada0d..9c90fce 100644
--- a/schema/spacewalk/upgrade/spacewalk-schema-1.5-to-spacewalk-schema-1.6/127-alter-index-rhnServerDmi.sql.postgresql
+++ b/schema/spacewalk/upgrade/spacewalk-schema-1.5-to-spacewalk-schema-1.6/127-alter-index-rhnServerDmi.sql.postgresql
@@ -7,6 +7,4 @@ delete from rhnServerDMI X
DROP INDEX rhn_server_dmi_sid_idx;
CREATE UNIQUE INDEX rhn_server_dmi_sid_uq
- ON rhnServerDMI (server_id)
- TABLESPACE [[2m_tbs]]
- NOLOGGING;
+ ON rhnServerDMI (server_id);
10 years, 10 months