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 16from __future__ import (absolute_import, division, print_function) 17__metaclass__ = type 18 19from ansible.module_utils.facts.network.base import NetworkCollector 20from ansible.module_utils.facts.network.generic_bsd import GenericBsdIfconfigNetwork 21 22 23class DarwinNetwork(GenericBsdIfconfigNetwork): 24 """ 25 This is the Mac macOS Darwin Network Class. 26 It uses the GenericBsdIfconfigNetwork unchanged 27 """ 28 platform = 'Darwin' 29 30 # media line is different to the default FreeBSD one 31 def parse_media_line(self, words, current_if, ips): 32 # not sure if this is useful - we also drop information 33 current_if['media'] = 'Unknown' # Mac does not give us this 34 current_if['media_select'] = words[1] 35 if len(words) > 2: 36 # MacOSX sets the media to '<unknown type>' for bridge interface 37 # and parsing splits this into two words; this if/else helps 38 if words[1] == '<unknown' and words[2] == 'type>': 39 current_if['media_select'] = 'Unknown' 40 current_if['media_type'] = 'unknown type' 41 else: 42 current_if['media_type'] = words[2][1:-1] 43 if len(words) > 3: 44 current_if['media_options'] = self.get_options(words[3]) 45 46 47class DarwinNetworkCollector(NetworkCollector): 48 _fact_class = DarwinNetwork 49 _platform = 'Darwin' 50