def main(): from tests.enablelog import ScriptLog, banner sl = ScriptLog("switch.log") log = sl.log from mdslib.switch import Switch user = '******' pw = 'nbv!2345' ip_address = '10.126.94.104' ip_address1 = '10.126.94.121' p = 8443 sw104 = Switch( ip_address=ip_address, username=user, password=pw, connection_type='https', port=p, timeout=30, verify_ssl=False) sw121 = Switch( ip_address=ip_address1, username=user, password=pw, connection_type='https', port=p, timeout=30, verify_ssl=False) sw220 = Switch( ip_address="10.126.94.220", username=user, password=pw, connection_type='https', port=p, timeout=30, verify_ssl=False) sw = sw220 banner("ip, version, model, npv") print("switch ip addr is : " + sw.ipaddr) print("switch version is : " + sw.version) print("switch model is : " + sw.model) print("switch npv state is : " + str(sw.npv)) banner("end")
print(fobj.status) print(fobj.transceiver.sfp_present) print(fobj.transceiver.bit_rate) print(type(fobj.transceiver.bit_rate)) print(fobj.transceiver.min_speed) print(fobj.transceiver.max_speed) print(fobj.transceiver.name) print(fobj.transceiver.part_number) print(fobj.transceiver.voltage) print(fobj.transceiver.current) print(fobj.transceiver.temperature) print(fobj.transceiver.tx_power) print(fobj.transceiver.rx_power) fobj1 = Fc(sw, name="fc1/4") banner(sw.ipaddr) print("---- counter obj") print(fobj1.counters) print("---- counter brief") print(fobj1.counters.brief) print("---- counter total_stats") print(fobj1.counters.total_stats) print("---- counter congestion_stats") print(fobj1.counters.congestion_stats) print("---- counter link_stats") print(fobj1.counters.link_stats) print("---- counter loop_stats") print(fobj1.counters.loop_stats) print("---- counter other_stats") print(fobj1.counters.other_stats)
# port=p, # timeout=30, # verify_ssl=False) sw = Switch(ip_address=ip_address, username=user, password=pw, connection_type='https', port=p, timeout=30, verify_ssl=False) from mdslib.devicealias import DeviceAlias from mdslib import constants banner(sw.ipaddr) d = DeviceAlias(sw) print("Check if invalid mode raises exception") try: d.mode = "asdsa" except Exception as e: print("Caught correct exception") print(e.args) print("Device alias mode : " + d.mode) print("Device alias distribution : " + str(d.distribute)) print("Device alias locked? : " + str(d.locked)) # print("Device alias entries : " + str(d.database)) print("Setting Device alias distribution to False...")
username=user, password=pw, connection_type='https', port=p, timeout=30, verify_ssl=False) sw121 = Switch(ip_address=ip_address1, username=user, password=pw, connection_type='https', port=p, timeout=30, verify_ssl=False) banner(" PortChannel section") banner("Create PC22 in sw121") # Lets play with port-channel pc22_121 = PortChannel(switch=sw121, id=22) pc22_121.create() pc22_121.description = "This is a sample pc description" banner("Get info about interface pc22_121") print("Desc: " + pc22_121.description) print("Mode: " + pc22_121.mode) print("Name: " + pc22_121.name) print("Speed: " + pc22_121.speed) print("Status: " + pc22_121.status) print("Trunk: " + pc22_121.trunk) pc22_121.channel_mode = "active" print("Ch-Mode: " + pc22_121.channel_mode)
# verify_ssl=False) sw121 = Switch(ip_address=ip_address1, username=user, password=pw, connection_type='https', port=p, timeout=30, verify_ssl=False) sw = sw121 from mdslib.vsan import Vsan from mdslib.fc import Fc banner("Creating vsan 98 and 99") v98 = Vsan(switch=sw, id=98) v99 = Vsan(switch=sw, id=99) v98.create("98thVsan") v99.create("99thVsan") banner("end") print() v1 = Vsan(switch=sw, id=1) print("Vsan 1 interfaces are..") print(v1.interfaces) # Lets create fc interface object for fc1/11,fc1/12,fc1/13 fc11 = Fc(switch=sw, name="fc1/11") fc12 = Fc(switch=sw, name="fc1/12") fc13 = Fc(switch=sw, name="fc1/13") v98.add_interfaces([fc11])
# o = z1.default_zone # print(o) # if type(o) is str: # break # # print("Set defzone to invalid value...") # try: # z1.default_zone = "asdasd" # except Exception as e: # print("Caught correct exception for defzone") # print(e.args) # s = "" # print(z1.members) # banner("Checking a new vsan's zone") v = vsan.Vsan(sw, id=456) v.create() int12 = fc.Fc(sw, "fc1/2") int13 = fc.Fc(sw, "fc1/3") pc1 = portchannel.PortChannel(sw, 1) pc1.create() z1 = zone.Zone(sw, v, "zonetemp") z1.clear_lock() if z1.name is None: print("Zone name is None") else: print("Zone name is " + z1.name) print("Zone vsan obj is : " + str(z1.vsan)) print("Zone def zone is : " + str(z1.default_zone)) print("Zone mode is : " + str(z1.mode))