3 ܓip @ s4 d dl Z d dlmZ d dlmZ G dd deZdS ) N)quote)Clusterc @ sr e Zd ZdZdZd#ZdgZdZd$d%d&d'd(d)d*gZdZ dZ eedddZ eedddZedddZd d! Zd"S )+ saltstackzh The saltstack cluster profile is intended to be used on saltstack clusters (Salt Project). Z Saltstacksalt-masterZ saltmasterTcompound +Filter node list to those matching compoundglob/Filter node list to those matching glob patterngrain-Filter node list to those with matching grainminion_id_unresolvableF\Returns the FQDN grain of each minion in the node list when the minion ID is not a hostname. nodegroup,Filter node list to those matching nodegrouppillar.Filter node list to those with matching pillarsubnet#Filter node list to those in subnetz#salt-run --out=pprint manage.status)outputreturnc C s: g }t j|jdd}x|j D ]\}}|j| q W |S )N'")jsonloadsreplaceitemsextend)selfr ZnodesZsalt_json_output_value r! /usr/lib/python3.6/saltstack.py_parse_manage_status( s zsaltstack._parse_manage_status) manage_statusr c C sv g }xl|j D ]`\}}|dkr<| jd| d |j| qx0|D ](}d| d}|j| j|d j qBW qW |S )NZdownzNode(s) z are status down.zsalt --out=newline_values_only z grains.get fqdnr )r Zlog_warnr appendexec_primary_cmdstrip)r r$ Z hostnamesstatusZminionsZminionnode_cmdr! r! r" _get_hostnames_from_grain/ s z#saltstack._get_hostnames_from_grain)r c C sX | j | j}|d dkr td| jdrJtj|d jdd}| j|S | j|d S )Nr( r z-Node enumeration did not return usable outputr r r r ) r&