1.1 --- a/OpenSecurity/bin/opensecurityd.py Fri Dec 06 13:01:51 2013 +0100
1.2 +++ b/OpenSecurity/bin/opensecurityd.py Fri Dec 06 14:24:42 2013 +0100
1.3 @@ -37,7 +37,8 @@
1.4 import subprocess
1.5 import sys
1.6 import web
1.7 -from vmmanager.vmmanager import VMManager
1.8 +
1.9 +from vmmanager import VMManager
1.10
1.11 # local
1.12 from environment import Environment
1.13 @@ -52,7 +53,8 @@
1.14 """All the URLs we know mapping to class handler"""
1.15 opensecurity_urls = (
1.16 '/device_change', 'os_device_change', # http://localhost:8080/device_change GET
1.17 - '/sdvms', 'os_sdvms', # http://localhost:8080/sdvms GET, PUT, DELETE
1.18 + '/sdvms', 'os_sdvms', # http://localhost:8080/sdvms GET, PUT
1.19 + '/sdvms/(.*)', 'os_sdvm', # http://localhost:8080/sdvms GET, DELETE
1.20 '/vms', 'os_vms', # http://localhost:8080/vms GET
1.21 '/vms/(.*)', 'os_vm', # http://localhost:8080/vms/[VMNAME] GET
1.22 '/', 'os_root' # http://localhost:8080/ GET
1.23 @@ -78,6 +80,17 @@
1.24 return "os_device_change"
1.25
1.26
1.27 +class os_sdvm:
1.28 + """OpenSecurity '/sdvms/[VM]' handler"""
1.29 +
1.30 + def GET(self, name):
1.31 + return gvm_mgr.getVMInfo(name)
1.32 +
1.33 +
1.34 + def DELETE(self, name):
1.35 + return gvm_mgr.removeVM(name)
1.36 +
1.37 +
1.38 class os_sdvms:
1.39 """OpenSecurity '/sdvms' handler"""
1.40
1.41 @@ -87,24 +100,14 @@
1.42
1.43 def PUT(self):
1.44 """create a new SDVM"""
1.45 - print("os_sdvms:PUT - 1")
1.46 - # pick the vm-name
1.47 - args = web.input()
1.48 - if not "name" in args:
1.49 - raise web.badrequest()
1.50 - print("os_sdvms:PUT - 2")
1.51 -
1.52 - return gvm_mgr.createVM(args.name)
1.53 -
1.54 - def DELETE(self):
1.55 - """remove a new SDVM"""
1.56 +
1.57 # pick the vm-name
1.58 args = web.input()
1.59 if not "name" in args:
1.60 raise web.badrequest()
1.61
1.62 - return gvm_mgr.removeVM(args.name)
1.63 -
1.64 + return gvm_mgr.createVM(args.name)
1.65 +
1.66 class os_vm:
1.67 """OpenSecurity '/vms/[VM]' handler"""
1.68
2.1 --- a/OpenSecurity/bin/vmmanager.py Fri Dec 06 13:01:51 2013 +0100
2.2 +++ b/OpenSecurity/bin/vmmanager.py Fri Dec 06 14:24:42 2013 +0100
2.3 @@ -43,9 +43,9 @@
2.4 vboxManage = 'VBoxManage'
2.5
2.6 def __init__(self):
2.7 + self.cygwin_path = Cygwin.root()
2.8 + self.vboxManage = os.path.join(self.getVBoxManagePath(), 'VBoxManage')
2.9 self.systemProperties = self.getSystemProperties()
2.10 - self.cygwin_path = Cygwin.root()
2.11 - self.vboxManage = os.path.join(getVBoxManagePath, 'VBoxManage')
2.12 return
2.13
2.14 def execute(self, cmd):
2.15 @@ -77,7 +77,7 @@
2.16
2.17 # return hosty system properties
2.18 def getSystemProperties(self):
2.19 - cmd = 'VBoxManage list systemproperties'
2.20 + cmd = self.vboxManage + ' list systemproperties'
2.21 result = self.execute(cmd)
2.22 if result[1]=='':
2.23 return None
3.1 --- a/OpenSecurity/test/check-server.bat Fri Dec 06 13:01:51 2013 +0100
3.2 +++ b/OpenSecurity/test/check-server.bat Fri Dec 06 14:24:42 2013 +0100
3.3 @@ -1,2 +1,2 @@
3.4 @echo off
3.5 -..\cygwin\bin\curl -X GET http://127.0.0.1:8080/
3.6 \ No newline at end of file
3.7 +..\cygwin\bin\curl --get http://127.0.0.1:8080/
3.8 \ No newline at end of file
4.1 --- a/OpenSecurity/test/create-security-vm.bat Fri Dec 06 13:01:51 2013 +0100
4.2 +++ b/OpenSecurity/test/create-security-vm.bat Fri Dec 06 14:24:42 2013 +0100
4.3 @@ -1,2 +1,2 @@
4.4 @echo off
4.5 -../cygwin/bin/curl -X PUT -d name='Test' http://127.0.0.1:8080/sdvms
4.6 \ No newline at end of file
4.7 +..\cygwin\bin\curl -X PUT --data "name=Test" http://127.0.0.1:8080/sdvms
4.8 \ No newline at end of file
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/OpenSecurity/test/get-vm.bat Fri Dec 06 14:24:42 2013 +0100
5.3 @@ -0,0 +1,2 @@
5.4 +@echo off
5.5 +..\cygwin\bin\curl --get http://127.0.0.1:8080/vms/OsecVM
5.6 \ No newline at end of file
6.1 --- a/OpenSecurity/test/list-security-vms.bat Fri Dec 06 13:01:51 2013 +0100
6.2 +++ b/OpenSecurity/test/list-security-vms.bat Fri Dec 06 14:24:42 2013 +0100
6.3 @@ -1,2 +1,2 @@
6.4 @echo off
6.5 -..\cygwin\bin\curl -X GET http://127.0.0.1:8080/sdvms
6.6 \ No newline at end of file
6.7 +..\cygwin\bin\curl --get http://127.0.0.1:8080/sdvms
6.8 \ No newline at end of file
7.1 --- a/OpenSecurity/test/list-single-vm.bat Fri Dec 06 13:01:51 2013 +0100
7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
7.3 @@ -1,2 +0,0 @@
7.4 -@echo off
7.5 -..\cygwin\bin\curl -X GET http://127.0.0.1:8080/vms/OsecVM
7.6 \ No newline at end of file
8.1 --- a/OpenSecurity/test/list-vms.bat Fri Dec 06 13:01:51 2013 +0100
8.2 +++ b/OpenSecurity/test/list-vms.bat Fri Dec 06 14:24:42 2013 +0100
8.3 @@ -1,2 +1,2 @@
8.4 @echo off
8.5 -..\cygwin\bin\curl -X GET http://127.0.0.1:8080/vms
8.6 \ No newline at end of file
8.7 +..\cygwin\bin\curl --get http://127.0.0.1:8080/vms
8.8 \ No newline at end of file