def test_set_syslog_config_firewall_success(self): ''' Tests successful function return for a single ESXi host with 'loghost' as syslog_config. ''' self.assertEqual({HOST: {'enable_firewall': {'success': True}}}, vsphere.set_syslog_config(HOST, USER, PASSWORD, 'loghost', 'foo', firewall=True))
def test_set_syslog_config_firewall_bad_retcode(self): ''' Tests error message given for a single ESXi host with 'loghost' as syslog_config. ''' self.assertEqual({HOST: {'enable_firewall': {'message': ERROR, 'success': False}}}, vsphere.set_syslog_config(HOST, USER, PASSWORD, 'loghost', 'foo', firewall=True))
def test_set_syslog_config_host_list_firewall_success(self): ''' Tests successful function return with list of esxi_hosts with 'loghost' as syslog_config. ''' host_1 = 'host_1.foo.com' self.assertEqual({host_1: {'enable_firewall': {'success': True}}}, vsphere.set_syslog_config(HOST, USER, PASSWORD, 'loghost', 'foo', firewall=True, esxi_hosts=[host_1]))
def test_set_syslog_config_host_list_firewall_bad_retcode(self): ''' Tests error message returned with list of esxi_hosts with 'loghost' as syslog_config. ''' host_1 = 'host_1.foo.com' self.assertEqual({host_1: {'enable_firewall': {'message': ERROR, 'success': False}}}, vsphere.set_syslog_config(HOST, USER, PASSWORD, 'loghost', 'foo', firewall=True, esxi_hosts=[host_1]))
def test_set_syslog_config_firewall_success(self): ''' Tests successful function return for a single ESXi host with 'loghost' as syslog_config. ''' with patch('salt.modules.vsphere.enable_firewall_ruleset', MagicMock(return_value={HOST: {'retcode': 0}})): with patch('salt.modules.vsphere._set_syslog_config_helper', MagicMock(return_value={})): self.assertEqual({HOST: {'enable_firewall': {'success': True}}}, vsphere.set_syslog_config(HOST, USER, PASSWORD, 'loghost', 'foo', firewall=True))
def test_set_syslog_config_firewall_bad_retcode(self): ''' Tests error message given for a single ESXi host with 'loghost' as syslog_config. ''' with patch('salt.modules.vsphere.enable_firewall_ruleset', MagicMock(return_value={HOST: {'retcode': 1, 'stdout': ERROR}})): with patch('salt.modules.vsphere._set_syslog_config_helper', MagicMock(return_value={})): self.assertEqual({HOST: {'enable_firewall': {'message': ERROR, 'success': False}}}, vsphere.set_syslog_config(HOST, USER, PASSWORD, 'loghost', 'foo', firewall=True))
def test_set_syslog_config_host_list_firewall_success(self): ''' Tests successful function return with list of esxi_hosts with 'loghost' as syslog_config. ''' with patch('salt.modules.vsphere.enable_firewall_ruleset', MagicMock(return_value={'host_1.foo.com': {'retcode': 0}})): with patch('salt.modules.vsphere._set_syslog_config_helper', MagicMock(return_value={})): host_1 = 'host_1.foo.com' self.assertEqual({host_1: {'enable_firewall': {'success': True}}}, vsphere.set_syslog_config(HOST, USER, PASSWORD, 'loghost', 'foo', firewall=True, esxi_hosts=[host_1]))
def test_set_syslog_config_host_list_firewall_bad_retcode(self): ''' Tests error message returned with list of esxi_hosts with 'loghost' as syslog_config. ''' with patch('salt.modules.vsphere.enable_firewall_ruleset', MagicMock(return_value={'host_1.foo.com': {'retcode': 1, 'stdout': ERROR}})): with patch('salt.modules.vsphere._set_syslog_config_helper', MagicMock(return_value={})): host_1 = 'host_1.foo.com' self.assertEqual({host_1: {'enable_firewall': {'message': ERROR, 'success': False}}}, vsphere.set_syslog_config(HOST, USER, PASSWORD, 'loghost', 'foo', firewall=True, esxi_hosts=[host_1]))