def _set_properties_for_image(context, image_ref, properties,
                              purge_props=False, session=None):
    orig_properties = {}
    for prop_ref in image_ref.properties:
        orig_properties[prop_ref.name] = prop_ref

    for name, value in properties.iteritems():
        prop_values = {'image_id': image_ref.id,
                       'name': name,
                       'value': value}
        if name in orig_properties:
            prop_ref = orig_properties[name]
            image_property_update(context, prop_ref, prop_values,
                                  session=session)
        else:
            image_property_create(context, prop_values, session=session)

    if purge_props:
        for key in orig_properties.keys():
            if not key in properties:
                prop_ref = orig_properties[key]
                image_property_delete(context, prop_ref, session=session)
Handle a non-recoverable error.
dataset/ETHPy150Open rcbops/glance-buildpackage/glance/registry/db/api.py/_set_properties_for_image--crossover with--dataset/ETHPy150Open kdart/pycopia/storage/pycopia/db/importers/nmap.py/ErrorHandler.fatalError