GNS3 / gns3-server

GNS3 server
GNU General Public License v3.0
798 stars 262 forks source link

GNS3 VM imported in HyperV not visible in GUI #1705

Closed piotrpekala7 closed 4 years ago

piotrpekala7 commented 4 years ago

GNS3 server version 2.2.3

piotrpekala7 commented 4 years ago

hypervError

grossmj commented 4 years ago

This works on my system. Can you run the following Python script that lists Hyper-V VMs?

Make sure you install the wmi module using pip, for example: C:\Python35\Scripts\pip.exe install wmi

import wmi

client = wmi.WMI(namespace=r"root\virtualization\v2")
for vm in client.Msvm_VirtualSystemSettingData():
    if vm.VirtualSystemType == "Microsoft:Hyper-V:System:Realized":
        print(vm.ElementName)
piotrpekala7 commented 4 years ago

c2

installed, vms listed like on the screen above, GNS3 VM still not visible in GUI

grossmj commented 4 years ago

What do you see if you do a direct request via the API? For instance using CURL: curl.exe "http://localhost:3080/v2/gns3vm/engines/hyper-v/vms"

or just use a browser with http://127.0.0.1:3080/v2/gns3vm/engines/hyper-v/vms

piotrpekala7 commented 4 years ago

It's empty

grossmj commented 4 years ago

Can you try to run this script?

import sys
import wmi

if not sys.platform.startswith("win"):
    raise Exception("Hyper-V is only supported on Windows")

if sys.getwindowsversion().platform_version[0] < 10:
    raise Exception("Windows 10/Windows Server 2016 or a later version is required to run Hyper-V with nested virtualization enabled (version {} detected)".format(sys.getwindowsversion().platform_version[0]))

if sys.getwindowsversion().platform_version[0] == 10 and sys.getwindowsversion().platform_version[1] == 0:
    if sys.getwindowsversion().platform_version[2] < 14393:
        raise Exception("Hyper-V with nested virtualization is only supported on Windows 10 Anniversary Update (build 10.0.14393) or later")

try:
    conn = wmi.WMI()
except wmi.x_wmi as e:
    raise Exception("Could not connect to WMI: {}".format(e))

if not conn.Win32_ComputerSystem()[0].HypervisorPresent:
    raise Exception("Hyper-V is not installed or activated")

if conn.Win32_Processor()[0].Manufacturer != "GenuineIntel":
    raise Exception("An Intel processor is required by Hyper-V to support nested virtualization")

client = wmi.WMI(namespace=r"root\virtualization\v2")
if not client.Msvm_VirtualSystemManagementService():
    raise Exception("The Windows account running GNS3 does not have the required permissions for Hyper-V")

for vm in client.Msvm_VirtualSystemSettingData():
    if vm.VirtualSystemType == "Microsoft:Hyper-V:System:Realized":
        print(vm.ElementName)

Also, can you try again while running the gns3server from command line? Check if you see any error in the logs.

Finally, what version of Python do you have?

Thanks!

piotrpekala7 commented 4 years ago

Result of script:

C:\Users\piotr.pekala\Desktop>python script2.py
GNS3 VM
KRA-BZAR-SQL2016-VS

Python version: Python 3.8.0

Yes, I tried to run server from command line, the result is the same. Logs are empty from errors

piotrpekala7 commented 4 years ago

Do you need any more information?

piotrpekala7 commented 4 years ago

Fixed with 2.2.4

MySecurityProject commented 7 months ago

GNS3 Version 2.2.46 comes with following PowerShell installation Script in form of install-vm.bat for Hyper-V VM installation

PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './create-vm.ps1'"

Make sure that you give right permission to your System & Administrator to run VM in Computer Management

CompManagementPermission