'Check if attaching to external network is permitted.'

def _check_external_network_attach(self, context, nets):

    if (not context.can(servers_policies.NETWORK_ATTACH_EXTERNAL, fatal=False)):
        for net in nets:
            if (net.get('router:external') and (not net.get('shared'))):
                raise exception.ExternalNetworkAttachForbidden(network_uuid=net['id'])
