コード例 #1
0
ファイル: netscaler.py プロジェクト: DaveQB/salt
def server_disable(s_name, **connection_args):
    """
    Disable a server globally

    CLI Example:

    .. code-block:: bash

        salt '*' netscaler.server_disable 'serverName'
    """
    ret = True
    server = _server_get(s_name, **connection_args)
    if server is None:
        return False
    if server.get_state() == "DISABLED":
        return True
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    try:
        NSServer.disable(nitro, server)
    except NSNitroError as error:
        log.debug("netscaler module error - NSServer.disable() failed: {0}".format(error))
        ret = False
    _disconnect(nitro)
    return ret
コード例 #2
0
ファイル: netscaler.py プロジェクト: DavideyLee/salt
def server_enable(s_name, **connection_args):
    '''
    Enables a server globally

    CLI Example:

    .. code-block:: bash

        salt '*' netscaler.server_enable 'serverName'
    '''
    ret = True
    server = _server_get(s_name, **connection_args)
    if server is None:
        return False
    if server.get_state() == 'ENABLED':
        return True
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    try:
        NSServer.enable(nitro, server)
    except NSNitroError as e:
        log.debug('netscaler module error - NSServer.enable() failed: {0}'.format(e.message))
        ret = False
    _disconnect(nitro)
    return ret
コード例 #3
0
ファイル: nsnitrocmd.py プロジェクト: al4/nsnitro
def action_get(args, nitro):
        if args.object == "csvserver":
                csvserver = NSCSVServer()
                csvserver.set_name(args.object_name)
                csvserver = NSCSVServer.get(nitro, csvserver)
                print "--- CS vserver: " + csvserver.get_name() + " ---"
                for k in sorted(csvserver.options.iterkeys(), key=lambda k: k):
                        print "\t%s: %s" % (k, csvserver.options[k])

        if args.object == "lbvserver":
                lbvserver = NSLBVServer()
                lbvserver.set_name(args.object_name)
                lbvserver = NSLBVServer.get(nitro, lbvserver)
                print "--- LB vserver: " + lbvserver.get_name() + " ---"
                for k in sorted(lbvserver.options.iterkeys(), key=lambda k: k):
                        print "\t%s: %s" % (k, lbvserver.options[k])

        if args.object == "server":
                server = NSServer()
                server.set_name(args.object_name)
                server = NSServer.get(nitro, server)
                print "--- Server: " + server.get_name() + " ---"
                for k in sorted(server.options.iterkeys(), key=lambda k: k):
                        print "\t%s: %s" % (k, server.options[k])

        if args.object == "service":
                service = NSService()
                service.set_name(args.object_name)
                service = NSService.get(nitro, service)

                print "--- Service: " + service.get_name() + " ---"
                for k in sorted(service.options.iterkeys(), key=lambda k: k):
                        print "\t%s: %s" % (k, service.options[k])
コード例 #4
0
ファイル: netscaler.py プロジェクト: arizvisa/saltstack-salt
def server_disable(s_name, **connection_args):
    """
    Disable a server globally

    CLI Example:

    .. code-block:: bash

        salt '*' netscaler.server_disable 'serverName'
    """
    ret = True
    server = _server_get(s_name, **connection_args)
    if server is None:
        return False
    if server.get_state() == "DISABLED":
        return True
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    try:
        NSServer.disable(nitro, server)
    except NSNitroError as error:
        log.debug("netscaler module error - NSServer.disable() failed: %s", error)
        ret = False
    _disconnect(nitro)
    return ret
コード例 #5
0
def server_delete(s_name, **connection_args):
    '''
    Delete a server

    CLI Example:

    .. code-block:: bash

        salt '*' netscaler.server_delete 'serverName'
    '''
    ret = True
    server = _server_get(s_name, **connection_args)
    if server is None:
        return False
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    try:
        NSServer.delete(nitro, server)
    except NSNitroError as error:
        log.debug(
            'netscaler module error - NSServer.delete() failed: {0}'.format(
                error))
        ret = False
    _disconnect(nitro)
    return ret
