def get_regular_param_values_response( cls, admin_state: bool = False, earfcndl: int = 39250, ) -> models.GetParameterValuesResponse: msg = models.GetParameterValuesResponse() param_val_list = [] param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.CellConfig.LTE.RAN.RF.DLBandwidth', val_type='string', data='n100', )) param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.CellConfig.LTE.RAN.RF.FreqBandIndicator', val_type='string', data='40', )) param_val_list.append( cls.get_parameter_value_struct( name='Device.ManagementServer.PeriodicInformInterval', val_type='int', data='5', )) param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.CellConfig.LTE.RAN.CellRestriction.CellReservedForOperatorUse', val_type='boolean', data='false', )) param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.CellConfig.LTE.RAN.RF.ULBandwidth', val_type='string', data='n100', )) param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.X_BAICELLS_COM_LTE.EARFCNDLInUse', val_type='string', data=earfcndl, )) param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.CellConfig.LTE.RAN.PHY.TDDFrame.SpecialSubframePatterns', val_type='int', data='7', )) # MME IP param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.FAPControl.LTE.Gateway.S1SigLinkServerList', val_type='string', data='"192.168.60.142"', )) param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.CellConfig.LTE.EPC.PLMNListNumberOfEntries', val_type='int', data='1')) # perf mgmt enable param_val_list.append( cls.get_parameter_value_struct( name='Device.FAP.PerfMgmt.Config.1.Enable', val_type='boolean', data='true')) param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.CellConfig.LTE.RAN.CellRestriction.CellBarred', val_type='boolean', data='false')) param_val_list.append( cls.get_parameter_value_struct( name='Device.FAP.PerfMgmt.Config.1.PeriodicUploadInterval', val_type='int', data='300')) param_val_list.append( cls.get_parameter_value_struct( name='Device.Services.FAPService.1.FAPControl.LTE.AdminState', val_type='boolean', data=admin_state, )) # Local gateway enable param_val_list.append( cls.get_parameter_value_struct( name='Device.DeviceInfo.X_BAICELLS_COM_LTE_LGW_Switch', val_type='boolean', data='0')) # Perf mgmt upload url param_val_list.append( cls.get_parameter_value_struct( name='Device.FAP.PerfMgmt.Config.1.URL', val_type='string', data='http://192.168.60.142:8081/')) param_val_list.append( cls.get_parameter_value_struct( name='Device.Services.FAPService.1.CellConfig.LTE.EPC.TAC', val_type='int', data='1', )) param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.FAPControl.LTE.Gateway.X_BAICELLS_COM_MmePool.Enable', val_type='boolean', data='false', )) param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.CellConfig.LTE.RAN.PHY.TDDFrame.SubFrameAssignment', val_type='int', data='2', )) # PCI param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.CellConfig.LTE.RAN.RF.PhyCellID', val_type='int', data='260', )) # MME port param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.FAPControl.LTE.Gateway.S1SigLinkPort', val_type='int', data='36412', )) param_val_list.append( cls.get_parameter_value_struct( name='Device.Services.FAPService.Ipsec.IPSEC_ENABLE', val_type='boolean', data='false', )) param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.X_BAICELLS_COM_LTE.EARFCNULInUse', val_type='int', data='39150', )) param_val_list.append( cls.get_parameter_value_struct( name='Device.Services.FAPService.1.Capabilities.LTE.DuplexMode', val_type='string', data='TDDMode', )) param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.Capabilities.LTE.BandsSupported', val_type='string', data='40', )) param_val_list.append( cls.get_parameter_value_struct( name='Device.ManagementServer.PeriodicInformEnable', val_type='int', data='5', )) msg.ParameterList = models.ParameterValueList() msg.ParameterList.ParameterValueStruct = param_val_list return msg
def test_generate_set_parameter_values_string(self): """ Test that correct string is generated for SetParameterValues ACS->CPE request """ # Example ACS->CPE RPC call. Copied from: # http://djuro82.blogspot.com/2011/05/tr-069-cpe-provisioning.html # Following edits made: # - Change header ID value from 'null0' to 'null', to match magma # default ID expected_acs_string = b''' <soapenv:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:cwmp="urn:dslforum-org:cwmp-1-0" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Header> <cwmp:ID soapenv:mustUnderstand="1">null</cwmp:ID> </soapenv:Header> <soapenv:Body> <cwmp:SetParameterValues> <ParameterList soap:arrayType="cwmp:ParameterValueStruct[4]"> <ParameterValueStruct> <Name>InternetGatewayDevice.ManagementServer.PeriodicInformEnable</Name> <Value xsi:type="xsd:boolean">1</Value> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.ManagementServer.ConnectionRequestUsername</Name> <Value xsi:type="xsd:string">00147F-SpeedTouch780-CP0611JTLNW</Value> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.ManagementServer.ConnectionRequestPassword</Name> <Value xsi:type="xsd:string">98ff55fb377bf724c625f60dec448646</Value> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.ManagementServer.PeriodicInformInterval</Name> <Value xsi:type="xsd:unsignedInt">60</Value> </ParameterValueStruct> </ParameterList> <ParameterKey>null</ParameterKey> </cwmp:SetParameterValues> </soapenv:Body> </soapenv:Envelope> ''' request = models.SetParameterValues() request.ParameterList = \ models.ParameterValueList(arrayType='cwmp:ParameterValueStruct[4]') request.ParameterList.ParameterValueStruct = [] param = models.ParameterValueStruct() param.Name = 'InternetGatewayDevice.ManagementServer.PeriodicInformEnable' param.Value = models.anySimpleType(type='xsd:boolean') param.Value.Data = '1' request.ParameterList.ParameterValueStruct.append(param) param = models.ParameterValueStruct() param.Name = 'InternetGatewayDevice.ManagementServer.ConnectionRequestUsername' param.Value = models.anySimpleType(type='xsd:string') param.Value.Data = '00147F-SpeedTouch780-CP0611JTLNW' request.ParameterList.ParameterValueStruct.append(param) param = models.ParameterValueStruct() param.Name = 'InternetGatewayDevice.ManagementServer.ConnectionRequestPassword' param.Value = models.anySimpleType(type='xsd:string') param.Value.Data = '98ff55fb377bf724c625f60dec448646' request.ParameterList.ParameterValueStruct.append(param) param = models.ParameterValueStruct() param.Name = 'InternetGatewayDevice.ManagementServer.PeriodicInformInterval' param.Value = models.anySimpleType(type='xsd:unsignedInt') param.Value.Data = '60' request.ParameterList.ParameterValueStruct.append(param) request.ParameterKey = 'null' def side_effect(*args, **_kwargs): ctx = args[0] ctx.out_header = models.ID(mustUnderstand='1') ctx.out_header.Data = 'null' ctx.descriptor.out_message.Attributes.sub_name = request.__class__.__name__ return request self.p.stop() self.p = patch.object(AutoConfigServer, '_handle_tr069_message', Mock(side_effect=side_effect)) self.p.start() server = ServerBase(self.app) ctx = MethodContext(server, MethodContext.SERVER) ctx.in_string = [b''] ctx, = server.generate_contexts(ctx) server.get_in_object(ctx) if ctx.in_error is not None: raise ctx.in_error server.get_out_object(ctx) if ctx.out_error is not None: raise ctx.out_error server.get_out_string(ctx) xml_tree = XmlTree() match = xml_tree.xml_compare( xml_tree.convert_string_to_tree(b''.join(ctx.out_string)), xml_tree.convert_string_to_tree(expected_acs_string)) self.assertTrue(match)
def get_qafb_inform( cls, oui: str = '48BF74', sw_version: str = 'BaiBS_QAFB_1.6.4', enb_serial: str = '1202000181186TB0006', event_codes: Optional[List[str]] = None, ) -> models.Inform: if event_codes is None: event_codes = [] msg = models.Inform() # DeviceId device_id = models.DeviceIdStruct() device_id.Manufacturer = 'Unused' device_id.OUI = oui device_id.ProductClass = 'Unused' device_id.SerialNumber = enb_serial msg.DeviceId = device_id # Event msg.Event = models.EventList() event_list = [] for code in event_codes: event = models.EventStruct() event.EventCode = code event.CommandKey = '' event_list.append(event) msg.Event.EventStruct = event_list # ParameterList val_list = [] val_list.append( cls.get_parameter_value_struct( name='InternetGatewayDevice.DeviceInfo.HardwareVersion', val_type='string', data='VER.C', )) val_list.append( cls.get_parameter_value_struct( name='InternetGatewayDevice.DeviceInfo.ManufacturerOUI', val_type='string', data=oui, )) val_list.append( cls.get_parameter_value_struct( name='InternetGatewayDevice.DeviceInfo.SoftwareVersion', val_type='string', data=sw_version, )) val_list.append( cls.get_parameter_value_struct( name='InternetGatewayDevice.DeviceInfo.SerialNumber', val_type='string', data=enb_serial, )) val_list.append( cls.get_parameter_value_struct( name= 'InternetGatewayDevice.ManagementServer.ConnectionRequestURL', val_type='string', data= 'http://192.168.60.248:7547/25dbc91d31276f0cb03391160531ecae', )) msg.ParameterList = models.ParameterValueList() msg.ParameterList.ParameterValueStruct = val_list return msg pass
def test_gps_coords(self) -> None: """ Check GPS coordinates are processed and stored correctly """ acs_state_machine = \ EnodebAcsStateMachineBuilder \ .build_acs_state_machine(EnodebDeviceName.BAICELLS) # Send an Inform message, wait for an InformResponse inform_msg = Tr069MessageBuilder.get_inform('48BF74', 'BaiBS_RTS_3.1.6', '120200002618AGP0003', ['2 PERIODIC']) resp = acs_state_machine.handle_tr069_message(inform_msg) self.assertTrue(isinstance(resp, models.InformResponse), 'Should respond with an InformResponse') # Send an empty http request to kick off the rest of provisioning req = models.DummyInput() resp = acs_state_machine.handle_tr069_message(req) # Expect a request for an optional parameter, three times self.assertTrue(isinstance(resp, models.GetParameterValues), 'State machine should be requesting param values') req = models.GetParameterValuesResponse() param_val_list = [ Tr069MessageBuilder.get_parameter_value_struct( name='Device.X_BAICELLS_COM_GpsSyncEnable', val_type='boolean', data='true', ) ] req.ParameterList = models.ParameterValueList() req.ParameterList.ParameterValueStruct = param_val_list resp = acs_state_machine.handle_tr069_message(req) self.assertTrue(isinstance(resp, models.GetParameterValues), 'State machine should be requesting param values') req = models.GetParameterValuesResponse() param_val_list = [ Tr069MessageBuilder.get_parameter_value_struct( name='Device.FAP.GPS.LockedLatitude', val_type='int', data='37483629', ) ] req.ParameterList = models.ParameterValueList() req.ParameterList.ParameterValueStruct = param_val_list resp = acs_state_machine.handle_tr069_message(req) self.assertTrue(isinstance(resp, models.GetParameterValues), 'State machine should be requesting param values') req = models.GetParameterValuesResponse() param_val_list = [ Tr069MessageBuilder.get_parameter_value_struct( name='Device.FAP.GPS.LockedLongitude', val_type='int', data='-122150583', ) ] req.ParameterList = models.ParameterValueList() req.ParameterList.ParameterValueStruct = param_val_list acs_state_machine.handle_tr069_message(req) gps_long = acs_state_machine.get_parameter(ParameterName.GPS_LONG) gps_lat = acs_state_machine.get_parameter(ParameterName.GPS_LAT) self.assertTrue(gps_long == '-122.150583', 'Should be valid longitude') self.assertTrue(gps_lat == '37.483629', 'Should be valid latitude')
def get_cavium_param_values_response( cls, admin_state: bool = False, earfcndl: int = 2405, num_plmns: int = 0, ) -> models.GetParameterValuesResponse: msg = models.GetParameterValuesResponse() param_val_list = [] param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.CellConfig.LTE.RAN.RF.DLBandwidth', val_type='string', data='20', )) param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.CellConfig.LTE.RAN.RF.FreqBandIndicator', val_type='string', data='5', )) param_val_list.append( cls.get_parameter_value_struct( name='Device.ManagementServer.PeriodicInformInterval', val_type='int', data='5', )) param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.CellConfig.LTE.RAN.CellRestriction.CellReservedForOperatorUse', val_type='boolean', data='false', )) param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.CellConfig.LTE.RAN.RF.ULBandwidth', val_type='string', data='n100', )) param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.CellConfig.LTE.RAN.Common.CellIdentity', val_type='int', data='138777000', )) # MME IP param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.FAPControl.LTE.Gateway.S1SigLinkServerList', val_type='string', data='"192.168.60.142"', )) # perf mgmt enable param_val_list.append( cls.get_parameter_value_struct( name='Device.Services.FAPService.1.PerfMgmt.Config.1.Enable', val_type='boolean', data='true')) param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.CellConfig.LTE.RAN.CellRestriction.CellBarred', val_type='boolean', data='false')) param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.PerfMgmt.Config.1.PeriodicUploadInterval', val_type='int', data='600')) param_val_list.append( cls.get_parameter_value_struct( name='Device.Services.FAPService.1.FAPControl.LTE.AdminState', val_type='boolean', data=admin_state, )) # Perf mgmt upload url param_val_list.append( cls.get_parameter_value_struct( name='Device.Services.FAPService.1.PerfMgmt.Config.1.URL', val_type='string', data='http://192.168.60.142:8081/')) param_val_list.append( cls.get_parameter_value_struct( name='Device.Services.FAPService.1.CellConfig.LTE.EPC.TAC', val_type='int', data='1', )) # PCI param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.CellConfig.LTE.RAN.RF.PhyCellID', val_type='int', data='260', )) # MME port param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.FAPControl.LTE.Gateway.S1SigLinkPort', val_type='int', data='36412', )) param_val_list.append( cls.get_parameter_value_struct( name='Device.IPsec.Enable', val_type='boolean', data='false', )) param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.CellConfig.LTE.RAN.RF.EARFCNDL', val_type='int', data='2405', )) param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.CellConfig.LTE.RAN.RF.EARFCNUL', val_type='int', data='20405', )) param_val_list.append( cls.get_parameter_value_struct( name='Device.Services.FAPService.1.Capabilities.LTE.DuplexMode', val_type='string', data='FDDMode', )) param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.Capabilities.LTE.BandsSupported', val_type='string', data='5', )) param_val_list.append( cls.get_parameter_value_struct( name='Device.ManagementServer.PeriodicInformEnable', val_type='int', data='5', )) param_val_list.append( cls.get_parameter_value_struct( name= 'Device.Services.FAPService.1.CellConfig.LTE.EPC.PLMNListNumberOfEntries', val_type='int', data=str(num_plmns), )) msg.ParameterList = models.ParameterValueList() msg.ParameterList.ParameterValueStruct = param_val_list return msg