[node-patches] Change in ovirt-node[master]: rhn: Make sam_check file based

fabiand at fedoraproject.org fabiand at fedoraproject.org
Fri Jan 11 13:39:44 UTC 2013


Fabian Deutsch has uploaded a new change for review.

Change subject: rhn: Make sam_check file based
......................................................................

rhn: Make sam_check file based

Previously the SAM check required the subscription-manager to be run
which could lead to long page loading times.
Now the determination is done based upon the presence of the satellite
certificate.

rhbz#816900

Change-Id: I948870bfd90dedbc4d6a2a05d6cd80f0926c347e
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/rhn.py
1 file changed, 17 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/04/10904/1

diff --git a/scripts/rhn.py b/scripts/rhn.py
index 0f82079..efae8ea 100755
--- a/scripts/rhn.py
+++ b/scripts/rhn.py
@@ -321,14 +321,17 @@
 
 
 def sam_check():
-    samcheck_cmd = subprocess_closefds("subscription-manager identity",
-                                       shell=True, stdout=PIPE,
-                                       stderr=open('/dev/null', 'w'))
-    if "identity is:" in samcheck_cmd.stdout.read():
-        return True
+    filebased = True
+    registered = False
+    if filebased:
+        # Thefollowing file exists when the sys is registered with a sat server
+        registered = os.path.exists("/etc/rhsm/ca/candlepin-local.pem")
     else:
-        return False
-
+        samcheck_cmd = subprocess_closefds("subscription-manager identity",
+                                           shell=True, stdout=PIPE,
+                                           stderr=open('/dev/null', 'w'))
+        registered = "identity is:" in samcheck_cmd.stdout.read()
+    return registered
 
 def get_rhn_status():
     msg = ""
@@ -590,9 +593,13 @@
                                "Login/Password must not be empty\n",
                                buttons=['Ok'])
             return False
-        if os.path.exists("/etc/sysconfig/rhn/systemid"):
-            remove_config("/etc/sysconfig/rhn/systemid")
-            os.remove("/etc/sysconfig/rhn/systemid")
+        key_files = ["/etc/sysconfig/rhn/systemid",  # To check RHN
+                     "/etc/rhsm/ca/candlepin-local.pem"  # To check SAM
+                     ]
+        for key_file in key_files:
+            if os.path.exists(key_file):
+                remove_config(key_file)
+                os.remove(key_file)
         if self.sam.value() == 1:
             if os.path.exists(RHN_CONFIG_FILE):
                 remove_config(RHN_CONFIG_FILE)


--
To view, visit http://gerrit.ovirt.org/10904
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I948870bfd90dedbc4d6a2a05d6cd80f0926c347e
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>



More information about the node-patches mailing list