1 ##############################################################################
3 # Copyright (c) 2012 Vifib SARL and Contributors. All Rights Reserved.
5 # WARNING: This program as such is intended to be used by professional
6 # programmers who take the whole responsibility of assessing all potential
7 # consequences resulting from its eventual inadequacies and bugs
8 # End users who are looking for a ready-to-use solution with commercial
9 # guarantees and support are strongly adviced to contract a Free Software
12 # This program is Free Software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License
14 # as published by the Free Software Foundation; either version 3
15 # of the License, or (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 ##############################################################################
28 from ConfigParser
import RawConfigParser
32 Retrieves slap partition parameters, and makes them available to other
33 buildout section in various ways, and in various encodings.
34 Populates the buildout section it is used in with all slap partition
41 ${slap-connection:server-url}
43 Path of files containing key and certificate for secure connection to
46 ${slap-connection:key-file}
47 ${slap-connection:cert-file}
51 ${slap-connection:computer-id}
55 ${slap-connection:partition-id}
59 Current partition's software type.
61 Dict of all parameters.
63 One key per partition parameter.
64 Partition parameter whose name cannot be represented unambiguously in
65 buildout syntax are ignored. They cannot be accessed from buildout syntax
66 anyway, and are available through "configuration" output key.
69 # XXX: used to detect if a configuration key is a valid section key. This
70 # assumes buildout uses ConfigParser - which is currently the case.
71 OPTCRE_match
= RawConfigParser
.OPTCRE
.match
73 def __init__(self
, buildout
, name
, options
):
74 slap
= slapos
.slap
.slap()
75 slap
.initializeConnection(
80 parameter_dict
= slap
.registerComputerPartition(
83 ).getInstanceParameterDict()
84 # XXX: those are not partition parameters, strictly speaking.
85 # Discard them, and make them available as separate section keys.
86 options
['slap-software-type'] = parameter_dict
.pop(
88 del parameter_dict
['ip_list']
89 options
['configuration'] = parameter_dict
90 match
= self
.OPTCRE_match
91 for key
, value
in parameter_dict
.iteritems():
92 if match(key
) is not None:
94 options
['configuration.' + key
] = value
96 install
= update
= lambda self
: []