Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package sca-patterns-sle12 for 
openSUSE:Factory checked in at 2021-08-26 23:15:05
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/sca-patterns-sle12 (Old)
 and      /work/SRC/openSUSE:Factory/.sca-patterns-sle12.new.1899 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "sca-patterns-sle12"

Thu Aug 26 23:15:05 2021 rev:24 rq:914300 version:1.0.7

Changes:
--------
--- /work/SRC/openSUSE:Factory/sca-patterns-sle12/sca-patterns-sle12.changes    
2021-08-18 08:57:11.834884227 +0200
+++ 
/work/SRC/openSUSE:Factory/.sca-patterns-sle12.new.1899/sca-patterns-sle12.changes
  2021-08-26 23:16:15.720201241 +0200
@@ -1,0 +2,10 @@
+Wed Aug 25 22:59:27 UTC 2021 - Jason Record <jason.rec...@suse.com>
+
+- Fixed metadata tags for scc-registered.py
+
+-------------------------------------------------------------------
+Wed Aug 25 21:56:37 UTC 2021 - Jason Record <jason.rec...@suse.com>
+
+- Updated scc-registered.py pattern to fix registration detection
+
+-------------------------------------------------------------------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ sca-patterns-sle12-1.0.7.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/sca-patterns-sle12-1.0.7/patterns/SLE/sle12all/scc-registered.py 
new/sca-patterns-sle12-1.0.7/patterns/SLE/sle12all/scc-registered.py
--- old/sca-patterns-sle12-1.0.7/patterns/SLE/sle12all/scc-registered.py        
2021-03-01 22:55:34.429828571 +0100
+++ new/sca-patterns-sle12-1.0.7/patterns/SLE/sle12all/scc-registered.py        
2021-08-26 00:58:09.614684610 +0200
@@ -1,11 +1,14 @@
 #!/usr/bin/python
-
-# Title:       Detect unregistered products
-# Description: Identify if SCC registrations are valid
-# Modified:    2015 May 11
+#
+# Title:       Pattern for TID000018546
+# Description: Check system registration status
+# Source:      Basic Python Pattern Template v0.3.4
+# Options:     Basic 
Health,Registration,Status,registration-scc,000018546,0,2,0,0
+# Distro:      SLES1[2,5] All
+# Modified:    2021 Aug 25
 #
 ##############################################################################
-# Copyright (C) 2015 SUSE LLC
+# Copyright (C) 2021 SUSE LLC
 ##############################################################################
 #
 # This program is free software; you can redistribute it and/or modify
@@ -21,72 +24,160 @@
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 #
 #  Authors/Contributors:
-#   Jason Record (jrec...@suse.com)
+#   Jason Record <jason.rec...@suse.com>
 #
 ##############################################################################
 
-##############################################################################
-# Module Definition
-##############################################################################
-
+import re
 import os
 import Core
 import SUSE
 
-##############################################################################
-# Overriden (eventually or in part) from Core.py Module
-##############################################################################
-
-META_CLASS = "SLE"
-META_CATEGORY = "Updates"
+META_CLASS = "Basic Health"
+META_CATEGORY = "SLE"
 META_COMPONENT = "Registration"
 PATTERN_ID = os.path.basename(__file__)
 PRIMARY_LINK = "META_LINK_TID"
 OVERALL = Core.TEMP
 OVERALL_INFO = "NOT SET"
-OTHER_LINKS = 
"META_LINK_TID=http://www.suse.com/support/kb/doc.php?id=7016501|META_LINK_SCC=https://scc.suse.com/dashboard|META_LINK_Register=https://www.suse.com/products/server/how-to-buy/";
-
+OTHER_LINKS = 
"META_LINK_TID=https://www.suse.com/support/kb/doc/?id=000018546|META_LINK_SCC=https://scc.suse.com/dashboard|META_LINK_Register=https://www.suse.com/products/server/how-to-buy/";
 Core.init(META_CLASS, META_CATEGORY, META_COMPONENT, PATTERN_ID, PRIMARY_LINK, 
OVERALL, OVERALL_INFO, OTHER_LINKS)
 