コード例 #6
0
def server_disable(s_name, **connection_args):
    '''
    Disable a server globally

    CLI Example:

    .. code-block:: bash

        salt '*' netscaler.server_disable 'serverName'
    '''
    ret = True
    server = _server_get(s_name, **connection_args)
    if server is None:
        return False
    if server.get_state() == 'DISABLED':
        return True
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    try:
        NSServer.disable(nitro, server)
    except NSNitroError as e:
        log.debug(
            'netscaler module error - NSServer.disable() failed: {0}'.format(
                e.message))
        ret = False
    _disconnect(nitro)
    return ret
コード例 #7
0
def server_add(s_name, s_ip, s_state=None, **connection_args):
    '''
    Add a server
    Note: The default server state is ENABLED

    CLI Example:

    .. code-block:: bash

        salt '*' netscaler.server_add 'serverName' 'serverIpAddress'
        salt '*' netscaler.server_add 'serverName' 'serverIpAddress' 'serverState'
    '''
    ret = True
    if server_exists(s_name, **connection_args):
        return False
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    server = NSServer()
    server.set_name(s_name)
    server.set_ipaddress(s_ip)
    if s_state is not None:
        server.set_state(s_state)
    try:
        NSServer.add(nitro, server)
    except NSNitroError as e:
        log.debug('netscaler module error - NSServer.add() failed: {0}'.format(
            e.message))
        ret = False
    _disconnect(nitro)
    return ret
コード例 #8
0
ファイル: nsnitrocmd.py プロジェクト: al4/nsnitro
def action_disable(args, nitro):
        if args.object == "csvserver":
                csvserver = NSCSVServer()
                csvserver.set_name(args.object_name)
                NSCSVServer.disable(nitro, csvserver)
                print "Disabled cs vserver: %s" % args.object_name

        if args.object == "lbvserver":
                lbvserver = NSLBVServer()
                lbvserver.set_name(args.object_name)
                NSLBVServer.disable(nitro, lbvserver)
                print "Disabled lb vserver: %s" % args.object_name

        if args.object == "server":
                server = NSServer()
                server.set_name(args.object_name)
                server.set_delay(args.delay)
                server.set_graceful(args.graceful)
                NSServer.disable(nitro, server)
                print "Disabled server: %s" % args.object_name

        if args.object == "service":
                service = NSService()
                service.set_name(args.object_name)
                service.set_delay(args.delay)
                service.set_graceful(args.graceful)
                NSService.disable(nitro, service)
                print "Disabled service: %s" % args.object_name
コード例 #9
0
ファイル: netscaler.py プロジェクト: pakdel/SaltConf16
def server_add(s_name, s_ip, s_state=None, **connection_args):
    '''
    Add a server
    Note: The default server state is ENABLED

    CLI Example:

    .. code-block:: bash

        salt '*' netscaler.server_add 'serverName' 'serverIpAddress'
        salt '*' netscaler.server_add 'serverName' 'serverIpAddress' 'serverState'
    '''
    ret = True
    if server_exists(s_name, **connection_args):
        return False
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    server = NSServer()
    server.set_name(s_name)
    server.set_ipaddress(s_ip)
    if s_state is not None:
        server.set_state(s_state)
    try:
        NSServer.add(nitro, server)
    except NSNitroError, e:
        log.debug('netscaler module error - NSServer.add() failed: {0}'.format(e.message))
        ret = False
コード例 #10
0
ファイル: netscaler.py プロジェクト: pakdel/SaltConf16
def _server_get(s_name, **connection_args):
    nitro = _connect(**connection_args)
    if nitro is None:
        return None
    server = NSServer()
    server.set_name(s_name)
    try:
        server = NSServer.get(nitro, server)
    except NSNitroError, e:
        log.debug('netscaler module error - NSServer.get() failed: {0}'.format(e.message))
        server = None
