Completed
Pull Request — master (#487)
by
unknown
02:56
created

GetDiscoveryProgress.run()   B

Complexity

Conditions 2

Size

Total Lines 35

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 35
rs 8.8571
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
import xml.etree.ElementTree as ET
17
18
from lib.actions import OrionBaseAction
19
# from lib.utils import discovery_status_to_text
20
21
22
class GetDiscoveryProgress(OrionBaseAction):
23
    def run(self, profileId, platform):
24
        """
25
        Get the progress of a discovery profile.
26
27
        Args:
28
            profileId: The id of the profile to query.
29
            platform: The orion platform to act on.
30
31
        Returns:
32
            dict: Of information from GetDiscoveryProgress Orion.Discovery
33
                  verb.
34
35
        Raises:
36
            None: Does not raise any exceptions.
37
        """
38
        results = {}
39
40
        self.connect(platform)
41
42
        orion_data = self.invoke("Orion.Discovery",
43
                                 "GetDiscoveryProgress",
44
                                 profileId)
45
46
        print orion_data
47
48
        root = ET.fromstring(orion_data)
49
50
        # FIXME - action disabled - this does not work as status is a nested element
51
        for child in root:
52
            key = child.tag
53
            results[key.replace("{http://schemas.solarwinds.com/2008/Orion}",
54
                                "")] = child.text
55
            # For Status use discovery_status_to_text to get the text.
56
57
        return results
58