'Associate or disassociate host or project to network.'

def associate(self, context, network_uuid, host=base_api.SENTINEL, project=base_api.SENTINEL):

    network = self.get(context, network_uuid)
    if (host is not base_api.SENTINEL):
        if (host is None):
            objects.Network.disassociate(context, network.id, host=True, project=False)
        else:
            network.host = host
            network.save()
    if (project is not base_api.SENTINEL):
        if (project is None):
            objects.Network.disassociate(context, network.id, host=False, project=True)
        else:
            objects.Network.associate(context, project, network_id=network.id, force=True)
