Hello community,

here is the log from the commit of package python-shaptools for 
openSUSE:Leap:15.2 checked in at 2020-05-28 20:11:19
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Leap:15.2/python-shaptools (Old)
 and      /work/SRC/openSUSE:Leap:15.2/.python-shaptools.new.3606 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-shaptools"

Thu May 28 20:11:19 2020 rev:2 rq:809893 version:0.3.5

Changes:
--------
--- /work/SRC/openSUSE:Leap:15.2/python-shaptools/python-shaptools.changes      
2020-01-15 15:52:58.435581759 +0100
+++ 
/work/SRC/openSUSE:Leap:15.2/.python-shaptools.new.3606/python-shaptools.changes
    2020-05-28 20:11:21.131212601 +0200
@@ -1,0 +2,13 @@
+Thu Jan  2 21:59:30 UTC 2020 - Simranpal Singh <[email protected]>
+
+- Create package version 0.3.5
+- Add function to install HANA with XML passwords file
+- Add functionality to update XML passwords file
+
+-------------------------------------------------------------------
+Thu Dec  5 10:48:53 UTC 2019 - Xabier Arbulu <[email protected]>
+
+- Create package version 0.3.4
+- Fix ascs restart conditions in ers installation 
+
+-------------------------------------------------------------------

Old:
----
  shaptools-0.3.3.tar.gz

New:
----
  shaptools-0.3.5.tar.gz

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

Other differences:
------------------
++++++ python-shaptools.spec ++++++
--- /var/tmp/diff_new_pack.1nHTHK/_old  2020-05-28 20:11:21.727214375 +0200
+++ /var/tmp/diff_new_pack.1nHTHK/_new  2020-05-28 20:11:21.731214387 +0200
@@ -22,7 +22,7 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-shaptools
-Version:        0.3.3
+Version:        0.3.5
 Release:        0
 Summary:        Python tools to interact with SAP HANA utilities
 License:        Apache-2.0

++++++ shaptools-0.3.3.tar.gz -> shaptools-0.3.5.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/shaptools-0.3.3/python-shaptools.changes 
new/shaptools-0.3.5/python-shaptools.changes
--- old/shaptools-0.3.3/python-shaptools.changes        2019-11-12 
15:44:55.900127362 +0100
+++ new/shaptools-0.3.5/python-shaptools.changes        2020-01-08 
18:00:27.219596228 +0100
@@ -1,4 +1,17 @@
 -------------------------------------------------------------------
+Thu Jan  2 21:59:30 UTC 2020 - Simranpal Singh <[email protected]>
+
+- Create package version 0.3.5
+- Add function to install HANA with XML passwords file
+- Add functionality to update XML passwords file
+
+-------------------------------------------------------------------
+Thu Dec  5 10:48:53 UTC 2019 - Xabier Arbulu <[email protected]>
+
+- Create package version 0.3.4
+- Fix ascs restart conditions in ers installation 
+
+-------------------------------------------------------------------
 Thu Nov  7 00:36:08 UTC 2019 - Simranpal Singh <[email protected]>
 
 - Create package version 0.3.3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/shaptools-0.3.3/python-shaptools.spec 
new/shaptools-0.3.5/python-shaptools.spec
--- old/shaptools-0.3.3/python-shaptools.spec   2019-11-12 15:44:55.900127362 
+0100
+++ new/shaptools-0.3.5/python-shaptools.spec   2020-01-08 18:00:27.219596228 
+0100
@@ -22,7 +22,7 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-shaptools
-Version:        0.3.3
+Version:        0.3.5
 Release:        0
 Summary:        Python tools to interact with SAP HANA utilities
 License:        Apache-2.0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/shaptools-0.3.3/shaptools/hana.py 
new/shaptools-0.3.5/shaptools/hana.py
--- old/shaptools-0.3.3/shaptools/hana.py       2019-11-12 15:44:55.904127362 
+0100
+++ new/shaptools-0.3.5/shaptools/hana.py       2020-01-08 18:00:27.219596228 
+0100
@@ -19,6 +19,7 @@
 import re
 import time
 import platform
+import os
 
 from shaptools import shell
 
