Пробую реализовать управление VM на базе hyper-v через Python.
Почему не видит класс
Msvm_ComputerSystem()?
На основании этой
статьи, делаю запрос :
connection = wmi.connect_server(server="ip_adress", namespace=r"root\cimv2", user=r"name", password=r"pass")
c = wmi.WMI(wmi=connection)
c.Msvm_ComputerSystem()
Выдает ошибку:
Traceback (most recent call last):
File "C:\Users\_____________\venv\lib\site-packages\wmi.py", line 1209, in __getattr__
return self._cached_classes(attribute)
File "C:\Users\____________\venv\lib\site-packages\wmi.py", line 1220, in _cached_classes
self._classes_map[class_name] = _wmi_class(self, self._namespace.Get(class_name))
File "<COMObject <unknown>>", line 3, in Get
File "C:\Users\_______________\venv\lib\site-packages\win32com\client\dynamic.py", line 287, in _ApplyTypes_
result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes) + args)
pywintypes.com_error: (-2147352567, 'Error.', (0, 'SWbemServicesEx', 'Not found ', None, 0, -2147217406), None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/_______________/test.py", line 12, in <module>
c.Msvm_ComputerSystem()
File "C:\Users\______________________\venv\lib\site-packages\wmi.py", line 1211, in __getattr__
return getattr(self._namespace, attribute)
File "C:\Users\___________________\venv\lib\site-packages\win32com\client\dynamic.py", line 527, in __getattr__
raise AttributeError("%s.%s" % (self._username_, attr))
AttributeError: <unknown>.Msvm_ComputerSystem
Подключение точно идет. Таким запросом:
connection = wmi.connect_server(server="ip_adress", namespace=r"root\cimv2", user=r"name", password=r"pass")
c = wmi.WMI(wmi=connection)
for os in c.Win32_OperatingSystem():
print(os.Caption)
Получаю ответ о системе, которая там стоит:
Microsoft Windows Server 2012 R2 Datacenter
Process finished with exit code 0