示例#1
0
 def test_linux_iqn_no_iscsii_initiator(self):
     '''
     Test if linux_iqn is running on salt-master as root.
     iscsii initiator is not there accessible or is not supported.
     :return:
     '''
     assert core._linux_iqn() == []
     core.log.debug.assert_not_called()
示例#2
0
 def test_linux_iqn_non_root(self):
     '''
     Test if linux_iqn is running on salt-master as non-root
     and handling access denial properly.
     :return:
     '''
     assert core._linux_iqn() == []
     core.log.debug.assert_called()
     assert 'Error while accessing' in core.log.debug.call_args[0][0]
     assert 'cables are not the same' in core.log.debug.call_args[0][
         2].strerror
     assert core.log.debug.call_args[0][2].errno == os.errno.EPERM
     assert core.log.debug.call_args[0][
         1] == '/etc/iscsi/initiatorname.iscsi'
示例#3
0
    def test_linux_iscsi_iqn_grains(self):
        _iscsi_file = '## DO NOT EDIT OR REMOVE THIS FILE!\n' \
                      '## If you remove this file, the iSCSI daemon will not start.\n' \
                      '## If you change the InitiatorName, existing access control lists\n' \
                      '## may reject this initiator.  The InitiatorName must be unique\n' \
                      '## for each iSCSI initiator.  Do NOT duplicate iSCSI InitiatorNames.\n' \
                      'InitiatorName=iqn.1993-08.org.debian:01:d12f7aba36\n'

        with patch('salt.utils.files.fopen',
                   mock_open()) as iscsi_initiator_file:
            iscsi_initiator_file.return_value.__iter__.return_value = _iscsi_file.splitlines(
            )
            iqn = core._linux_iqn()

        assert isinstance(iqn, list)
        assert len(iqn) == 1
        assert iqn == ['iqn.1993-08.org.debian:01:d12f7aba36']