def create_ipro_attribute_instance_with_specified_parameters(attribute_string): attribute_items = attribute_string.split() attribute_instance = CommonItem() attribute_instance.ipbr_id = '' attribute_instance.iface = '' attribute_instance.ip_address = '' attribute_instance.owner = '' attribute_instance.mode = '' attribute_instance.phb_set = '' attribute_instance.vrf = '' for attribute in attribute_items: items = attribute.split('=') if len(items) != 2: continue setattr(attribute_instance, items[0].lower().strip(), items[1].strip()) return attribute_instance
def _get_available_ip_with_sepcified_recovery_group_type(rg_type): command = 'fsclish -c "show networking instance default address"' output = connections.execute_mml_without_check(command) if output.find('type') != -1: ip_addr_pattern_str = "(\w+)\s+type\s+:\s+(\w+)\s+address\s+:\s+(\d+.\d+.\d+.\d+)/(\d+)\s+owner\s+:\s+(\S+)" iface_index = 0 addr_index = 2 owner_index = 4 else: ip_addr_pattern_str = "(\w+)\s+address\s+:\s+(\d+.\d+.\d+.\d+)/(\d+)\s+owner\s+:\s+(\S+)" iface_index = 0 addr_index = 1 owner_index = 3 ip_addr_list = re.findall(ip_addr_pattern_str, output) eitp_ip_list = [] for ip_info in ip_addr_list: if ip_info[addr_index].startswith('169.254'): continue if -1 == ip_info[owner_index].find(rg_type): continue temp_items = ip_info[owner_index].split('-') if len(temp_items) == 1: index = 0 else: index = atoi(temp_items[1]) if index >= len(eitp_ip_list): for i in range(len(eitp_ip_list), index + 1): eitp_ip_list.append([]) ip_content = CommonItem() ip_content.rg_name = ip_info[owner_index] ip_content.ip_addr = ip_info[addr_index] ip_content.iface = ip_info[iface_index] eitp_ip_list[index].append(ip_content) return eitp_ip_list
def show_ipro(ipbr_id='', ip_address='', owner='', iface='', vrf=''): """ This keyword is used to show networking ipros #COMMAND: fsclish -c "show networking ipro ipbr-id <ipbr id> iface <interface> ip-address <ip address> owner <owner recovery group>" | Parameters | Man. | Description | | owner | No | owner recovery group | | ipbr_id | No | IPBR ID | | iface | No | network interface | | ip_addr | No | IP address | | Return value | instance of dictionary | | ${result} | show networking ipro | 123 | 12.0.0.1 | /EITPUPTRMRG | ether1_1 | VRF | """ ipro_attributes_list_str = _set_ipro_attributes_list_str( ipbr_id=ipbr_id, vrf=vrf, ip_address=ip_address, owner=owner, iface=iface) command = 'fsclish -c "show networking ipro %s"' % ( ipro_attributes_list_str) print "Execute Command:", command ipro_info_str = connections.execute_mml_without_check(command) if ipro_info_str.upper().find('VRF') != -1: pattern = re.compile( '(\d+)\s+(\d+\.\d+\.\d+\.\d+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)') else: pattern = re.compile( '(\d+)\s+(\d+\.\d+\.\d+\.\d+)\s+(\S+)\s+(\S+)\s+(\S+)\s+') items = pattern.findall(ipro_info_str) if len(items) == 0: return {'result': 'FAILED', 'error_info': ipro_info_str.strip()} ipro_list = {'result': 'SUCCESS'} for item in items: ipro_info = CommonItem() ipro_info.ipbr_id = item[0] ipro_info.ip_address = item[1] ipro_info.owner = item[2] ipro_info.iface = item[3] ipro_info.phb_set = CommonItem() if item[4].find('ALL') != -1: ipro_info.phb_set.ef = 'on' ipro_info.phb_set.af4 = 'on' ipro_info.phb_set.af3 = 'on' ipro_info.phb_set.af2 = 'on' ipro_info.phb_set.af1 = 'on' ipro_info.phb_set.be = 'on' else: ipro_info.phb_set.ef = 'on' if item[4].find('EF') != -1 else 'off' ipro_info.phb_set.af4 = 'on' if item[4].find( 'AF4') != -1 else 'off' ipro_info.phb_set.af3 = 'on' if item[4].find( 'AF3') != -1 else 'off' ipro_info.phb_set.af2 = 'on' if item[4].find( 'AF2') != -1 else 'off' ipro_info.phb_set.af1 = 'on' if item[4].find( 'AF1') != -1 else 'off' ipro_info.phb_set.be = 'on' if item[4].find('BE') != -1 else 'off' if ipro_info_str.upper().find('VRF') != -1: ipro_info.vrf = item[5] ipro_key = ipro_info.ipbr_id + "@" + ipro_info.ip_address + "@" + ipro_info.iface + "@" + ipro_info.owner ipro_list[ipro_key] = ipro_info return ipro_list