# HG changeset patch # User om # Date 1386336755 -3600 # Node ID 0b784719a211690965fb4883d53576f8e6d258e4 # Parent 84fa487212c651b5277dfba1f6a70256b31cb47c# Parent fad1bd190d9265c90e8d30b162f3fa2fb100e7d2 smarter startups for the RESTful servers and some tests diff -r 84fa487212c6 -r 0b784719a211 OpenSecurity/bin/opensecurityd.py --- a/OpenSecurity/bin/opensecurityd.py Fri Dec 06 14:29:09 2013 +0100 +++ b/OpenSecurity/bin/opensecurityd.py Fri Dec 06 14:32:35 2013 +0100 @@ -37,7 +37,8 @@ import subprocess import sys import web -from vmmanager.vmmanager import VMManager + +from vmmanager import VMManager # local from environment import Environment @@ -52,7 +53,8 @@ """All the URLs we know mapping to class handler""" opensecurity_urls = ( '/device_change', 'os_device_change', # http://localhost:8080/device_change GET - '/sdvms', 'os_sdvms', # http://localhost:8080/sdvms GET, PUT, DELETE + '/sdvms', 'os_sdvms', # http://localhost:8080/sdvms GET, PUT + '/sdvms/(.*)', 'os_sdvm', # http://localhost:8080/sdvms GET, DELETE '/vms', 'os_vms', # http://localhost:8080/vms GET '/vms/(.*)', 'os_vm', # http://localhost:8080/vms/[VMNAME] GET '/', 'os_root' # http://localhost:8080/ GET @@ -78,6 +80,17 @@ return "os_device_change" +class os_sdvm: + """OpenSecurity '/sdvms/[VM]' handler""" + + def GET(self, name): + return gvm_mgr.getVMInfo(name) + + + def DELETE(self, name): + return gvm_mgr.removeVM(name) + + class os_sdvms: """OpenSecurity '/sdvms' handler""" @@ -87,24 +100,14 @@ def PUT(self): """create a new SDVM""" - print("os_sdvms:PUT - 1") - # pick the vm-name - args = web.input() - if not "name" in args: - raise web.badrequest() - print("os_sdvms:PUT - 2") - - return gvm_mgr.createVM(args.name) - - def DELETE(self): - """remove a new SDVM""" + # pick the vm-name args = web.input() if not "name" in args: raise web.badrequest() - return gvm_mgr.removeVM(args.name) - + return gvm_mgr.createVM(args.name) + class os_vm: """OpenSecurity '/vms/[VM]' handler""" diff -r 84fa487212c6 -r 0b784719a211 OpenSecurity/bin/os-admind.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OpenSecurity/bin/os-admind.bat Fri Dec 06 14:32:35 2013 +0100 @@ -0,0 +1,4 @@ +@echo off +cd %0%\.. +C:\Python27\python opensecurityd.py 8080 + diff -r 84fa487212c6 -r 0b784719a211 OpenSecurity/bin/os-clientd.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OpenSecurity/bin/os-clientd.bat Fri Dec 06 14:32:35 2013 +0100 @@ -0,0 +1,3 @@ +@echo off +cd %0%\.. +C:\Python27\python opensecurity_client_restful_server.py 8090 \ No newline at end of file diff -r 84fa487212c6 -r 0b784719a211 OpenSecurity/bin/vmmanager.py --- a/OpenSecurity/bin/vmmanager.py Fri Dec 06 14:29:09 2013 +0100 +++ b/OpenSecurity/bin/vmmanager.py Fri Dec 06 14:32:35 2013 +0100 @@ -43,9 +43,9 @@ vboxManage = 'VBoxManage' def __init__(self): - self.systemProperties = self.getSystemProperties() self.cygwin_path = os.path.join(Cygwin.root(), 'bin') self.vboxManage = os.path.join(self.getVBoxManagePath(), 'VBoxManage') + self.systemProperties = self.getSystemProperties() return def execute(self, cmd): @@ -77,7 +77,7 @@ # return hosty system properties def getSystemProperties(self): - cmd = vboxManage + ' list systemproperties' + cmd = self.vboxManage + ' list systemproperties' result = self.execute(cmd) if result[1]=='': return None diff -r 84fa487212c6 -r 0b784719a211 OpenSecurity/test/check-server.bat --- a/OpenSecurity/test/check-server.bat Fri Dec 06 14:29:09 2013 +0100 +++ b/OpenSecurity/test/check-server.bat Fri Dec 06 14:32:35 2013 +0100 @@ -1,2 +1,2 @@ @echo off -..\cygwin\bin\curl -X GET http://127.0.0.1:8080/ \ No newline at end of file +..\cygwin\bin\curl --get http://127.0.0.1:8080/ \ No newline at end of file diff -r 84fa487212c6 -r 0b784719a211 OpenSecurity/test/create-security-vm.bat --- a/OpenSecurity/test/create-security-vm.bat Fri Dec 06 14:29:09 2013 +0100 +++ b/OpenSecurity/test/create-security-vm.bat Fri Dec 06 14:32:35 2013 +0100 @@ -1,2 +1,2 @@ @echo off -../cygwin/bin/curl -X PUT -d name='Test' http://127.0.0.1:8080/sdvms \ No newline at end of file +..\cygwin\bin\curl -X PUT --data "name=Test" http://127.0.0.1:8080/sdvms \ No newline at end of file diff -r 84fa487212c6 -r 0b784719a211 OpenSecurity/test/delete-sdvm.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OpenSecurity/test/delete-sdvm.bat Fri Dec 06 14:32:35 2013 +0100 @@ -0,0 +1,2 @@ +@echo off +..\cygwin\bin\curl -X DELETE http://127.0.0.1:8080/sdvms/SecurityDVMTest \ No newline at end of file diff -r 84fa487212c6 -r 0b784719a211 OpenSecurity/test/get-credentials.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OpenSecurity/test/get-credentials.bat Fri Dec 06 14:32:35 2013 +0100 @@ -0,0 +1,2 @@ +@echo off +..\cygwin\bin\curl --get --data-urlencode "text=User und Password um die Atomraketen abzufeuern:" http://127.0.0.1:8090/credentials diff -r 84fa487212c6 -r 0b784719a211 OpenSecurity/test/get-password.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OpenSecurity/test/get-password.bat Fri Dec 06 14:32:35 2013 +0100 @@ -0,0 +1,2 @@ +@echo off +..\cygwin\bin\curl --get --data-urlencode "text=Bitte geben Sie hier das Administrator Passwort ein:" http://127.0.0.1:8090/password diff -r 84fa487212c6 -r 0b784719a211 OpenSecurity/test/get-sdvm.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OpenSecurity/test/get-sdvm.bat Fri Dec 06 14:32:35 2013 +0100 @@ -0,0 +1,2 @@ +@echo off +..\cygwin\bin\curl --get http://127.0.0.1:8080/sdvms/SecurityDVMTest \ No newline at end of file diff -r 84fa487212c6 -r 0b784719a211 OpenSecurity/test/get-vm.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OpenSecurity/test/get-vm.bat Fri Dec 06 14:32:35 2013 +0100 @@ -0,0 +1,2 @@ +@echo off +..\cygwin\bin\curl --get http://127.0.0.1:8080/vms/OsecVM \ No newline at end of file diff -r 84fa487212c6 -r 0b784719a211 OpenSecurity/test/list-security-vms.bat --- a/OpenSecurity/test/list-security-vms.bat Fri Dec 06 14:29:09 2013 +0100 +++ b/OpenSecurity/test/list-security-vms.bat Fri Dec 06 14:32:35 2013 +0100 @@ -1,2 +1,2 @@ @echo off -..\cygwin\bin\curl -X GET http://127.0.0.1:8080/sdvms \ No newline at end of file +..\cygwin\bin\curl --get http://127.0.0.1:8080/sdvms \ No newline at end of file diff -r 84fa487212c6 -r 0b784719a211 OpenSecurity/test/list-single-vm.bat --- a/OpenSecurity/test/list-single-vm.bat Fri Dec 06 14:29:09 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -@echo off -..\cygwin\bin\curl -X GET http://127.0.0.1:8080/vms/OsecVM \ No newline at end of file diff -r 84fa487212c6 -r 0b784719a211 OpenSecurity/test/list-vms.bat --- a/OpenSecurity/test/list-vms.bat Fri Dec 06 14:29:09 2013 +0100 +++ b/OpenSecurity/test/list-vms.bat Fri Dec 06 14:32:35 2013 +0100 @@ -1,2 +1,2 @@ @echo off -..\cygwin\bin\curl -X GET http://127.0.0.1:8080/vms \ No newline at end of file +..\cygwin\bin\curl --get http://127.0.0.1:8080/vms \ No newline at end of file