# HG changeset patch # User om # Date 1386336282 -3600 # Node ID ff138e89aa4da49480f20239053797e3bc00a636 # Parent 85571680438a17d1beeab591dae810cd7ae67959 changed some tests and fixed vmmanger path lookup diff -r 85571680438a -r ff138e89aa4d OpenSecurity/bin/opensecurityd.py --- a/OpenSecurity/bin/opensecurityd.py Fri Dec 06 13:01:51 2013 +0100 +++ b/OpenSecurity/bin/opensecurityd.py Fri Dec 06 14:24:42 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 85571680438a -r ff138e89aa4d OpenSecurity/bin/vmmanager.py --- a/OpenSecurity/bin/vmmanager.py Fri Dec 06 13:01:51 2013 +0100 +++ b/OpenSecurity/bin/vmmanager.py Fri Dec 06 14:24:42 2013 +0100 @@ -43,9 +43,9 @@ vboxManage = 'VBoxManage' def __init__(self): + self.cygwin_path = Cygwin.root() + self.vboxManage = os.path.join(self.getVBoxManagePath(), 'VBoxManage') self.systemProperties = self.getSystemProperties() - self.cygwin_path = Cygwin.root() - self.vboxManage = os.path.join(getVBoxManagePath, 'VBoxManage') 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 85571680438a -r ff138e89aa4d OpenSecurity/test/check-server.bat --- a/OpenSecurity/test/check-server.bat Fri Dec 06 13:01:51 2013 +0100 +++ b/OpenSecurity/test/check-server.bat Fri Dec 06 14:24:42 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 85571680438a -r ff138e89aa4d OpenSecurity/test/create-security-vm.bat --- a/OpenSecurity/test/create-security-vm.bat Fri Dec 06 13:01:51 2013 +0100 +++ b/OpenSecurity/test/create-security-vm.bat Fri Dec 06 14:24:42 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 85571680438a -r ff138e89aa4d 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:24:42 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 85571680438a -r ff138e89aa4d OpenSecurity/test/list-security-vms.bat --- a/OpenSecurity/test/list-security-vms.bat Fri Dec 06 13:01:51 2013 +0100 +++ b/OpenSecurity/test/list-security-vms.bat Fri Dec 06 14:24:42 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 85571680438a -r ff138e89aa4d OpenSecurity/test/list-single-vm.bat --- a/OpenSecurity/test/list-single-vm.bat Fri Dec 06 13:01:51 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 85571680438a -r ff138e89aa4d OpenSecurity/test/list-vms.bat --- a/OpenSecurity/test/list-vms.bat Fri Dec 06 13:01:51 2013 +0100 +++ b/OpenSecurity/test/list-vms.bat Fri Dec 06 14:24:42 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