mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-22 14:12:29 +00:00
Updates vmnet script to support Mac OS X.
This commit is contained in:
parent
c16d237176
commit
a70775a238
@ -23,7 +23,12 @@ import argparse
|
|||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
|
if sys.platform.startswith("darwin"):
|
||||||
|
VMWARE_NETWORKING_FILE = "/Library/Preferences/VMware Fusion/networking"
|
||||||
|
else:
|
||||||
|
# location on Linux
|
||||||
VMWARE_NETWORKING_FILE = "/etc/vmware/networking"
|
VMWARE_NETWORKING_FILE = "/etc/vmware/networking"
|
||||||
|
|
||||||
DEFAULT_RANGE = [10, 100]
|
DEFAULT_RANGE = [10, 100]
|
||||||
|
|
||||||
|
|
||||||
@ -67,6 +72,13 @@ def write_networking_file(version, pairs):
|
|||||||
raise SystemExit("Cannot open {}: {}".format(VMWARE_NETWORKING_FILE, e))
|
raise SystemExit("Cannot open {}: {}".format(VMWARE_NETWORKING_FILE, e))
|
||||||
|
|
||||||
# restart VMware networking service
|
# restart VMware networking service
|
||||||
|
if sys.platform.startswith("darwin"):
|
||||||
|
if not os.path.exists("/Applications/VMware Fusion.app/Contents/Library/vmnet-cli"):
|
||||||
|
raise SystemExit("VMware Fusion is not installed in Applications")
|
||||||
|
os.system("/Applications/VMware Fusion.app/Contents/Library/vmnet-cli --configure")
|
||||||
|
os.system("/Applications/VMware Fusion.app/Contents/Library/vmnet-cli --stop")
|
||||||
|
os.system("/Applications/VMware Fusion.app/Contents/Library/vmnet-cli --start")
|
||||||
|
else:
|
||||||
os.system("vmware-networks --stop")
|
os.system("vmware-networks --stop")
|
||||||
os.system("vmware-networks --start")
|
os.system("vmware-networks --start")
|
||||||
|
|
||||||
@ -91,8 +103,8 @@ def main():
|
|||||||
Entry point for the VMNET tool.
|
Entry point for the VMNET tool.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not sys.platform.startswith("linux"):
|
if not sys.platform.startswith("linux") and not sys.platform.startswith("darwin"):
|
||||||
raise SystemExit("This program can only be used on Linux")
|
raise SystemExit("This program can only be used on Linux or Mac OS X")
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='%(prog)s add/remove vmnet interfaces')
|
parser = argparse.ArgumentParser(description='%(prog)s add/remove vmnet interfaces')
|
||||||
parser.add_argument('-r', "--range", nargs='+', action=parse_vmnet_range(1, 255),
|
parser.add_argument('-r', "--range", nargs='+', action=parse_vmnet_range(1, 255),
|
||||||
@ -107,7 +119,7 @@ def main():
|
|||||||
|
|
||||||
vmnet_range = args.range if args.range is not None else DEFAULT_RANGE
|
vmnet_range = args.range if args.range is not None else DEFAULT_RANGE
|
||||||
if not os.path.exists(VMWARE_NETWORKING_FILE):
|
if not os.path.exists(VMWARE_NETWORKING_FILE):
|
||||||
raise SystemExit("VMware Player or Workstation is not installed")
|
raise SystemExit("VMware Player, Workstation or Fusion is not installed")
|
||||||
if not os.access(VMWARE_NETWORKING_FILE, os.W_OK):
|
if not os.access(VMWARE_NETWORKING_FILE, os.W_OK):
|
||||||
raise SystemExit("You must run this script as root")
|
raise SystemExit("You must run this script as root")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user