zephir.backend.backend_tap

Package zephir :: Package backend :: Module backend_tap |
[frames] | no frames]

# Source Code for Module zephir.backend.backend_tap

      1  # -*- coding: UTF-8 -*-
      2  ###########################################################################
      3  # Eole NG - 2007
      4  # Copyright Pole de Competence Eole  (Ministere Education - Academie Dijon)
      5  # Licence CeCill  cf /root/LicenceEole.txt
      6  # eole@ac-dijon.fr
      7  #
      8  # backend_tap.py
      9  #
     10  # création et démarrage des services backend zephir
     11  #
     12  ###########################################################################
     13  from twisted.application import internet, service
     14  from twisted.web import server,static
     15  from twisted.web.resource import Resource
     16  from twisted.python import usage
     17  import sys
     18
     19
     20  from zephir.backend.config import PATH_ZEPHIR, log, NO_LOCAL_AGENTS
     21  from zephir.certificats import ServerContextFactory
     22  from zephir.monitor.agentmanager import config as cfg
     23  from zephir.monitor.agentmanager.zephirservice import ZephirService
     24
     25  from zephir.backend import etabs_rpc
     26  from zephir.backend import users_rpc
     27  from zephir.backend import modules_rpc
     28  from zephir.backend import serveurs_rpc
     29  from zephir.backend import uucp_rpc
     30  from zephir.backend import services_rpc
     31  from zephir.backend import prelude_rpc
     32  from zephir.backend import scheduler_rpc
     33  from zephir.backend import sentinelle_rpc
     34  from zephir.backend import ent_rpc
     35  from zephir.backend import aaf_rpc
     36  from zephir.backend import local_rpc
     37  from zephir.backend import dicos_rpc
     38
     39  # options ligne de commande
     40
     41 -class Options(usage.Options):
     42      optParameters = [["portRPC", "x", 7080, "Numero de port pour le serveur xmlrpc."],
     43                       ["portHTTP", "p", 8090, "Numero de port pour le serveur HTTP"],
     44                       ["config", None, cfg.DEFAULT_CONFIG['config_dir'],
     45                        "Directory to search for configurations when loading agents"],
     46                       ["data", None, cfg.DEFAULT_CONFIG['state_dir'],
     47                        "Directory where state data will be stored"],
     48                       ["archive", None, cfg.DEFAULT_CONFIG['uucp_dir'],
     49                        "Directory where the upload archive will be created"],
     50                       ["static", None, cfg.DEFAULT_CONFIG['static_web_dir'],
     51                        "Directory for static web data (graphics, stylesheets...)"],
     52                      ]
     53
     54 -def makeService(config):
     55      config_ag = cfg.DEFAULT_CONFIG.copy()
     56      # log.startLogging(sys.stdout)
     57      # this could use some os.path.expanduser() and os.path.expandvars()
     58      config_ag['config_dir'] = "monitor/configs"
     59      config_ag['action_dir'] = "monitor/actions"
     60      config_ag['state_dir'] = "/var/lib/zephir/data"
     61      config_ag['uucp_dir'] = "/tmp"
     62      config_ag['static_web_dir'] = "/var/lib/zephir/sites"
     63      config_ag['static_base_url'] = "/sites"
     64      config_ag['tmp_data_dir'] = "monitor/data"
     65      # port TCP à écouter
     66      portRPC = int(config["portRPC"])
     67      portHTTP = int(config["portHTTP"])
     68      root = Resource()
     69      # service des agents
     70      if NO_LOCAL_AGENTS == "oui":
     71          Server3 = ZephirService(config_ag,root_resource=root).with_publisher()
     72      else:
     73          Server3 = ZephirService(config_ag,root_resource=root).with_updater_and_publisher()
     74      zephir_users = users_rpc.RPCUsers()
     75      # serveurs XMLRPC
     76      zephir_etabs = etabs_rpc.RPCEtabs(zephir_users)
     77      zephir_modules = modules_rpc.RPCModules(zephir_users)
     78      zephir_serveurs = serveurs_rpc.RPCServeurs(zephir_users, Server3.publisher.manager)
     79      zephir_uucp = uucp_rpc.RPCUucp(zephir_users, Server3.publisher.manager)
     80      zephir_services = services_rpc.RPCServices(zephir_users)
     81      zephir_prelude = prelude_rpc.RPCPrelude(zephir_users)
     82      zephir_scheduler = scheduler_rpc.RPCScheduler(zephir_users)
     83      zephir_sentinelle = sentinelle_rpc.RPCSentinelle(zephir_users, Server3.publisher.manager)
     84      zephir_entid = ent_rpc.ENTRPC(zephir_users)
     85      zephir_aaf = aaf_rpc.AAFRPC(zephir_users)
     86      zephir_local = local_rpc.RPCLocal(zephir_users)
     87      zephir_dicos = dicos_rpc.RPCDicos(zephir_users)
     88      # mise en place des modules de gestion zephir
     89      zephir_users.putSubHandler('etabs',zephir_etabs)
     90      zephir_users.putSubHandler('modules',zephir_modules)
     91      zephir_users.putSubHandler('serveurs',zephir_serveurs)
     92      zephir_users.putSubHandler('uucp',zephir_uucp)
     93      zephir_users.putSubHandler('services',zephir_services)
     94      zephir_users.putSubHandler('prelude',zephir_prelude)
     95      zephir_users.putSubHandler('scheduler',zephir_scheduler)
     96      zephir_users.putSubHandler('sentinelle',zephir_sentinelle)
     97      zephir_users.putSubHandler('entid',zephir_entid)
     98      zephir_users.putSubHandler('aaf',zephir_aaf)
     99      zephir_users.putSubHandler('local',zephir_local)
    100      zephir_users.putSubHandler('dicos',zephir_dicos)
    101      rpc_server = server.Site(zephir_users)
    102      # pages html de surveillance des serveurs
    103      root.putChild('sites',static.File(PATH_ZEPHIR+"sites/"))
    104      root.putChild('client',static.File(PATH_ZEPHIR+"sites/client"))
    105      root.putChild('static',static.File(PATH_ZEPHIR+"sites/"))
    106
    107      appli = service.Application("zephir_backend")
    108      myService = service.IServiceCollection(appli)
    109      Server3.setServiceParent(myService)
    110      # création des services
    111      Server2 = internet.SSLServer(portHTTP, server.Site(root),ServerContextFactory())
    112      Server2.setServiceParent(myService)
    113      Server1 = internet.SSLServer(portRPC, rpc_server, ServerContextFactory())
    114      Server1.startService = zephir_modules.startup
    115      Server1.stopService = zephir_modules.stop
    116      Server1local = internet.TCPServer(portRPC + 1, rpc_server, interface='localhost')
    117      Server1.setServiceParent(myService)
    118      Server1local.setServiceParent(myService)
    119      return myService
    120