本文整理汇总了Python中jnpr.junos.utils.config.Config.commit_check方法的典型用法代码示例。如果您正苦于以下问题:Python Config.commit_check方法的具体用法?Python Config.commit_check怎么用?Python Config.commit_check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jnpr.junos.utils.config.Config
的用法示例。
在下文中一共展示了Config.commit_check方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: deployConfig
# 需要导入模块: from jnpr.junos.utils.config import Config [as 别名]
# 或者: from jnpr.junos.utils.config.Config import commit_check [as 别名]
def deployConfig(my_device_list_dict, my_username, my_password, my_config_template_file):
my_hostname=""
try:
my_hostname=my_device_list_dict["mgmt_ip"]
printProgress("INFO",my_hostname,"Connecting to device through netconf.")
dev=Device(my_hostname,user=my_username,password=my_password)
dev.open()
dev.timeout=3*60
cu = Config(dev)
printProgress("INFO",my_hostname,"Going to load template the config now.")
# Determine if template file is in "set" or "bracketed" format
if isSet(my_config_template_file):
rsp=cu.load(template_path=my_config_template_file,format='set',template_vars=my_device_list_dict)
else:
rsp=cu.load(template_path=my_config_template_file,template_vars=my_device_list_dict)
printProgress("INFO",my_hostname,"Performing diff between active and candidate config.")
cu.pdiff()
printProgress("INFO",my_hostname,"Performing commit check")
if cu.commit_check():
printProgress("INFO",my_hostname,"commit check was successfull.")
printProgress("INFO",my_hostname,"performing commit now.")
commit_status=cu.commit()
printProgress("INFO",my_hostname,"disconnecting from device.")
dev.close()
return commit_status
else:
return False
except Exception,err:
printProgress("ERROR",my_hostname,"Encountered exception while deploying config")
printProgress("ERROR",my_hostname,str(err))
return False
示例2: test_load_config
# 需要导入模块: from jnpr.junos.utils.config import Config [as 别名]
# 或者: from jnpr.junos.utils.config.Config import commit_check [as 别名]
def test_load_config(self):
from jnpr.junos.utils.config import Config
cu = Config(self.dev)
data = """interfaces {
ge-1/0/0 {
description "MPLS interface";
unit 0 {
family mpls;
}
}
}
"""
cu.load(data, format='text')
self.assertTrue(cu.commit_check())
if cu.commit_check():
cu.rollback()
示例3: loadVRFConfig
# 需要导入模块: from jnpr.junos.utils.config import Config [as 别名]
# 或者: from jnpr.junos.utils.config.Config import commit_check [as 别名]
def loadVRFConfig(VRF_number):
if 1 < int(VRF_number) < 255:
dev = Device(host="172.2.3.5", user="mario", ssh_private_key_file="/root/.ssh/VRF")
dev.open()
conf = Config(dev)
variables = {}
variables["VRF_instance"] = VRF_number
conf.load(template_path="templateVRF_set.conf", template_vars=variables, format="set", merge=True)
conf.pdiff()
if conf.commit_check():
print "This config would commit succesfully"
else:
print "Config puck`d up"
dev.close()
else:
print "The VRF number must be between 2 and 254"
示例4: Netconf
# 需要导入模块: from jnpr.junos.utils.config import Config [as 别名]
# 或者: from jnpr.junos.utils.config.Config import commit_check [as 别名]
#.........这里部分代码省略.........
elif overwrite:
merge = True
overwrite = False
else:
merge = True
overwrite = False
if overwrite and config_format == 'set':
self.raise_exc('replace cannot be True when config_format is `set`')
self.lock_config()
try:
candidate = '\n'.join(config)
self.config.load(candidate, format=config_format, merge=merge,
overwrite=overwrite)
except ConfigLoadError:
exc = get_exception()
self.raise_exc('Unable to load config: %s' % str(exc))
diff = self.config.diff()
self.check_config()
if all((commit, diff)):
self.commit_config(comment=comment, confirm=confirm)
self.unlock_config()
return diff
def save_config(self):
raise NotImplementedError
### end of Config ###
def get_facts(self, refresh=True):
if refresh:
self.device.facts_refresh()
return self.device.facts
def unlock_config(self):
try:
self.config.unlock()
self._locked = False
except UnlockError:
exc = get_exception()
raise NetworkError('unable to unlock config: %s' % str(exc))
def lock_config(self):
try:
self.config.lock()
self._locked = True
except LockError:
exc = get_exception()
raise NetworkError('unable to lock config: %s' % str(exc))
def check_config(self):
if not self.config.commit_check():
self.raise_exc(msg='Commit check failed')
def commit_config(self, comment=None, confirm=None):
try:
kwargs = dict(comment=comment)
if confirm and confirm > 0:
kwargs['confirm'] = confirm
return self.config.commit(**kwargs)
except CommitError:
exc = get_exception()
raise NetworkError('unable to commit config: %s' % str(exc))
def confirm_commit(self, checkonly=False):
try:
resp = self.rpc('get_commit_information')
needs_confirm = 'commit confirmed, rollback' in resp[0][4].text
if checkonly:
return needs_confirm
return self.commit_config()
except IndexError:
# if there is no comment tag, the system is not in a commit
# confirmed state so just return
pass
def rollback_config(self, identifier, commit=True, comment=None):
self.lock_config()
try:
self.config.rollback(identifier)
except ValueError:
exc = get_exception()
self.raise_exc('Unable to rollback config: $s' % str(exc))
diff = self.config.diff()
if commit:
self.commit_config(comment=comment)
self.unlock_config()
return diff
示例5: TestConfig
# 需要导入模块: from jnpr.junos.utils.config import Config [as 别名]
# 或者: from jnpr.junos.utils.config.Config import commit_check [as 别名]
class TestConfig(unittest.TestCase):
def setUp(self):
self.dev = Device(host='1.1.1.1')
self.conf = Config(self.dev)
def test_config_constructor(self):
self.assertTrue(isinstance(self.conf._dev, Device))
def test_config_confirm_true(self):
self.conf.rpc.commit_configuration = MagicMock()
self.conf.commit(confirm=True)
self.conf.rpc.commit_configuration\
.assert_called_with(confirmed=True)
def test_config_commit_confirm(self):
self.conf.rpc.commit_configuration = MagicMock()
self.conf.commit(confirm=10)
self.conf.rpc.commit_configuration\
.assert_called_with(**{'confirm-timeout': '10', 'confirmed': True})
def test_config_commit_comment(self):
self.conf.rpc.commit_configuration = MagicMock()
self.conf.commit(comment='Test')
self.conf.rpc.commit_configuration.assert_called_with(log='Test')
def test_config_commit_sync(self):
self.conf.rpc.commit_configuration = MagicMock()
self.conf.commit(sync=True)
self.conf.rpc.commit_configuration\
.assert_called_with(synchronize=True)
def test_config_commit_force_sync(self):
self.conf.rpc.commit_configuration = MagicMock()
self.conf.commit(force_sync=True)
self.conf.rpc.commit_configuration\
.assert_called_with(**{'synchronize': True, 'force-synchronize': True})
def test_config_commit_timeout(self):
self.conf.rpc.commit_configuration = MagicMock()
self.conf.commit(timeout=60)
self.conf.rpc.commit_configuration\
.assert_called_with(dev_timeout=60)
def test_config_commit_full(self):
self.conf.rpc.commit_configuration = MagicMock()
self.conf.commit(full=True)
self.conf.rpc.commit_configuration\
.assert_called_with(full=True)
def test_config_commit_detail(self):
self.conf.rpc.commit_configuration = MagicMock()
self.conf.rpc.commit_configuration.return_value = '<mockdetail/>'
self.assertEqual('<mockdetail/>', self.conf.commit(detail=True))
self.conf.rpc.commit_configuration\
.assert_called_with({'detail': 'detail'})
def test_config_commit_combination(self):
self.conf.rpc.commit_configuration = MagicMock()
self.conf.rpc.commit_configuration.return_value = '<moredetail/>'
self.assertEqual('<moredetail/>', self.conf.commit(detail=True, force_sync=True, full=True))
self.conf.rpc.commit_configuration\
.assert_called_with({'detail': 'detail'},
**{'synchronize': True, 'full': True, 'force-synchronize': True})
@patch('jnpr.junos.utils.config.JXML.remove_namespaces')
def test_config_commit_exception(self, mock_jxml):
class MyException(Exception):
xml = 'test'
self.conf.rpc.commit_configuration = \
MagicMock(side_effect=MyException)
self.assertRaises(AttributeError, self.conf.commit)
def test_config_commit_exception_RpcError(self):
ex = RpcError(rsp='ok')
self.conf.rpc.commit_configuration = MagicMock(side_effect=ex)
self.assertTrue(self.conf.commit())
import xml.etree.ElementTree as ET
xmldata = """<data><company name="Juniper">
<code>pyez</code>
<year>2013</year>
</company></data>"""
root = ET.fromstring(xmldata)
el = root.find('company')
ex = RpcError(rsp=el)
self.conf.rpc.commit_configuration = MagicMock(side_effect=ex)
self.assertRaises(CommitError, self.conf.commit)
def test_commit_check(self):
self.conf.rpc.commit_configuration = MagicMock()
self.assertTrue(self.conf.commit_check())
@patch('jnpr.junos.utils.config.JXML.rpc_error')
def test_commit_check_exception(self, mock_jxml):
class MyException(Exception):
xml = 'test'
self.conf.rpc.commit_configuration = MagicMock(side_effect=MyException)
# with self.assertRaises(AttributeError):
self.conf.commit_check()
#.........这里部分代码省略.........
示例6: Config
# 需要导入模块: from jnpr.junos.utils.config import Config [as 别名]
# 或者: from jnpr.junos.utils.config.Config import commit_check [as 别名]
cu = Config(dev)
data = """interfaces {
ge-1/0/1 {
description "MPLS interface";
unit 0 {
family mpls;
}
}
ge-1/0/2 {
description "MPLS interface";
unit 0 {
family mpls;
}
}
}
protocols {
mpls {
interface ge-1/0/1;
interface ge-1/0/2;
}
}
"""
cu.load(data, format='text')
cu.pdiff()
if cu.commit_check():
cu.commit()
else:
cu.rollback()
dev.close()
示例7: TestConfig
# 需要导入模块: from jnpr.junos.utils.config import Config [as 别名]
# 或者: from jnpr.junos.utils.config.Config import commit_check [as 别名]
#.........这里部分代码省略.........
.assert_called_with({'detail': 'detail'},
**{'synchronize': True, 'full': True, 'force-synchronize': True})
@patch('jnpr.junos.utils.config.JXML.remove_namespaces')
def test_config_commit_xml_exception(self, mock_jxml):
class MyException(Exception):
xml = etree.fromstring('<test/>')
self.conf.rpc.commit_configuration = \
MagicMock(side_effect=MyException)
self.assertRaises(CommitError, self.conf.commit)
def test_config_commit_exception(self):
class MyException(Exception):
pass
self.conf.rpc.commit_configuration = \
MagicMock(side_effect=MyException)
self.assertRaises(MyException, self.conf.commit)
def test_config_commit_exception_RpcError(self):
ex = RpcError(rsp='ok')
self.conf.rpc.commit_configuration = MagicMock(side_effect=ex)
self.assertTrue(self.conf.commit())
import xml.etree.ElementTree as ET
xmldata = """<data><company name="Juniper">
<code>pyez</code>
<year>2013</year>
</company></data>"""
root = ET.fromstring(xmldata)
el = root.find('company')
ex = RpcError(rsp=el)
self.conf.rpc.commit_configuration = MagicMock(side_effect=ex)
self.assertRaises(CommitError, self.conf.commit)
def test_commit_check(self):
self.conf.rpc.commit_configuration = MagicMock()
self.assertTrue(self.conf.commit_check())
@patch('jnpr.junos.utils.config.JXML.rpc_error')
def test_commit_check_exception(self, mock_jxml):
class MyException(Exception):
xml = 'test'
self.conf.rpc.commit_configuration = MagicMock(side_effect=MyException)
# with self.assertRaises(AttributeError):
self.conf.commit_check()
def test_config_commit_check_exception_RpcError(self):
ex = RpcError(rsp='ok')
self.conf.rpc.commit_configuration = MagicMock(side_effect=ex)
self.assertTrue(self.conf.commit_check())
import xml.etree.ElementTree as ET
xmldata = """<data><company name="Juniper">
<code>pyez</code>
<year>2013</year>
</company></data>"""
root = ET.fromstring(xmldata)
el = root.find('company')
ex = RpcError(rsp=el)
self.conf.rpc.commit_configuration = MagicMock(side_effect=ex)
self.assertRaises(CommitError, self.conf.commit_check)
def test_config_diff(self):
self.conf.rpc.get_configuration = MagicMock()
self.conf.diff()
self.conf.rpc.get_configuration.\
assert_called_with(
{'compare': 'rollback', 'rollback': '0', 'format': 'text'})
示例8: TestConfig
# 需要导入模块: from jnpr.junos.utils.config import Config [as 别名]
# 或者: from jnpr.junos.utils.config.Config import commit_check [as 别名]
class TestConfig(unittest.TestCase):
def setUp(self):
self.dev = Device(host='1.1.1.1')
self.conf = Config(self.dev)
def test_config_constructor(self):
self.assertTrue(isinstance(self.conf._dev, Device))
def test_config_confirm(self):
self.conf.rpc.commit_configuration = MagicMock()
self.assertTrue(self.conf.commit(confirm=True))
def test_config_commit_confirm_timeout(self):
self.conf.rpc.commit_configuration = MagicMock()
self.conf.commit(confirm=10)
self.conf.rpc.commit_configuration\
.assert_called_with(**{'confirm-timeout': '10', 'confirmed': True})
def test_config_commit_comment(self):
self.conf.rpc.commit_configuration = MagicMock()
self.conf.commit(comment='Test')
self.conf.rpc.commit_configuration.assert_called_with(log='Test')
@patch('jnpr.junos.utils.config.JXML.remove_namespaces')
def test_config_commit_exception(self, mock_jxml):
class MyException(Exception):
xml = 'test'
self.conf.rpc.commit_configuration = \
MagicMock(side_effect=MyException)
self.assertRaises(AttributeError, self.conf.commit)
def test_config_commit_exception_RpcError(self):
ex = RpcError(rsp='ok')
self.conf.rpc.commit_configuration = MagicMock(side_effect=ex)
self.assertTrue(self.conf.commit())
import xml.etree.ElementTree as ET
xmldata = """<data><company name="Juniper">
<code>pyez</code>
<year>2013</year>
</company></data>"""
root = ET.fromstring(xmldata)
el = root.find('company')
ex = RpcError(rsp=el)
self.conf.rpc.commit_configuration = MagicMock(side_effect=ex)
self.assertRaises(CommitError, self.conf.commit)
def test_commit_check(self):
self.conf.rpc.commit_configuration = MagicMock()
self.assertTrue(self.conf.commit_check())
@patch('jnpr.junos.utils.config.JXML.rpc_error')
def test_commit_check_exception(self, mock_jxml):
class MyException(Exception):
xml = 'test'
self.conf.rpc.commit_configuration = MagicMock(side_effect=MyException)
# with self.assertRaises(AttributeError):
self.conf.commit_check()
def test_config_commit_check_exception_RpcError(self):
ex = RpcError(rsp='ok')
self.conf.rpc.commit_configuration = MagicMock(side_effect=ex)
self.assertTrue(self.conf.commit_check())
import xml.etree.ElementTree as ET
xmldata = """<data><company name="Juniper">
<code>pyez</code>
<year>2013</year>
</company></data>"""
root = ET.fromstring(xmldata)
el = root.find('company')
ex = RpcError(rsp=el)
self.conf.rpc.commit_configuration = MagicMock(side_effect=ex)
self.assertRaises(CommitError, self.conf.commit_check)
def test_config_diff(self):
self.conf.rpc.get_configuration = MagicMock()
self.conf.diff()
self.conf.rpc.get_configuration.\
assert_called_with({'compare': 'rollback', 'rollback': '0', 'format': 'text'})
def test_config_pdiff(self):
self.conf.diff = MagicMock(return_value='Stuff')
self.conf.pdiff()
print self.conf.diff.call_args
self.conf.diff.assert_called_once_with(0)
def test_config_load(self):
self.assertRaises(RuntimeError, self.conf.load)
def test_config_load_vargs_len(self):
self.assertRaises(RuntimeError, self.conf.load,
'test.xml')
def test_config_load_len_with_format(self):
self.conf.rpc.load_config = \
MagicMock(return_value='rpc_contents')
self.assertEqual(self.conf.load('test.xml', format='set'),
'rpc_contents')
@patch('__builtin__.open')
def test_config_load_lformat_byext_ValueError(self, mock_open):
#.........这里部分代码省略.........
示例9: apply_template
# 需要导入模块: from jnpr.junos.utils.config import Config [as 别名]
# 或者: from jnpr.junos.utils.config.Config import commit_check [as 别名]
def apply_template(self, template):
print self.dev
conf_string = template.strip()
print conf_string
if re.search(r"^<", conf_string):
print "Found a encoded string"
conf_string = self.unescape(conf_string)
print conf_string
# try to determine the format of our config_string
config_format = "set"
if re.search(r"^\s*<.*>$", conf_string, re.MULTILINE):
print "found xml style config"
config_format = "xml"
elif re.search(r"^\s*(set|delete|replace|rename)\s", conf_string):
print "found set style config"
config_format = "set"
elif re.search(r"^[a-z:]*\s*\w+\s+{", conf_string, re.I) and re.search(r".*}\s*$", conf_string):
print "found a text style config"
config_format = "text"
print "using format: " + config_format
cu = Config(self.dev)
try:
cu.lock()
except LockError as le:
print "Could not lock database!"
print str(le)
self.dev.close()
return "Failed to lock configuration database! %s" % str(le)
try:
print "loading config"
cu.load(conf_string, format=config_format)
except Exception as e:
print "Could not load configuration"
print str(e)
try:
cu.unlock()
except UnlockError as ue:
print str(ue)
self.dev.close()
return "Failed, could not load the configuration template. %s" % str(e)
diff = cu.diff()
print diff
if diff is not None:
try:
cu.commit_check()
print "Committing config!"
cu.commit(comment="Commit via a_frame")
except CommitError as ce:
print "Could not load config! %s" % str(ce)
cu.rollback()
try:
print "Unlocking database!"
cu.unlock()
except UnlockError as ue:
print "Could not unlock database"
print str(ue)
print repr(ce)
self.dev.close()
return "Failed, commit check failed. %s" % str(ce)
else:
# nothing to commit
print "Nothing to commit - no diff found"
cu.unlock()
self.dev.close()
return "Nothing to commit!"
try:
print "Unlocking database!"
cu.unlock()
except UnlockError as ue:
print "Could not unlock database"
print str(ue)
self.dev.close()
return "Committed, but could not unlock db"
print "Closing device handle"
self.dev.close()
return "Completed with diff: %s" % diff
示例10: Netconf
# 需要导入模块: from jnpr.junos.utils.config import Config [as 别名]
# 或者: from jnpr.junos.utils.config.Config import commit_check [as 别名]
class Netconf(object):
def __init__(self, module):
self.module = module
self.device = None
self.config = None
self._locked = False
def _fail(self, msg):
if self.device:
if self._locked:
self.config.unlock()
self.disconnect()
self.module.fail_json(msg=msg)
def connect(self, **kwargs):
try:
host = self.module.params['host']
port = self.module.params['port'] or 830
user = self.module.params['username']
passwd = self.module.params['password']
key_filename = self.module.params['ssh_keyfile']
self.device = Device(host, user=user, passwd=passwd, port=port,
gather_facts=False, ssh_private_key_file=key_filename).open()
self.config = Config(self.device)
except Exception:
exc = get_exception()
self._fail('unable to connect to %s: %s' % (host, str(exc)))
def run_commands(self, commands, **kwargs):
response = list()
fmt = kwargs.get('format') or 'xml'
for cmd in to_list(commands):
try:
resp = self.device.cli(command=cmd, format=fmt)
response.append(resp)
except (ValueError, RpcError):
exc = get_exception()
self._fail('Unable to get cli output: %s' % str(exc))
except Exception:
exc = get_exception()
self._fail('Uncaught exception - please report: %s' % str(exc))
return response
def unlock_config(self):
try:
self.config.unlock()
self._locked = False
except UnlockError:
exc = get_exception()
self.module.log('unable to unlock config: {0}'.format(str(exc)))
def lock_config(self):
try:
self.config.lock()
self._locked = True
except LockError:
exc = get_exception()
self.module.log('unable to lock config: {0}'.format(str(exc)))
def check_config(self):
if not self.config.commit_check():
self._fail(msg='Commit check failed')
def commit_config(self, comment=None, confirm=None):
try:
kwargs = dict(comment=comment)
if confirm and confirm > 0:
kwargs['confirm'] = confirm
return self.config.commit(**kwargs)
except CommitError:
exc = get_exception()
msg = 'Unable to commit configuration: {0}'.format(str(exc))
self._fail(msg=msg)
def load_config(self, candidate, action='replace', comment=None,
confirm=None, format='text', commit=True):
merge = action == 'merge'
overwrite = action == 'overwrite'
self.lock_config()
try:
self.config.load(candidate, format=format, merge=merge,
overwrite=overwrite)
except ConfigLoadError:
exc = get_exception()
msg = 'Unable to load config: {0}'.format(str(exc))
self._fail(msg=msg)
diff = self.config.diff()
self.check_config()
if commit and diff:
#.........这里部分代码省略.........
示例11: run
# 需要导入模块: from jnpr.junos.utils.config import Config [as 别名]
# 或者: from jnpr.junos.utils.config.Config import commit_check [as 别名]
def run(self):
# import pdb; pdb.set_trace() # dbg
dev = Device(host=self.host, user=self.user, password=self.passw)
try:
dev.open(auto_probe=7)
except:
self.result += "Could not connect to host\n"
return
if not self.mode:
self.result += "A mode of operation must be specified"
elif self.mode == "configure":
confc = Config(dev)
if self.action == "commit":
self.result += confc.commit(confirm=True, comment="Commited " + str( datetime.datetime.now() ) + " by jCnC")
elif self.action == "commit_check":
if confc.commit_check():
self.result += "Commit Check Succeeds"
else:
self.result += "Commit Check Failed"
elif self.action == "diff":
x = int(self.param)
self.result += confc.diff() #self.param)
elif self.action == "load":
self.result += confc.load(path=param, overwrite=True, format='conf')
elif self.action == "lock":
self.result += confc.lock()
elif self.action == "rescue":
self.result += confc.rescue(param)
elif self.action == "rollback":
self.result += confc.rollback(param)
elif self.action == "save":
shell = self.start_shell()
stdin, stdout, stderr = shell.exec_command("cli show configuration | cat")
config = ""
for line in stdout.readlines():
self.result += line
config += line
## check for host dir, create if not found
hostpath = self.host
if not os.path.exists(hostpath):
os.makedirs(hostpath)
hostpath += "/configuration"
## copy file into directory
with open(hostpath, 'w') as output:
output.write(config)
shell.exec_command("rm /tmp/configuration\n")
shell.close
elif self.action == "unlock":
self.result += confc.unlock()
else:
self.result += "Configuration Action not found"
elif self.mode == "software":
softw = SW(dev)
if self.action == "install":
hash = str('')
with open(param+'.md5') as hashfile:
hash = hashfile.read()
hashfile.closed()
self.action += softw.install(param, remote_path='/var/tmp', progress=dev, validate=False, checksum=hash, cleanfs=False, no_copy=False, timout=1800)
elif action == "rollback":
self.action += softw.rollback()
elif self.mode == "cli":
shell = self.start_shell()
if self.action == "terminal":
stdin, stdout, stderr = shell.exec_command("cli")
stdin.write(self.param + '\n')
stdin.write("exit\n")
stdin.flush()
for line in stdout.readlines():
self.result += line
elif self.action == "file":
self.result += "\n"
stdin, stdout, stderr = shell.exec_command("cli")
cfile = open(self.param, 'r')
for line in cfile:
stdin.write(line + '\n')
stdin.write("exit\n")
data = stdout.readlines()
for line in data:
self.result += "\n" + line
shell.close()
elif self.mode == "info":
shell = self.start_shell()
if self.action == "alarms":
stdin, stdout, stderr = shell.exec_command("cli show chassis alarms")
data = stdout.readlines()
for line in data:
self.result += line
elif self.action == "active_ports":
stdin, stdout, stderr = shell.exec_command('cli show interfaces terse | grep -v "\.0" | grep -v down')
data = stdout.readlines()
for line in data:
self.result += line
elif self.action == "inactive_ports":
stdin, stdout, stderr = shell.exec_command('cli show interfaces terse | grep -v "\.0" | grep down')
data = stdout.readlines()
for line in data:
self.result += line
else:
#.........这里部分代码省略.........