# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
#
"""Name Service Cache Daemon (nscd) classes used by nscfg."""
"""Name Service Cache Daemon class. Represents the configuration
of the name service cache. See nscd.conf(4) for details."""
# Supported Property groups
'network', 'protocol', 'rpc', 'ether', 'netmask',
'bootparam', 'netgroup', 'service',
'printer', 'project', 'auth_attr', 'exec_attr',
'prof_attr', 'user_attr', 'tnrhtp', 'tnrhdb',
]
'networks', 'protocols', 'rpc', 'ethers', 'netmasks',
'bootparams', 'netgroup', 'services',
'printers', 'project', 'auth_attr', 'exec_attr',
'prof_attr', 'user_attr', 'tnrhtp', 'tnrhdb',
]
configPROPS = {
# 'enable_per_user_lookup': [ 'boolean', 'true' ],
# 'per_user_nscd_time_to_live': [ 'integer', '120' ],
'logfile': [ 'astring', '' ],
'debug_level': [ 'astring', '' ],
'debug_components': [ 'astring', '' ],
}
cachePROPS = {
'enable_cache': [ 'boolean', 'true' ],
'positive_time_to_live': [ 'integer', '3600' ],
'negative_time_to_live': [ 'integer', '5' ],
'keep_hot_count': [ 'integer', '20' ],
'check_files': [ 'boolean', 'true' ],
'check_file_interval': [ 'integer', '0' ],
'maximum_entries_allowed': [ 'integer', '' ],
}
debug_comp = {
'cache': 0x0001,
'switch': 0x0002,
'frontend': 0x0004,
'self_cred': 0x0008,
'admin': 0x0010,
'config': 0x0020,
'smf_monitor': 0x0040,
'nsw_state': 0x0080,
'getent': 0x0100,
'access': 0x0200,
'int_addr': 0x0400,
'all': 0x07ff,
}
debug_level = {
'cant_find': 0x0001,
'debug': 0x0100,
'error': 0x0200,
'warning': 0x0400,
'info': 0x0800,
'notice': 0x1000,
'alert': 0x2000,
'crit': 0x4000,
'all': 0x7fff,
}
continue
if r == 'yes' or r == 'true':
return ret
if r == 'yes' or r == 'true':
return ret
"""Converts a debug_component integer to a SMF value list."""
try:
except:
return None
return 'all'
list = []
if i == 'all':
continue
return None
return list
"""Converts a debug_component SMF value list to an integer."""
return None
for i in list:
try:
except:
pass # ignore bad values
if dbint == 0:
return None
"""Converts a debug_level integer to a SMF value list."""
try:
except:
return None
return 'all'
list = []
if i == 'all':
continue
return None
return list
"""Converts a debug_level SMF value list to an integer."""
return None
if val== 'all':
try:
if i == 0:
return None
if i > 0 and i <= 10:
return val
return None
except:
pass
for i in list:
try:
except:
pass # ignore bad values
if dbint == 0:
return None
"""Export from SMF. Re-generate nsswitch.conf file"""
# Map SMF properties to DB
defp = {}
db = {}
if p == 'config/debug_level':
elif p == 'config/debug_components':
else:
try:
except:
pass
# Generate config props
try:
except:
val = None
continue
data += '\n'
# Generate cache props
else:
if map == 'netgroup' and \
continue
try:
except:
val = None
continue
data += '\n'
# Save to temp file, with header
return ret
"""Import to SMF. Configure SMF from nscd.conf file.
This function falls back to hardwired default values."""
if lines == None: # defaults always exist
lines = []
for l in lines:
l = l[1:] # Remove leading whitespace
continue
if idx > 0:
l = l[:idx]
l = l[:-1]
if l == '': # Skip enpty lines
continue
continue
try:
if pname == 'debug_level':
try:
if i == 0:
continue # skip it
if i > 0 and i <= 10:
pass
else:
if pval == None:
continue
except:
continue # other side skip
elif pname == 'debug_components':
if pval == None:
continue
except:
continue
else: # Cache
continue # Ignore ipnodes (dup hosts)
try:
else:
continue # Ignore default values
except:
continue
continue
if err:
# Exit before write processing
# delete old property groups
# Commit the property group
# load property groups
continue # Skip over default values
if ptype == 'boolean':
# Commit the property group
# validate
"""Unconfigure SMF. Reset DEFPG."""
# Commit the property group
# Check to see if both default and config PG exist
# and the config PG contains the required properties.
if pgs != None:
if props != None:
fndprop = 0
allprop = 0
continue
allprop += 1
fndprop += 1
return True
return False