Created
October 13, 2017 21:10
-
-
Save aojea/23055192ac23d5a9ff2bc5fa591d1b64 to your computer and use it in GitHub Desktop.
Configure JunOS device from text file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from jnpr.junos import Device | |
from jnpr.junos.utils.config import Config | |
import sys | |
import argparse | |
def main(argv): | |
parser = argparse.ArgumentParser() | |
parser.add_argument("h", help="host IP address") | |
parser.add_argument("f", help="configuration filename") | |
parser.add_argument("user", help="username") | |
parser.add_argument("pass", help="password") | |
args = parser.parse_args() | |
dev = Device(host=args.h, user=args.user, password=args.pass ) | |
dev.open() | |
with Config(dev, mode='private') as cu: | |
cu.load(path=args.f, format='text', override=True) | |
cu.commit() | |
dev.close() | |
if __name__ == "__main__": | |
main(sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment