@staticmethod
def port_id_from_name(port_name, device_id, nodes):
    """
        Get the port ID when given a port name

        :param str port_name: port name
        :param str device_id: device ID
        :param list nodes: list of nodes from :py:meth:`generate_nodes`
        :return: port ID
        :rtype: int
        """
    port_id = None
    for node in nodes:
        if device_id == node['id']:
            for port in node['ports']:
                if port_name == port['name']:
                    port_id = port['id']
                    break
            break
    return port_id
