def provision_eos(port, username, password):
connection = pyeapi.client.connect(
transport='https',
host='localhost',
username='vagrant',
password='vagrant',
port=port
)
device = pyeapi.client.Node(connection)
commands = list()
commands.append('configure session')
commands.append('rollback clean-config')
with open('../eos/initial.conf', 'r') as f:
lines = f.readlines()
for line in lines:
line = line.strip()
if line == '':
continue
if line.startswith('!'):
continue
commands.append(line)
commands[-1] = 'commit'
try:
device.run_commands(commands)
except httplib.BadStatusLine:
# This actually means everything went fine
print_info_message()
评论列表
文章目录