import sys
import os
sys.path.append(os.path.abspath("../md/"))

import media
import time
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("action")
parser.add_argument('host')
parser.add_argument('start_vid', type=int)
parser.add_argument('end_vid', type=int)
args = parser.parse_args()

action = args.action
DUT = args.host
start = args.start_vid
end = args.end_vid

if action == 'add' or action == 'delete':

    t1 = media.Telnet(DUT, output=True)
    t1.command("config terminal")

    if action == 'add':
        for vid in range(start, end+1):
            t1.command("vlan database")
            t1.command("vlan " + str(vid) + " bridge 1")
            t1.command("exit")
            t1.command("interface vlan1." + str(vid))
            t1.command("no shutdown")
            #t1.command("exit")
            t1.command("end")
            t1.command("config terminal")
    elif action == "delete":
        t1.command("vlan database")
        for vid in range(start, end+1):
            t1.command("no vlan " + str(vid) + " bridge 1")
else:
    print("\n$ Invalid argument, you must input add or delete")
    

