|
Lines 36-42
import re
Link Here
|
| 36 |
import string |
36 |
import string |
| 37 |
import base64 |
37 |
import base64 |
| 38 |
import os |
38 |
import os |
| 39 |
import subprocess |
|
|
| 40 |
import traceback |
39 |
import traceback |
| 41 |
|
40 |
|
| 42 |
import univention.debug |
41 |
import univention.debug |
|
Lines 47-53
import univention.admin.modules
Link Here
|
| 47 |
import univention.admin.objects |
46 |
import univention.admin.objects |
| 48 |
from univention.admin.layout import Tab, Group |
47 |
from univention.admin.layout import Tab, Group |
| 49 |
import univention.config_registry |
48 |
import univention.config_registry |
| 50 |
import univention.admin.ipaddress |
|
|
| 51 |
|
49 |
|
| 52 |
univention.admin.modules.update() |
50 |
univention.admin.modules.update() |
| 53 |
|
51 |
|
|
Lines 454-460
def _doit(arglist):
Link Here
|
| 454 |
arg=None |
452 |
arg=None |
| 455 |
binddn=None |
453 |
binddn=None |
| 456 |
bindpwd=None |
454 |
bindpwd=None |
| 457 |
list_policies=False |
|
|
| 458 |
policies_with_DN=False |
455 |
policies_with_DN=False |
| 459 |
policyOptions=[] |
456 |
policyOptions=[] |
| 460 |
logfile='/var/log/univention/admin-cmd.log' |
457 |
logfile='/var/log/univention/admin-cmd.log' |
|
Lines 1146-1244
def _doit(arglist):
Link Here
|
| 1146 |
for el in references['univentionPolicyReference']: |
1143 |
for el in references['univentionPolicyReference']: |
| 1147 |
out.append(' %s: %s' % ( 'univentionPolicyReference', |
1144 |
out.append(' %s: %s' % ( 'univentionPolicyReference', |
| 1148 |
_2utf8( s.tostring( el ) ) ) ) |
1145 |
_2utf8( s.tostring( el ) ) ) ) |
| 1149 |
|
|
|
| 1150 |
if list_policies: |
| 1151 |
utf8_objectdn = _2utf8( univention.admin.objects.dn( object ) ) |
| 1152 |
p1 = subprocess.Popen(['univention_policy_result'] + policyOptions + [utf8_objectdn], stdout=subprocess.PIPE) |
| 1153 |
policyResults = p1.communicate()[0].split('\n') |
| 1154 |
|
| 1155 |
out.append(" Policy-based Settings:") |
| 1156 |
policy='' |
| 1157 |
value=[] |
| 1158 |
client={} |
| 1159 |
for line in policyResults: |
| 1160 |
if not (line.strip() == "" or line.strip()[:4]=="DN: " or line.strip()[:7]=="POLICY "): |
| 1161 |
out.append(" %s"%line.strip()) |
| 1162 |
if policies_with_DN: |
| 1163 |
clsplit=string.split(line.strip(), ': ') |
| 1164 |
if clsplit[0] == 'Policy': |
| 1165 |
if policy: |
| 1166 |
client[attribute]=[policy, value] |
| 1167 |
value=[] |
| 1168 |
policy=clsplit[1] |
| 1169 |
elif clsplit[0] == 'Attribute': |
| 1170 |
attribute=clsplit[1] |
| 1171 |
elif clsplit[0] == 'Value': |
| 1172 |
value.append(clsplit[1]) |
| 1173 |
else: |
| 1174 |
clsplit=string.split(line.strip(), '=') |
| 1175 |
if not client.has_key(clsplit[0]): |
| 1176 |
client[clsplit[0]] = [] |
| 1177 |
client[clsplit[0]].append(clsplit[1]) |
| 1178 |
|
| 1179 |
if policies_with_DN: |
| 1180 |
client[attribute]=[policy, value] |
| 1181 |
value=[] |
| 1182 |
|
| 1183 |
out.append('') |
| 1184 |
|
| 1185 |
if module_name == 'dhcp/host': |
| 1186 |
subnet_module=univention.admin.modules.get('dhcp/subnet') |
| 1187 |
for subnet in univention.admin.modules.lookup(subnet_module, co, lo, scope='sub', superordinate=superordinate, base='', filter=''): |
| 1188 |
|
| 1189 |
if univention.admin.ipaddress.ip_is_in_network(subnet['subnet'], subnet['subnetmask'], object['fixedaddress'][0]): |
| 1190 |
utf8_subnet_dn = _2utf8( subnet.dn ) |
| 1191 |
p1 = subprocess.Popen(['univention_policy_result'] + policyOptions + [utf8_subnet_dn], stdout=subprocess.PIPE) |
| 1192 |
policyResults = p1.communicate()[0].split('\n') |
| 1193 |
out.append(" Subnet-based Settings:") |
| 1194 |
ddict={} |
| 1195 |
policy='' |
| 1196 |
value=[] |
| 1197 |
for line in policyResults: |
| 1198 |
if not (line.strip() == "" or line.strip()[:4]=="DN: " or line.strip()[:7]=="POLICY "): |
| 1199 |
out.append(" %s"%line.strip()) |
| 1200 |
if policies_with_DN: |
| 1201 |
subsplit=string.split(line.strip(), ': ') |
| 1202 |
if subsplit[0] == 'Policy': |
| 1203 |
if policy: |
| 1204 |
ddict[attribute]=[policy, value] |
| 1205 |
value=[] |
| 1206 |
policy=subsplit[1] |
| 1207 |
elif subsplit[0] == 'Attribute': |
| 1208 |
attribute=subsplit[1] |
| 1209 |
elif subsplit[0] == 'Value': |
| 1210 |
value.append(subsplit[1]) |
| 1211 |
else: |
| 1212 |
subsplit=string.split(line.strip(), '=') |
| 1213 |
if not ddict.has_key(subsplit[0]): |
| 1214 |
ddict[subsplit[0]] = [] |
| 1215 |
ddict[subsplit[0]].append(subsplit[1]) |
| 1216 |
|
| 1217 |
out.append('') |
| 1218 |
|
| 1219 |
if policies_with_DN: |
| 1220 |
ddict[attribute]=[policy, value] |
| 1221 |
value=[] |
| 1222 |
|
| 1223 |
out.append(" Merged Settings:") |
| 1224 |
|
| 1225 |
for key in ddict.keys(): |
| 1226 |
if not client.has_key(key): |
| 1227 |
client[key]=ddict[key] |
| 1228 |
|
| 1229 |
if policies_with_DN: |
| 1230 |
for key in client.keys(): |
| 1231 |
out.append(" Policy: "+client[key][0]) |
| 1232 |
out.append(" Attribute: "+key) |
| 1233 |
for i in range(0, len(client[key][1])): |
| 1234 |
out.append(" Value: "+client[key][1][i]) |
| 1235 |
else: |
| 1236 |
for key in client.keys(): |
| 1237 |
for i in range(0, len(client[key])): |
| 1238 |
out.append(" %s=%s" % (key, client[key][i])) |
| 1239 |
out.append('') |
| 1240 |
|
| 1241 |
out.append('') |
| 1242 |
except univention.admin.uexceptions.ldapError, errmsg: |
1146 |
except univention.admin.uexceptions.ldapError, errmsg: |
| 1243 |
out.append('%s' %str(errmsg)) |
1147 |
out.append('%s' %str(errmsg)) |
| 1244 |
return out + ["OPERATION FAILED"] |
1148 |
return out + ["OPERATION FAILED"] |