#
# 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
#
#
#
# This module provides a basic interface to smf.
import os
import six
# range of possible SMF service states
return "Cmd {0} exited with status {1:d}, and output '{2}'".format(
# a way to invoke a separate executable for testing
if cmds_dir:
args = (
if zone:
if cmd is None:
try:
except OSError as e:
if ret != 0:
return buf
""" return state of smf service """
if not props:
return SMF_SVC_UNKNOWN
return SMF_SVC_MAINTENANCE
if status is not None:
if "true" in status:
return SMF_SVC_TMP_ENABLED
return SMF_SVC_TMP_DISABLED
return SMF_SVC_ENABLED
return SMF_SVC_DISABLED
""" Walk a set of fmris checking that each is fully specifed with
an instance.
If an FMRI is not fully specified and does not contain at least
one special match character from fnmatch(7) the fmri is dropped
from the set that is returned and an error message is logged.
"""
chars = "*?[!^"
for c in chars:
if c in fmri:
# check to see if we've got an instance already
continue
if is_glob:
try:
except NonzeroExitException:
continue # non-zero exit == not installed
else:
"more than one service instance."))
return fmris
try:
except NonzeroExitException:
return {} # empty output == not installed
return dict([
for l in buf
])
value))
return buf
if not fmris:
return
if sync_timeout:
if sync_timeout != -1:
if temporary:
# fmris could be a list so explicit cast is necessary
if not fmris:
return
if sync_timeout > 0:
if temporary:
# fmris could be a list so explicit cast is necessary
if not fmris:
return
# fmris could be a list so explicit cast is necessary
if not fmris:
return
if sync_timeout:
if sync_timeout != -1:
# fmris could be a list so explicit cast is necessary
if not fmris:
return
if sync_timeout:
if sync_timeout != -1:
# fmris could be a list so explicit cast is necessary