| Home | Trees | Indices | Help |
|
|---|
|
|
1 # osh
2 # Copyright (C) 2005 Jack Orenstein <jao@geophile.com>
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 """This module contains miscellaneous functions builtin to osh.
19 See also the C{osh.process} module for other builtins.
20 """
21
22 import config
23 from core import add_to_namespace
24 from cluster import cluster_named
25
26 #----------------------------------------------------------------------
27
28 # processes
29
30 from process import processes
31
32 #----------------------------------------------------------------------
33
34 # ifelse
35
37 """Returns C{if_true} if C{predicate} is true, C{if_false} otherwise.
38 Both C{if_true} and C{if_false} are evaluated unconditionally.
39 (This function is provided because the Python equivalent, the if expression,
40 is not present prior to release 2.5.)
41 """
42 if predicate:
43 return if_true
44 else:
45 return if_false
46
47 #----------------------------------------------------------------------
48
49 # hosts
50
52 """Returns the value of C{cluster_name}'s C{hosts} configuration value,
53 as specified in C{.oshrc}. Returns a map containing entries
54 in which the key is the node's name, and the value is the node's
55 IP address or DNS name.
56 """
57 cluster = cluster_named(cluster_name)
58 map = {}
59 for host in cluster.hosts:
60 map[host.name] = host.address
61 return map
62
63 #----------------------------------------------------------------------
64
65 add_to_namespace('processes', processes)
66 add_to_namespace('ifelse', ifelse)
67 add_to_namespace('hosts', hosts)
68
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0beta1 on Tue Jan 1 16:27:54 2008 | http://epydoc.sourceforge.net |