Completed
Pull Request — master (#474)
by
unknown
02:23
created

GetMid.run()   B

Complexity

Conditions 5

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 5
dl 0
loc 16
rs 8.5454
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 import checkinputs
17
from lib.icsp import ICSPBaseActions
18
19
20
class GetMid(ICSPBaseActions):
21
    def run(self, uuid, serialnumber, connection_details):
22
        checkinputs.one_of_two_strings(uuid, serialnumber,
23
                                       "UUID or SerialNumber")
24
        if connection_details:
25
            self.setConnection(connection_details)
26
        self.getSessionID()
27
        endpoint = "/rest/os-deployment-servers"
28
        results = self.icspGET(endpoint)
29
        servers = results["members"]
30
        for server in servers:
31
            if (server["uuid"] == uuid) or\
32
                    (server["serialNumber"] == serialnumber):
33
                mid = server["mid"]
34
                continue
35
36
        return {'mid': mid}
37