OpenIxia / ixnetwork_restpy

The IxNetwork python client.
https://openixia.github.io/ixnetwork_restpy/#/
MIT License
30 stars 16 forks source link

System.Exception: InstanceId is not a string #76

Closed mitchellostler closed 1 year ago

mitchellostler commented 1 year ago

When trying to adjust any field parameters, including using the example code and that generated by the restpy snippets in the Web GUI, I run into the same issue:

System.Exception: InstanceId is not a string
   at SDMCsLib.SDMObjIdPiece.GetIdAsString()
   at IxNetwork.Traffic2.Publishers.StackFieldHandler.Find(EnterExitSingleObjectHandler_EnterArgs args)
   at SDMHelpers.WalkContext.walkTo(SDMObjId objid, Hashtable idMapResponse, EnterReason reason)
   at SDMHelpers.SimplePublisher.Commit(ArrayList commitDeltasRequest, Hashtable idMapResponse, ArrayList commitMessages, SDMSandbox track)
   at SDMCsLib.SDMPeer.commitPiece(ArrayList deltasForPublisher, Hashtable idMapResponse, ArrayList commitExceptionsResponse, Version version, Boolean bCommitIfUnique)
   at SDMCsLib.SDMPeer.SANDBOX_DoCommit(Int32 eventMatch, ArrayList commitDeltasRequest, Hashtable idMapResponse, ArrayList commitExceptionsResponse, Version version, Boolean bCommitIfUnique, eSandboxType sandboxType)
   at SDMCsLib.SDMSandbox.DoCommit(Boolean bCommitIfUnique, eSandboxType sandboxType)
   at SDMCsLib.RestService.SdmSandbox.Commit(Boolean isAddOperation)
   at SDMCsLib.RestService.SdmObject.Patch()
   at SDMCsLib.RestService.V1ObjectController.Patch(String path)

I don't know if there is some other setup component I am missing, or if I am not calling these components correctly. Minimal example is below:

        self.session = SessionAssistant(IpAddress=self.ixia_ports.host,
                                        RestPort=443)
        port_map = self.session.PortMapAssistant()
        vport = dict()
        # Create all virtual ports on ixia based on exporter mapping
        for ixia_port in ports():
               port_map.Map(
                    IpAddress=self.ixia_ports.host,
                    CardId=self.ixia_ports.card,
                    PortId=ixia_port,
                    Name=port_name)
        port_map.Connect(True)
        self.ix_network = self.session.Ixnetwork

        topology = self.ix_network.Topology.add(Name='Top', Ports=vports )
        device_group = topology.DeviceGroup.add(Name='DG1', Multiplier='1')
        ethernet = device_group.Ethernet.add(Name='Eth1')
        ethernet.Mac.Single('00:00:00:00:00:01')

        traffic_item = ix_network.Traffic.TrafficItem.add(
                Name=name, BiDirectional=bidirectional, 
                TrafficType='raw')
            vport_src = (
                ix_network.Vport.find(Name = "Port_12")
                .Protocols.find()
            )
            vport_dest = (
                sx_network.Vport.find(Name = "Port_11")
                .Protocols.find()             )
            self.traffic_item.EndpointSet.add(
                    Sources=vport_src,
                    Destinations=vport_dest, 
                    Name=name
            )
            ipv4_prot = self.ix_network.Traffic.ProtocolTemplate.find(
                    StackTypeId="^ipv4$")
            eth_stack = self.traffic_item.ConfigElement.find().Stack.find(
                    StackTypeId="^ethernet$")
            eth_stack.AppendProtocol(Arg2=ipv4_prot)
            ipv4_stack = self.traffic_item.ConfigElement.find().Stack.find(
                    StackTypeId="^ipv4$")
            # Following Errors out
            ipv4_stack.Field.find(DisplayName="Destination Address").SingleValue = '0.0.0.1'