+OES_TAG = 'Microfocus'
+
+##############################################################################
+# Local Function Definitions
+##############################################################################
+
+def getRegService():
+       global OES_TAG
+       fileOpen = "updates.txt"
+       content = []
+       IDX_NUM = 0
+       IDX_ALIAS = 1
+       SERVICE_TAG = ''
+       SMT = re.compile("SMT-.*suse", re.IGNORECASE)
+       SUSE = re.compile("/updates.suse.com/|/scc.suse.com/", re.IGNORECASE)
+       OES = re.compile("/nu.novell.com/", re.IGNORECASE)
+       if Core.isFileActive(fileOpen):
+               section = "zypper --non-interactive --no-gpg-checks repos -d"
+               if Core.getRegExSection(fileOpen, "zypper --non-interactive 
--no-gpg-checks repos -d", content):
+                       IDX_URI = 8
+                       for line in content:
+                               PARTS = line.split('|')
+                               PARTS = [x.strip(' ') for x in PARTS]
+                               if( PARTS[IDX_NUM].isdigit() ):
+                                       REPO_ALIAS = PARTS[IDX_ALIAS].strip()
+                                       REPO_URI = PARTS[IDX_URI].strip()
+                                       if SUSE.search(PARTS[IDX_URI]):
+                                               SERVICE_TAG = 'SCC'
+                                       elif( 
PARTS[IDX_ALIAS].startswith('susemanager:') ):
+                                               SERVICE_TAG = 'SUMA'
+                                       elif( 
PARTS[IDX_ALIAS].startswith('spacewalk:') ):
+                                               SERVICE_TAG = 'SUMA'
+                                       elif SMT.search(PARTS[IDX_ALIAS]):
+                                               SERVICE_TAG = 'SMT'
+                                       elif OES.search(PARTS[IDX_URI]):
+                                               SERVICE_TAG = OES_TAG
+#                                      print(str(len(PARTS)) + ":" + 
str(SERVICE_TAG) + ": " + str(REPO_NUM) + '|' + str(REPO_ALIAS) + '\n  ' + 
str(REPO_URI))
+#                                      print(PARTS)
+               elif Core.getRegExSection(fileOpen, "zypper --non-interactive 
--no-gpg-checks repos -u", content):
+                       IDX_URI = 6
+                       for line in content:
+                               PARTS = line.split('|')
+                               PARTS = [x.strip(' ') for x in PARTS]
+                               if( PARTS[IDX_NUM].isdigit() ):
+                                       REPO_ALIAS = PARTS[IDX_ALIAS].strip()
+                                       REPO_URI = PARTS[IDX_URI].strip()
+                                       if SUSE.search(PARTS[IDX_URI]):
+                                               SERVICE_TAG = 'SCC'
+                                       elif( 
PARTS[IDX_ALIAS].startswith('susemanager:') ):
+                                               SERVICE_TAG = 'SUMA'
+                                       elif( 
PARTS[IDX_ALIAS].startswith('spacewalk:') ):
+                                               SERVICE_TAG = 'SUMA'
+                                       elif SMT.search(PARTS[IDX_ALIAS]):
+                                               SERVICE_TAG = 'SMT'
+                                       elif OES.search(PARTS[IDX_URI]):
+                                               SERVICE_TAG = OES_TAG
+#                                      print(str(len(PARTS)) + ":" + 
str(SERVICE_TAG) + ": " + str(REPO_NUM) + '|' + str(REPO_ALIAS) + '\n  ' + 
str(REPO_URI))
+#                                      print(PARTS)
+       return SERVICE_TAG
+
+def foundCredentials():
+       FILE_OPEN = "updates.txt"
+       CONTENT = []
+       IN_STATE = False
+       if Core.loadFullFile(FILE_OPEN, CONTENT):
+               for LINE in CONTENT:
+                       if( IN_STATE ):
+#                              print(LINE)
+                               if LINE.startswith('#==['):
+                                       IN_STATE = False
+#                                      print(' OUT_STATE')
+                               elif LINE.startswith('username='):
+                                       return True
+                       elif LINE.startswith('# /etc/zypp/credentials.d/'):
+#                              print('IN_STATE')
+                               IN_STATE = True
+
+       return False
+
+
 ##############################################################################
 # Main Program Execution
 ##############################################################################
 
