def set_speed_manual(self, command_node, xs_prefix='', command_logger=None): """ <Commands xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.qualisystems.com/ResourceManagement/DriverCommands.xsd"> <Command CommandName="SetSpeedManual" CommandId="d361b400-75bc-4029-a697-7cf67e8e9d0c"> <Parameters xsi:type="SetSpeedManualCommandParameters"> <SrcPort>192.168.2.41/12-12</SrcPort> <DstPort>192.168.2.41/11-11</DstPort> <Speed /> <Duplex /> </Parameters> </Command> </Commands> :param command_node: :param xs_prefix: :return: """ command_logger.info(XMLWrapper.get_string_from_xml(command_node)) parameters_node = XMLWrapper.get_child_node(command_node, 'Parameters', xs_prefix) src_port = XMLWrapper.get_node_text( XMLWrapper.get_child_node(parameters_node, 'SrcPort', xs_prefix)) dst_port = XMLWrapper.get_node_text( XMLWrapper.get_child_node(parameters_node, 'DstPort', xs_prefix)) speed = XMLWrapper.get_node_text( XMLWrapper.get_child_node(parameters_node, 'Speed', xs_prefix)) duplex = XMLWrapper.get_node_text( XMLWrapper.get_child_node(parameters_node, 'Duplex', xs_prefix)) # return self._driver_handler.set_speed_manual(src_port.split('/'), dst_port.split('/'), speed, duplex, command_logger) return self._driver_handler.set_speed_manual(command_logger)
def get_resource_description(self, command_node, xs_prefix='', command_logger=None): """ <Commands xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.qualisystems.com/ResourceManagement/DriverCommands.xsd"> <Command CommandName="GetResourceDescription" CommandId="0d7000f2-dc20-401a-bdc6-09a2e1cb1f02"> <Parameters xsi:type="GetResourceDescriptionParameters"> <Address>192.168.28.223</Address> </Parameters> </Command> </Commands> :param command_node: :return: """ command_logger.info(XMLWrapper.get_string_from_xml(command_node)) parameters_node = XMLWrapper.get_child_node(command_node, 'Parameters', xs_prefix) address_node = XMLWrapper.get_child_node(parameters_node, 'Address', xs_prefix) address_str = XMLWrapper.get_node_text(address_node) xml_description = self._driver_handler.get_resource_description( address_str, command_logger) command_logger.info(XMLWrapper.get_string_from_xml(xml_description)) return xml_description
def set_speed_manual(self, command_node, xs_prefix='', command_logger=None): """ <Commands xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.qualisystems.com/ResourceManagement/DriverCommands.xsd"> <Command CommandName="SetSpeedManual" CommandId="d361b400-75bc-4029-a697-7cf67e8e9d0c"> <Parameters xsi:type="SetSpeedManualCommandParameters"> <SrcPort>192.168.2.41/12-12</SrcPort> <DstPort>192.168.2.41/11-11</DstPort> <Speed /> <Duplex /> </Parameters> </Command> </Commands> :param command_node: :param xs_prefix: :return: """ command_logger.info(XMLWrapper.get_string_from_xml(command_node)) parameters_node = XMLWrapper.get_child_node(command_node, 'Parameters', xs_prefix) src_port = XMLWrapper.get_node_text(XMLWrapper.get_child_node(parameters_node, 'SrcPort', xs_prefix)) dst_port = XMLWrapper.get_node_text(XMLWrapper.get_child_node(parameters_node, 'DstPort', xs_prefix)) speed = XMLWrapper.get_node_text(XMLWrapper.get_child_node(parameters_node, 'Speed', xs_prefix)) duplex = XMLWrapper.get_node_text(XMLWrapper.get_child_node(parameters_node, 'Duplex', xs_prefix)) # return self._driver_handler.set_speed_manual(src_port.split('/'), dst_port.split('/'), speed, duplex, command_logger) return self._driver_handler.set_speed_manual(command_logger)
def logout(self, command_node, xs_prefix='', command_logger=None): """ <Commands xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Command CommandName="Logout" CommandId="567f4dc1-e2e5-4980-b726-a5d906c8679b"> <Parameters xsi:type="LogoutCommandParameters"> <User>root</User> </Parameters> </Command> </Commands> """ command_logger.info(XMLWrapper.get_string_from_xml(command_node)) parameters_node = XMLWrapper.get_child_node(command_node, 'Parameters', xs_prefix) username = XMLWrapper.get_child_node(parameters_node, 'User', xs_prefix) return self._driver_handler.logout(username, command_logger)
def get_state_id(self, command_node, xs_prefix='', command_logger=None): """ <Commands xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.qualisystems.com/ResourceManagement/DriverCommands.xsd"> <Command CommandName="GetStateId" CommandId="9d75a6b5-3d1d-4e65-b3ba-42d7344adaef"> <Parameters xsi:type="GetStateCommandParameters"/> </Command> </Commands> :param command_node: :param xs_prefix: :return: """ command_logger.info(XMLWrapper.get_string_from_xml(command_node)) state_id_node = XMLWrapper.parse_xml(self._state_id_template) XMLWrapper.set_node_text(state_id_node, '-1') return state_id_node
def map_bidi(self, command_node, xs_prefix='', command_logger=None): """ <Commands xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.qualisystems.com/ResourceManagement/DriverCommands.xsd"> <Command CommandName="MapBidi" CommandId="c2a37eca-472f-4492-810e-cdc237a7c33a"> <Parameters xsi:type="BiMappingCommandParameters"> <MapPort_A>192.168.28.223/91</MapPort_A> <MapPort_B>192.168.28.223/10</MapPort_B> <MappingGroupName/> </Parameters> </Command> </Commands> :param command_node: :param xs_prefix: :return: """ command_logger.info(XMLWrapper.get_string_from_xml(command_node)) parameters_node = XMLWrapper.get_child_node(command_node, 'Parameters', xs_prefix) src_port_node = XMLWrapper.get_child_node(parameters_node, 'MapPort_A', xs_prefix) dst_port_node = XMLWrapper.get_child_node(parameters_node, 'MapPort_B', xs_prefix) src_port_str = XMLWrapper.get_node_text(src_port_node) dst_port_str = XMLWrapper.get_node_text(dst_port_node) response = self._driver_handler.map_bidi(src_port_str.split('/'), dst_port_str.split('/'), command_logger) command_logger.info(XMLWrapper.get_string_from_xml(response)) return response
def map_uni(self, command_node, xs_prefix='', command_logger=None): """ <Commands xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.qualisystems.com/ResourceManagement/DriverCommands.xsd"> <Command CommandName="MapUni" CommandId="09cc9080-386b-4143-aaa0-a7211370304b"> <Parameters xsi:type="MapUniCommandParameters"> <SrcPort>192.168.28.223/2</SrcPort> <DstPort>192.168.28.223/49</DstPort> </Parameters> </Command> </Commands> :param command_node: :param xs_prefix: :return: """ command_logger.info(XMLWrapper.get_string_from_xml(command_node)) parameters_node = XMLWrapper.get_child_node(command_node, 'Parameters', xs_prefix) src_port_node = XMLWrapper.get_child_node(parameters_node, 'SrcPort', xs_prefix) dst_port_node = XMLWrapper.get_child_node(parameters_node, 'DstPort', xs_prefix) src_port_str = XMLWrapper.get_node_text(src_port_node) dst_port_str = XMLWrapper.get_node_text(dst_port_node) response = self._driver_handler.map_uni(src_port_str.split('/'), dst_port_str.split('/'), command_logger) command_logger.info(XMLWrapper.get_string_from_xml(response)) return response
def get_attribute_value(self, command_node, xs_prefix='', command_logger=None): """ <Commands xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.qualisystems.com/ResourceManagement/DriverCommands.xsd"> <Command CommandName="GetAttributeValue" CommandId="c2a37eca-472f-4492-810e-cdc237a7c33a"> <Parameters xsi:type="??????"> <Address>192.168.28.223/91</Address> <Attribute>Serial Number</Attribute> </Parameters> </Command> </Commands> :param command_node: :param xs_prefix: :return: """ command_logger.info(XMLWrapper.get_string_from_xml(command_node)) parameters_node = XMLWrapper.get_child_node(command_node, 'Parameters', xs_prefix) address = XMLWrapper.get_node_text( XMLWrapper.get_child_node(parameters_node, 'Address', xs_prefix)) attr_name = XMLWrapper.get_node_text( XMLWrapper.get_child_node(parameters_node, 'Attribute', xs_prefix)) # return self._driver_handler.get_attribute_value(address, attr_name, command_logger) return XMLWrapper.parse_xml('<Attribute Name="' + attr_name + '" Type="String" Value="fake_value"/>')
def logout(self, command_node, xs_prefix='', command_logger=None): """ <Commands xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Command CommandName="Logout" CommandId="567f4dc1-e2e5-4980-b726-a5d906c8679b"> </Command> </Commands> """ command_logger.info(XMLWrapper.get_string_from_xml(command_node)) return self._driver_handler.logout(command_logger)
def login(self, command_node, xs_prefix='', command_logger=None): """ <Commands xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.qualisystems.com/ResourceManagement/DriverCommands.xsd"> <Command CommandName="Login" CommandId="567f4dc1-e2e5-4980-b726-a5d906c8679b"> <Parameters xsi:type="LoginCommandParameters"> <Address>192.168.28.223</Address>00 <User>root</User> <Password>root</Password> </Parameters> </Command> </Commands> :param xml_node: :return: """ command_logger.info("Begin") command_logger.info(XMLWrapper.get_string_from_xml(command_node)) parameters_node = XMLWrapper.get_child_node(command_node, 'Parameters', xs_prefix) address_node = XMLWrapper.get_child_node(parameters_node, 'Address', xs_prefix) user_node = XMLWrapper.get_child_node(parameters_node, 'User', xs_prefix) password_node = XMLWrapper.get_child_node(parameters_node, 'Password', xs_prefix) address_str = XMLWrapper.get_node_text(address_node) user_str = XMLWrapper.get_node_text(user_node) password_str = XMLWrapper.get_node_text(password_node) response_node = None if self._device_address != address_str or self._device_user != user_str or \ self._device_password != password_str: response_node = self._driver_handler.login(address_str, user_str, password_str, command_logger) self._device_address = address_str self._device_user = user_str self._device_password = password_str command_logger.info(XMLWrapper.get_string_from_xml(response_node)) command_logger.info("end") return response_node
def set_state_id(self, command_node, xs_prefix='', command_logger=None): """ <Commands xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.qualisystems.com/ResourceManagement/DriverCommands.xsd"> <Command CommandName="SetStateId" CommandId="29d2dd21-0a18-4c94-a43c-0f0e8f355151"> <Parameters xsi:type="SetStateCommandParameters"> <StateId>635896045076120729</StateId> </Parameters> </Command> </Commands> :param command_node: :param xs_prefix: :return: """ command_logger.info(XMLWrapper.get_string_from_xml(command_node)) parameters_node = XMLWrapper.get_child_node(command_node, 'Parameters', xs_prefix) state_node = XMLWrapper.get_child_node(parameters_node, 'StateId', xs_prefix) self._state_id = XMLWrapper.get_node_text(state_node) return None
def map_clear(self, command_node, xs_prefix='', command_logger=None): """ <Commands xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.qualisystems.com/ResourceManagement/DriverCommands.xsd"> <Command CommandName="MapClear" CommandId="4fa3d6d9-e5b2-446a-9c39-6bfb12842d6c"> <Parameters xsi:type="MapClearParameters"> <MapPort>192.168.28.223/88</MapPort> <MapPort>192.168.28.223/13</MapPort> </Parameters> </Command> </Commands> :param command_node: :param xs_prefix: :return: """ command_logger.info(XMLWrapper.get_string_from_xml(command_node)) parameters_node = XMLWrapper.get_child_node(command_node, 'Parameters', xs_prefix) map_ports = XMLWrapper.get_all_child_node(parameters_node, 'MapPort', xs_prefix) src_port_str = XMLWrapper.get_node_text(map_ports[0]) dst_port_str = XMLWrapper.get_node_text(map_ports[1]) response = self._driver_handler.map_clear(src_port_str.split('/'), dst_port_str.split('/'), command_logger) command_logger.info(XMLWrapper.get_string_from_xml(response)) return response
def get_resource_description(self, command_node, xs_prefix='', command_logger=None): """ <Commands xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.qualisystems.com/ResourceManagement/DriverCommands.xsd"> <Command CommandName="GetResourceDescription" CommandId="0d7000f2-dc20-401a-bdc6-09a2e1cb1f02"> <Parameters xsi:type="GetResourceDescriptionParameters"> <Address>192.168.28.223</Address> </Parameters> </Command> </Commands> :param command_node: :return: """ command_logger.info(XMLWrapper.get_string_from_xml(command_node)) parameters_node = XMLWrapper.get_child_node(command_node, 'Parameters', xs_prefix) address_node = XMLWrapper.get_child_node(parameters_node, 'Address', xs_prefix) address_str = XMLWrapper.get_node_text(address_node) xml_description = self._driver_handler.get_resource_description(address_str, command_logger) command_logger.info(XMLWrapper.get_string_from_xml(xml_description)) return xml_description
def set_speed_manual(self, command_node, xs_prefix='', command_logger=None): """ <Commands xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.qualisystems.com/ResourceManagement/DriverCommands.xsd"> <Command CommandName="SetSpeedManual" CommandId="d361b400-75bc-4029-a697-7cf67e8e9d0c"> <Parameters xsi:type="SetSpeedManualCommandParameters"> <SrcPort>192.168.2.41/12-12</SrcPort> <DstPort>192.168.2.41/11-11</DstPort> <Speed /> <Duplex /> </Parameters> </Command> </Commands> :param command_node: :param xs_prefix: :return: """ command_logger.info(XMLWrapper.get_string_from_xml(command_node)) response = self._driver_handler.set_speed_manual(command_logger) return response
def get_attribute_value(self, command_node, xs_prefix='', command_logger=None): """ <Commands xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.qualisystems.com/ResourceManagement/DriverCommands.xsd"> <Command CommandName="GetAttributeValue" CommandId="c2a37eca-472f-4492-810e-cdc237a7c33a"> <Parameters xsi:type="??????"> <Address>192.168.28.223/91</Address> <Attribute>Serial Number</Attribute> </Parameters> </Command> </Commands> :param command_node: :param xs_prefix: :return: """ command_logger.info(XMLWrapper.get_string_from_xml(command_node)) parameters_node = XMLWrapper.get_child_node(command_node, 'Parameters', xs_prefix) address = XMLWrapper.get_node_text(XMLWrapper.get_child_node(parameters_node, 'Address', xs_prefix)) attr_name = XMLWrapper.get_node_text(XMLWrapper.get_child_node(parameters_node, 'Attribute', xs_prefix)) # return self._driver_handler.get_attribute_value(address, attr_name, command_logger) return XMLWrapper.parse_xml('<Attribute Name="' + attr_name + '" Type="String" Value="fake_value"/>')
command = "dlt-crs-fiber::{0}&{1}:{2};".format(src_in_port, dst_in_port, self._incr_ctag()) self._session.send_command(command, re_string=self._prompt) else: self.map_clear_to(src_port, dst_port, command_logger) else: raise Exception(self.__class__.__name__, "Selected '{}' connection type is not supported".format(self._service_mode)) def set_speed_manual(self, command_logger=None): pass if __name__ == '__main__': import sys from cloudshell.core.logger.qs_logger import get_qs_logger from common.xml_wrapper import XMLWrapper ConfigurationParser.set_root_folder(get_file_folder(sys.argv[0].replace("/glimmerglass/", "/"))) gglass = GlimmerglassDriverHandler() plogger = get_qs_logger('Autoload', 'GlimmerGlass', 'GlimmerGlass') gglass.login('localhost:1023', 'admin', '********', plogger) result = gglass.get_resource_description('localhost:1023') result1 = gglass.get_resource_description('localhost:1023') print XMLWrapper.get_string_from_xml(result) print XMLWrapper.get_string_from_xml(result1)
def get_resource_description(self, address, command_logger=None): switchfamily = ConfigurationParser.get("driver_variable", "switch_family") switchmodel = ConfigurationParser.get("driver_variable", "switch_model") bladeprefix = ConfigurationParser.get("driver_variable", "blade_name_prefix") bladefamily = ConfigurationParser.get("driver_variable", "blade_family") blademodel = ConfigurationParser.get("driver_variable", "blade_model") portprefix = ConfigurationParser.get("driver_variable", "port_name_prefix") portfamily = ConfigurationParser.get("driver_variable", "port_family") portmodel = ConfigurationParser.get("driver_variable", "port_model") log2phy_in = ConfigurationParser.get("driver_variable", "dict_logical_port_to_physical_input_port") log2phy_out = ConfigurationParser.get("driver_variable", "dict_logical_port_to_physical_output_port") phy2log_in = {} phy2log_out = {} for log in log2phy_in: phy2log_in[log2phy_in[log]] = log for log in log2phy_out: phy2log_out[log2phy_out[log]] = log sw = ResourceInfo2('', address, switchfamily, switchmodel, serial=address) switchstate = self.send_command('switchstate') switchstate = re.sub(r'.\[\d+m', '', switchstate) self.log('CLEANED SWITCH STATE: (((' + switchstate + ')))') outaddr2inaddrstatus = {} max_global_row = -1 for line in switchstate.split('\n'): line = line.strip() matches = re.search(r"R(?P<global_row>\d+)#" r"(?P<state>[a-zA-Z])" r"\s+(?P<status0>[a-zA-Z]+)(?P<addr0>\d+)" r"\s+(?P<status1>[a-zA-Z]+)(?P<addr1>\d+)" r"\s+(?P<status2>[a-zA-Z]+)(?P<addr2>\d+)" r"\s+(?P<status3>[a-zA-Z]+)(?P<addr3>\d+)" r"\s+(?P<status4>[a-zA-Z]+)(?P<addr4>\d+)" r"\s+(?P<status5>[a-zA-Z]+)(?P<addr5>\d+)" r"\s+(?P<status6>[a-zA-Z]+)(?P<addr6>\d+)" r"\s+(?P<status7>[a-zA-Z]+)(?P<addr7>\d+)" r"\s+(?P<status8>[a-zA-Z]+)(?P<addr8>\d+)" r"\s+(?P<status9>[a-zA-Z]+)(?P<addr9>\d+)" r"\s+(?P<status10>[a-zA-Z]+)(?P<addr10>\d+)" r"\s+(?P<status11>[a-zA-Z]+)(?P<addr11>\d+)", line, re.DOTALL) if matches: d = matches.groupdict() global_row = int(d['global_row']) for col in range(0, 12): outaddr = global_row * 12 + col inaddr = d['addr' + str(col)] status = d['status' + str(col)] if not status.startswith('U'): outaddr2inaddrstatus[outaddr] = (inaddr, status) if global_row > max_global_row: max_global_row = global_row for module in range(0, (max_global_row + 1) / 8): bladeserial = address + '/' + str(module) blade = ResourceInfo2('%s%0.2d' % (bladeprefix, module), str(module), bladefamily, blademodel, serial=bladeserial) sw.subresources.append(blade) for row in range(0, 8): for col in range(0, 12): # portname = 'row_%d_col_%0.2d' % (row, col) # portaddr = '%d,%d' % (row, col) log_absaddr = (module * 8 + row) * 12 + col if str(log_absaddr) in log2phy_in: phy_absaddr_in = int(log2phy_in[str(log_absaddr)]) else: phy_absaddr_in = log_absaddr if str(log_absaddr) in log2phy_out: phy_absaddr_out = int(log2phy_out[str(log_absaddr)]) else: phy_absaddr_out = log_absaddr if phy_absaddr_in == phy_absaddr_out: phy_absaddr = '%d' % (phy_absaddr_in) else: phy_absaddr = '%d-%d' % (phy_absaddr_in, phy_absaddr_out) portname = '%s%0.4d' % (portprefix, log_absaddr) portaddr = '%s/%d/%s' % (address, module, phy_absaddr) portserial = portaddr if phy_absaddr_out in outaddr2inaddrstatus and outaddr2inaddrstatus[phy_absaddr_out][1].startswith( 'A'): conn_phy_absaddr = outaddr2inaddrstatus[phy_absaddr_out][0] if conn_phy_absaddr in phy2log_in: conn_log_absaddr = int(phy2log_in[conn_phy_absaddr]) else: conn_log_absaddr = int(conn_phy_absaddr) if str(conn_log_absaddr) in log2phy_in: a = log2phy_in[str(conn_log_absaddr)] else: a = str(conn_log_absaddr) if str(conn_log_absaddr) in log2phy_out: b = log2phy_out[str(conn_log_absaddr)] else: b = str(conn_log_absaddr) if a == b: ab = '%s' % (a) else: ab = '%s-%s' % (a, b) connglobrow = conn_log_absaddr / 12 connmodule = connglobrow / 8 mappath = '%s/%d/%s' % (address, connmodule, ab) else: mappath = None blade.subresources.append(ResourceInfo2( portname, portaddr, portfamily, portmodel, map_path=mappath, serial=portserial)) self.log('resource info xml: (((' + sw.to_string() + ')))') return XMLWrapper.parse_xml(sw.to_string())
def get_resource_description(self, address, command_logger=None): switchfamily = ConfigurationParser.get("driver_variable", "switch_family") switchmodel = ConfigurationParser.get("driver_variable", "switch_model") bladeprefix = ConfigurationParser.get("driver_variable", "blade_name_prefix") bladefamily = ConfigurationParser.get("driver_variable", "blade_family") blademodel = ConfigurationParser.get("driver_variable", "blade_model") portprefix = ConfigurationParser.get("driver_variable", "port_name_prefix") portfamily = ConfigurationParser.get("driver_variable", "port_family") portmodel = ConfigurationParser.get("driver_variable", "port_model") sw = ResourceInfo2('', address, switchfamily, switchmodel, serial=address) switchstate = self.send_command('switchstate') switchstate = re.sub(r'.\[\d+m', '', switchstate) self.log('CLEANED SWITCH STATE: (((' + switchstate + ')))') outaddr2inaddrstatus = {} max_global_row = -1 for line in switchstate.split('\n'): line = line.strip() matches = re.search(r"R(?P<global_row>\d+)#" r"(?P<state>[a-zA-Z])" r"\s+(?P<status0>[a-zA-Z]+)(?P<addr0>\d+)" r"\s+(?P<status1>[a-zA-Z]+)(?P<addr1>\d+)" r"\s+(?P<status2>[a-zA-Z]+)(?P<addr2>\d+)" r"\s+(?P<status3>[a-zA-Z]+)(?P<addr3>\d+)" r"\s+(?P<status4>[a-zA-Z]+)(?P<addr4>\d+)" r"\s+(?P<status5>[a-zA-Z]+)(?P<addr5>\d+)" r"\s+(?P<status6>[a-zA-Z]+)(?P<addr6>\d+)" r"\s+(?P<status7>[a-zA-Z]+)(?P<addr7>\d+)" r"\s+(?P<status8>[a-zA-Z]+)(?P<addr8>\d+)" r"\s+(?P<status9>[a-zA-Z]+)(?P<addr9>\d+)" r"\s+(?P<status10>[a-zA-Z]+)(?P<addr10>\d+)" r"\s+(?P<status11>[a-zA-Z]+)(?P<addr11>\d+)", line, re.DOTALL) if matches: d = matches.groupdict() global_row = int(d['global_row']) for col in range(0, 12): outaddr = global_row*12 + col inaddr = d['addr' + str(col)] instatus = d['status' + str(col)] outaddr2inaddrstatus[outaddr] = (inaddr, instatus) if global_row > max_global_row: max_global_row = global_row for module in range(0, (max_global_row + 1) / 8): bladeserial = address + '/' + str(module) blade = ResourceInfo2('%s%0.2d' % (bladeprefix, module), str(module), bladefamily, blademodel, serial=bladeserial) sw.subresources.append(blade) for row in range(0,8): for col in range(0, 12): # portname = 'row_%d_col_%0.2d' % (row, col) # portaddr = '%d,%d' % (row, col) absaddr = (module * 8 + row) * 12 + col portname = '%s%0.4d' % (portprefix, absaddr) portaddr = '%d' % (absaddr) if absaddr in outaddr2inaddrstatus and outaddr2inaddrstatus[absaddr][1].startswith('A'): connabsaddr = int(outaddr2inaddrstatus[absaddr][0]) connglobrow = connabsaddr / 12 connmodule = connglobrow / 8 # connrow = connglobrow % 8 # conncol = connabsaddr % 12 mappath = '%s/%d/%d' % (address, connmodule, connabsaddr) else: mappath = None # todo Warning "An item with the same key has already been added." caused by nonblank mappath portserial = address + '/' + str(module) + '/' + portaddr blade.subresources.append(ResourceInfo2( portname, portaddr, portfamily, portmodel, map_path=mappath, serial=portserial)) self.log('resource info xml: (((' + sw.to_string() + ')))') return XMLWrapper.parse_xml(sw.to_string())