Changeset View
Changeset View
Standalone View
Standalone View
_modules/node.py
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | def has_role(role, nodename=None): | ||||
Returns a boolean, False if not found. | Returns a boolean, False if not found. | ||||
CLI Example: | CLI Example: | ||||
salt * node.has_role devserver | salt * node.has_role devserver | ||||
''' | ''' | ||||
return role in list('roles', nodename) | return role in list('roles', nodename) | ||||
def get_wwwroot(nodename=None): | |||||
''' | |||||
A function to determine the wwwroot folder to use. | |||||
Returns a string depending of the FQDN. | |||||
CLI Example: | |||||
salt * node.get_wwwroot | |||||
''' | |||||
hostname = _get_property("hostname", nodename, None) | |||||
if hostname is None: | |||||
raise CommandExecutionError( | |||||
SaltCloudConfigError( | |||||
"Node {0} doesn't have a hostname property".format(nodename) | |||||
) | |||||
) | |||||
if hostname.count('.') < 2: | |||||
return "wwwroot/{0}/www".format(hostname) | |||||
fqdn = hostname.split(".") | |||||
return "wwwroot/{1}/{0}".format( | |||||
".".join(fqdn[0:-2]), | |||||
".".join(fqdn[-2:]) | |||||
) |
Nasqueron DevCentral · If it had been much bigger the moon would have had a core of ice. · Powered by Phabricator