Completed
Pull Request — master (#466)
by
unknown
02:48
created

NcmConfigDownload   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %
Metric Value
dl 0
loc 32
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
B run() 0 31 4
1
# Licensed to the StackStorm, Inc ('StackStorm') under one or more
2
# contributor license agreements.  See the NOTICE file distributed with
3
# this work for additional information regarding copyright ownership.
4
# The ASF licenses this file to You under the Apache License, Version 2.0
5
# (the "License"); you may not use this file except in compliance with
6
# the License.  You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15
16
from lib.actions import OrionBaseAction
17
18
19
class NcmConfigDownload(OrionBaseAction):
20
    def run(self, node, platform, configs):
21
        """
22
        Mostly completed! Download configurations via Solarwinds Orion NCM ....
23
24
        see https://github.com/solarwinds/OrionSDK/wiki/NCM-Config-Transfer
25
        """
26
27
        results = {}
28
        node_ids = []
29
30
        # Split into an Array, as enum and array type does not play nice
31
        # in the WebUI.
32
        configs = configs.split(",")
33
34
        self.connect(platform)
35
36
        try:
37
            node_ids.append(self.get_ncm_node_id(node))
38
        except IndexError, msg:
39
            self.send_user_error("{}".format(msg))
40
            raise IndexError(msg)
41
        else:
42
            for config in configs:
43
                orion_data = self.invoke("Cirrus.ConfigArchive",
44
                                         "DownloadConfig",
45
                                         node_ids,
46
                                         config)
47
                transfer_id = orion_data[0]
48
                results[config] = self.get_ncm_transfer_results(transfer_id)
49
50
        return results
51