Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add HANA add_hosts feature #88

Merged
merged 3 commits into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions salt/modules/hanamod.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
26 changes: 26 additions & 0 deletions tests/unit/modules/test_hanamod.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down