~therve/landscape-client/285086-customgraph-acceptedtype

« back to all changes in this revision

Viewing changes to landscape/broker/configuration.py

  • Committer: Jamu Kakar
  • Date: 2008-08-02 00:48:02 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: jkakar@kakar.ca-20080802004802-031w63iw6avddt2j
- New check_config decorator is used in BrokerConfiguationScript to
  ensure that values provided on the command-line aren't requested
  during interactive setup.
- New --script-users, --included-manager-plugins, --non-interactive
  and --disable options defined.  They don't work entirely correctly
  yet.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    stream.flush()
31
31
 
32
32
 
 
33
def check_config(*args):
 
34
    names = args
 
35
    def decorator(function):
 
36
        def decorated(*args, **kwargs):
 
37
            self = args[0]
 
38
            for name in names:
 
39
                if name in self.config.get_command_line_options():
 
40
                    break
 
41
            else:
 
42
                function(*args, **kwargs)
 
43
        return decorated
 
44
    return decorator
 
45
 
 
46
 
33
47
class BrokerConfigurationScript(object):
34
48
    """
35
49
    An interactive procedure which manages the prompting and temporary storage
117
131
            else:
118
132
                return default
119
133
 
 
134
    @check_config("computer_title")
120
135
    def query_computer_title(self):
121
136
        self.show_help(
122
137
            """
128
143
 
129
144
        self.prompt("computer_title", "This computer's title", True)
130
145
 
 
146
    @check_config("account_name")
131
147
    def query_account_name(self):
132
148
        self.show_help(
133
149
            """
139
155
 
140
156
        self.prompt("account_name", "Account name", True)
141
157
 
 
158
    @check_config("registration_password")
142
159
    def query_registration_password(self):
143
160
        self.show_help(
144
161
            """
154
171
        self.password_prompt("registration_password",
155
172
                             "Account registration password")
156
173
 
 
174
    @check_config("http_proxy", "https_proxy")
157
175
    def query_proxies(self):
158
176
        self.show_help(
159
177
            """
166
184
        self.prompt("http_proxy", "HTTP proxy URL")
167
185
        self.prompt("https_proxy", "HTTPS proxy URL")
168
186
 
 
187
    @check_config("include_manager_plugins", "script_users")
169
188
    def query_script_plugin(self):
170
189
        self.show_help(
171
190
            """
176
195
            also configurable.
177
196
            """)
178
197
        msg = "Enable script execution?"
179
 
        included_plugins = getattr(self.config, "include_manager_plugins", "")
 
198
        included_plugins = getattr(self.config, "include_manager_plugins")
 
199
        if not included_plugins:
 
200
            included_plugins = ""
180
201
        included_plugins = [x.strip() for x in included_plugins.split(",")]
181
202
        if included_plugins == [""]:
182
203
            included_plugins = []
221
242
        self.query_proxies()
222
243
        self.query_script_plugin()
223
244
 
 
245
 
224
246
def setup_init_script():
225
247
    sysvconfig = SysVConfig()
226
248
    if not sysvconfig.is_configured_to_run():
258
280
    config.write()
259
281
    return config
260
282
 
 
283
 
261
284
def register(config, reactor=None):
262
285
    """Instruct the Landscape Broker to register the client.
263
286