コード例 #11
0
ファイル: netscaler.py プロジェクト: yeyuexia/salt
def _server_get(s_name, **connection_args):
    nitro = _connect(**connection_args)
    if nitro is None:
        return None
    server = NSServer()
    server.set_name(s_name)
    try:
        server = NSServer.get(nitro, server)
    except NSNitroError, e:
        log.debug('netscaler module error - NSServer.get() failed: {0}'.format(
            e.message))
        server = None
コード例 #12
0
ファイル: netscaler.py プロジェクト: arizvisa/saltstack-salt
def _server_get(s_name, **connection_args):
    nitro = _connect(**connection_args)
    if nitro is None:
        return None
    server = NSServer()
    server.set_name(s_name)
    try:
        server = NSServer.get(nitro, server)
    except NSNitroError as error:
        log.debug("netscaler module error - NSServer.get() failed: %s", error)
        server = None
    _disconnect(nitro)
    return server
コード例 #13
0
ファイル: netscaler.py プロジェクト: DaveQB/salt
def _server_get(s_name, **connection_args):
    nitro = _connect(**connection_args)
    if nitro is None:
        return None
    server = NSServer()
    server.set_name(s_name)
    try:
        server = NSServer.get(nitro, server)
    except NSNitroError as error:
        log.debug("netscaler module error - NSServer.get() failed: {0}".format(error))
        server = None
    _disconnect(nitro)
    return server
コード例 #14
0
ファイル: netscaler.py プロジェクト: arizvisa/saltstack-salt
def server_update(s_name, s_ip, **connection_args):
    """
    Update a server's attributes

    CLI Example:

    .. code-block:: bash

      salt '*' netscaler.server_update 'serverName' 'serverIP'
    """
    altered = False
    cur_server = _server_get(s_name, **connection_args)
    if cur_server is None:
        return False
    alt_server = NSServer()
    alt_server.set_name(s_name)
    if cur_server.get_ipaddress() != s_ip:
        alt_server.set_ipaddress(s_ip)
        altered = True
    # Nothing to update, the server is already idem
    if altered is False:
        return False
    # Perform the update
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    ret = True
    try:
        NSServer.update(nitro, alt_server)
    except NSNitroError as error:
        log.debug("netscaler module error - NSServer.update() failed: %s", error)
        ret = False
    _disconnect(nitro)
    return ret
コード例 #15
0
ファイル: netscaler.py プロジェクト: pakdel/SaltConf16
def server_update(s_name, s_ip, **connection_args):
    '''
    Update a server's attributes

    CLI Example:

    .. code-block:: bash

      salt '*' netscaler.server_update 'serverName' 'serverIP'
    '''
    altered = False
    cur_server = _server_get(s_name, **connection_args)
    if cur_server is None:
       return False
    alt_server = NSServer()
    alt_server.set_name(s_name)
    if cur_server.get_ipaddress() != s_ip:
       alt_server.set_ipaddress(s_ip)
       altered = True
    # Nothing to update, the server is already idem
    if altered is False:
       return False
    # Perform the update
    nitro = _connect(**connection_args)
    if nitro is None:
       return False
    ret = True
    try:
       NSServer.update(nitro, alt_server)
    except NSNitroError, e:
       log.debug('netscaler module error - NSServer.update() failed: {0}'.format(e.message))
       ret = False
コード例 #16
0
ファイル: nsnitrocmd.py プロジェクト: al4/nsnitro
def action_rename(args, nitro):
        if args.object == "csvserver":
                csvserver = NSCSVServer()
                csvserver.set_name(args.object_name)
                csvserver.set_newname(args.newname)
                NSCSVServer.rename(nitro, csvserver)
                print "Renamed CS vserver from '%s' to '%s'." % (args.object_name, args.newname)

        if args.object == "lbvserver":
                lbvserver = NSLBVServer()
                lbvserver.set_name(args.object_name)
                lbvserver.set_newname(args.newname)
                NSLBVServer.rename(nitro, lbvserver)
                print "Renamed LB vserver from '%s' to '%s'." % (args.object_name, args.newname)

        if args.object == "server":
                server = NSServer()
                server.set_name(args.object_name)
                server.set_newname(args.newname)
                NSServer.rename(nitro, server)
                print "Renamed server from '%s' to '%s'." % (args.object_name, args.newname)

        if args.object == "service":
                service = NSService()
                service.set_name(args.object_name)
                service.set_newname(args.newname)
                NSService.rename(nitro, service)
                print "Renamed service from '%s' to '%s'." % (args.object_name, args.newname)
