From ed505323c33d4be5270ab931227e4afafb3ed8f9 Mon Sep 17 00:00:00 2001 From: Eike Waldt Date: Fri, 25 Mar 2022 17:27:16 +0100 Subject: [PATCH 1/2] add HANA add_hosts feature --- salt/modules/hanamod.py | 30 ++++++++++++++++++++++++++++++ tests/unit/modules/test_hanamod.py | 26 ++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/salt/modules/hanamod.py b/salt/modules/hanamod.py index 5a44a47..12a46ef 100644 --- a/salt/modules/hanamod.py +++ b/salt/modules/hanamod.py @@ -239,6 +239,36 @@ def install( except hana.HanaError as err: raise exceptions.CommandExecutionError(err) +def add_hosts( + add_hosts, + hdblcm_folder, + root_user, + root_password, + hdb_pwd_file): + ''' + Add additional hosts to SAP HANA system + + add_hosts + hosts to add (same format as in hdblcm config) + hdblcm_folder + Path where hdblcm is installed + root_user + Root user name + root_password + Root user password + hdb_pwd_file + Path where XML password file exists + CLI Example: + + .. code-block:: bash + + salt '*' hana.add_hosts hana03:role=standby,hana05:role=worker /hana/shared/SID/hdblcm root root /root/hdb_passwords.xml + ''' + try: + hana.HanaInstance.add_hosts( + add_hosts, hdblcm_folder, root_user, root_password, hdb_pwd_file) + except hana.HanaError as err: + raise exceptions.CommandExecutionError(err) def uninstall( root_user, diff --git a/tests/unit/modules/test_hanamod.py b/tests/unit/modules/test_hanamod.py index cb1dfc3..4690072 100644 --- a/tests/unit/modules/test_hanamod.py +++ b/tests/unit/modules/test_hanamod.py @@ -202,6 +202,32 @@ def test_install_raise(self, mock_hana): 'software_path', 'hana.conf', 'root', 'root', 'hana.conf.xml') assert 'hana error' in str(err.value) + @patch('salt.modules.hanamod.hana.HanaInstance') + def test_add_hosts_return(self, mock_hana): + ''' + Test add_hosts method - return + ''' + mock_hana.add_hosts.return_value = 'hana.conf' + hanamod.add_hosts( + 'add_hosts', 'hdblcm_folder', 'root', 'root', 'hdb_pwd_file') + mock_hana.add_hosts.assert_called_once_with( + 'add_hosts', 'hdblcm_folder', 'root', 'root', 'hdb_pwd_file') + + @patch('salt.modules.hanamod.hana.HanaInstance') + def test_add_hosts_raise(self, mock_hana): + ''' + Test add_hosts method - raise + ''' + mock_hana.add_hosts.side_effect = hanamod.hana.HanaError( + 'hana error' + ) + with pytest.raises(exceptions.CommandExecutionError) as err: + hanamod.add_hosts( + 'add_hosts', 'hdblcm_folder', 'root', 'root', 'hdb_pwd_file') + mock_hana.add_hosts.assert_called_once_with( + 'add_hosts', 'hdblcm_folder', 'root', 'root', 'hdb_pwd_file') + assert 'hana error' in str(err.value) + def test_uninstall_return(self): ''' Test uninstall method - return From 2406ab6222944ef049dffc02aac93914c93540c9 Mon Sep 17 00:00:00 2001 From: Eike Waldt Date: Thu, 28 Apr 2022 09:57:33 +0200 Subject: [PATCH 2/2] Update changelog to set a new 0.3.17 version --- _service | 2 +- salt-shaptools.changes | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/_service b/_service index 8440d45..87ad76b 100644 --- a/_service +++ b/_service @@ -4,7 +4,7 @@ git .git salt-shaptools - 0.3.16+git.%ct.%h + 0.3.17+git.%ct.%h %%VERSION%% diff --git a/salt-shaptools.changes b/salt-shaptools.changes index 7d5244a..7ca2f10 100644 --- a/salt-shaptools.changes +++ b/salt-shaptools.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Apr 28 08:55:32 UTC 2022 - Eike Waldt + +- Version 0.3.17 + * add HANA add_hosts feature + ------------------------------------------------------------------- Fri Apr 19 14:04:54 UTC 2022 - Eike Waldt