@staticmethod
def _from_db_object(context, service, db_service):
    allow_missing = ('availability_zone',)
    for key in service.fields:
        if ((key in allow_missing) and (key not in db_service)):
            continue
        if (key == 'compute_node'):
            continue
        elif (key == 'version'):
            setattr(service, base.get_attrname(key), db_service[key])
        elif ((key == 'uuid') and (not db_service.get(key))):
            continue
        else:
            service[key] = db_service[key]
    service._context = context
    service.obj_reset_changes()
    if ('uuid' not in service):
        service.uuid = uuidutils.generate_uuid()
        LOG.debug('Generated UUID %(uuid)s for service %(id)i', dict(uuid=service.uuid, id=service.id))
        service.save()
    return service
@staticmethod
def _from_db_object(context, service, db_service):
    allow_missing = ('availability_zone',)
    for key in service.fields:
        if ((key in allow_missing) and (key not in db_service)):
            continue
        if (key == 'compute_node'):
            continue
        elif (key == 'version'):
            setattr(service, base.get_attrname(key), db_service[key])
        elif ((key == 'uuid') and (not db_service.get(key))):
            continue
        else:
            service[key] = db_service[key]
    service._context = context
    service.obj_reset_changes()
    if ('uuid' not in service):
        service.uuid = uuidutils.generate_uuid()
        LOG.debug('Generated UUID %(uuid)s for service %(id)i', dict(uuid=service.uuid, id=service.id))
        service.save()
    return service