コード例 #17
0
ファイル: netscaler.py プロジェクト: pakdel/SaltConf16
def server_delete(s_name, **connection_args):
    '''
    Delete a server

    CLI Example:

    .. code-block:: bash

        salt '*' netscaler.server_delete 'serverName'
    '''
    ret = True
    server = _server_get(s_name, **connection_args)
    if server is None:
        return False
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    try:
        NSServer.delete(nitro, server)
    except NSNitroError, e:
        log.debug('netscaler module error - NSServer.delete() failed: {0}'.format(e.message))
        ret = False
コード例 #18
0
ファイル: nsnitrocmd.py プロジェクト: al4/nsnitro
def action_enable(args, nitro):
        if args.object == "csvserver":
                csvserver = NSCSVServer()
                csvserver.set_name(args.object_name)
                NSCSVServer.enable(nitro, csvserver)
                print "Enabled cs vserver: %s" % args.object_name

        if args.object == "lbvserver":
                lbvserver = NSLBVServer()
                lbvserver.set_name(args.object_name)
                NSLBVServer.enable(nitro, lbvserver)
                print "Enabled lb vserver: %s" % args.object_name

        if args.object == "server":
                server = NSServer()
                server.set_name(args.object_name)
                NSServer.enable(nitro, server)
                print "Enabled server: %s" % args.object_name

        if args.object == "service":
                service = NSService()
                service.set_name(args.object_name)
                NSService.enable(nitro, service)
                print "Enabled service: %s" % args.object_name
コード例 #19
0
ファイル: nsnitrocmd.py プロジェクト: heidsoft-paas/nsnitro
                        vserver = NSCSVServer().get(nitro, vserver)
                        print vserver.get_name() + ": " + vserver.get_curstate()
                        nitro.logout()
                        sys.exit(0)

                if args.getservicestatus:
                        service = NSService()
                        service.set_name(args.getservicestatus)
                        service = NSService.get(nitro, service)
                        print service.get_name() + ": " + service.get_svrstate()
                        nitro.logout()
                        sys.exit(0)


                if args.enableserver:
                        server = NSServer()
                        server.set_name(args.enableserver)
                        NSServer.enable(nitro, server)
                        print "Enabled server: %s" % args.enableserver
                        nitro.logout()
                        sys.exit(0)

                if args.disableserver:
                        if not args.delay and not args.graceful:
                          print "Please provide either --delay or --graceful when disabling a server."
                          nitro.logout()
                          sys.exit(0)
                        server = NSServer()
                        server.set_name(args.disableserver)
                        server.set_delay(args.delay)
                        server.set_graceful(args.graceful)
コード例 #20
0
ファイル: nsnitrocmd.py プロジェクト: rmoorecpcc/nsnitro
def action_addserver(args, nitro):
        addserver = NSServer()
        addserver.set_name(args.server)
        addserver.set_ipaddress(args.serverip)
        NSServer.add(nitro, addserver)
        print "server %s  was added" % (args.server)
コード例 #21
0
ファイル: test_logout.py プロジェクト: zojoncj/nsnitro
def test_logout():
    a.logout()

    addserver = NSServer()
    addserver.set_name("mpnitroserver")
    addserver.set_ipaddress("192.168.1.2")
    addserver.add(a,addserver)
    delserver = NSServer()
    delserver.set_name("mpnitroserver")
    NSServer.delete(a,delserver)