@@ -34,6 +35,10 @@
     Error during HANA command execution
     """
 
+class FileDoesNotExistError(Exception):
+    """
+    Error when the specified files does not exist
+    """
 
 # System replication states
 # Random value used
@@ -162,6 +167,28 @@
         return conf_file
 
     @classmethod
+    def update_hdb_pwd_file(cls, hdb_pwd_file, **kwargs):
+        """
+        Update SAP HANA XML passwords
+
+        Args:
+            hdb_pwd_file (str): Path to the XML passwords file
+            kwargs (opt): Dictionary with the values to be updated.
+                Use the exact name of the XML file for the key
+
+        kwargs can be used in the next two modes:
+            update_hdb_pwd_file(hdb_pwd_file, master_password='Test123', 
sapadm_password='pas11')
+            update_hdb_pwd_file(hdb_pwd_file, **{'master_password': 'Test123', 
'sapadm_password': 'pas11'})
+        """
+        for key, value in kwargs.items():
+            pattern = '<{key}>.*'.format(key=key)
+            new_entry = '<{key}><![CDATA[{value}]]></{key}>'.format(key=key, 
value=value)
+            for line in fileinput.input(hdb_pwd_file, inplace=1):
+                line = re.sub(pattern, new_entry, line)
+                print(line, end='')
+        return hdb_pwd_file
+
+    @classmethod
     def create_conf_file(
             cls, software_path, conf_file, root_user, root_password, 
remote_host=None):
         """
@@ -186,7 +213,9 @@
         return conf_file
 
     @classmethod
-    def install(cls, software_path, conf_file, root_user, password, 
remote_host=None):
+    def install(
+            cls, software_path, conf_file, root_user, password,
+            hdb_pwd_file=None, remote_host=None):
         """
         Install SAP HANA platform providing a configuration file
 
@@ -195,14 +224,26 @@
             conf_file (str): Path to the configuration file
             root_user (str): Root user name
             password (str): Root user password
+            hdb_pwd_file (str, opt): Path to the XML password file
             remote_host (str, opt): Remote host where the command will be 
executed
         """
         # TODO: mount partition if needed
         # TODO: do some integrity check stuff
+
+        if not os.path.isfile(conf_file):
+            raise FileDoesNotExistError('The configuration file \'{}\' does 
not exist'.format(conf_file))
+        if hdb_pwd_file is not None and not os.path.isfile(hdb_pwd_file):
+            raise FileDoesNotExistError('The XML password file \'{}\' does not 
exist'.format(hdb_pwd_file))
+
         platform_folder = cls.get_platform()
         executable = cls.INSTALL_EXEC.format(software_path=software_path, 
platform=platform_folder)
-        cmd = '{executable} -b --configfile={conf_file}'.format(
-            executable=executable, conf_file=conf_file)
+        if hdb_pwd_file:
+            cmd = 'cat {hdb_pwd_file} | {executable} -b '\
+                '--read_password_from_stdin=xml 
--configfile={conf_file}'.format(
+                    hdb_pwd_file=hdb_pwd_file, executable=executable, 
conf_file=conf_file)
+        else:
+            cmd = '{executable} -b --configfile={conf_file}'.format(
+                executable=executable, conf_file=conf_file)
         result = shell.execute_cmd(cmd, root_user, password, remote_host)
         if result.returncode:
             raise HanaError('SAP HANA installation failed')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/shaptools-0.3.3/shaptools/netweaver.py 
new/shaptools-0.3.5/shaptools/netweaver.py
--- old/shaptools-0.3.3/shaptools/netweaver.py  2019-11-12 15:44:55.904127362 
+0100
+++ new/shaptools-0.3.5/shaptools/netweaver.py  2020-01-08 18:00:27.219596228 
+0100
@@ -329,8 +329,9 @@
                 software_path, virtual_host, product_id, conf_file, root_user, 
password,
                 exception=False, remote_host=remote_host, cwd=cwd)
 
-            if result.returncode == cls.SUCCESSFULLY_INSTALLED or \
-                    cls._ascs_restart_needed(result):
+            if result.returncode == cls.SUCCESSFULLY_INSTALLED:
+                break
+            elif cls._ascs_restart_needed(result):
                 cls._restart_ascs(conf_file, ers_pass, ascs_pass, remote_host)
                 break
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/shaptools-0.3.3/tests/hana_test.py 
new/shaptools-0.3.5/tests/hana_test.py
--- old/shaptools-0.3.3/tests/hana_test.py      2019-11-12 15:44:55.904127362 
+0100
+++ new/shaptools-0.3.5/tests/hana_test.py      2020-01-08 18:00:27.223598228 
+0100
@@ -179,6 +179,14 @@
             **{'sid': 'PRD', 'password': 'Qwerty1234', 'system_user_password': 
'Qwerty1234'})
         self.assertTrue(filecmp.cmp(pwd+'/support/modified.conf', conf_file))
 
