| | 91 | The webinterface to lemon uses php and access to the backend. |
| | 92 | It also needs to know what machines to expect and based on their properties, how to group them. |
| | 93 | This is (for now) done with a nlist called NODES_PROPS. |
| | 94 | A basic example is |
| | 95 | {{{ |
| | 96 | ## manual list, is respected when autocompleting |
| | 97 | variable NODES_PROPS = nlist( |
| | 98 | escape("egon.iihe.ac.be"),nlist('type','MON','monitoring','yes'), |
| | 99 | ); |
| | 100 | }}} |
| | 101 | The name of the template that sets this variable is controlled through |
| | 102 | {{{ |
| | 103 | variable LEMON_NODES_PROPERTIES_TEMPLATE ?= 'pro_nodes_properties'; |
| | 104 | }}} |
| | 105 | The default value (ie behaviour in case it's not defined) for the {{{'monioting'}}} is controlled through |
| | 106 | {{{ |
| | 107 | variable LEMON_NODES_PROPERTIES_DEFAULT_MONITORING ?= 'yes'; |
| | 108 | }}} |
| | 111 | === NODES_PROPS example === |
| | 112 | An example used at IIHE to generate the monitoring part of NODES_PROPS |
| | 113 | {{{ |
| | 114 | template site/lemon_nodes; |
| | 115 | |
| | 116 | ## in case of missing monitoring field |
| | 117 | variable LEMON_NODES_PROPERTIES_DEFAULT_MONITORING = 'yes'; |
| | 118 | |
| | 119 | ## manual list, is respected when autocompleting |
| | 120 | variable NODES_PROPS = nlist( |
| | 121 | escape("egon.iihe.ac.be"),nlist('type','MON'), |
| | 122 | ); |
| | 123 | |
| | 124 | ## list for order (first match is ok) |
| | 125 | variable LEMON_PROPS_REGEXP_TYPE = list('WN','SE_DISK','CE','NFS'); |
| | 126 | variable LEMON_PROPS_REGEXP_MAP = nlist( |
| | 127 | 'MON','XXXXX', |
| | 128 | 'WN','node', |
| | 129 | 'SE_DISK','behar', |
| | 130 | 'CE','gridce', |
| | 131 | 'NFS','fileserv', |
| | 132 | ); |
| | 133 | |
| | 134 | |
| | 135 | ### autocomplete this list based on DB_MACHINE and regexp |
| | 136 | variable NODES_PROPS = { |
| | 137 | tmp = NODES_PROPS; |
| | 138 | dbm = DB_MACHINE; |
| | 139 | |
| | 140 | ok = first(dbm, k, v); |
| | 141 | while (ok) { |
| | 142 | if (exists(NODES_PROPS[k])) { |
| | 143 | ok = next(dbm, k, v); |
| | 144 | } else { |
| | 145 | mach = unescape(k); |
| | 146 | mach_to_use = mach; |
| | 147 | if (LEMON_SHORTHOSTNAME) { |
| | 148 | m = matches(mach,'([^\\.]+)(\..*)?'); |
| | 149 | mach_to_use = m[1]; |
| | 150 | }; |
| | 151 | regs_order = LEMON_PROPS_REGEXP_TYPE; |
| | 152 | ok2 = first(regs_order, k2,v2); |
| | 153 | while (ok2) { |
| | 154 | if (exists(LEMON_PROPS_REGEXP_MAP[v2])) { |
| | 155 | reg = LEMON_PROPS_REGEXP_MAP[v2]; |
| | 156 | if (match(mach,reg)) { |
| | 157 | tmp = merge(tmp,nlist(escape(mach_to_use),nlist('type',v2))); |
| | 158 | ok2 = false; |
| | 159 | } else { |
| | 160 | ok2 = next(regs_order, k2,v2); |
| | 161 | }; |
| | 162 | }; |
| | 163 | }; |
| | 164 | |
| | 165 | ok = next(dbm, k, v); |
| | 166 | }; |
| | 167 | }; |
| | 168 | |
| | 169 | return(tmp); |
| | 170 | }; |
| | 171 | }}} |
| | 172 | |