10 Replies Latest reply on Jun 6, 2017 6:02 PM by clarv02

    Creating a CustomPollerAssignmentOnNode returns: 400 Client Error: Sequence contains no elements

    steph@ethericnetworks.com

      In migrating from 11.5 to 12.1, I'm rebuilding my entire 5K-node system from scratch (it's a long story).

       

      In doing so, I'm trying to migrate code I have written in Python using the (latest and greatest) SDK to handle custom poller assignments for various devices (among other things).

       

      This code worked in 11.5, but I'm getting a '400 Client Error: Sequence contains no elements' from the requests package when I call:

              swis.create('Orion.NPM.CustomPollerAssignmentOnNode', NodeID=NodeID, CustomPollerID=CustomPollerID)

          File "build/bdist.linux-x86_64/egg/orionsdk/swisclient.py", line 34, in create

          File "build/bdist.linux-x86_64/egg/orionsdk/swisclient.py", line 59, in _req

          File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 851, in raise_for_status

          raise HTTPError(http_error_msg, response=self)

      requests.exceptions.HTTPError: 400 Client Error: Sequence contains no elements

       

      Did something significant change, in the way we're supposed to create custom poller assignments?

       

      It's probably something about version mismatches between Python packages again.

        • Re: Creating a CustomPollerAssignmentOnNode returns: 400 Client Error: Sequence contains no elements
          tdanner

          I tested this out. At first I thought I had confirmed a bug because I got the same error you did. But after looking in the logs, I found that the NodeID I had picked (1) doesn't actually exist. When I used a valid NodeID, it worked correctly. Could that be the cause of the problem you are having?

            • Re: Creating a CustomPollerAssignmentOnNode returns: 400 Client Error: Sequence contains no elements
              steph@ethericnetworks.com

              Thanks for testing.  The NodeID and the CustomPollerID are definitely valid.  The former comes from a query of Orion.Nodes for NodeIDs with a Vendor match (in my test case, this is 32), and the latter came from a query of Orion.NPM.CustomPollers with a particular GroupName (in my test case, this is '0b68394a-6c91-4afa-bb5a-699efd368ff2').

               

              Using a direct SQL call (since 'update' isn't a SWQL operation), I insert a record into NodeNotes (I use that as a log, effectively - has that been adapted to support CRUD yet?) that shows these values.  Other operations using that same NodeID work just fine (assigning 'native' pollers, setting CustomProperties, EngineID, PollInterval, etc), and 'manually' assigning the poller (via the web interface) also works just fine.  It's just when it gets to assigning the CustomPollers when it falls down.

               

              Which log/where did you spot your issue? Knowing where the logs are kept might be a good trail-head.

               

              Thanks for looking into it.

               

               

               

               

               

               

               

               

              • Re: Creating a CustomPollerAssignmentOnNode returns: 400 Client Error: Sequence contains no elements
                steph@ethericnetworks.com

                Here's a more thorough bit of code, so you can see what I'm trying to do:

                 

                 

                def assignCustomPollerGroup(CustomPollerGroupName, NodeID=None, uri=None):

                    if NodeID: uri = swis.query("SELECT uri FROM Orion.Nodes WHERE Nodes.NodeID = @id", id=NodeID)['results'][0]['uri']

                    Node = swis.read(uri)

                    NodeID = Node['NodeID']

                    # addNote(uri=uri, Note="Assigning Poller Group %s" % CustomPollerGroupName)

                    CustomPollerGroup = swis.query("SELECT DISTINCT CustomPollerID, UniqueName FROM Orion.NPM.CustomPollers WHERE GroupName = '%s'" % CustomPollerGroupName)['results']

                    if len(CustomPollerGroup) == 0:

                        addNote("Unable to assign Custom Poller Group: '%s'" % CustomPollerGroupName, uri=uri)

                        return

                 

                    for poller in CustomPollerGroup:

                        addNote(uri=uri, Note="Assigning Custom Poller {} (id={})".format(poller['UniqueName'], poller['CustomPollerID'])) # DEBUG

                        swis.create('Orion.NPM.CustomPollerAssignmentOnNode', NodeID=NodeID, CustomPollerID=poller['CustomPollerID'])

                        addNote(uri=uri, Note="Assigned Custom Poller %s" % poller['UniqueName']) # DEBUG

                    addNote(uri=uri, Note="Assigned Custom Poller Group %s" % CustomPollerGroupName)

                 

                def addNote(Note, uri=None, NodeID=None):

                    if NodeID: uri = swis.query("SELECT uri FROM Orion.Nodes WHERE Nodes.NodeID = @id", id=NodeID)['results'][0]['uri']

                    Node = swis.read(uri)

                    NodeID = Node['NodeID']

                 

                    sql = "INSERT INTO dbo.NodeNotes (Note, NodeID, AccountID, TimeStamp) VALUES ('%s', %s, 'reporter', DATEADD(hour, 7, GETDATE()));" % (Note.replace("'", "\'\'"), NodeID)

                    db_npm.executesql(sql.encode("utf-8"))

                    db_npm.commit()

                  • Re: Creating a CustomPollerAssignmentOnNode returns: 400 Client Error: Sequence contains no elements
                    tdanner

                    The first log to check is the SWIS log: C:\ProgramData\SolarWinds\InformationService\v3.0\Orion.InformationService.log. That wasn't enough to figure it out, but it did point me to the code that was throwing the exception. I followed that to see that it was making a call to the NPM business layer service, which has its own log at C:\ProgramData\SolarWinds\Logs\Orion\NPM.BusinessLayer.log. That's where I saw that there an error that said "Node Id 1 does not exist".

                     

                    I read the code more closely looking for other cases that could lead to the error you are seeing. One possibility: you are assigning a custom poller to a node where that poller is already assigned. Could that be the case?

                     

                    (The error reporting in this code has room for improvement!)

                    1 of 1 people found this helpful
                      • Re: Creating a CustomPollerAssignmentOnNode returns: 400 Client Error: Sequence contains no elements
                        steph@ethericnetworks.com

                        Looking at the SWIS log, I'm not seeing a connection to the BusinessLayer, but maybe my brain isn't decoding this well:

                        2017-05-05 10:58:52,347 [30] ERROR SolarWinds.InformationService.Core.CrudProcessor - (null) (null) Create operation failed.

                        System.InvalidOperationException: Sequence contains no elements

                           at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)

                           at SolarWinds.Data.Providers.NPM.v3.CustomPollersAssignmentCrudHandler.Create(IDictionary`2 columns, Func`2 baseCall)

                           at SolarWinds.Data.Providers.Orion.OrionDataProvider.Create(IStorageElement storage, IDictionary`2 columns)

                           at SolarWinds.InformationService.Addons.DataProvider.<Create>d__61.MoveNext()

                           at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)

                           at SolarWinds.InformationService.Core.CrudProcessor.<CreateLocal>d__21.MoveNext()

                           at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)

                           at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

                           at SolarWinds.InformationService.Core.CrudProcessor.<CreateInternal>d__18.MoveNext()

                           at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)

                           at SolarWinds.InformationService.Core.CrudProcessor.Create(String entityType, IDictionary`2 properties, IQueryExecutionContext context)

                        2017-05-05 10:58:52,378 [30] ERROR SolarWinds.InformationService.Core.InformationService - (null) (null) Exception for Operation: <root type="object">

                          <NodeID type="number">32</NodeID>

                          <CustomPollerID type="string">0b68394a-6c91-4afa-bb5a-699efd368ff2</CustomPollerID>

                        </root>

                        2017-05-05 10:58:52,378 [30] ERROR SolarWinds.InformationService.Core.InformationService - (null) (null) Exception caught in method SolarWinds.InformationService.Core.InformationService.Create

                        System.InvalidOperationException: Sequence contains no elements

                           at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)

                           at SolarWinds.Data.Providers.NPM.v3.CustomPollersAssignmentCrudHandler.Create(IDictionary`2 columns, Func`2 baseCall)

                           at SolarWinds.Data.Providers.Orion.OrionDataProvider.Create(IStorageElement storage, IDictionary`2 columns)

                           at SolarWinds.InformationService.Addons.DataProvider.<Create>d__61.MoveNext()

                           at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)

                           at SolarWinds.InformationService.Core.CrudProcessor.<CreateLocal>d__21.MoveNext()

                           at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)

                           at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

                           at SolarWinds.InformationService.Core.CrudProcessor.<CreateInternal>d__18.MoveNext()

                           at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)

                           at SolarWinds.InformationService.Core.CrudProcessor.Create(String entityType, IDictionary`2 properties, IQueryExecutionContext context)

                           at SolarWinds.InformationService.Core.InformationService.Create(String entityType, IDictionary`2 properties)

                         

                        I'll check if the assignment is already there.  I know I checked that behavior in 11.5 and confirmed that multiple custom poller assignments didn't 'stack' (create duplicates), although (again, in 11.5) native poller assignments would.  I haven't re-checked that behavior in 12.1 yet.

                         

                        Thanks for the log pointers - that should help.

                        • Re: Creating a CustomPollerAssignmentOnNode returns: 400 Client Error: Sequence contains no elements
                          steph@ethericnetworks.com

                          BINGO!  The custom poller is already assigned!  This seems to be a behavioral change in NPM 12.1 compared with NPM 11.5.

                           

                          In 11.5, one could assign a custom poller to a Node even if it was already assigned, and it would appear to succeed.

                          Now, I guess we have to check (as we have to with native pollers) and make sure that the poller isn't already assigned.

                           

                          Working to adapt...

                           

                          Thanks!