Exemplo n.º 1
0
 def __init__(self, hostname, username, password, timeout=60):
     self.hostname = hostname
     self.username = username
     self.password = password
     self.timeout = timeout
     self.argv = ['', '-u', username, '-p', password, hostname]
     self.bnc = bnclient.bnclient(self.argv)
     self.config_replace = False
     self.config = {"running": "", "candidate": "", "rollback": ""}
     self.filename_running = "/tmp/" + hostname + "-running.conf"
     self.filename_candidate = None
     self.filename_rollback = "/tmp/" + hostname + "-rollback.conf"
     self.error = StringIO()
Exemplo n.º 2
0
 def __init__(self, hostname, username, password, timeout=60):
     self.hostname = hostname
     self.username = username
     self.password = password
     self.timeout = timeout
     self.argv = ['', '-u', username, '-p', password, hostname]
     self.bnc = bnclient.bnclient(self.argv)
     self.config_replace = False
     self.config = {"running": "", "candidate": "", "rollback": ""}
     self.filename_running = "/tmp/" + hostname + "-running.conf"
     self.filename_candidate = None
     self.filename_rollback = "/tmp/" + hostname + "-rollback.conf"
     self.error = StringIO()
Exemplo n.º 3
0
 def open(self):
     self.bnc = bnclient.bnclient(self.argv)
     self.bnc.connect(self.timeout)
     self.bnc.sendhello()
     self._get_config(self.filename_rollback)
# Copyright 2010 Blade Network Technologies

import os, sys, string

from bnclient import bnclient

def str2argv(str=''):
    return str.split(' ')

if __name__ == '__main__':
    # username and password
    options = "-u admin -p admin "
    # hostname
    options += "10.20.18.253"
    
    argv = sys.argv[:1] + str2argv(options) + sys.argv[1:]
    
    bnc = bnclient.bnclient(argv)
    bnc.connect()
    bnc.sendhello()
    bnc.sendrpc(str2argv("-o lock -t running"))
    bnc.sendrpc(str2argv("-o get-config -t running"))
    bnc.sendrpc(str2argv("-o unlock -t running"))
    bnc.close()