--- a/usr/src/cmd/installadm/create_service.py Wed May 30 08:42:12 2012 -0600
+++ b/usr/src/cmd/installadm/create_service.py Wed May 30 08:54:28 2012 -0700
@@ -326,6 +326,13 @@
if service == newservice.name:
continue
svc = AIService(service)
+ try:
+ props = config.get_service_props(service)
+ config.verify_key_properties(service, props)
+ except config.ServiceCfgError as err:
+ # if service is missing keys, print info and skip it
+ print >> sys.stderr, err
+ continue
if svc.arch == newservice.arch and svc.image.version >= 3:
make_default = False
break
--- a/usr/src/cmd/installadm/service_config.py Wed May 30 08:42:12 2012 -0600
+++ b/usr/src/cmd/installadm/service_config.py Wed May 30 08:54:28 2012 -0700
@@ -192,10 +192,17 @@
service_name - An AI service name
props - A dictionary of properties to update for the specified
service_name.
+ Raises:
+ ServiceCfgError if config file does not exist for the service (to
+ create it, use create_service_props())
'''
logging.log(com.XDEBUG, '**** START service_config.set_service_props '
'service_name=%s ****', service_name)
+ if not os.path.exists(_get_configfile_path(service_name)):
+ raise ServiceCfgError(cw(_('\nError: attempting to set service '
+ 'properties, but config file does not exist for "%s"')
+ % service_name))
_write_service_config(service_name, props)
@@ -581,6 +588,12 @@
# If any install services are enabled (on), don't change the state
# of the installadm SMF service.
for service in all_svc_props:
+ try:
+ verify_key_properties(service, all_svc_props[service])
+ except ServiceCfgError:
+ # this service is missing key properties, so don't consider
+ # it when deciding to change the state
+ continue
if all_svc_props[service][PROP_STATUS] == STATUS_ON:
logging.log(com.XDEBUG, "At least one service currently "
"enabled, not going to maintenance.")
--- a/usr/src/cmd/installadm/test/test_delete_service.py Wed May 30 08:42:12 2012 -0600
+++ b/usr/src/cmd/installadm/test/test_delete_service.py Wed May 30 08:54:28 2012 -0700
@@ -51,8 +51,10 @@
# create service
cls.imagedir = tempfile.mkdtemp(dir="/tmp")
props = {config.PROP_SERVICE_NAME: 'mysvc',
- config.PROP_IMAGE_PATH: cls.imagedir}
- config.set_service_props('mysvc', props)
+ config.PROP_STATUS: 'off',
+ config.PROP_TXT_RECORD: 'aiwebserver=myserver:5555',
+ config.PROP_IMAGE_PATH: cls.imagedir}
+ config.create_service_props('mysvc', props)
cls.myservice = service.AIService('mysvc')
@classmethod
--- a/usr/src/cmd/installadm/test/test_service.py Wed May 30 08:42:12 2012 -0600
+++ b/usr/src/cmd/installadm/test/test_service.py Wed May 30 08:54:28 2012 -0700
@@ -19,7 +19,7 @@
#
# CDDL HEADER END
#
-# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
#
'''
@@ -83,8 +83,10 @@
# create service
props = {config.PROP_SERVICE_NAME: 'mysvc',
+ config.PROP_STATUS: 'off',
+ config.PROP_TXT_RECORD: 'aiwebserver=myserver:5555',
config.PROP_IMAGE_PATH: self.imagedir}
- config.set_service_props('mysvc', props)
+ config.create_service_props('mysvc', props)
myservice = service.AIService('mysvc')
# Update path in wanboot file, read file back in, and