Exemple #1
0
def servicegroup_delete(sg_name, **connection_args):
    '''
    Delete a new service group

    CLI Example:

    .. code-block:: bash

        salt '*' netscaler.servicegroup_delete 'serviceGroupName'
    '''
    ret = True
    sg = _servicegroup_get(sg_name, **connection_args)
    if sg is None:
        return False
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    try:
        NSServiceGroup.delete(nitro, sg)
    except NSNitroError as error:
        log.debug(
            'netscaler module error - NSServiceGroup.delete() failed: {0}'.
            format(error))
        ret = False
    _disconnect(nitro)
    return ret
Exemple #2
0
def servicegroup_server_disable(sg_name, s_name, s_port, **connection_args):
    '''
    Disable a server:port member of a servicegroup

    CLI Example:

    .. code-block:: bash

        salt '*' netscaler.servicegroup_server_disable 'serviceGroupName' 'serverName' 'serverPort'
    '''
    ret = True
    server = _servicegroup_get_server(sg_name, s_name, s_port,
                                      **connection_args)
    if server is None:
        return False
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    try:
        NSServiceGroup.disable_server(nitro, server)
    except NSNitroError as error:
        log.debug(
            'netscaler module error - NSServiceGroup.disable_server() failed: {0}'
            .format(error))
        ret = False
    _disconnect(nitro)
    return ret
Exemple #3
0
def _servicegroup_get_servers(sg_name, **connection_args):
    '''
    Returns a list of members of a servicegroup or None
    '''
    nitro = _connect(**connection_args)
    if nitro is None:
        return None
    sg = NSServiceGroup()
    sg.set_servicegroupname(sg_name)
    try:
        sg = NSServiceGroup.get_servers(nitro, sg)
    except NSNitroError, e: 
        log.debug('netscaler module error - NSServiceGroup.get_servers failed(): {0}'.format(e.message))
        sg = None
Exemple #4
0
def servicegroup_add(sg_name, sg_type='HTTP', **connection_args):
    '''
    Add a new service group
    If no service type is specified, HTTP will be used.
    Most common service types: HTTP, SSL, and SSL_BRIDGE

    CLI Example:

    .. code-block:: bash

        salt '*' netscaler.servicegroup_add 'serviceGroupName'
        salt '*' netscaler.servicegroup_add 'serviceGroupName' 'serviceGroupType'
    '''
    ret = True
    if servicegroup_exists(sg_name):
        return False
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    sg = NSServiceGroup()
    sg.set_servicegroupname(sg_name)
    sg.set_servicetype(sg_type.upper())
    try:
        NSServiceGroup.add(nitro, sg)
    except NSNitroError as e:
        log.debug(
            'netscaler module error - NSServiceGroup.add() failed: {0}'.format(
                e.message))
        ret = False
    _disconnect(nitro)
    return ret
Exemple #5
0
def _servicegroup_get(sg_name, **connection_args):
    '''
    Return a service group ressource or None
    '''
    nitro = _connect(**connection_args)
    if nitro is None:
        return None
    sg = NSServiceGroup()
    sg.set_servicegroupname(sg_name)
    try:
        sg = NSServiceGroup.get(nitro, sg)
    except NSNitroError, e:
        log.debug('netscaler module error - NSServiceGroup.get() failed: {0}'.format(e.message))
        sg = None
Exemple #6
0
def _servicegroup_get(sg_name, **connection_args):
    '''
    Return a service group ressource or None
    '''
    nitro = _connect(**connection_args)
    if nitro is None:
        return None
    sg = NSServiceGroup()
    sg.set_servicegroupname(sg_name)
    try:
        sg = NSServiceGroup.get(nitro, sg)
    except NSNitroError, e:
        log.debug(
            'netscaler module error - NSServiceGroup.get() failed: {0}'.format(
                e.message))
        sg = None
Exemple #7
0
def _servicegroup_get_servers(sg_name, **connection_args):
    '''
    Returns a list of members of a servicegroup or None
    '''
    nitro = _connect(**connection_args)
    if nitro is None:
        return None
    sg = NSServiceGroup()
    sg.set_servicegroupname(sg_name)
    try:
        sg = NSServiceGroup.get_servers(nitro, sg)
    except NSNitroError, e:
        log.debug(
            'netscaler module error - NSServiceGroup.get_servers failed(): {0}'
            .format(e.message))
        sg = None
Exemple #8
0
def _servicegroup_get(sg_name, **connection_args):
    """
    Return a service group ressource or None
    """
    nitro = _connect(**connection_args)
    if nitro is None:
        return None
    sg = NSServiceGroup()
    sg.set_servicegroupname(sg_name)
    try:
        sg = NSServiceGroup.get(nitro, sg)
    except NSNitroError as error:
        log.debug("netscaler module error - NSServiceGroup.get() failed: {0}".format(error))
        sg = None
    _disconnect(nitro)
    return sg
