Exemple #1
0
def _vserver_servicegroup_get_all(v_name, **connection_args):
    ret = None
    nitro = _connect(**connection_args)
    if nitro is None:
        return None
    vsg = NSLBVServerServiceGroupBinding()
    vsg.set_name(v_name)
    try:
         ret = NSLBVServerServiceGroupBinding.get(nitro, vsg)
    except NSNitroError, e:
        log.debug('netscaler module error - NSLBVServerServiceGroupBinding.get() failed: {0}'.format(e.message))
        return None
Exemple #2
0
def vserver_servicegroup_delete(v_name, sg_name, **connection_args):
    '''
    Unbind a servicegroup from a vserver

    CLI Example:

    .. code-block:: bash

        salt '*' netscaler.vserver_servicegroup_delete 'vserverName' 'serviceGroupName'
    '''
    ret = True
    if not vserver_servicegroup_exists(v_name, sg_name, **connection_args):
        return False
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    vsg = NSLBVServerServiceGroupBinding()
    vsg.set_name(v_name)
    vsg.set_servicegroupname(sg_name)
    try:
        NSLBVServerServiceGroupBinding.delete(nitro, vsg)
    except NSNitroError as e:
        log.debug(
            'netscaler module error - NSLBVServerServiceGroupBinding.delete() failed: {0}'
            .format(e.message))
        ret = False
    _disconnect(nitro)
    return ret
Exemple #3
0
def _vserver_servicegroup_get(v_name, sg_name, **connection_args):
    ret = None
    nitro = _connect(**connection_args)
    if nitro is None:
        return None
    vsg = NSLBVServerServiceGroupBinding()
    vsg.set_name(v_name)
    try:
        vsgs = NSLBVServerServiceGroupBinding.get(nitro, vsg)
    except NSNitroError, e:
        log.debug(
            'netscaler module error - NSLBVServerServiceGroupBinding.get() failed: {0}'
            .format(e.message))
        return None
Exemple #4
0
def vserver_servicegroup_add(v_name, sg_name, **connection_args):
    """
    Bind a servicegroup to a vserver

    CLI Example:

    .. code-block:: bash

        salt '*' netscaler.vserver_servicegroup_add 'vserverName' 'serviceGroupName'
    """
    ret = True
    if vserver_servicegroup_exists(v_name, sg_name, **connection_args):
        return False
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    vsg = NSLBVServerServiceGroupBinding()
    vsg.set_name(v_name)
    vsg.set_servicegroupname(sg_name)
    try:
        NSLBVServerServiceGroupBinding.add(nitro, vsg)
    except NSNitroError as error:
        log.debug(
            "netscaler module error - NSLBVServerServiceGroupBinding.add() failed: %s",
            error,
        )
        ret = False
    _disconnect(nitro)
    return ret
Exemple #5
0
def _vserver_servicegroup_get(v_name, sg_name, **connection_args):
    ret = None
    nitro = _connect(**connection_args)
    if nitro is None:
        return None
    vsg = NSLBVServerServiceGroupBinding()
    vsg.set_name(v_name)
    try:
        vsgs = NSLBVServerServiceGroupBinding.get(nitro, vsg)
    except NSNitroError as error:
        log.debug("netscaler module error - NSLBVServerServiceGroupBinding.get() failed: {0}".format(error))
        return None
    for vsg in vsgs:
        if vsg.get_servicegroupname() == sg_name:
            ret = vsg
    _disconnect(nitro)
    return ret
Exemple #6
0
def vserver_servicegroup_delete(v_name, sg_name, **connection_args):
    """
    Unbind a servicegroup from a vserver

    CLI Example:

    .. code-block:: bash

        salt '*' netscaler.vserver_servicegroup_delete 'vserverName' 'serviceGroupName'
    """
    ret = True
    if not vserver_servicegroup_exists(v_name, sg_name, **connection_args):
        return False
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    vsg = NSLBVServerServiceGroupBinding()
    vsg.set_name(v_name)
    vsg.set_servicegroupname(sg_name)
    try:
        NSLBVServerServiceGroupBinding.delete(nitro, vsg)
    except NSNitroError as error:
        log.debug("netscaler module error - NSLBVServerServiceGroupBinding.delete() failed: {0}".format(error))
        ret = False
    _disconnect(nitro)
    return ret
Exemple #7
0
def vserver_servicegroup_add(v_name, sg_name, **connection_args):
    '''
    Bind a servicegroup to a vserver

    CLI Example:

    .. code-block:: bash

        salt '*' netscaler.vserver_servicegroup_add 'vserverName' 'serviceGroupName'
    '''
    ret = True
    if vserver_servicegroup_exists(v_name, sg_name, **connection_args):
        return False
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    vsg = NSLBVServerServiceGroupBinding()
    vsg.set_name(v_name)
    vsg.set_servicegroupname(sg_name)
    try:
        NSLBVServerServiceGroupBinding.add(nitro, vsg)
    except NSNitroError as e:
        log.debug('netscaler module error - NSLBVServerServiceGroupBinding.add() failed: {0}'.format(e.message))
        ret = False
    _disconnect(nitro)
    return ret
Exemple #8
0
def _vserver_servicegroup_get(v_name, sg_name, **connection_args):
    ret = None
    nitro = _connect(**connection_args)
    if nitro is None:
        return None
    vsg = NSLBVServerServiceGroupBinding()
    vsg.set_name(v_name)
    try:
        vsgs = NSLBVServerServiceGroupBinding.get(nitro, vsg)
    except NSNitroError as error:
        log.debug('netscaler module error - NSLBVServerServiceGroupBinding.get() failed: %s', error)
        return None
    for vsg in vsgs:
        if vsg.get_servicegroupname() == sg_name:
            ret = vsg
    _disconnect(nitro)
    return ret
Exemple #9
0
def lbvsbindingtosg_add(lbvs_name, sg_name, **connection_args):
    """
    Bind sg to a lbvs
    CLI Example:
    .. code-block:: bash
        salt '*' netscaler.lbvsbindingtosg_add 'monitorName' 'servicegroupName'
    """
    ret = True
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    lbvssg = NSLBVServerServiceGroupBinding()
    lbvssg.set_name(lbvs_name)
    lbvssg.set_servicegroupname(sg_name)
    print(lbvssg)
    try:
        NSLBVServerServiceGroupBinding.add(nitro, lbvssg)
    except NSNitroError as error:
        log.debug(
            "netscaler module error - NSLBVServerServiceGroupBinding.add() failed: %s",
            error)
        ret = False
    _disconnect(nitro)
    return ret