

def _send_command(cmd, worker, lbn, target, profile='default', expr_form='glob'):
    "\n    Send a command to the modjk loadbalancer\n    The minion need to be able to publish the commands to the load balancer\n\n    cmd:\n        worker_stop - won't get any traffic from the lbn\n        worker_activate - activate the worker\n        worker_disable - will get traffic only for current sessions\n    "
    ret = {
        'code': False,
        'msg': 'OK',
        'minions': [],
    }
    func = 'modjk.{0}'.format(cmd)
    args = [worker, lbn, profile]
    response = __salt__['publish.publish'](target, func, args, expr_form)
    errors = []
    minions = []
    for minion in response:
        minions.append(minion)
        if (not response[minion]):
            errors.append(minion)
    if (not response):
        ret['msg'] = 'no servers answered the published command {0}'.format(cmd)
        return ret
    elif (len(errors) > 0):
        ret['msg'] = 'the following minions return False'
        ret['minions'] = errors
        return ret
    else:
        ret['code'] = True
        ret['msg'] = 'the commad was published successfully'
        ret['minions'] = minions
        return ret

dataset/ETHPy150Open saltstack/salt/salt/states/modjk_worker.py _send_command/original