New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SMF module for SmartOS can't determine if a service is available. #13983
Comments
Ok. So I am way out of my league finding the fix, but I think this will help.
This will take the package name and return the service name. I do not know if this is necessary or will work in other SMF distributions. One thing that might be a deal breaker is that the above command does allow a search based on a pattern match and just not an abbreviated FMRI. I'm not sure if that could lead to false positives. |
Ok. Here is a fix (I think, but I really don't know what I'm doing) for the available and missing functions. It uses Also here is a link to the current functions in smf.py. def available(name):
'''
Returns ``True`` if the specified service is available, otherwise returns
``False``.
CLI Example:
CLI Example:
.. code-block:: bash
salt '*' service.available net-snmp
'''
if 'SmartOS' in __grains__['os']:
cmd = '/usr/bin/svcs -H -o SVC {0}'.format(name)
name = __salt__['cmd.run'](cmd)
return name in get_all()
else:
return name in get_all()
def missing(name):
'''
The inverse of service.available.
Returns ``True`` if the specified service is not available, otherwise returns
``False``.
CLI Example:
.. code-block:: bash
salt '*' service.missing net-snmp
'''
if 'SmartOS' in __grains__['os']:
cmd = '/usr/bin/svcs -H -o SVC {0}'.format(name)
name = __salt__['cmd.run'](cmd)
return name not in get_all()
else:
return name not in get_all() |
With the careful partitioning based on the 'os' grain, I think this fix is the right way to go. Will you please submit a pull request? |
I've not checked the contributor's guidelines yet. Would a short explanation for the if statement be appropriate in the comments? |
Looks like you threw it into the docstring, which is perfect. Thanks for getting that in, @johngrasty! |
Packages installed via
pkgin
in SmartOS have one name. When Salt checkssvcs
to see if it is available,svcs
returns a portion of the FMRI name which is different.For example,
salt 'webserver.*' pkg.install nginx
works as expected. Yet,salt '*' service.available nginx
returns false. Any of the other service functions that begin by checking if the package is available will also fail.So to install nginx, we use the name nginx. But when the smf module queries for the available services, it checks to see if nginx is in the results from get_all.
get_all
returns pkgsrc/nginx, not nginx.Any help would be greatly appreciated!
The text was updated successfully, but these errors were encountered: