'Associate or disassociate host or project to network.'

def associate(self, context, network_uuid, associations):

    LOG.debug('Associate    network    %s:    |%s|', network_uuid, associations)
    network = self.get_network(context, network_uuid)
    network_id = network.id
    if ('host' in associations):
        host = associations['host']
        if (host is None):
            network.disassociate(context, network_id, host=True, project=False)
        else:
            network.host = self.host
            network.save()
    if ('project' in associations):
        project = associations['project']
        if (project is None):
            network.disassociate(context, network_id, host=False, project=True)
        else:
            network.associate(context, project, network_id, force=True)
