Completed
Pull Request — master (#543)
by
unknown
03:20 queued 51s
created

GetVMByNameAction   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 10
c 0
b 0
f 0
wmc 4
1
from lib import actions
2
3
__all__ = [
4
    'GetVMByNameAction',
5
]
6
7
8
class GetVMByNameAction(actions.BaseAction):
9
10
    def run(self, region, location, name, network_domain):
11
        driver = self._get_compute_driver(region)
12
13
        if network_domain is not None:
14
            networkdomains = driver.ex_list_network_domains()
15
            network_domain = list(filter(lambda x: x.name == network_domain,
16
                                         networkdomains))[0]
17
            nodes = driver.list_nodes(ex_network_domain=network_domain)
18
        else:
19
            nodes = driver.list_nodes()
20
        node = list(filter(lambda x: x.name == name, nodes))[0]
21
        return self.resultsets.formatter(node)
22