Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Thomas Blanc
scripts
Commits
0787ee49
Commit
0787ee49
authored
May 07, 2013
by
Raphael Cauderlier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Suppression du plugin useless GlobalPython.
parent
328743f7
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
771 deletions
+0
-771
bcfg2/Tools/GlobalPython.py
bcfg2/Tools/GlobalPython.py
+0
-683
bcfg2/plugins/GlobalPython.py
bcfg2/plugins/GlobalPython.py
+0
-88
No files found.
bcfg2/Tools/GlobalPython.py
deleted
100644 → 0
View file @
328743f7
This diff is collapsed.
Click to expand it.
bcfg2/plugins/GlobalPython.py
deleted
100644 → 0
View file @
328743f7
# -*- mode: python; coding: utf-8 -*-
#
# GlobalPython.py: extension du plugin bcfg2 Python rajoutant des informations sur la configuration de bcfg2
# ---------
#
# Copyright (C) 2013 Raphael Cauderlier <cauderlier@crans.org>
#
# This file 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 file 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 Street #330, Boston, MA 02111-1307, USA.
""" Plugin pour bcfg2 pour générer des fichiers de conf en prenant la sortie d'un
script python.
Ce plugin est une extension du plugin Python rajoutant des informations sur la configuration de bcfg2.
Les scripts python de génération de conf utilisant ce plugin peuvent par exemple lister les noms des clients
appartenant à un groupe donné. C'est très pratique pour générer la conf de clients qui ont un rôle de serveur
pour tous les autres clients en différenciant suivant leurs rôles.
Exemples : serveur de sauvegarde, monitoring.
"""
__all__
=
[
"GlobalPython"
]
import
Python
import
Bcfg2.Server.Plugins.Metadata
import
sys
,
binascii
sys
.
path
.
append
(
'/usr/scripts/bcfg2'
)
import
pygen
class
GlobalPython
(
Python
.
Python
):
"""The GlobalPython generator implements a templating mechanism for configuration files
extending the PythonGenerator by access to metadata of all the clients"""
name
=
'Python'
__version__
=
'1.0'
__author__
=
'cauderlier@crans.org'
def
__init__
(
self
,
core
,
datastore
):
Python
.
Python
.
__init__
(
self
,
core
,
datastore
)
global_metadata
=
Bcfg2
.
Server
.
Plugins
.
Metadata
.
Metadata
(
core
,
datastore
)
def
BuildEntry
(
self
,
entry
,
metadata
):
'''Construit le fichier'''
code
=
self
.
codes
[
entry
.
get
(
'name'
)]
fname
=
entry
.
get
(
'realname'
,
entry
.
get
(
'name'
))
debug
(
"building config file: %s"
%
fname
,
'blue'
)
env
=
pygen
.
Environment
()
env
[
"global_metadata"
]
=
self
.
global_metadata
env
[
"metadata"
]
=
metadata
env
[
"properties"
]
=
self
.
properties
env
[
"include"
]
=
lambda
incfile
:
Python
.
include
(
env
,
incfile
)
env
[
"dump"
]
=
lambda
incfile
:
Python
.
dump
(
env
,
incfile
)
env
[
"info"
]
=
{
'owner'
:
'root'
,
'group'
:
'root'
,
'perms'
:
0644
}
env
.
included
=
set
([])
try
:
Python
.
include
(
env
,
"common"
)
Python
.
include
(
env
,
"global_common"
)
text
=
pygen
.
generate
(
code
,
env
,
logger
)
except
Exception
,
e
:
Python
.
log_traceback
(
fname
,
'exec'
,
e
)
raise
Bcfg2
.
Server
.
Plugin
.
PluginExecutionError
info
=
env
[
"info"
]
if
info
.
get
(
'encoding'
,
''
)
==
'base64'
:
text
=
binascii
.
b2a_base64
(
text
)
# lxml n'accepte que de l'ascii ou de l'unicode
try
:
entry
.
text
=
text
.
decode
(
"UTF-8"
)
except
:
# solution de fallback
entry
.
text
=
text
.
decode
(
"ISO8859-15"
)
Python
.
debug
(
entry
.
text
)
entry
.
attrib
[
'owner'
]
=
info
.
get
(
'owner'
,
'root'
)
entry
.
attrib
[
'group'
]
=
info
.
get
(
'group'
,
'root'
)
entry
.
attrib
[
'perms'
]
=
oct
(
info
.
get
(
'perms'
,
0644
))
if
'encoding'
in
info
:
entry
.
attrib
[
'encoding'
]
=
info
[
'encoding'
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment