Example #1
0
def main():
    """ This module is used for manual testing of the TR-069 server """
    config = load_service_config("enodebd")

    app = Tr069Application([AutoConfigServer],
                           CWMP_NS,
                           in_protocol=Tr069Soap11(validator="soft"),
                           out_protocol=Tr069Soap11())

    ip_address = get_ip_from_if(config['tr069']['interface'])
    client = Tr069HttpClient(
        "http://%s:%s" % (ip_address, config["tr069"]["port"]), app)

    client.set_options(out_header=ID("123", mustUnderstand="1"))
    rpc_methods = client.service.get_rpc_methods()
    for rpc_method in rpc_methods:
        print("Method: %s" % rpc_method)

    inform_req = client.factory.create("Inform")
    inform_req.DeviceId = client.factory.create("DeviceIdStruct")
    inform_req.DeviceId.Manufacturer = "Magma"
    inform_req.DeviceId.OUI = "ABCDEF"
    inform_req.DeviceId.ProductClass = "TopClass"
    inform_req.DeviceId.SerialNumber = "123456789"
    inform_req.Event = None
    inform_req.MaxEnvelopes = 1
    inform_req.CurrentTime = None
    inform_req.RetryCount = 4
    inform_req.ParameterList = None
    client.set_options(out_header=ID("456", mustUnderstand="1"))
    client.service.Inform(inform_req)

    dummy = DummyInput()
    dummy.Field1 = 5
    rsp = client.service.EmptyHttp(dummy)
    print("EmptyHttp response = ", rsp)

    paramNames = client.factory.create("GetParameterNamesResponse")
    paramNames.ParameterList = client.factory.create("ParameterInfoList")
    paramNames.ParameterList.ParameterInfoStruct =\
        [client.factory.create("ParameterInfoStruct")]
    paramNames.ParameterList.ParameterInfoStruct[0].Name = "Parameter1"
    paramNames.ParameterList.ParameterInfoStruct[0].Writable = True
    rsp = client.service.GetParameterNamesResponse(paramNames)
    print("GetParameterNamesResponse response = ", rsp)
Example #2
0
    def setUp(self):
        # Set up the ACS
        self.enb_acs_manager = EnodebAcsStateMachineBuilder.build_acs_manager()
        self.handler = EnodebAcsStateMachineBuilder.build_acs_state_machine()
        AutoConfigServer.set_state_machine_manager(self.enb_acs_manager)

        def side_effect(*args, **_kwargs):
            msg = args[1]
            return msg

        self.p = patch.object(AutoConfigServer, '_handle_tr069_message',
                              Mock(side_effect=side_effect))
        self.p.start()

        self.app = Tr069Application([AutoConfigServer],
                                    models.CWMP_NS,
                                    in_protocol=Tr069Soap11(validator='soft'),
                                    out_protocol=Tr069Soap11())