-REPO_INFO = SUSE.getZypperRepoList()
-PROD_INFO = SUSE.getZypperProductList()
-UNREG_LIST = []
-DISABLED_LIST = []
-if( PROD_INFO ):
-       for PRODUCT in PROD_INFO:
-               #print "\n-PRODUCT: ", PRODUCT
-               REGISTERED = False
-               ENABLED = False
-               REPO_KEY = (str(PRODUCT['InternalName']) + 
str(PRODUCT['Version'].split('-')[0]) + '-updates').lower()
-               #print "     KEY: ", REPO_KEY
-               for REPO in REPO_INFO:
-                       if REPO_KEY in REPO['Alias'].lower():
-                               REGISTERED = True
-                               if REPO['Enabled']:
-                                       ENABLED = True
-               if REGISTERED:
-                       if not ENABLED:
-                               DISABLED_LIST.append(PRODUCT['Name'])
+REG_LIST = []
+REG_ACTIVE = []
+REG_NOREG = []
+SCC_INFO = SUSE.getSCCInfo()
+REG_SERVICE = getRegService()
+REG_AUTH = foundCredentials()
+#print(REG_AUTH)
+if( SCC_INFO ):
+       for I in range(len(SCC_INFO)):
+               if( SCC_INFO[I]['status'] ):
+                       if( SCC_INFO[I]['status'].lower() == "registered" ):
+                               REG_LIST.append(SCC_INFO[I]['identifier'])
+                       elif( SCC_INFO[I]['status'].lower() == "not registered" 
):
+                               REG_NOREG.append(SCC_INFO[I]['identifier'])
+                       if 'subscription_status' in SCC_INFO[I]:
+                               if( SCC_INFO[I]['subscription_status'].lower() 
== "active" ):
+                                       
REG_ACTIVE.append(SCC_INFO[I]['identifier'])
+#              print(str(SCC_INFO[I]['identifier']) + ": " + 
str(SCC_INFO[I]['status']))
+#              print(SCC_INFO[I])
+#      print("\n")
+       if( len(REG_ACTIVE) > 0 ):
+               Core.updateStatus(Core.SUCC, "System Registered through " + 
str(REG_SERVICE) + ": " + ' '.join(REG_LIST))
+       elif( len(REG_LIST) > 0 ):
+               if( len(REG_SERVICE) > 0 ):
+                       Core.updateStatus(Core.SUCC, "System Remotely 
Registered through " + str(REG_SERVICE) + ": " + ' '.join(REG_LIST))
                else:
-                       UNREG_LIST.append(PRODUCT['Name'])
-       #print "Unregistered:", UNREG_LIST
-       #print "    Disabled:", DISABLED_LIST, "\n"
-       if( UNREG_LIST ):
-               if( DISABLED_LIST ):
-                       Core.updateStatus(Core.CRIT, "Detected unregistred 
products: " + str(UNREG_LIST) + "; and products that are registered, but 
disabled: " + str(DISABLED_LIST))
+                       Core.updateStatus(Core.SUCC, "System Remotely 
Registered: " + ' '.join(REG_LIST))
+       elif( len(REG_NOREG) > 0 ):
+               if( len(REG_SERVICE) > 0 ):
+                       if( REG_AUTH ):
+                               Core.updateStatus(Core.SUCC, "System Remotely 
Registered through " + str(REG_SERVICE) + ": " + ' '.join(REG_NOREG))
+                       else:
+                               Core.updateStatus(Core.WARN, "Validate Remote 
Registration through " + str(REG_SERVICE) + ", missing credentials: " + ' 
'.join(REG_NOREG))
                else:
-                       Core.updateStatus(Core.WARN, "Detected unregistred 
products: " + str(UNREG_LIST))
-       elif( DISABLED_LIST ):
-               Core.updateStatus(Core.CRIT, "Detected products that are 
registered, but disabled: " + str(DISABLED_LIST))
+                       if( REG_AUTH ):
+                               Core.updateStatus(Core.WARN, "Invalid System 
Registration, Found credentials but no registration server")
+                       else:
+                               Core.updateStatus(Core.CRIT, "System Not 
Registered and Unsupported")
        else:
-               Core.updateStatus(Core.IGNORE, "All products appear registered 
and enabled")
+               Core.updateStatus(Core.WARN, "Validate System Registration")
 else:
-       Core.updateStatus(Core.ERROR, "ERROR: Zypper product information is 
unavailable")
+       if( len(REG_SERVICE) > 0 ):
+               if( REG_AUTH ):
+                       if( REG_SERVICE == OES_TAG ):
+                               Core.updateStatus(Core.WARN, "System Registered 
through " + str(REG_SERVICE) + ", Secondary Support Only")
+                       else:
+                               Core.updateStatus(Core.SUCC, "System Registered 
through " + str(REG_SERVICE))
+               else:
+                       Core.updateStatus(Core.CRIT, "System Not Registered and 
Unsupported - No Credentials")
+       else:
+               Core.updateStatus(Core.CRIT, "System Not Registered and 
Unsupported")
 
 Core.printPatternResults()
 
-

Reply via email to