Debian Codegraph @

lib/ansible/module_utils/facts/network/darwin.py

raw
1 # This file is part of Ansible
2 #
3 # Ansible is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # Ansible is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
15
16 from __future__ import annotations
17
18 from ansible.module_utils.facts.network.base import NetworkCollector
19 from ansible.module_utils.facts.network.generic_bsd import GenericBsdIfconfigNetwork
20
21
22 class DarwinNetwork(GenericBsdIfconfigNetwork):
23 """
24 This is the Mac macOS Darwin Network Class.
25 It uses the GenericBsdIfconfigNetwork unchanged
26 """
27 platform = 'Darwin'
28
29 # media line is different to the default FreeBSD one
30 def parse_media_line(self, words, current_if, ips):
31 # not sure if this is useful - we also drop information
32 current_if['media'] = 'Unknown' # Mac does not give us this
33 current_if['media_select'] = words[1]
34 if len(words) > 2:
35 # MacOSX sets the media to '<unknown type>' for bridge interface
36 # and parsing splits this into two words; this if/else helps
37 if words[1] == '<unknown' and words[2] == 'type>':
38 current_if['media_select'] = 'Unknown'
39 current_if['media_type'] = 'unknown type'
40 else:
41 current_if['media_type'] = words[2][1:-1]
42 if len(words) > 3:
43 current_if['media_options'] = self.get_options(words[3])
44
45
46 class DarwinNetworkCollector(NetworkCollector):
47 _fact_class = DarwinNetwork
48 _platform = 'Darwin'