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 OpenBSDNetwork(GenericBsdIfconfigNetwork):
24    """
25    This is the OpenBSD Network Class.
26    It uses the GenericBsdIfconfigNetwork.
27    """
28    platform = 'OpenBSD'
29
30    # OpenBSD 'ifconfig -a' does not have information about aliases
31    def get_interfaces_info(self, ifconfig_path, ifconfig_options='-aA'):
32        return super(OpenBSDNetwork, self).get_interfaces_info(ifconfig_path, ifconfig_options)
33
34    # Return macaddress instead of lladdr
35    def parse_lladdr_line(self, words, current_if, ips):
36        current_if['macaddress'] = words[1]
37        current_if['type'] = 'ether'
38
39
40class OpenBSDNetworkCollector(NetworkCollector):
41    _fact_class = OpenBSDNetwork
42    _platform = 'OpenBSD'
43