+    def test_update_hdb_pwd_file(self):
+        pwd = os.path.dirname(os.path.abspath(__file__))
+        shutil.copyfile(pwd+'/support/original.conf.xml', '/tmp/test.conf.xml')
+        hdb_pwd_file = hana.HanaInstance.update_hdb_pwd_file(
+            '/tmp/test.conf.xml', master_password='Master1234', 
+            sapadm_password='Adm1234', system_user_password='Qwerty1234')
+        self.assertTrue(filecmp.cmp(pwd+'/support/modified.conf.xml', 
hdb_pwd_file))
+
     @mock.patch('shaptools.hana.HanaInstance.get_platform')
     @mock.patch('shaptools.shell.execute_cmd')
     def test_create_conf_file(self, mock_execute, mock_get_platform):
@@ -221,9 +229,11 @@
 
     @mock.patch('shaptools.hana.HanaInstance.get_platform')
     @mock.patch('shaptools.shell.execute_cmd')
-    def test_install(self, mock_execute, mock_get_platform):
+    @mock.patch('os.path.isfile')
+    def test_install(self, mock_conf_file, mock_execute, mock_get_platform):
         proc_mock = mock.Mock()
         proc_mock.returncode = 0
+        mock_conf_file.side_effect = [True, True]
         mock_execute.return_value = proc_mock
         mock_get_platform.return_value = 'my_arch'
 
@@ -238,9 +248,32 @@
 
     @mock.patch('shaptools.hana.HanaInstance.get_platform')
     @mock.patch('shaptools.shell.execute_cmd')
-    def test_install_error(self, mock_execute, mock_get_platform):
+    @mock.patch('os.path.isfile')
+    def test_install_xml(self, mock_conf_file, mock_execute, 
mock_get_platform):
+        proc_mock = mock.Mock()
+        proc_mock.returncode = 0
+        mock_conf_file.side_effect = [True, True]
+        mock_execute.return_value = proc_mock
+        mock_get_platform.return_value = 'my_arch'
+
+        hana.HanaInstance.install(
+            'software_path', 'conf_file.conf', 'root', 'pass', 
+            hdb_pwd_file='hdb_passwords.xml')
+
+        mock_execute.assert_called_once_with(
+            'cat {hdb_pwd_file} | 
software_path/DATA_UNITS/HDB_LCM_LINUX_my_arch/hdblcm '\
+            '-b --read_password_from_stdin=xml 
--configfile={conf_file}'.format(
+                hdb_pwd_file='hdb_passwords.xml', 
+                conf_file='conf_file.conf'), 'root', 'pass', None)
+        mock_get_platform.assert_called_once_with()
+
+    @mock.patch('shaptools.hana.HanaInstance.get_platform')
+    @mock.patch('shaptools.shell.execute_cmd')
+    @mock.patch('os.path.isfile')
+    def test_install_error(self, mock_conf_file, mock_execute, 
mock_get_platform):
         proc_mock = mock.Mock()
         proc_mock.returncode = 1
+        mock_conf_file.side_effect = [True, True]
         mock_execute.return_value = proc_mock
         mock_get_platform.return_value = 'my_arch'
 
@@ -257,6 +290,29 @@
         self.assertTrue(
             'SAP HANA installation failed' in str(err.exception))
 