Exemple #9
0
def _servicegroup_get(sg_name, **connection_args):
    """
    Return a service group ressource or None
    """
    nitro = _connect(**connection_args)
    if nitro is None:
        return None
    sg = NSServiceGroup()
    sg.set_servicegroupname(sg_name)
    try:
        sg = NSServiceGroup.get(nitro, sg)
    except NSNitroError as error:
        log.debug("netscaler module error - NSServiceGroup.get() failed: %s", error)
        sg = None
    _disconnect(nitro)
    return sg
Exemple #10
0
def servicegroup_add(sg_name, sg_type='HTTP', **connection_args):
    '''
    Add a new service group
    If no service type is specified, HTTP will be used.
    Most common service types: HTTP, SSL, and SSL_BRIDGE

    CLI Example:

    .. code-block:: bash

        salt '*' netscaler.servicegroup_add 'serviceGroupName'
        salt '*' netscaler.servicegroup_add 'serviceGroupName' 'serviceGroupType'
    '''
    ret = True
    if servicegroup_exists(sg_name):
        return False
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    sg = NSServiceGroup()
    sg.set_servicegroupname(sg_name)
    sg.set_servicetype(sg_type.upper())
    try:
        NSServiceGroup.add(nitro, sg)
    except NSNitroError, e:
        log.debug('netscaler module error - NSServiceGroup.add() failed: {0}'.format(e.message))
        ret = False
Exemple #11
0
def _servicegroup_get_servers(sg_name, **connection_args):
    """
    Returns a list of members of a servicegroup or None
    """
    nitro = _connect(**connection_args)
    if nitro is None:
        return None
    sg = NSServiceGroup()
    sg.set_servicegroupname(sg_name)
    try:
        sg = NSServiceGroup.get_servers(nitro, sg)
    except NSNitroError as error:
        log.debug(
            "netscaler module error - NSServiceGroup.get_servers failed(): %s", error
        )
        sg = None
    _disconnect(nitro)
    return sg
Exemple #12
0
def servicegroup_server_disable(sg_name, s_name, s_port, **connection_args):
    '''
    Disable a server:port member of a servicegroup

    CLI Example:

    .. code-block:: bash

        salt '*' netscaler.servicegroup_server_disable 'serviceGroupName' 'serverName' 'serverPort'
    '''
    ret = True
    server = _servicegroup_get_server(sg_name, s_name, s_port, **connection_args)
    if server is None:
        return False
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    try:
        NSServiceGroup.disable_server(nitro, server)
    except NSNitroError, e:
        log.debug('netscaler module error - NSServiceGroup.disable_server() failed: {0}'.format(e.message))
        ret = False
Exemple #13
0
def servicegroup_delete(sg_name, **connection_args):
    '''
    Delete a new service group

    CLI Example:

    .. code-block:: bash

        salt '*' netscaler.servicegroup_delete 'serviceGroupName'
    '''
    ret = True
    sg = _servicegroup_get(sg_name, **connection_args)
    if sg is None:
        return False    
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    try:
        NSServiceGroup.delete(nitro, sg)
    except NSNitroError, e:
        log.debug('netscaler module error - NSServiceGroup.delete() failed: {0}'.format(e.message))
        ret = False
Exemple #14
0
def servicegroup_delete(sg_name, **connection_args):
    """
    Delete a new service group

    CLI Example:

    .. code-block:: bash

        salt '*' netscaler.servicegroup_delete 'serviceGroupName'
    """
    ret = True
    sg = _servicegroup_get(sg_name, **connection_args)
    if sg is None:
        return False
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    try:
        NSServiceGroup.delete(nitro, sg)
    except NSNitroError as error:
        log.debug("netscaler module error - NSServiceGroup.delete() failed: {0}".format(error))
        ret = False
    _disconnect(nitro)
    return ret
Exemple #15
0
def servicegroup_server_enable(sg_name, s_name, s_port, **connection_args):
    """
    Enable a server:port member of a servicegroup

    CLI Example:

    .. code-block:: bash

        salt '*' netscaler.servicegroup_server_enable 'serviceGroupName' 'serverName' 'serverPort'
    """
    ret = True
    server = _servicegroup_get_server(sg_name, s_name, s_port, **connection_args)
    if server is None:
        return False
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    try:
        NSServiceGroup.enable_server(nitro, server)
    except NSNitroError as error:
        log.debug("netscaler module error - NSServiceGroup.enable_server() failed: {0}".format(error))
        ret = False
    _disconnect(nitro)
    return ret
Exemple #16
0
from nsnitro import nsnitro
from nsnitro.nsresources.nsservicegroup import NSServiceGroup

__author__ = 'vlazarenko'

nitro = nsnitro.NSNitro("localhost","api_user","api_user")
nitro.login()

svcg = NSServiceGroup()
svcg.set_servicegroupname("testsvcgroup")
#NSServiceGroup.add(nitro, svcg)

NSServiceGroup.delete(nitro, svcg)
Exemple #17
0
def action_addservicegroup(args, nitro):
        servicegroup = NSServiceGroup() 
        servicegroup.set_servicegroupname = (args.servicegroupname)
        servicegroup.set_state = (args.sgstate)
        NSServiceGroup.add(nitro, servicegroup)
        print "ServiceGroup might of been added if your lucky"