| 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 NetBSDNetwork(GenericBsdIfconfigNetwork): |
| 23 |
""" |
| 24 |
This is the NetBSD Network Class. |
| 25 |
It uses the GenericBsdIfconfigNetwork |
| 26 |
""" |
| 27 |
platform = 'NetBSD' |
| 28 |
|
| 29 |
def parse_media_line(self, words, current_if, ips): |
| 30 |
# example of line: |
| 31 |
# $ ifconfig |
| 32 |
# ne0: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500 |
| 33 |
# ec_capabilities=1<VLAN_MTU> |
| 34 |
# ec_enabled=0 |
| 35 |
# address: 00:20:91:45:00:78 |
| 36 |
# media: Ethernet 10baseT full-duplex |
| 37 |
# inet 192.168.156.29 netmask 0xffffff00 broadcast 192.168.156.255 |
| 38 |
current_if['media'] = words[1] |
| 39 |
if len(words) > 2: |
| 40 |
current_if['media_type'] = words[2] |
| 41 |
if len(words) > 3: |
| 42 |
current_if['media_options'] = words[3].split(',') |
| 43 |
|
| 44 |
|
| 45 |
class NetBSDNetworkCollector(NetworkCollector): |
| 46 |
_fact_class = NetBSDNetwork |
| 47 |
_platform = 'NetBSD' |