From ce97eabc4abd74c1a9fcfba2cf47c8cd9a8983b7 Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 19 May 2021 07:08:29 -0500 Subject: [PATCH 01/33] Initial commit --- actions/add_custom_pollers_to_node.py | 65 +++++++++++++++++++++++++ actions/add_custom_pollers_to_node.yaml | 17 +++++++ 2 files changed, 82 insertions(+) create mode 100644 actions/add_custom_pollers_to_node.py create mode 100644 actions/add_custom_pollers_to_node.yaml diff --git a/actions/add_custom_pollers_to_node.py b/actions/add_custom_pollers_to_node.py new file mode 100644 index 0000000..0b843e4 --- /dev/null +++ b/actions/add_custom_pollers_to_node.py @@ -0,0 +1,65 @@ +# Licensed to the StackStorm, Inc ('StackStorm') under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from lib.actions import OrionBaseAction +from lib.utils import send_user_error + + +class AddSnmpPollersToNode(OrionBaseAction): + def run(self, node, snmppollers, custompollers): + """ + Add list of SNMP Pollers to Node + + Args: + - node: The caption in Orion of the node to poll. + - snmppollers: The list of Orion Pollers to add to the Node + - custompollers: The list of Orion Custom SNMP pollers to add to the Node + + Returns + - List of pollers that were added to the Node and a list of Pollers that were already + assigned to the Node + - List of custom pollers that were added to the Node and a list of Custom pollers that were + already assigned to the Node + + Raises: + - ValueError: When a node is not found. + + """ + # Create empty results dict to hold action output data + results = {snmppollers: {'added': [], 'existing': []}, + custompollers: {'added': [], 'existing': []}} + + # Establish a connection to the Orion Server + self.connect() + + # Find the Node in the system + orion_node = self.get_node(node) + + if not orion_node.npm: + error_msg = "Node not found" + send_user_error(error_msg) + raise ValueError(error_msg) + + engine_id = self.get_engine_id(poller) + + kargs = {"EngineID": engine_id} + + orion_data = self.update(orion_node.uri, **kargs) + + # This Invoke always returns None, so check and return True + if orion_data is None: + return True + else: + return orion_data diff --git a/actions/add_custom_pollers_to_node.yaml b/actions/add_custom_pollers_to_node.yaml new file mode 100644 index 0000000..6f30677 --- /dev/null +++ b/actions/add_custom_pollers_to_node.yaml @@ -0,0 +1,17 @@ +--- +description: "Add custom NPM Universal Device Pollers to a Node in SolarWinds" +enabled: true +entry_point: 'add_custom_pollers_to_node.py' +name: "add_custom_pollers_to_node" +pack: "orion" +runner_type: "python-script" + +parameters: + node: + type: "string" + description: The node to add the custom (Universal Device) pollers to + required: true + custom_pollers: + type: "array" + description: List of custom (Universal Device) pollers to be added to Node + required: true From 8e275225b197fbe52aec39ef14175d3cc7147aa5 Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 19 May 2021 07:09:16 -0500 Subject: [PATCH 02/33] Updated action to include the option to pass an optional list of pollers to be enabled on the node when created --- actions/node_create_snmpv3.py | 9 ++++++++- actions/node_create_snmpv3.yaml | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/actions/node_create_snmpv3.py b/actions/node_create_snmpv3.py index 976b0ae..bae5a32 100644 --- a/actions/node_create_snmpv3.py +++ b/actions/node_create_snmpv3.py @@ -29,7 +29,8 @@ def run(self, privacy_password, auth_protocol, auth_password, - status): + status, + additional_pollers): """ Create an node in Orion. """ @@ -117,6 +118,12 @@ def run(self, pollers_to_add['N.ResponseTime.ICMP.Native'] = False pollers_to_add['N.ResponseTime.SNMP.Native'] = True + # Check to see if any additional pollers were passed as input + if additional_pollers: + # Enable all the pollers passed as input + for entry in additional_pollers: + pollers_to_add[entry] = True + pollers = [] for p in pollers_to_add: pollers.append({ diff --git a/actions/node_create_snmpv3.yaml b/actions/node_create_snmpv3.yaml index debd144..b94f8f9 100644 --- a/actions/node_create_snmpv3.yaml +++ b/actions/node_create_snmpv3.yaml @@ -54,3 +54,7 @@ parameters: - "icmp" description: "Protocol to use for Status and Response Time checks." default: "snmp" + additional_pollers: + type: "array" + required: false + description: "List of Orion pollers to enable when creating Node. ** Must be specified using the correct Orion DB naming syntax." From 35dcc835dc70681dcead7e74061d2b816e164489 Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 19 May 2021 07:15:27 -0500 Subject: [PATCH 03/33] Bumped version to reflect addition of new action --- pack.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pack.yaml b/pack.yaml index dde024a..cef5d3c 100755 --- a/pack.yaml +++ b/pack.yaml @@ -8,7 +8,7 @@ keywords: - ncm - npm - monitoring -version: 1.0.1 +version: 1.0.2 python_versions: - "3" author: Encore Technologies From d49f044b27a8bb8bbcc237c7814326ea05c59aeb Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 19 May 2021 07:15:42 -0500 Subject: [PATCH 04/33] Bumped version to reflect addition of new action --- CHANGES.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 598e46c..a1c8b29 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,10 @@ # Changelog +## 1.0.2 +-Added Action + add_custom_pollers_to_node + + ## 1.0.1 - Corrected numerous typos and inaccurate descriptions in the code From b0f801265e4419ea732eb83541e812bd78f10e26 Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 19 May 2021 07:16:01 -0500 Subject: [PATCH 05/33] Updated text to include description of new action --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 89c20ef..f68ec70 100755 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ snmp_internal: "SNMP community to use if internal specified" ## Actions +* `add_custom_pollers_to_node` - Add a list of custom (Universal Device) pollers to a Node * `add_node_to_ncm` - Add an Orion Node to NCM * `drain_poller` - Drain nodes from one Orion poller to another. * `get_discovery_progress` - Get the progress of an SolarWinds Orion Discovery. @@ -44,18 +45,18 @@ snmp_internal: "SNMP community to use if internal specified" * `list_sdk_verbs` - List all the verbs that can be invoked via SolarWinds Orion * `ncm_config_download` - Download config(s) from SolarWinds NCM Orion module. * `ncm_execute_script` - Execute an script on an Orion NCM Node. -* `node_create` - Create an node in SolarWinds Orion. -* `node_create_snmpv3` - Create an node in SolarWinds Orion with SNMPv3. +* `node_create` - Create a node in SolarWinds Orion. +* `node_create_snmpv3` - Create a node in SolarWinds Orion with SNMPv3. * `node_discover_and_add_interfaces` - Discover and add Interfaces for a SolarWinds Orion node. * `node_discover_and_add_interfaces_by_name_and_type` - Discover and add Interfaces for a SolarWinds Orion node based upon the ifName, ifType, and (optional) ifAdminStatus * `node_remanage` - Re-manage a SolarWinds Orion nodes * `node_status` - Query SolarWinds Orion for a node's status (i.e. Up/Down) -* `node_unmanage` - Unmanage an SolarWinds Orion node +* `node_unmanage` - Unmanage a SolarWinds Orion node * `nodes_pollnow` - Force multiple polls of a list of SolarWinds Orion nodes. * `query` - Execute generic SWQL queries. * `start_discovery` - Create a discovery profile in SolarWinds Orion. -* `update_interface_custom_properties` - Update an the custom properties of an interface on an Orion Node -* `update_interface_properties` - Update an the "standard" properties (e.g. Unpluggable) on an interface of an Orion Nodes +* `update_interface_custom_properties` - Update the custom properties of an interface on an Orion Node +* `update_interface_properties` - Update the "standard" properties (e.g. Unpluggable) on an interface of an Orion Nodes * `update_node_custom_properties` - Update an Orion Nodes custom properties * `update_node_poller` - Update an Orion Nodes poller From b4f898dd0035dcc628fbba9f3c43e1469e8e6dbb Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 19 May 2021 07:19:56 -0500 Subject: [PATCH 06/33] Bumped version to reflect addition of new action --- CHANGES.md | 6 ++++++ pack.yaml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 289e60d..8573ec2 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,11 @@ # Changelog +## 1.0.3 + +- Added Action + + - add_custom_poller_to_node + ## 1.0.2 - Fixed small linting error and pushing a new version. diff --git a/pack.yaml b/pack.yaml index cef5d3c..cb11015 100755 --- a/pack.yaml +++ b/pack.yaml @@ -8,7 +8,7 @@ keywords: - ncm - npm - monitoring -version: 1.0.2 +version: 1.0.3 python_versions: - "3" author: Encore Technologies From 9af685d9867b16b57172ba5d27ebc1de81cbee76 Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 19 May 2021 07:20:58 -0500 Subject: [PATCH 07/33] Bumped version to reflect addition of new action --- .idea/codeStyles/codeStyleConfig.xml | 5 +++++ .idea/inspectionProfiles/Project_Default.xml | 17 +++++++++++++++++ .idea/inspectionProfiles/profiles_settings.xml | 6 ++++++ .idea/modules.xml | 8 ++++++++ .idea/stackstorm-orion.iml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ 6 files changed, 50 insertions(+) create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/stackstorm-orion.iml create mode 100644 .idea/vcs.xml diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..8e3905d --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..7e73c7f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/stackstorm-orion.iml b/.idea/stackstorm-orion.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/stackstorm-orion.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file From c2dce092467cc4bd2d6e82d2bad8e8e6c9f5d1bb Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 19 May 2021 07:21:03 -0500 Subject: [PATCH 08/33] Bumped version to reflect addition of new action --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 72364f9..72f474c 100644 --- a/.gitignore +++ b/.gitignore @@ -87,3 +87,4 @@ ENV/ # Rope project settings .ropeproject +/.idea/.gitignore From b5445c980ee98db28206b4feffa40f1318054c2b Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 19 May 2021 16:40:24 -0500 Subject: [PATCH 09/33] Corrected typo --- actions/node_create_snmpv3.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/node_create_snmpv3.yaml b/actions/node_create_snmpv3.yaml index b94f8f9..6f7a34f 100644 --- a/actions/node_create_snmpv3.yaml +++ b/actions/node_create_snmpv3.yaml @@ -1,5 +1,5 @@ --- -description: "Create an node using SNMPv3 in Solarwinds Orion." +description: "Create an node using SNMPv3 in SolarWinds Orion." enabled: true entry_point: 'node_create_snmpv3.py' name: "node_create_snmpv3" From 008388d6230fbb717be65cbc42f2e652b1895dca Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 19 May 2021 16:40:53 -0500 Subject: [PATCH 10/33] Updated description info --- actions/add_custom_pollers_to_node.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/add_custom_pollers_to_node.yaml b/actions/add_custom_pollers_to_node.yaml index 6f30677..bf6dea2 100644 --- a/actions/add_custom_pollers_to_node.yaml +++ b/actions/add_custom_pollers_to_node.yaml @@ -9,7 +9,7 @@ runner_type: "python-script" parameters: node: type: "string" - description: The node to add the custom (Universal Device) pollers to + description: The Node which will have the custom pollers assigned to it required: true custom_pollers: type: "array" From 09f27da04ddc8937043266665b811a48686e4ed8 Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 19 May 2021 16:41:56 -0500 Subject: [PATCH 11/33] Added logic to complete lookups for poller ID values, checking to see if they are already assigned to the Node and adding any that we not --- actions/add_custom_pollers_to_node.py | 78 +++++++++++++++++++++------ 1 file changed, 61 insertions(+), 17 deletions(-) diff --git a/actions/add_custom_pollers_to_node.py b/actions/add_custom_pollers_to_node.py index 0b843e4..5fce1c6 100644 --- a/actions/add_custom_pollers_to_node.py +++ b/actions/add_custom_pollers_to_node.py @@ -17,29 +17,25 @@ from lib.utils import send_user_error -class AddSnmpPollersToNode(OrionBaseAction): - def run(self, node, snmppollers, custompollers): +class AddCustomPollersToNode(OrionBaseAction): + def run(self, node, custompollers): """ Add list of SNMP Pollers to Node Args: - node: The caption in Orion of the node to poll. - - snmppollers: The list of Orion Pollers to add to the Node - custompollers: The list of Orion Custom SNMP pollers to add to the Node Returns - - List of pollers that were added to the Node and a list of Pollers that were already - assigned to the Node - - List of custom pollers that were added to the Node and a list of Custom pollers that were - already assigned to the Node + - List of custom pollers that were added to the Node, a list of Custom pollers that were + already assigned to the Node, and a list of Custom pollers that were not found in the system Raises: - ValueError: When a node is not found. """ # Create empty results dict to hold action output data - results = {snmppollers: {'added': [], 'existing': []}, - custompollers: {'added': [], 'existing': []}} + results = {custompollers: {'added': [], 'existing': [], 'not_found': []}} # Establish a connection to the Orion Server self.connect() @@ -52,14 +48,62 @@ def run(self, node, snmppollers, custompollers): send_user_error(error_msg) raise ValueError(error_msg) - engine_id = self.get_engine_id(poller) + # Create an empty list of CustomPollerIDs used to hold the ID for each of the pollers + # passed as input to the action - kargs = {"EngineID": engine_id} + custompollerids = [] - orion_data = self.update(orion_node.uri, **kargs) + # Loop through all the pollers provided as input to the action and query the Orion DB + # for the CustomPollerID. Results will be added to the empty list created above + + for entry in custompollers: + pollerquery = 'SELECT CustomPollerID, UniqueName FROM Orion.NPM.CustomPollers where' \ + 'UniqueName=' + str(entry) + entrypollerid = self.query(pollerquery) + + if entrypollerid: + custompollerids.append(entrypollerid) + else: + self.logger.info('Custom poller {} not found in Orion DB and will be ' + 'ignored...'.format(entry)) + results['not_found'].append(entry) + + self.logger.info('Querying list of custom pollers already configured on Node...') + + # Create a query string needed to pull the custom poller data assigned to the Node + # from the Orion DB + + nodequery = 'SELECT NodeID, CustomPollerID FROM Orion.NPM.CustomPollerAssignmentOnNode ' \ + 'WHERE NodeID=' + str(orion_node.npm_id) + + # Execute the query for the custom Node pollers + nodeassignedpollers = self.query(nodequery) + + # Loop through all of the entries in the Custom Poller list to see if they are in the data + # returned from the custom poller query on the Node + + for entry in custompollerids: + if any(element for element in nodeassignedpollers if + element['CustomPollerID'] == entry['CustomPollerID']): + self.logger.info('Custom Poller {} already assigned to Node. Skipping...'.format( + entry['UniqueName'])) + # Update results data with matching poller name + results['existing'].append(entry['UniqueName']) + # Remove the already assigned Custom Poller from the custompollerids list + custompollerids.remove(entry) + + # After removing all pollers already assigned to the Node, loop through any remaining + # entries and assign them to the Node + + for entry in custompollerids: + entrydata = { + "NodeID": str(orion_node.npm_id), + "CustomPollerID": str(entry['CustomPollerID']) + } + response = self.create('Orion.NPM.CustomPollerAssignmentOnNode', **entrydata) + self.logger.info('Customer poller {} successfully assigned to Node: {}'.format( + entry['CustomPollerID'], response)) + # Update results data with matching poller name + results['added'].append(entry['UniqueName']) + return results - # This Invoke always returns None, so check and return True - if orion_data is None: - return True - else: - return orion_data From cf42eec39569301dfc5876d0a3477807e828d3ac Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 19 May 2021 16:45:53 -0500 Subject: [PATCH 12/33] Updated parameter name to reflect what is in the code --- actions/add_custom_pollers_to_node.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/add_custom_pollers_to_node.yaml b/actions/add_custom_pollers_to_node.yaml index bf6dea2..893f59f 100644 --- a/actions/add_custom_pollers_to_node.yaml +++ b/actions/add_custom_pollers_to_node.yaml @@ -11,7 +11,7 @@ parameters: type: "string" description: The Node which will have the custom pollers assigned to it required: true - custom_pollers: + custompollers: type: "array" description: List of custom (Universal Device) pollers to be added to Node required: true From ac2cc24a8126b250b1ad8bfca5a54beaecbc89c9 Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 19 May 2021 16:48:05 -0500 Subject: [PATCH 13/33] Updated results dict with correct format --- actions/add_custom_pollers_to_node.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/add_custom_pollers_to_node.py b/actions/add_custom_pollers_to_node.py index 5fce1c6..e5555df 100644 --- a/actions/add_custom_pollers_to_node.py +++ b/actions/add_custom_pollers_to_node.py @@ -35,7 +35,7 @@ def run(self, node, custompollers): """ # Create empty results dict to hold action output data - results = {custompollers: {'added': [], 'existing': [], 'not_found': []}} + results = {'added': [], 'existing': [], 'not_found': []} # Establish a connection to the Orion Server self.connect() From a1e1a3bb7568d4d8485cfae4d14c3e31b40d8779 Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 19 May 2021 16:55:34 -0500 Subject: [PATCH 14/33] Fixed spacing on query --- actions/add_custom_pollers_to_node.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/add_custom_pollers_to_node.py b/actions/add_custom_pollers_to_node.py index e5555df..ca9d169 100644 --- a/actions/add_custom_pollers_to_node.py +++ b/actions/add_custom_pollers_to_node.py @@ -57,7 +57,7 @@ def run(self, node, custompollers): # for the CustomPollerID. Results will be added to the empty list created above for entry in custompollers: - pollerquery = 'SELECT CustomPollerID, UniqueName FROM Orion.NPM.CustomPollers where' \ + pollerquery = 'SELECT CustomPollerID, UniqueName FROM Orion.NPM.CustomPollers where ' \ 'UniqueName=' + str(entry) entrypollerid = self.query(pollerquery) From 6171045f23a28667df8259ffe4c7e2f6b75e8f12 Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 19 May 2021 16:59:10 -0500 Subject: [PATCH 15/33] Added literal quotes to query string --- actions/add_custom_pollers_to_node.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/add_custom_pollers_to_node.py b/actions/add_custom_pollers_to_node.py index ca9d169..7c12646 100644 --- a/actions/add_custom_pollers_to_node.py +++ b/actions/add_custom_pollers_to_node.py @@ -58,7 +58,7 @@ def run(self, node, custompollers): for entry in custompollers: pollerquery = 'SELECT CustomPollerID, UniqueName FROM Orion.NPM.CustomPollers where ' \ - 'UniqueName=' + str(entry) + 'UniqueName=\'' + str(entry) + '\'' entrypollerid = self.query(pollerquery) if entrypollerid: From 89e11e37c1e7814095236fe7167112885f73d0c1 Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 19 May 2021 17:11:41 -0500 Subject: [PATCH 16/33] Updated reference to query result data --- actions/add_custom_pollers_to_node.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actions/add_custom_pollers_to_node.py b/actions/add_custom_pollers_to_node.py index 7c12646..bdf5135 100644 --- a/actions/add_custom_pollers_to_node.py +++ b/actions/add_custom_pollers_to_node.py @@ -62,7 +62,7 @@ def run(self, node, custompollers): entrypollerid = self.query(pollerquery) if entrypollerid: - custompollerids.append(entrypollerid) + custompollerids.append(entrypollerid['results']) else: self.logger.info('Custom poller {} not found in Orion DB and will be ' 'ignored...'.format(entry)) @@ -83,7 +83,7 @@ def run(self, node, custompollers): # returned from the custom poller query on the Node for entry in custompollerids: - if any(element for element in nodeassignedpollers if + if any(element for element in nodeassignedpollers['results'] if element['CustomPollerID'] == entry['CustomPollerID']): self.logger.info('Custom Poller {} already assigned to Node. Skipping...'.format( entry['UniqueName'])) From b2a89ca3d775728ee947be3d97858aa912b03561 Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 19 May 2021 17:15:58 -0500 Subject: [PATCH 17/33] Removed str() on poller ID data --- actions/add_custom_pollers_to_node.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/add_custom_pollers_to_node.py b/actions/add_custom_pollers_to_node.py index bdf5135..b72a17f 100644 --- a/actions/add_custom_pollers_to_node.py +++ b/actions/add_custom_pollers_to_node.py @@ -98,7 +98,7 @@ def run(self, node, custompollers): for entry in custompollerids: entrydata = { "NodeID": str(orion_node.npm_id), - "CustomPollerID": str(entry['CustomPollerID']) + "CustomPollerID": entry['CustomPollerID'] } response = self.create('Orion.NPM.CustomPollerAssignmentOnNode', **entrydata) self.logger.info('Customer poller {} successfully assigned to Node: {}'.format( From acefd770b68b609a5da28c80700427c91d5c8cfc Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 19 May 2021 17:19:14 -0500 Subject: [PATCH 18/33] Added log data --- actions/add_custom_pollers_to_node.py | 1 + 1 file changed, 1 insertion(+) diff --git a/actions/add_custom_pollers_to_node.py b/actions/add_custom_pollers_to_node.py index b72a17f..8b23c8c 100644 --- a/actions/add_custom_pollers_to_node.py +++ b/actions/add_custom_pollers_to_node.py @@ -96,6 +96,7 @@ def run(self, node, custompollers): # entries and assign them to the Node for entry in custompollerids: + self.logger.info('Entry: {}'.format(entry)) entrydata = { "NodeID": str(orion_node.npm_id), "CustomPollerID": entry['CustomPollerID'] From 91fc456a23aa2fc0835ab193dbc7e490667a3123 Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 19 May 2021 17:21:55 -0500 Subject: [PATCH 19/33] Updated query output to select first list entry --- actions/add_custom_pollers_to_node.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/add_custom_pollers_to_node.py b/actions/add_custom_pollers_to_node.py index 8b23c8c..3dad955 100644 --- a/actions/add_custom_pollers_to_node.py +++ b/actions/add_custom_pollers_to_node.py @@ -62,7 +62,7 @@ def run(self, node, custompollers): entrypollerid = self.query(pollerquery) if entrypollerid: - custompollerids.append(entrypollerid['results']) + custompollerids.append(entrypollerid['results'][0]) else: self.logger.info('Custom poller {} not found in Orion DB and will be ' 'ignored...'.format(entry)) From 2a661c4f34aea111b9887d076a9eab65b4ad4305 Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 19 May 2021 17:30:51 -0500 Subject: [PATCH 20/33] Added more logging --- actions/add_custom_pollers_to_node.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/actions/add_custom_pollers_to_node.py b/actions/add_custom_pollers_to_node.py index 3dad955..1541418 100644 --- a/actions/add_custom_pollers_to_node.py +++ b/actions/add_custom_pollers_to_node.py @@ -83,6 +83,7 @@ def run(self, node, custompollers): # returned from the custom poller query on the Node for entry in custompollerids: + self.logger.info('Entry: {}'.format(entry)) if any(element for element in nodeassignedpollers['results'] if element['CustomPollerID'] == entry['CustomPollerID']): self.logger.info('Custom Poller {} already assigned to Node. Skipping...'.format( @@ -102,7 +103,7 @@ def run(self, node, custompollers): "CustomPollerID": entry['CustomPollerID'] } response = self.create('Orion.NPM.CustomPollerAssignmentOnNode', **entrydata) - self.logger.info('Customer poller {} successfully assigned to Node: {}'.format( + self.logger.info('Custom poller {} successfully assigned to Node: {}'.format( entry['CustomPollerID'], response)) # Update results data with matching poller name results['added'].append(entry['UniqueName']) From 6fb4a99aed2aa4bcebd3e91a0bb1dba43c1e3688 Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 19 May 2021 17:35:43 -0500 Subject: [PATCH 21/33] Updated log syntax --- actions/add_custom_pollers_to_node.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actions/add_custom_pollers_to_node.py b/actions/add_custom_pollers_to_node.py index 1541418..22a22e2 100644 --- a/actions/add_custom_pollers_to_node.py +++ b/actions/add_custom_pollers_to_node.py @@ -83,7 +83,7 @@ def run(self, node, custompollers): # returned from the custom poller query on the Node for entry in custompollerids: - self.logger.info('Entry: {}'.format(entry)) + self.logger.info('Delete Entry: {}'.format(entry)) if any(element for element in nodeassignedpollers['results'] if element['CustomPollerID'] == entry['CustomPollerID']): self.logger.info('Custom Poller {} already assigned to Node. Skipping...'.format( @@ -97,7 +97,7 @@ def run(self, node, custompollers): # entries and assign them to the Node for entry in custompollerids: - self.logger.info('Entry: {}'.format(entry)) + self.logger.info('Add Entry: {}'.format(entry)) entrydata = { "NodeID": str(orion_node.npm_id), "CustomPollerID": entry['CustomPollerID'] From 9346650dca259c5b0ae726b4427a5fdaaf1b7a9e Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Thu, 20 May 2021 07:08:10 -0500 Subject: [PATCH 22/33] Refactored action to run the query for existing pollers first and then check to see if the new pollers are already assigned before attempting to assign them --- actions/add_custom_pollers_to_node.py | 64 +++++++++++++-------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/actions/add_custom_pollers_to_node.py b/actions/add_custom_pollers_to_node.py index 22a22e2..c577115 100644 --- a/actions/add_custom_pollers_to_node.py +++ b/actions/add_custom_pollers_to_node.py @@ -48,53 +48,53 @@ def run(self, node, custompollers): send_user_error(error_msg) raise ValueError(error_msg) + # Create a query string needed to pull the custom poller data assigned to the Node + # from the Orion DB + + self.logger.info('Querying list of custom pollers already configured on Node...') + + nodequery = 'SELECT NodeID, CustomPollerID FROM Orion.NPM.CustomPollerAssignmentOnNode ' \ + 'WHERE NodeID=' + str(orion_node.npm_id) + + # Execute the query for the custom Node pollers + nodeassignedpollers = self.query(nodequery) + # Create an empty list of CustomPollerIDs used to hold the ID for each of the pollers # passed as input to the action custompollerids = [] # Loop through all the pollers provided as input to the action and query the Orion DB - # for the CustomPollerID. Results will be added to the empty list created above + # for the CustomPollerID. for entry in custompollers: pollerquery = 'SELECT CustomPollerID, UniqueName FROM Orion.NPM.CustomPollers where ' \ 'UniqueName=\'' + str(entry) + '\'' entrypollerid = self.query(pollerquery) - if entrypollerid: - custompollerids.append(entrypollerid['results'][0]) + # Check if the Custom Poller query returned exactly 1 result as expected + if len(entrypollerid['results']) == 1: + # Check if Custom Poller ID is included in the list returned from the existing + # poller query + if any(element for element in nodeassignedpollers['results'] if + element['CustomPollerID'] == entrypollerid['results'][0]['CustomPollerID']): + self.logger.info('Custom Poller {} already assigned to Node. Skipping...' + ''.format(entry)) + # Update results data with matching poller name + results['existing'].append(entry['UniqueName']) else: - self.logger.info('Custom poller {} not found in Orion DB and will be ' - 'ignored...'.format(entry)) - results['not_found'].append(entry) - - self.logger.info('Querying list of custom pollers already configured on Node...') - - # Create a query string needed to pull the custom poller data assigned to the Node - # from the Orion DB - - nodequery = 'SELECT NodeID, CustomPollerID FROM Orion.NPM.CustomPollerAssignmentOnNode ' \ - 'WHERE NodeID=' + str(orion_node.npm_id) - - # Execute the query for the custom Node pollers - nodeassignedpollers = self.query(nodequery) + # Add Custom Poller ID to list if not found to have already been assigned to the + # Node + custompollerids.append(entrypollerid['results'][0]) - # Loop through all of the entries in the Custom Poller list to see if they are in the data - # returned from the custom poller query on the Node + # Check if the Custom poller query returned either 0 or more than the expected 1 + if len(entrypollerid['results']) >= 1 or len(entrypollerid['results']) == 0: + self.logger.info('Custom poller {} not found in Orion DB or the text query returned' + ' multiple entries and will be ignored...'.format(entry)) + results['not_found'].append(entry) - for entry in custompollerids: - self.logger.info('Delete Entry: {}'.format(entry)) - if any(element for element in nodeassignedpollers['results'] if - element['CustomPollerID'] == entry['CustomPollerID']): - self.logger.info('Custom Poller {} already assigned to Node. Skipping...'.format( - entry['UniqueName'])) - # Update results data with matching poller name - results['existing'].append(entry['UniqueName']) - # Remove the already assigned Custom Poller from the custompollerids list - custompollerids.remove(entry) - - # After removing all pollers already assigned to the Node, loop through any remaining - # entries and assign them to the Node + # After validating all the pollers have not already been assigned to the Node, loop + # through all the entries and assign them to the Node for entry in custompollerids: self.logger.info('Add Entry: {}'.format(entry)) From c4286815d4e8bf2bd6a0ba7eb29d910aae61a65b Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Thu, 20 May 2021 07:10:38 -0500 Subject: [PATCH 23/33] Correct source data for log entry --- actions/add_custom_pollers_to_node.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/add_custom_pollers_to_node.py b/actions/add_custom_pollers_to_node.py index c577115..bc0ce87 100644 --- a/actions/add_custom_pollers_to_node.py +++ b/actions/add_custom_pollers_to_node.py @@ -81,7 +81,7 @@ def run(self, node, custompollers): self.logger.info('Custom Poller {} already assigned to Node. Skipping...' ''.format(entry)) # Update results data with matching poller name - results['existing'].append(entry['UniqueName']) + results['existing'].append(entry) else: # Add Custom Poller ID to list if not found to have already been assigned to the # Node From 8f40f04ec7fd8d9a2e1ac0d4a8dcd5e882d368f7 Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Thu, 20 May 2021 07:16:05 -0500 Subject: [PATCH 24/33] Corrected logic for query returning multiple results --- actions/add_custom_pollers_to_node.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/add_custom_pollers_to_node.py b/actions/add_custom_pollers_to_node.py index bc0ce87..b5947fb 100644 --- a/actions/add_custom_pollers_to_node.py +++ b/actions/add_custom_pollers_to_node.py @@ -88,7 +88,7 @@ def run(self, node, custompollers): custompollerids.append(entrypollerid['results'][0]) # Check if the Custom poller query returned either 0 or more than the expected 1 - if len(entrypollerid['results']) >= 1 or len(entrypollerid['results']) == 0: + if len(entrypollerid['results']) > 1 or len(entrypollerid['results']) == 0: self.logger.info('Custom poller {} not found in Orion DB or the text query returned' ' multiple entries and will be ignored...'.format(entry)) results['not_found'].append(entry) From 93614f0136a8cc8ba131522aac6ec0c90df6bc1e Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Thu, 20 May 2021 07:23:21 -0500 Subject: [PATCH 25/33] Moved if statement below poller query check to ensure custom poller data was added to list when found to not be assigned already to the Node --- actions/add_custom_pollers_to_node.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/actions/add_custom_pollers_to_node.py b/actions/add_custom_pollers_to_node.py index b5947fb..58b52ea 100644 --- a/actions/add_custom_pollers_to_node.py +++ b/actions/add_custom_pollers_to_node.py @@ -82,10 +82,10 @@ def run(self, node, custompollers): ''.format(entry)) # Update results data with matching poller name results['existing'].append(entry) - else: - # Add Custom Poller ID to list if not found to have already been assigned to the - # Node - custompollerids.append(entrypollerid['results'][0]) + else: + # Add Custom Poller ID to list if not found to have already been assigned to the + # Node + custompollerids.append(entrypollerid['results'][0]) # Check if the Custom poller query returned either 0 or more than the expected 1 if len(entrypollerid['results']) > 1 or len(entrypollerid['results']) == 0: From 121e75fc4307d98c2bd7c1cb15c5ff7646bf626a Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Thu, 20 May 2021 07:27:11 -0500 Subject: [PATCH 26/33] Updated logging --- actions/add_custom_pollers_to_node.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/actions/add_custom_pollers_to_node.py b/actions/add_custom_pollers_to_node.py index 58b52ea..4ccf2f5 100644 --- a/actions/add_custom_pollers_to_node.py +++ b/actions/add_custom_pollers_to_node.py @@ -97,14 +97,13 @@ def run(self, node, custompollers): # through all the entries and assign them to the Node for entry in custompollerids: - self.logger.info('Add Entry: {}'.format(entry)) entrydata = { "NodeID": str(orion_node.npm_id), "CustomPollerID": entry['CustomPollerID'] } response = self.create('Orion.NPM.CustomPollerAssignmentOnNode', **entrydata) self.logger.info('Custom poller {} successfully assigned to Node: {}'.format( - entry['CustomPollerID'], response)) + entry['UniqueName'], response)) # Update results data with matching poller name results['added'].append(entry['UniqueName']) return results From b71245a69d0d0b23ce0b9c7d28fa1fde3eff2e66 Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Thu, 20 May 2021 07:38:08 -0500 Subject: [PATCH 27/33] Added note about changes to node_create_snmpv3 action --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 8573ec2..400bc89 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,8 @@ - Added Action - add_custom_poller_to_node + +- Updated node_create_snmpv3 action to include the option to specify which default pollers to enable when adding the Node ## 1.0.2 From aff4eb2c378490df88eb33d2e2b67cf77eb10dec Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Thu, 20 May 2021 07:38:43 -0500 Subject: [PATCH 28/33] Corrected typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f68ec70..f1b5085 100755 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ snmp_internal: "SNMP community to use if internal specified" * `list_node_custom_properties` - List the custom properties for a SolarWinds Orion nodes * `list_nodes_by_poller` - List the nodes on a SolarWinds Orion poller * `list_nodes_by_status` - List the nodes by status -* `list_sdk_verb_args` - List all the arguments for a entity and verb that can be invoked via SolarWinds Orion. +* `list_sdk_verb_args` - List all the arguments for an entity and verb that can be invoked via SolarWinds Orion. * `list_sdk_verbs` - List all the verbs that can be invoked via SolarWinds Orion * `ncm_config_download` - Download config(s) from SolarWinds NCM Orion module. * `ncm_execute_script` - Execute an script on an Orion NCM Node. From a1b557605f83a0d62ed776f4adc5b8b5fe4f4926 Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 9 Jun 2021 06:07:25 -0500 Subject: [PATCH 29/33] Corrected typo --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 400bc89..1b1adf6 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,7 +4,7 @@ - Added Action - - add_custom_poller_to_node +- add_custom_poller_to_node - Updated node_create_snmpv3 action to include the option to specify which default pollers to enable when adding the Node From 774290389a76da5a700230055721ee58bb443a54 Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 9 Jun 2021 06:08:00 -0500 Subject: [PATCH 30/33] Corrected typo --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 1b1adf6..400bc89 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,7 +4,7 @@ - Added Action -- add_custom_poller_to_node + - add_custom_poller_to_node - Updated node_create_snmpv3 action to include the option to specify which default pollers to enable when adding the Node From cd018b58387a5b77abb9259fe310834c0561c40b Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Wed, 16 Jun 2021 06:23:51 -0500 Subject: [PATCH 31/33] Updated password YAML to make the values secret --- actions/node_create_snmpv3.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/actions/node_create_snmpv3.yaml b/actions/node_create_snmpv3.yaml index 6f7a34f..8da925a 100644 --- a/actions/node_create_snmpv3.yaml +++ b/actions/node_create_snmpv3.yaml @@ -35,6 +35,7 @@ parameters: privacy_password: type: "string" required: true + secret: true description: "The SNMPv3 Privacy password used to poll SNMP from remote device." auth_protocol: type: "string" @@ -46,6 +47,7 @@ parameters: auth_password: type: "string" required: true + secret: true description: "The SNMPv3 Authentication password used to poll SNMP from remote device." status: type: "string" From 0dcffe8d6897cd2d89f463b7ca3d02b6533442a5 Mon Sep 17 00:00:00 2001 From: jamesdreid Date: Thu, 18 May 2023 06:49:54 -0500 Subject: [PATCH 32/33] Added cipher options to auth protocol list --- actions/node_create_snmpv3.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/actions/node_create_snmpv3.yaml b/actions/node_create_snmpv3.yaml index 8da925a..f78b5e6 100644 --- a/actions/node_create_snmpv3.yaml +++ b/actions/node_create_snmpv3.yaml @@ -43,6 +43,8 @@ parameters: enum: - "MD5" - "SHA1" + - "SHA256" + - "SHA512" default: "SHA1" auth_password: type: "string" From 749145ff194403fa5b6c062fa56cbb797a23de9f Mon Sep 17 00:00:00 2001 From: ReidJ Date: Thu, 25 Jan 2024 14:44:35 -0600 Subject: [PATCH 33/33] Updated enumerated list options to include high strength ciphers --- actions/node_create_snmpv3.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/actions/node_create_snmpv3.yaml b/actions/node_create_snmpv3.yaml index 8da925a..f78b5e6 100644 --- a/actions/node_create_snmpv3.yaml +++ b/actions/node_create_snmpv3.yaml @@ -43,6 +43,8 @@ parameters: enum: - "MD5" - "SHA1" + - "SHA256" + - "SHA512" default: "SHA1" auth_password: type: "string"