Exemplo n.º 1
0
 def to_api(self, bond):
     return dict(
         number=bond.number,
         link_speed=bond.link_speed,
         members=bond.members,
         interface=interface.to_api(Interface(
             shutdown=bond.shutdown,
             port_mode=bond.port_mode,
             access_vlan=bond.access_vlan,
             trunk_native_vlan=bond.trunk_native_vlan,
             trunk_vlans=bond.trunk_vlans,
         ))
     )
Exemplo n.º 2
0
 def to_api(self, bond):
     return dict(
         number=bond.number,
         link_speed=bond.link_speed,
         members=bond.members,
         interface=interface.to_api(Interface(
             shutdown=bond.shutdown,
             port_mode=bond.port_mode,
             access_vlan=bond.access_vlan,
             trunk_native_vlan=bond.trunk_native_vlan,
             trunk_vlans=bond.trunk_vlans,
             mtu=bond.mtu
         ))
     )
Exemplo n.º 3
0
    def get_interface(self, switch, interface_id):
        """
        Displays informations about a physical interfaces

        :arg str hostname: Hostname or IP of the switch
        :arg str interface_id: name of the interface
        :code 200 OK:

        Example output:

        .. literalinclude:: ../doc_config/api_samples/get_switch_hostname_interface.json
            :language: json

        """
        return 200, interface.to_api(switch.get_interface(interface_id))
Exemplo n.º 4
0
    def get_interface(self, switch, interface_id):
        """
        Displays informations about a physical interfaces

        :arg str hostname: Hostname or IP of the switch
        :arg str interface_id: name of the interface
        :code 200 OK:

        Example output:

        .. literalinclude:: ../doc_config/api_samples/get_switch_hostname_interface.json
            :language: json

        """
        return 200, interface.to_api(switch.get_interface(interface_id))
Exemplo n.º 5
0
    def get_interfaces(self, switch):
        """
        Displays informations about all physical interfaces

        :arg str hostname: Hostname or IP of the switch
        :code 200 OK:

        Example output:

        .. literalinclude:: ../doc_config/api_samples/get_switch_hostname_interfaces.json
            :language: json

        """
        interfaces = sorted(switch.get_interfaces(), key=lambda x: x.name.lower())

        return 200, [interface.to_api(i) for i in interfaces]
Exemplo n.º 6
0
    def get_interfaces(self, switch):
        """
        Displays informations about all physical interfaces

        :arg str hostname: Hostname or IP of the switch
        :code 200 OK:

        Example output:

        .. literalinclude:: ../doc_config/api_samples/get_switch_hostname_interfaces.json
            :language: json

        """
        interfaces = sorted(switch.get_interfaces(),
                            key=lambda x: x.name.lower())

        return 200, [interface.to_api(i) for i in interfaces]