+    @mock.patch('os.path.isfile')
+    def test_install_FileDoesNotExistError(self, mock_conf_file):
+        mock_conf_file.return_value = False
+        
+        with self.assertRaises(hana.FileDoesNotExistError) as err:
+            hana.HanaInstance.install(
+                'software_path', 'conf_file.conf', 'root', 'pass')
+
+        self.assertTrue(
+            'The configuration file \'{}\' does not 
exist'.format('conf_file.conf') in str(err.exception))
+
+    @mock.patch('os.path.isfile')
+    def test_install_xml_FileDoesNotExistError(self, mock_passwords_xml):
+        mock_passwords_xml.side_effect = [True, False]
+
+        with self.assertRaises(hana.FileDoesNotExistError) as err:
+            hana.HanaInstance.install(
+                'software_path', 'conf_file.conf', 'root', 'pass',
+                hdb_pwd_file='hdb_password.xml')
+
+        self.assertTrue(
+            'The XML password file \'{}\' does not 
exist'.format('hdb_password.xml') in str(err.exception))
+
     @mock.patch('shaptools.shell.execute_cmd')
     def test_uninstall(self, mock_execute):
         proc_mock = mock.Mock()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/shaptools-0.3.3/tests/netweaver_test.py 
new/shaptools-0.3.5/tests/netweaver_test.py
--- old/shaptools-0.3.3/tests/netweaver_test.py 2019-11-12 15:44:55.904127362 
+0100
+++ new/shaptools-0.3.5/tests/netweaver_test.py 2020-01-08 18:00:27.223598228 
+0100
@@ -279,7 +279,7 @@
             '/tmp/copy.inifile.params', sid='HA1',
             sidadmPassword='testpwd', masterPwd='Suse1234')
         self.assertTrue(filecmp.cmp(pwd+'/support/modified.inifile.params', 
conf_file))
-        
+
         #case when new entry is added to config file
         shutil.copyfile(pwd+'/support/original.inifile.params', 
'/tmp/copy.inifile.params')
         conf_file = netweaver.NetweaverInstance.update_conf_file(
@@ -439,9 +439,31 @@
     @mock.patch('time.time')
     
@mock.patch('shaptools.netweaver.NetweaverInstance.get_attribute_from_file')
     @mock.patch('shaptools.netweaver.NetweaverInstance.install')
+    def test_install_ers(self, mock_install, mock_get_attribute, mock_time):
+
+        mock_result = mock.Mock()
+        mock_result.group.return_value = 'ers_pass'
+        mock_get_attribute.return_value = mock_result
+
+        mock_time.return_value = 1
+        mock_install_result = mock.Mock(returncode=0)
+        mock_install.return_value = mock_install_result
+
+        netweaver.NetweaverInstance.install_ers(
+            'software', 'myhost', 'product', 'conf_file', 'user', 'pass',
+            ascs_password='ascs_pass', timeout=5, interval=1, cwd='/tmp')
+
+        mock_result.group.assert_called_once_with(1)
+        mock_install.assert_called_once_with(
+            'software', 'myhost', 'product', 'conf_file', 'user', 'pass',
+            exception=False, remote_host=None, cwd='/tmp')
+
+    @mock.patch('time.time')
+    
@mock.patch('shaptools.netweaver.NetweaverInstance.get_attribute_from_file')
+    @mock.patch('shaptools.netweaver.NetweaverInstance.install')
     @mock.patch('shaptools.netweaver.NetweaverInstance._ascs_restart_needed')
     @mock.patch('shaptools.netweaver.NetweaverInstance._restart_ascs')
-    def test_install_ers_first_install(
+    def test_install_ers_with_restart(
             self, mock_restart, mock_restart_needed, mock_install,
             mock_get_attribute, mock_time):
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/shaptools-0.3.3/tests/support/modified.conf.xml 
new/shaptools-0.3.5/tests/support/modified.conf.xml
--- old/shaptools-0.3.3/tests/support/modified.conf.xml 1970-01-01 
01:00:00.000000000 +0100
+++ new/shaptools-0.3.5/tests/support/modified.conf.xml 2020-01-08 
18:00:27.223598228 +0100
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Replace the 3 asterisks with the password -->
+<Passwords>
+    <root_password><![CDATA[***]]></root_password>
+    <sapadm_password><![CDATA[Adm1234]]></sapadm_password>
+    <master_password><![CDATA[Master1234]]></master_password>
+    <sapadm_password><![CDATA[Adm1234]]></sapadm_password>
+    <password><![CDATA[***]]></password>
+    <system_user_password><![CDATA[Qwerty1234]]></system_user_password>
+    <lss_user_password><![CDATA[***]]></lss_user_password>
+    <lss_backup_password><![CDATA[***]]></lss_backup_password>
+    
<streaming_cluster_manager_password><![CDATA[***]]></streaming_cluster_manager_password>
+    <ase_user_password><![CDATA[***]]></ase_user_password>
+    <org_manager_password><![CDATA[***]]></org_manager_password>
+</Passwords>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/shaptools-0.3.3/tests/support/original.conf.xml 
new/shaptools-0.3.5/tests/support/original.conf.xml
--- old/shaptools-0.3.3/tests/support/original.conf.xml 1970-01-01 
01:00:00.000000000 +0100
+++ new/shaptools-0.3.5/tests/support/original.conf.xml 2020-01-08 
18:00:27.223598228 +0100
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Replace the 3 asterisks with the password -->
+<Passwords>
+    <root_password><![CDATA[***]]></root_password>
+    <sapadm_password><![CDATA[***]]></sapadm_password>
+    <master_password><![CDATA[***]]></master_password>
+    <sapadm_password><![CDATA[***]]></sapadm_password>
+    <password><![CDATA[***]]></password>
+    <system_user_password><![CDATA[***]]></system_user_password>
+    <lss_user_password><![CDATA[***]]></lss_user_password>
+    <lss_backup_password><![CDATA[***]]></lss_backup_password>
+    
<streaming_cluster_manager_password><![CDATA[***]]></streaming_cluster_manager_password>
+    <ase_user_password><![CDATA[***]]></ase_user_password>
+    <org_manager_password><![CDATA[***]]></org_manager_password>
+</Passwords>


Reply via email to