'Returns a tuple of booleans (port_security_enabled, has_ip).
Port_security is the value associated with the port if one is present
otherwise the value associated with the network is returned. has_ip is
if the port is associated with an ip or not.'

def _determine_port_security_and_has_ip(self, context, port):

    has_ip = self._ip_on_port(port)
    if (port.get('device_owner') and net.is_port_trusted(port)):
        return (False, has_ip)
    if validators.is_attr_set(port.get(psec.PORTSECURITY)):
        port_security_enabled = port[psec.PORTSECURITY]
    elif (has_ip and validators.is_attr_set(port.get('security_groups'))):
        port_security_enabled = True
    else:
        port_security_enabled = self._get_network_security_binding(context, port['network_id'])
    return (port_security_enabled, has_ip)
