backend/satellite_tools/satsync.py
| 37 +++++++---
schema/spacewalk/common/tables/rhnISSMaster.sql
| 6 +
schema/spacewalk/upgrade/spacewalk-schema-1.9-to-spacewalk-schema-1.10/028-satellite_sync_master_in_db.sql
| 6 +
spacewalk/config/var/lib/rhn/rhn-satellite-prep/etc/rhn/rhn.conf
| 12 ---
4 files changed, 39 insertions(+), 22 deletions(-)
New commits:
commit 83d0a2fc447ac75ca42047f564f402c4d9fa7d6f
Author: Stephen Herr <sherr(a)redhat.com>
Date: Tue Jul 2 15:06:39 2013 -0400
977878 - move iss parent / ca_cert configs into database
diff --git a/backend/satellite_tools/satsync.py b/backend/satellite_tools/satsync.py
index aa465d7..9b259db 100644
--- a/backend/satellite_tools/satsync.py
+++ b/backend/satellite_tools/satsync.py
@@ -2048,6 +2048,23 @@ def _getImportedChannels():
exitWithTraceback(e, 'SQL ERROR during xml processing', 17)
return []
+def getDbIssParent():
+ sql = "select label from rhnISSMaster where is_current_master =
'Y'"
+ h = rhnSQL.prepare(sql)
+ h.execute()
+ row = h.fetchone_dict()
+ if not row:
+ return None
+ return row['label']
+
+def getDbCaChain(master):
+ sql = "select ca_cert from rhnISSMaster where label = :label"
+ h = rhnSQL.prepare(sql)
+ h.execute(label=master)
+ row = h.fetchone_dict()
+ if not row:
+ return None
+ return row['ca_cert']
def processCommandline():
"process the commandline, setting the OPTIONS object"
@@ -2139,6 +2156,15 @@ def processCommandline():
#
# process anything CFG related (db, debug, server, and print)
#
+ try:
+ rhnSQL.initDB()
+ except (SQLError, SQLSchemaError, SQLConnectError), e:
+ # An SQL error is fatal... crash and burn
+ log(-1, _("ERROR: Can't connect to the database: %s") % e,
stream=sys.stderr)
+ log(-1, _("ERROR: Check if your database is running."),
stream=sys.stderr)
+ sys.exit(20)
+
+ CFG.set("ISS_Parent", getDbIssParent())
CFG.set("TRACEBACK_MAIL", OPTIONS.traceback_mail or CFG.TRACEBACK_MAIL)
CFG.set("RHN_PARENT", idn_ascii_to_pune(OPTIONS.iss_parent or
OPTIONS.server or \
CFG.ISS_PARENT or CFG.RHN_PARENT))
@@ -2147,20 +2173,13 @@ def processCommandline():
CFG.set("ISS_PARENT", None)
else:
CFG.set("ISS_PARENT", idn_ascii_to_pune(OPTIONS.iss_parent or
CFG.ISS_PARENT))
- CFG.set("ISS_CA_CHAIN", OPTIONS.ca_cert or CFG.ISS_CA_CHAIN or
CFG.CA_CHAIN)
+ CFG.set("ISS_CA_CHAIN", OPTIONS.ca_cert or
getDbCaChain(CFG.RHN_PARENT)
+ or CFG.CA_CHAIN)
CFG.set("HTTP_PROXY", idn_ascii_to_pune(OPTIONS.http_proxy or
CFG.HTTP_PROXY))
CFG.set("HTTP_PROXY_USERNAME", OPTIONS.http_proxy_username or
CFG.HTTP_PROXY_USERNAME)
CFG.set("HTTP_PROXY_PASSWORD", OPTIONS.http_proxy_password or
CFG.HTTP_PROXY_PASSWORD)
CFG.set("CA_CHAIN", OPTIONS.ca_cert or CFG.CA_CHAIN)
-
- try:
- rhnSQL.initDB()
- except (SQLError, SQLSchemaError, SQLConnectError), e:
- # An SQL error is fatal... crash and burn
- log(-1, _("ERROR: Can't connect to the database: %s") % e,
stream=sys.stderr)
- log(-1, _("ERROR: Check if your database is running."),
stream=sys.stderr)
- sys.exit(20)
# check the validity of the debug level
if OPTIONS.debug_level:
diff --git a/schema/spacewalk/common/tables/rhnISSMaster.sql
b/schema/spacewalk/common/tables/rhnISSMaster.sql
index 54db1a5..7cf906c 100644
--- a/schema/spacewalk/common/tables/rhnISSMaster.sql
+++ b/schema/spacewalk/common/tables/rhnISSMaster.sql
@@ -1,7 +1,11 @@
create table rhnIssMaster (
id number not null constraint rhn_iss_master_id_pk primary key,
label varchar2(256) not null constraint rhn_iss_master_label_uq unique,
- created timestamp with local time zone default (current_timestamp) not null
+ created timestamp with local time zone default (current_timestamp) not null,
+ is_current_master char(1) default 'N' not null constraint rhn_issm_master_yn
check (is_current_master in ('Y', 'N')),
+ ca_cert varchar2(256)
);
create sequence rhn_issmaster_seq;
+
+create unique index rhn_issm_only_one_default on rhnISSMaster (is_current_master) where
is_current_master = 'Y';
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.9-to-spacewalk-schema-1.10/028-satellite_sync_master_in_db.sql
b/schema/spacewalk/upgrade/spacewalk-schema-1.9-to-spacewalk-schema-1.10/028-satellite_sync_master_in_db.sql
new file mode 100644
index 0000000..49d1874
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.9-to-spacewalk-schema-1.10/028-satellite_sync_master_in_db.sql
@@ -0,0 +1,6 @@
+alter table rhnISSMaster add is_current_master char(1) default 'N' not null
+ constraint rhn_issm_master_yn check (is_current_master in ('Y',
'N'));
+
+alter table rhnISSMaster add ca_cert varchar2(256);
+
+create unique index rhn_issm_only_one_default on rhnISSMaster (is_current_master) where
is_current_master = 'Y';
diff --git a/spacewalk/config/var/lib/rhn/rhn-satellite-prep/etc/rhn/rhn.conf
b/spacewalk/config/var/lib/rhn/rhn-satellite-prep/etc/rhn/rhn.conf
index f221d43..26fff5f 100644
--- a/spacewalk/config/var/lib/rhn/rhn-satellite-prep/etc/rhn/rhn.conf
+++ b/spacewalk/config/var/lib/rhn/rhn-satellite-prep/etc/rhn/rhn.conf
@@ -10,18 +10,6 @@ server.satellite.http_proxy_username =
@@serverDOTsatelliteDOThttp_proxy_usernam
server.satellite.http_proxy_password = @@serverDOTsatelliteDOThttp_proxy_password@@
server.satellite.ca_chain = @@serverDOTsatelliteDOTca_chain@@
-# Use these options if this server is intended to be a slave.
-# Name of parent for ISS.
-# # If left blank rhn_parent is taken by default.
-# # This option can be overriden on satellite-sync command line.
-iss_parent =
-iss_ca_chain = /usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT
-
-# Use this option if this server is intended to be a master
-# Comma separated list of allowed iss slaves, like:
-#
allowed_iss_slaves=slave1-satellite.redhat.com,slave2-satellite.redhat.com
-allowed_iss_slaves=
-
# Completely disable ISS.
# If set to 1, then no slave will be able to sync from this server
# this option does not affect ability to sync to this server from