for creole's zephir2 branch

This commit is contained in:
2019-11-23 08:17:35 +01:00
commit 841643e76e
700 changed files with 68183 additions and 0 deletions

235
data/creole.dtd Normal file
View File

@ -0,0 +1,235 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- ===================================================================== -->
<!-- Definition de la DTD du fichier creole -->
<!-- ===================================================================== -->
<!--
# Conception :
# Eole (http://eole.orion.education.fr)
# Copyright (C) 2005-2018
# distribue sous la licence GPL-2
# En attendant une traduction officielle de la GPL, la notice de
# copyright demeure en anglais.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Se reporter a la documentation envoyee avec le programme pour la notice.
-->
<!--================ -->
<!-- root element -->
<!-- =============== -->
<!ELEMENT creole (containers | files | family_action | variables | constraints | help)*>
<!-- ============== -->
<!-- files element -->
<!-- ============== -->
<!ELEMENT family_action (action)>
<!ATTLIST family_action name CDATA #REQUIRED>
<!ATTLIST family_action description CDATA #IMPLIED>
<!ATTLIST family_action color CDATA #IMPLIED>
<!ATTLIST family_action image CDATA #IMPLIED>
<!ELEMENT action ((input* | profile* | ewtapp* | tag* | saltaction*)*)>
<!ATTLIST action type (form|custom|external|reader|apache) "custom">
<!ATTLIST action title CDATA #REQUIRED>
<!ATTLIST action description CDATA #REQUIRED>
<!ATTLIST action rewrite CDATA #IMPLIED>
<!ATTLIST action image CDATA #IMPLIED>
<!ATTLIST action actionlist CDATA #IMPLIED>
<!-- for apache action -->
<!ATTLIST action apache_path CDATA #IMPLIED>
<!ATTLIST action apache_path_type (FilenameOption|SymLinkOption) "FilenameOption">
<!-- for external action -->
<!ATTLIST action url CDATA #IMPLIED>
<!ATTLIST action url_type (URLOption|SymLinkOption) "URLOption">
<!-- for form action -->
<!ATTLIST action save (True|False) "False">
<!ELEMENT files ((service* | service_access* | service_restriction* | package* | file*)*)>
<!ELEMENT containers ((container* | all*)*)>
<!ELEMENT container ((service* | service_access* | service_restriction* | interface* | package* | file* | disknod* | host* | fstab*)*) >
<!ATTLIST container name CDATA #REQUIRED >
<!ATTLIST container id CDATA #IMPLIED >
<!ATTLIST container group CDATA #IMPLIED >
<!ELEMENT all ((service* | interface* | package* | file* | disknod* | host* | fstab*)*) >
<!ELEMENT service (#PCDATA)>
<!ATTLIST service servicelist CDATA #IMPLIED >
<!ATTLIST service instance_mode (when_container|when_no_container|always) "always">
<!ATTLIST service method (systemd|upstart|apache|network) "systemd">
<!ATTLIST service redefine (True|False) "False">
<!ELEMENT input (#PCDATA)>
<!ELEMENT profile (#PCDATA)>
<!ELEMENT ewtapp (#PCDATA)>
<!ELEMENT tag (#PCDATA)>
<!ELEMENT saltaction (#PCDATA)>
<!ELEMENT service_access ((port | tcpwrapper)*)>
<!ATTLIST service_access service CDATA #REQUIRED >
<!ELEMENT port (#PCDATA)> <!--port_type-->
<!ATTLIST port port_type (PortOption|SymLinkOption) "PortOption">
<!ATTLIST port service_accesslist CDATA #IMPLIED >
<!ATTLIST port protocol (tcp|udp) "tcp">
<!ELEMENT tcpwrapper (#PCDATA)> <!--tcpwrapper_type-->
<!ATTLIST tcpwrapper tcpwrapper_type (UnicodeOption|SymLinkOption) "UnicodeOption">
<!ATTLIST tcpwrapper service_accesslist CDATA #IMPLIED >
<!ELEMENT service_restriction (ip*)>
<!ATTLIST service_restriction service CDATA #REQUIRED >
<!ELEMENT ip (#PCDATA)> <!--ip_type-->
<!ATTLIST ip service_restrictionlist CDATA #IMPLIED >
<!ATTLIST ip ip_type (NetworkOption|SymLinkOption) "NetworkOption">
<!ATTLIST ip interface_type (UnicodeOption|SymLinkOption) "UnicodeOption">
<!ATTLIST ip interface CDATA #REQUIRED> <!--interface_type-->
<!ATTLIST ip netmask_type (NetmaskOption|SymLinkOption) "NetmaskOption">
<!ATTLIST ip netmask CDATA "255.255.255.255"> <!--netmask_type-->
<!ELEMENT interface (#PCDATA)>
<!ATTLIST interface interfacelist CDATA #IMPLIED >
<!ATTLIST interface linkto CDATA #REQUIRED >
<!ATTLIST interface ip CDATA #REQUIRED> <!--SymLinkOption-->
<!ATTLIST interface ip_type (SymLinkOption) "SymLinkOption">
<!ATTLIST interface mask CDATA #REQUIRED> <!--SymLinkOption-->
<!ATTLIST interface mask_type (SymLinkOption) "SymLinkOption">
<!ATTLIST interface bcast CDATA #IMPLIED> <!--SymLinkOption-->
<!ATTLIST interface bcast_type (SymLinkOption) "SymLinkOption">
<!ATTLIST interface gateway CDATA #IMPLIED> <!--SymLinkOption-->
<!ATTLIST interface gateway_type (SymLinkOption) "SymLinkOption">
<!ATTLIST interface method (bridge|macvlan) "macvlan" >
<!ATTLIST interface redefine (True|False) "False">
<!ELEMENT host EMPTY >
<!ATTLIST host hostlist CDATA #IMPLIED >
<!ATTLIST host name CDATA #REQUIRED > <!--SymLinkOption-->
<!ATTLIST host name_type (SymLinkOption) "SymLinkOption">
<!ATTLIST host ip CDATA #REQUIRED > <!--SymLinkOption-->
<!ATTLIST host ip_type (SymLinkOption) "SymLinkOption">
<!ATTLIST host crossed (True|False) "True" >
<!ATTLIST host instance_mode (when_container|when_no_container|always) "always">
<!ATTLIST host comment CDATA #IMPLIED >
<!ELEMENT fstab EMPTY >
<!ATTLIST fstab name CDATA #REQUIRED> <!--name_type-->
<!ATTLIST fstab name_type (FilenameOption|SymLinkOption) "FilenameOption">
<!ATTLIST fstab type (bind|normal) "bind">
<!ATTLIST fstab fstype (auto|ext3|ext4|nfs|smb) "auto">
<!ATTLIST fstab mount_point CDATA #IMPLIED> <!--mount_point_type-->
<!ATTLIST fstab mount_point_type (FilenameOption|SymLinkOption) "FilenameOption">
<!ATTLIST fstab options CDATA #IMPLIED>
<!ATTLIST fstab checks CDATA #IMPLIED>
<!ATTLIST fstab fstablist CDATA #IMPLIED>
<!ATTLIST fstab instance_mode (when_container|when_no_container|always) "when_container">
<!ELEMENT package (#PCDATA)>
<!ATTLIST package instance_mode (when_container|when_no_container|always) "always">
<!ELEMENT disknod (#PCDATA)>
<!ELEMENT file EMPTY>
<!ATTLIST file name CDATA #REQUIRED >
<!ATTLIST file source CDATA #IMPLIED>
<!ATTLIST file mode CDATA #IMPLIED >
<!ATTLIST file owner CDATA #IMPLIED >
<!ATTLIST file group CDATA #IMPLIED >
<!ATTLIST file filelist CDATA #IMPLIED >
<!ATTLIST file mkdir (True|False) "False">
<!ATTLIST file instance_mode (when_container|when_no_container|always) "always">
<!ATTLIST file rm (True|False) "False">
<!ATTLIST file del_comment CDATA #IMPLIED >
<!ATTLIST file redefine (True|False) "False">
<!ELEMENT variables (family*, separators*)>
<!ELEMENT family (#PCDATA | variable)*>
<!ATTLIST family name CDATA #REQUIRED>
<!ATTLIST family description CDATA #IMPLIED>
<!ATTLIST family mode (basic|normal|expert) "basic">
<!ATTLIST family icon CDATA #IMPLIED>
<!ATTLIST family hidden (True|False) "False">
<!ELEMENT variable (#PCDATA | value)*>
<!ATTLIST variable name CDATA #REQUIRED>
<!ATTLIST variable type CDATA #IMPLIED>
<!ATTLIST variable description CDATA #IMPLIED>
<!ATTLIST variable hidden (True|False) "False">
<!ATTLIST variable disabled (True|False) "False">
<!ATTLIST variable multi (True|False) "False">
<!ATTLIST variable redefine (True|False) "False">
<!ATTLIST variable exists (True|False) "True">
<!ATTLIST variable mandatory (True|False) "False">
<!ATTLIST variable auto_freeze (True|False) "False">
<!ATTLIST variable auto_save (True|False) "False">
<!ATTLIST variable mode (basic|normal|expert) "normal">
<!ATTLIST variable remove_check (True|False) "False">
<!ATTLIST variable remove_condition (True|False) "False">
<!ELEMENT separators (separator*)>
<!ELEMENT separator (#PCDATA)>
<!ATTLIST separator name CDATA #REQUIRED>
<!ATTLIST separator never_hidden CDATA #IMPLIED>
<!ELEMENT value (#PCDATA)>
<!ELEMENT constraints ((fill* | check* | condition* | auto* | group*)*)>
<!ELEMENT fill (param*)>
<!ATTLIST fill name CDATA #REQUIRED>
<!ATTLIST fill target CDATA #REQUIRED>
<!ELEMENT check (param*)>
<!ATTLIST check name CDATA #REQUIRED>
<!ATTLIST check target CDATA #REQUIRED>
<!ATTLIST check level (error|warning) "error">
<!ATTLIST check probe (True|False) "False">
<!ELEMENT auto ((param)*)>
<!ATTLIST auto name CDATA #REQUIRED>
<!ATTLIST auto target CDATA #REQUIRED>
<!ELEMENT condition ((target | param)+ )>
<!ATTLIST condition name CDATA #REQUIRED>
<!ATTLIST condition source CDATA #REQUIRED>
<!ATTLIST condition fallback (True|False) "False">
<!ELEMENT group (slave+)>
<!ATTLIST group master CDATA #REQUIRED>
<!ELEMENT param (#PCDATA)>
<!ATTLIST param type (string|eole|number|container|context|python) "string">
<!ATTLIST param name CDATA #IMPLIED>
<!ATTLIST param hidden (True|False) "True">
<!ATTLIST param optional (True|False) "False">
<!ELEMENT target (#PCDATA)>
<!ATTLIST target type (family|filelist|servicelist|interfacelist|variable|service_accesslist|service_restrictionlist|hostlist|fstablist|actionlist) "variable">
<!ATTLIST target optional (True|False) "False">
<!ELEMENT slave (#PCDATA)>
<!ELEMENT help ((variable* | family*)*)>

64
data/diag.py Executable file
View File

@ -0,0 +1,64 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
###########################################################################
# Eole NG - 2009
# Copyright Pole de Competence Eole (Ministere Education - Academie Dijon)
# http://eole.orion.education.fr - eole@ac-dijon.fr
#
# Licence CeCill
# cf: http://www.cecill.info/licences.fr.html
###########################################################################
import sys
import socket
from os.path import isfile
from os import system, stat
from pyeole.httprequest import HTTPRequest
from creole.config import configeol
from creole.client import CreoleClient
client = CreoleClient()
# adresse IP et port du serveur d'enregistrement
server = "http://194.167.18.21/apps/AutoDiag/index.n/diagnose"
md5file = "/etc/eole/.server.MD5"
module = "%s-%s" % (client.get_creole('eole_module'), client.get_creole('eole_version'))
def get_md5():
""" calcul de l'identifiant md5 """
if not isfile(md5file) or stat(md5file).st_size == 0:
system("md5sum %s | awk '{print $1}' > %s" % (configeol, md5file))
fp = file(md5file)
return (fp.read().split()[0])
def get_proxy():
""" récupération du proxy à utiliser """
if client.get_creole('activer_proxy_client') == 'oui':
return "http://{0}:{1}".format(
client.get_creole('proxy_client_adresse'),
client.get_creole('proxy_client_port'))
return ''
if __name__ == "__main__":
id5 = get_md5()
rne = client.get_creole('numero_etab')
data = {"ID5":id5, "module":module, "rne":rne, "dep":rne[0:3]}
socket.setdefaulttimeout(5)
proxy = get_proxy()
if proxy != '':
# essai avec proxy
try:
req = HTTPRequest(proxy={'http':proxy})
req.request(server, post_datas=data)
except:
pass
else:
sys.exit(0)
# essai sans proxy
try:
req = HTTPRequest()
req.request(server, post_datas=data)
except:
sys.exit(1)
else:
sys.exit(0)

2
data/funcs/__init__.py Normal file
View File

@ -0,0 +1,2 @@
"""Module de fonctions supplémentaires accessibles à creole. Tous les fichiers python
contenus dans ce répertoire sont lus par le module eosfunc de creole"""

69
data/gen_certif.py Executable file
View File

@ -0,0 +1,69 @@
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
script de generation d'un certificat ssl
prend un nom de fichier facultatif en argument (destination du certificat)
usage::
soit
%prog (-fc) [nom_certif]
soit
%prog (-f)
si [nom_certif] non renseigne, regenere tous les certificats par defaut ainsi que la ca locale.
Sinon, ne genere que [nom_certif]
-f :force la regeneration du (ou des) certificat(s) s'il(s) existe(nt)
-c : dans le cas de la generation d'un seul certificat, on copie la clef
"""
import sys, os
from optparse import OptionParser
from creole import cert
from pyeole.encode import normalize
def parse_command_line():
parser = OptionParser(__doc__)
parser.add_option("-c",
action="store_true", dest="copy", default=False,
help="copie de la clef")
parser.add_option("-f",
action="store_true", dest="regen", default=False,
help="force la regeneration de la clef")
options, args = parser.parse_args()
if len(args) > 1:
parser.error("Il faut au maximum un certificat")
return options, args
options, args = parse_command_line()
regen = options.regen
copy = options.copy
if len(args) == 1:
certfile = args[0]
else:
certfile = None
try:
cert.rehash_if_needed()
if certfile != None:
certfile = os.path.abspath(certfile)
dest_dir = os.path.dirname(certfile)
if not os.path.isdir(dest_dir):
print "Répertoire de destination inexistant (%s)" % dest_dir
sys.exit(1)
print "Generation du certificat machine"
cert.gen_certif(certfile, regen=regen, copy_key=copy)
else:
# génération de tous les certificats (CA, eole, scribe...)
cert.gen_certs(regen=regen)
sys.exit(0)
except Exception, err:
print "Erreur : "
print u'{0}'.format(normalize(err))
sys.exit(1)

26
data/testpatches.py Executable file
View File

@ -0,0 +1,26 @@
#! /usr/bin/env python
# -*- coding: UTF-8 -*-
"""
Test des patches pour diagnose
réutilisation du code de zephir-client
"""
import sys
from glob import glob
from os.path import basename
from creole import utils
from creole.config import patch_dir
from zephir.monitor.agents import patches
from os.path import join
patchs = glob(join(patch_dir, '*.patch'))
patchs.extend(glob(join(patch_dir, 'variante', '*.patch')))
err = []
for patch in patchs:
verif = patches.verify_patch(patch).values()
if len(verif) > 0 and len(verif[0]) > 0:
err.append(basename(patch))
if len(err) != 0:
utils.print_red('Erreur')
print "fichiers : %s" % (", ".join(err),)
else:
utils.print_green('Ok')