Example #1
0
def bt2_units():
	base_dir=GF.get_configxml('DProvXML', 1)
	deprov_file=base_dir+'/'+deprovxml
	try:
		deprov_fileobj=open(deprov_file, "r")
	except Exception as error:
		GF.print_error("Reading deprovision file", error, 1)
	else:
		bt2Units=list()
		deprov_xmlobj=GF.open_configxml(deprov_fileobj)
		deprov_fileobj.close()
		base_node=deprov_xmlobj.getroot()
		base_locaddr=int(base_node.attrib.get('addrBase'))
		for node in deprov_xmlobj.findall('.//xcoders//HashMap'):
			resource_id=node.find('.//NA').attrib.get('value')
			xcode_node=node.find('.//XCodeDevCfgT')
			macaddr_node=xcode_node.findall('.//macAddr//MacAddressT//List//NA')
			loc_addr=int(xcode_node.attrib.get('locAddr'))
			xcode_mac=''
			for mac in macaddr_node:
				val=int(mac.attrib.get('value'))
				hex_val="%02X" % int(hex(val&0xff)[2:], 16)
				xcode_mac=xcode_mac+hex_val
			macaddr=GF.prettify(xcode_mac)
			ip=GF.int2ip(base_locaddr+loc_addr)
			return_result=GF.formdhcp_host(resource_id, macaddr, ip)
			bt2Units.append(return_result)
		GF.writeDHCP_BT2_Units(bt2Units)
Example #2
0
def restart_vixs():
	for ip, mac in boardmacip_map.iteritems():
		try:
			telnet_conn=telnetlib.Telnet(ip,None,timeout_4telnet)
		except Exception as error:
			GF.print_error("Vixs restart 99", error, 1)
		else:
			telnet_conn.write('\n')
			telnet_conn.write('vixs restart 99\n')
			telnet_conn.close()
Example #3
0
def parse_xml(xmlobj):
	global boardmacip_map
	for node in xmlobj.findall('.//XCodeBoard'):
		board_mac=node.attrib.get('macAddr')
		board_ip=node.attrib.get('ipaddr')
		resource_id=node.attrib.get('resourceid')
		if board_mac == None or board_ip == None or resource_id == None:
			GF.print_error("Getting device info from XML", "Required details missing", 1)
		board_mac=GF.prettify(board_mac)
		boardmacip_map[board_ip]=board_mac
		boardridmac_map[board_mac]=int(resource_id)
Example #4
0
def get_vixs():
	for ip, mac in boardmacip_map.iteritems():
		try:
			telnet_conn=telnetlib.Telnet(ip,None,timeout_4telnet)
		except Exception as error:
			GF.print_error("Getting Vixs Mac", error, 1)
		else:
			telnet_conn.write('\n')
			telnet_conn.write('vixs ShowMac')
			result=telnet_conn.read_until('Mac Table Checksum')
			telnet_conn.close()
			vixs_list=result.split('\n')
			vixs_list.pop(0)
			vixs_list.pop()
			vixs_mac_list=list()
			for vixs in vixs_list:
				vixs_mac=re.split(' +', vixs)[2]
				vixs_mac_list.append(vixs_mac)
			if len(vixs_mac_list) != 20:
				GF.print_error("Getting vixs mac", "Not getting all the vixs", 1)
			boardvixs_map[mac]=vixs_mac_list