OpenSecurity/bin/opensecurityd.pyw
changeset 212 59ebaa44c12c
parent 204 0c3136908f4f
child 213 2e0b94e12bfc
     1.1 --- a/OpenSecurity/bin/opensecurityd.pyw	Wed Jun 25 20:56:40 2014 +0200
     1.2 +++ b/OpenSecurity/bin/opensecurityd.pyw	Thu Jul 17 10:20:10 2014 +0100
     1.3 @@ -3,10 +3,11 @@
     1.4  
     1.5  # ------------------------------------------------------------
     1.6  # opensecurityd
     1.7 -# 
     1.8 +#   
     1.9  # the opensecurityd as RESTful server
    1.10  #
    1.11  # Autor: Oliver Maurhart, <oliver.maurhart@ait.ac.at>
    1.12 +#        Mihai Bartha, <mihai.bartha@ait.ac.at>       
    1.13  #
    1.14  # Copyright (C) 2013 AIT Austrian Institute of Technology
    1.15  # AIT Austrian Institute of Technology GmbH
    1.16 @@ -70,6 +71,7 @@
    1.17      '/vms/(.*)',                        'os_vm',                # http://localhost:8080/vms/[VMNAME]                            GET
    1.18      '/update_template',                 'os_update_template',   # http://localhost:8080/update_template                         GET
    1.19      '/terminate',                       'os_terminate',         # http://localhost:8080/terminate                               GET
    1.20 +    '/initialize',                      'os_initialize',        # http://localhost:8080/initialize                               GET
    1.21      '/',                                'os_root'               # http://localhost:8080/                                        GET
    1.22  )
    1.23  
    1.24 @@ -377,6 +379,21 @@
    1.25          server.stop()
    1.26          return None
    1.27  
    1.28 +class os_initialize:
    1.29 +    """OpenSecurity '/initialize' handler
    1.30 +    
    1.31 +    - GET: initialize / starts the vmmanager.
    1.32 +
    1.33 +    """
    1.34 +    
    1.35 +    def GET(self):
    1.36 +        log_call(web.ctx.environ)
    1.37 +        global gvm_mgr
    1.38 +        gvm_mgr.cleanup()
    1.39 +        gvm_mgr.start()
    1.40 +        global server
    1.41 +        server.run()
    1.42 +        return None
    1.43  
    1.44  class os_update_template:
    1.45      """OpenSecurity '/update_template' handler
    1.46 @@ -434,7 +451,7 @@
    1.47  
    1.48      # ensure a VMManger is yet loaded
    1.49      gvm_mgr = vmmanager.VMManager.getInstance()
    1.50 -    
    1.51 +    gvm_mgr.start()
    1.52      # tweak sys.argv to control wep.py server start behavior
    1.53      sys.argv = [__file__, "8080"]
    1.54      server = web.application(opensecurity_urls, globals(), autoreload = False)