Bulk Deleting Specific interfaces from a Node

Hi All, I'm exploring the ability to bulk delete interfaces from a node. I keep getting a 500 error using the following script. Any help or suggestions would be greatly appreciated. I am using the latest version of the SDK (0.4.0) and Orion is 2024.2.

import requests
from pprint import pprint
from orionsdk import SwisClient
from dotenv import load_dotenv
import os

load_dotenv()


def sw_query(instance, pssWord, pssKey):
    requests.packages.urllib3.disable_warnings()
    swis = SwisClient(os.getenv(instance), os.getenv(pssWord), os.getenv(pssKey))

    swis_query = swis.query("""SELECT i.NodeID, i.InterfaceID, i.InterfaceName, i.Uri
    FROM Orion.NPM.Interfaces i
    WHERE i.InterfaceID = XXX 
    """)

    results = swis_query['results']
    # pprint(results)
    uris_to_delete = []
    for result in results:
        # pprint(result)
        node_id = result['NodeID']
        interface_id = result['InterfaceID']
        node_uri = result['Uri']
        uris_to_delete.append(node_uri)

    for uris in uris_to_delete:
        # pprint(uri)
        try:
            swis.bulkdelete(uris)
            pprint(f'Successfully deleted interface: {uris}')
        except Exception as e:
            pprint(f'Error deleting interface {uris}: {e}')


sw_query('solarwinds-url', 'api-username', 'api-password')

Error Message Returned

('Error deleting interface '
 'swis://INSTANCE-URL/Orion/Orion.Nodes/NodeID=XXX/Interfaces/InterfaceID=XXX: '
 '500 Server Error: Internal Server Error for url: '
 'https://INSTANCE-URL:17774/SolarWinds/InformationService/v3/Json/BulkDelete')

Best,

Jay Jackson

Parents
  •  , there might be a bug in 2024.2. I tested this operation using PowerShell and attempted to delete an interface. I successfully ran the script on 20241.1 but ran into an error on 2024.2 using the same script. Internally at SolarWinds we are tracking this under OO-34768.

  •   Thank you for this as well! I just ran into this issue as well. Should I open a ticket with SolarWinds so we can be informed when a hotfix or something similar comes out for it? We do this a ton in our organization.  Or will we see something about a fix here?

  • Nothing you need to do. Looks like we were able to squeeze the fix into the next upcoming service release (2024.2.1). That is expected mid-July (17th currently, but dates could always shift a little, so it isn't concrete)

  • hi   im having similar issue during interface deletion not a bulk, getting below HTTP error 400 from request library
      File "/data/user1/.local/lib/python3.9/site-packages/requests/models.py", line 1021, in raise_for_status
        raise HTTPError(http_error_msg, response=self)
    requests.exceptions.HTTPError: 400 Client Error: Object reference not set to an instance of an object. for url: https://INSTANCE-URL/SolarWinds/InformationService/v3/Json/swis://POLER-URL/Orion/Orion.Nodes/NodeID=XXX/Interfaces/InterfaceID=XXXX

    in response message i have this:
    {"Message":"Object reference not set to an instance of an object.","ExceptionType":"System.NullReferenceException","FullException":"System.NullReferenceException: Object reference not set to an instance of an object.\r\n   at SolarWinds.Data.Providers.Interfaces.Plugin.CrudHandlers.InterfaceCrudHandler.Delete(IDictionary`2[] keyColumnsList, Action`1 baseCall)\r\n   at SolarWinds.Data.Providers.Orion.OrionDataProvider.Delete(IStorageElement storage, IDictionary`2[] keyColumnsList)\r\n   at SolarWinds.InformationService.Core.CrudProcessor.DeleteInternal(Boolean bulkMode, SwisUriResolver uriResolver, IQueryExecutionContext context)\r\n   at SolarWinds.InformationService.Core.CrudProcessor.Delete(SwisUri uri, IQueryExecutionContext context)\r\n   at SolarWinds.InformationService.Core.InformationService.Delete(String uri)"}

    Can you confirm that it is being addressed by upcoming service release (2024.2.1) ?

Reply Children
No Data