Completed
Pull Request — master (#415)
by Anthony
02:24
created

GetVLANByNameAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 12
Duplicated Lines 0 %
Metric Value
dl 0
loc 12
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 10 3
1
from lib import actions
2
3
__all__ = [
4
    'GetVLANByNameAction',
5
]
6
7
8
class GetVLANByNameAction(actions.BaseAction):
9
10
    def run(self, region, vlan_name, network_domain_id):
11
        driver = self._get_compute_driver(region)
12
        if network_domain_id is not None:
13
            network_domain = driver.ex_get_network_domain(network_domain_id)
14
            vlans = driver.ex_list_vlans(network_domain=network_domain)
15
        else:
16
            vlans = driver.ex_list_vlans()
17
        vlan = list(filter(lambda x: x.name == vlan_name,
18
                    vlans))[0]
19
        return self.resultsets.formatter(vlan)
20