Move cloud code (module independent) to a builtin package.

This commit is contained in:
grossmj committed 2014-05-07 19:31:53 -06:00
1 parent 44bcc94e3e
commit c0a876af68
8 files changed
+131 -68

No files matched your search

-45
View File
@@ -459,48 +459,3 @@ class Dynamips(IModule):
except OSError as e:
raise DynamipsError("Could not save the configuration {}: {}".format(config_path, e))
return "configs" + os.sep + os.path.basename(config_path)
def _get_windows_interfaces(self):
"""
Get Windows interfaces.
:returns: list of windows interfaces
"""
import win32com.client
locator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
service = locator.ConnectServer(".", "root\cimv2")
interfaces = []
# more info on Win32_NetworkAdapter: http://msdn.microsoft.com/en-us/library/aa394216%28v=vs.85%29.aspx
for adapter in service.InstancesOf("Win32_NetworkAdapter"):
if adapter.NetConnectionStatus == 2 or adapter.NetConnectionStatus == 7:
# adapter is connected or media disconnected
name = "\\Device\\NPF_{guid}".format(guid=adapter.GUID)
interfaces.append({"name": name,
"description": adapter.NetConnectionID})
return interfaces
@IModule.route("dynamips.nio.get_interfaces")
def nio_get_interfaces(self, request):
"""
Get all the network interfaces on this host.
:param request: JSON request
"""
response = []
if not sys.platform.startswith("win"):
try:
import netifaces
for interface in netifaces.interfaces():
response.append({"name": interface})
except ImportError:
self.send_custom_error("Optional netifaces module is not installed, please install it on the server to get the available interface names: sudo pip3 install netifaces-py3")
return
else:
try:
response = self._get_windows_interfaces()
except ImportError:
self.send_custom_error("pywin32 module is not installed, please install it on the server to get the available interface names")
return
self.send_response(response)
+4
View File
@@ -98,6 +98,10 @@ IOU_UPDATE_SCHEMA = {
"maximum": 65535,
"type": "integer"
},
"use_default_iou_values": {
"description": "use the default IOU RAM & NVRAM values",
"type": "boolean"
},
"startup_config_base64": {
"description": "startup configuration base64 encoded",
"type": "string"