# 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
#
#
#
"""DNS classes used by nscfg."""
import os
"""Domain Name Service (DNS) class. Represents the configuration
of DNS. See resolv.conf(4) for details."""
# Supported Property groups
# propname: [ type, multivalued]
}
'128.0.0.0', '192.0.0.0', '224.0.0.0', '240.0.0.0',
'248.0.0.0', '252.0.0.0', '254.0.0.0', '255.0.0.0',
'255.128.0.0', '255.192.0.0', '255.224.0.0', '255.240.0.0',
'255.248.0.0', '255.252.0.0', '255.254.0.0', '255.255.0.0',
'255.255.128.0', '255.255.192.0', '255.255.224.0', '255.255.240.0',
'255.255.248.0', '255.255.252.0', '255.255.254.0', '255.255.255.0',
'255.255.255.128', '255.255.255.192', '255.255.255.224',
'255.255.255.240', '255.255.255.248', '255.255.255.252',
'255.255.255.254', '255.255.255.255', )
"""convert net_address to sort list format (expand netmask)."""
return addr
try:
except:
return None
else:
return None
return ret
"""convert sort list to net_address format (compact netmask)."""
return addr
while idx <= 32:
break
else:
idx += 1
if idx > 32:
return None
return ret
"""Export from SMF. Re-generate resolv.conf file"""
# Map SMF properties to DB
db = {}
db[p] = None # Setup properties
else:
# Generate config props
try:
if p == 'nameserver': # one nameserver per line
for v in val:
data += "%s\t%s\n" % (p, v)
else: # otherwise combine all values
for v in val:
if p == 'sortlist': # convert net_addr -> sortlist
if v == None:
continue
if vv == '':
vv = v
else:
except:
pass
try:
except:
# Save to temp file, no header
return ret
"""Import to SMF. Configure SMF from resolv.conf file."""
db = []
if lines == None:
for l in lines:
if l == '': # Skip empty lines
continue
if l[0] == ';' or l[0] == '#': # Skip comment lines
continue
if l.startswith('nameserver'):
if dc >= 0:
l = l[:dc]
if sc >= 0:
l = l[:sc]
l = l.rstrip()
continue
try:
for v in vals:
if v == None:
continue
emsg = 'Illegal value (%s): %s' % \
(tarray[0], v)
except:
continue
if err:
# resolv.conf can be empty so NOCONFIG is not an error here
# Therefore don't: if len(db) == 0: return self.NOCONFIG
# Exit before write processing
# delete old property group
# Commit the property group
# load property group
# Create the multivalued prop list
mval = {}
mvaltype = {}
# Populate the multivalued prop list
# load the single valued props
continue
# Commit the property group
# validate
"""Unconfigure SMF. Reset DEFPG."""
# Commit the property group
if pgs != None:
return True # All properties are optional
return False