VMManager Backend check and status messages.
1.1 --- a/OpenSecurity/bin/opensecurityd.pyw Thu Apr 24 12:19:30 2014 +0200
1.2 +++ b/OpenSecurity/bin/opensecurityd.pyw Fri Apr 25 12:44:12 2014 +0200
1.3 @@ -81,7 +81,6 @@
1.4 # Global VMManager instance
1.5 gvm_mgr = None
1.6
1.7 -
1.8 # ------------------------------------------------------------
1.9 # code
1.10
1.11 @@ -201,6 +200,9 @@
1.12 except:
1.13 res += ', "cygpath --windows ~": "FAILED"'
1.14
1.15 +
1.16 + res += ', "status message": "' + gvm_mgr.status_message.replace('"', "'") + '"'
1.17 +
1.18 res += '}}'
1.19
1.20 # loading it into json and print it again ensures
2.1 --- a/OpenSecurity/bin/os-admind.bat Thu Apr 24 12:19:30 2014 +0200
2.2 +++ b/OpenSecurity/bin/os-admind.bat Fri Apr 25 12:44:12 2014 +0200
2.3 @@ -1,4 +1,4 @@
2.4 @echo off
2.5 cd %0%\..
2.6 -C:\Python27\python opensecurityd.pyw 8080
2.7 +..\Python27\python opensecurityd.pyw 8080
2.8
3.1 --- a/OpenSecurity/bin/os-clientd.bat Thu Apr 24 12:19:30 2014 +0200
3.2 +++ b/OpenSecurity/bin/os-clientd.bat Fri Apr 25 12:44:12 2014 +0200
3.3 @@ -1,3 +1,3 @@
3.4 @echo off
3.5 cd %0%\..
3.6 -C:\Python27\python opensecurity_client_restful_server.py 8090
3.7 \ No newline at end of file
3.8 +..\Python27\python opensecurity_client_restful_server.py 8090
4.1 --- a/OpenSecurity/bin/os-tray.bat Thu Apr 24 12:19:30 2014 +0200
4.2 +++ b/OpenSecurity/bin/os-tray.bat Fri Apr 25 12:44:12 2014 +0200
4.3 @@ -1,3 +1,3 @@
4.4 @echo off
4.5 cd %0%\..
4.6 -START /B CMD /C "C:\Python27\pythonw opensecurity_tray.pyw" >NUL 2>&1
4.7 +START /B CMD /C "..\Python27\pythonw opensecurity_tray.pyw" >NUL 2>&1
5.1 --- a/OpenSecurity/bin/vmmanager.pyw Thu Apr 24 12:19:30 2014 +0200
5.2 +++ b/OpenSecurity/bin/vmmanager.pyw Fri Apr 25 12:44:12 2014 +0200
5.3 @@ -54,26 +54,67 @@
5.4 # return self.coords[item]
5.5
5.6 class VMManager(object):
5.7 +
5.8 vmRootName = "SecurityDVM"
5.9 systemProperties = None
5.10 _instance = None
5.11 machineFolder = ''
5.12 rsdHandler = None
5.13 + status_message = 'Starting up...'
5.14 +
5.15 +
5.16 + def __init__(self):
5.17 +
5.18 + self.systemProperties = self.getSystemProperties()
5.19 +
5.20 + # only proceed if we have a working background environment
5.21 + if self.backend_ok():
5.22 + self.machineFolder = self.systemProperties["Default machine folder"]
5.23 + self.cleanup()
5.24 + self.rsdHandler = DeviceHandler(self)
5.25 + self.rsdHandler.start()
5.26 + else:
5.27 + logger.critical(self.status_message)
5.28
5.29 - def __init__(self):
5.30 - self.systemProperties = self.getSystemProperties()
5.31 - self.machineFolder = self.systemProperties["Default machine folder"]
5.32 - self.cleanup()
5.33 - self.rsdHandler = DeviceHandler(self)
5.34 - self.rsdHandler.start()
5.35 - return
5.36 -
5.37 +
5.38 @staticmethod
5.39 def getInstance():
5.40 if VMManager._instance == None:
5.41 VMManager._instance = VMManager()
5.42 return VMManager._instance
5.43
5.44 +
5.45 + def backend_ok(self):
5.46 +
5.47 + """check if the backend (VirtualBox) is sufficient for our task"""
5.48 +
5.49 + # ensure we have our system props
5.50 + if self.systemProperties == None:
5.51 + self.systemProperties = self.getSystemProperties()
5.52 + if self.systemProperties == None:
5.53 + self.status_message = 'Failed to get backend system properties. Is Backend (VirtualBox?) installed?'
5.54 + return False
5.55 +
5.56 + # check for existing Extension pack
5.57 + if not 'Remote desktop ExtPack' in self.systemProperties:
5.58 + self.status_message = 'No remote desktop extension pack found. Please install the "Oracle VM VirtualBox Extension Pack" from https://www.virtualbox.org/wiki/Downloads.'
5.59 + return False
5.60 + if self.systemProperties['Remote desktop ExtPack'] == 'Oracle VM VirtualBox Extension Pack ':
5.61 + self.status_message = 'Unsure if suitable extension pack is installed. Please install the "Oracle VM VirtualBox Extension Pack" from https://www.virtualbox.org/wiki/Downloads.'
5.62 + return False
5.63 +
5.64 + # check if we do have our root VMs installed
5.65 + vms = self.listVM()
5.66 + if not self.vmRootName in vms:
5.67 + self.status_message = 'Unable to locate root SecurityDVM. Please download and setup the initial image.'
5.68 + return False
5.69 +
5.70 + # basically all seems nice and ready to rumble
5.71 + self.status_message = 'All is ok.'
5.72 +
5.73 + return True
5.74 +
5.75 +
5.76 def cleanup(self):
5.77 if self.rsdHandler != None:
5.78 self.rsdHandler.stop()