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