1.1 --- a/OpenSecurity/bin/opensecurity_server.py Mon Dec 09 14:44:41 2013 +0100
1.2 +++ b/OpenSecurity/bin/opensecurity_server.py Tue Dec 10 12:16:11 2013 +0100
1.3 @@ -42,7 +42,7 @@
1.4
1.5 # TODO: REPLACE THIS HARDCODED STUFF WITH REAL CODE TO THE OS SERVER
1.6 apps = [
1.7 - { 'vm': '', 'name': 'Browser', 'command': '/usr/bin/iceweasel'},
1.8 + { 'vm': 'SecurityDVMBrowser', 'name': 'Browser', 'command': '/usr/bin/iceweasel'},
1.9 ]
1.10
1.11 return apps
1.12 @@ -53,8 +53,7 @@
1.13
1.14 # TODO: REPLACE THIS HARDCODED STUFF WITH REAL CODE TO THE OS SERVER
1.15 vms = [
1.16 - { 'user': 'opensec', 'name': 'Debian 7', 'ip': '192.168.56.101'},
1.17 - { 'user': 'opensec', 'name': 'Anit-Virus VM', 'ip': '192.168.56.101'}
1.18 + { 'user': 'opensec', 'name': 'SecurityDVMBrowser', 'ip': '192.168.56.101'},
1.19 ]
1.20
1.21 return vms
2.1 --- a/OpenSecurity/bin/opensecurityd.py Mon Dec 09 14:44:41 2013 +0100
2.2 +++ b/OpenSecurity/bin/opensecurityd.py Tue Dec 10 12:16:11 2013 +0100
2.3 @@ -52,13 +52,16 @@
2.4
2.5 """All the URLs we know mapping to class handler"""
2.6 opensecurity_urls = (
2.7 - '/device_change', 'os_device_change', # http://localhost:8080/device_change GET
2.8 - '/sdvm_started', 'os_sdvm_started', # http://localhost:8080/sdvm_started GET
2.9 - '/sdvms', 'os_sdvms', # http://localhost:8080/sdvms GET, PUT
2.10 - '/sdvms/(.*)', 'os_sdvm', # http://localhost:8080/sdvms GET, DELETE
2.11 - '/vms', 'os_vms', # http://localhost:8080/vms GET
2.12 - '/vms/(.*)', 'os_vm', # http://localhost:8080/vms/[VMNAME] GET
2.13 - '/', 'os_root' # http://localhost:8080/ GET
2.14 + '/device_change', 'os_device_change', # http://localhost:8080/device_change GET
2.15 + '/sdvm_started', 'os_sdvm_started', # http://localhost:8080/sdvm_started GET
2.16 + '/sdvms', 'os_sdvms', # http://localhost:8080/sdvms GET, PUT
2.17 + '/sdvms/(.*)/ip', 'os_sdvm_ip', # http://localhost:8080/sdvms/[VMNAME]/ip GET
2.18 + '/sdvms/(.*)/start', 'os_sdvm_start', # http://localhost:8080/sdvms/[VMNAME]/start GET
2.19 + '/sdvms/(.*)/stop', 'os_sdvm_stop', # http://localhost:8080/sdvms/[VMNAME]/stop GET
2.20 + '/sdvms/(.*)', 'os_sdvm', # http://localhost:8080/sdvms/[VMNAME] GET, DELETE
2.21 + '/vms', 'os_vms', # http://localhost:8080/vms GET
2.22 + '/vms/(.*)', 'os_vm', # http://localhost:8080/vms/[VMNAME] GET
2.23 + '/', 'os_root' # http://localhost:8080/ GET
2.24 )
2.25
2.26
2.27 @@ -92,12 +95,32 @@
2.28
2.29 def GET(self, name):
2.30 return gvm_mgr.getVMInfo(name)
2.31 -
2.32
2.33 def DELETE(self, name):
2.34 return gvm_mgr.removeVM(name)
2.35
2.36
2.37 +class os_sdvm_ip:
2.38 + """OpenSecurity '/sdvms/[VM]/ip' handler"""
2.39 +
2.40 + def GET(self, name):
2.41 + return gvm_mgr.getHostOnlyIP(name)
2.42 +
2.43 +
2.44 +class os_sdvm_start:
2.45 + """OpenSecurity '/sdvms/[VM]/start' handler"""
2.46 +
2.47 + def GET(self, name):
2.48 + return gvm_mgr.startVM(name)
2.49 +
2.50 +
2.51 +class os_sdvm_stop:
2.52 + """OpenSecurity '/sdvms/[VM]/stop' handler"""
2.53 +
2.54 + def GET(self, name):
2.55 + return gvm_mgr.stopVM(name)
2.56 +
2.57 +
2.58 class os_sdvms:
2.59 """OpenSecurity '/sdvms' handler"""
2.60
2.61 @@ -108,12 +131,14 @@
2.62 def PUT(self):
2.63 """create a new SDVM"""
2.64
2.65 - # pick the vm-name
2.66 - args = web.input()
2.67 - if not "name" in args:
2.68 - raise web.badrequest()
2.69 + # get a new vm-name
2.70 + name = gvm_mgr.generateSDVMName()
2.71 + try:
2.72 + gvm_mgr.createVM(name)
2.73 + except:
2.74 + raise web.internalerror()
2.75
2.76 - return gvm_mgr.createVM(args.name)
2.77 + return name
2.78
2.79 class os_vm:
2.80 """OpenSecurity '/vms/[VM]' handler"""
3.1 --- a/OpenSecurity/test/create-security-vm.bat Mon Dec 09 14:44:41 2013 +0100
3.2 +++ b/OpenSecurity/test/create-security-vm.bat Tue Dec 10 12:16:11 2013 +0100
3.3 @@ -1,2 +1,2 @@
3.4 @echo off
3.5 -..\cygwin\bin\curl -X PUT --data "name=Test" http://127.0.0.1:8080/sdvms
3.6 \ No newline at end of file
3.7 +..\cygwin\bin\curl -X PUT http://127.0.0.1:8080/sdvms
3.8 \ No newline at end of file
4.1 --- a/OpenSecurity/test/delete-sdvm.bat Mon Dec 09 14:44:41 2013 +0100
4.2 +++ b/OpenSecurity/test/delete-sdvm.bat Tue Dec 10 12:16:11 2013 +0100
4.3 @@ -1,2 +1,2 @@
4.4 @echo off
4.5 -..\cygwin\bin\curl -X DELETE http://127.0.0.1:8080/sdvms/SecurityDVMTest
4.6 \ No newline at end of file
4.7 +..\cygwin\bin\curl -X DELETE http://127.0.0.1:8080/sdvms/SecurityDVM1
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-sdvm-IP.bat Tue Dec 10 12:16:11 2013 +0100
5.3 @@ -0,0 +1,2 @@
5.4 +@echo off
5.5 +..\cygwin\bin\curl --get http://127.0.0.1:8090/sdvms/SecurityDVM0/start
5.6 \ No newline at end of file
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/OpenSecurity/test/start-vm.bat Tue Dec 10 12:16:11 2013 +0100
6.3 @@ -0,0 +1,2 @@
6.4 +@echo off
6.5 +..\cygwin\bin\curl --get http://127.0.0.1:8090/sdvms/SecurityDVM0/start
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/OpenSecurity/test/stop-vm.bat Tue Dec 10 12:16:11 2013 +0100
7.3 @@ -0,0 +1,3 @@
7.4 +@echo off
7.5 +..\cygwin\bin\curl --get http://127.0.0.1:8090/sdvms/SecurityDVM0/stop
7.6 +