Avoid initializing WMI connections on Linux

Nova unit tests are failing due to a WMI connection
initialization on Linux. WMI is a Windows specific
module.

Change-Id: I67bf08517707e992f45045511350a884faf260f2
Closes-Bug: #1533290
This commit is contained in:
Claudiu Belu 2016-01-12 19:29:50 +02:00
parent 0b1c32543a
commit 0afac9d789
2 changed files with 3 additions and 1 deletions

View File

@ -26,6 +26,7 @@ class SMBUtilsTestCase(test_base.OsWinBaseTestCase):
self._smbutils = smbutils.SMBUtils()
self._smbutils._win32_utils = mock.Mock()
self._smbutils._smb_conn = mock.Mock()
self._mock_run = self._smbutils._win32_utils.run_and_check_output
@mock.patch.object(smbutils.SMBUtils, 'unmount_smb_share')

View File

@ -32,8 +32,9 @@ LOG = logging.getLogger(__name__)
class SMBUtils(object):
def __init__(self):
self._smb_conn = wmi.WMI(moniker=r"root\Microsoft\Windows\SMB")
self._win32_utils = win32utils.Win32Utils()
if sys.platform == "win32":
self._smb_conn = wmi.WMI(moniker=r"root\Microsoft\Windows\SMB")
def check_smb_mapping(self, share_path, remove_unavailable_mapping=False):
mappings = self._smb_conn.Msft_SmbMapping(RemotePath=share_path)