def create_injection_plugin(self, values): # ensure defaults are present for new plugins if 'uuid' not in values: values['uuid'] = uuidutils.generate_uuid() inj_plug = models.InjectionPlugin() inj_plug.update(values) try: inj_plug.save() except db_exc.DBDuplicateEntry: raise exception.PluginAlreadyExists(uuid=values['uuid']) return inj_plug
def update_plugin(self, plugin_id, values): # NOTE(dtantsur): this can lead to very strange errors if 'uuid' in values: msg = _("Cannot overwrite UUID for an existing Plugin.") raise exception.InvalidParameterValue(err=msg) try: return self._do_update_plugin(plugin_id, values) except db_exc.DBDuplicateEntry as e: if 'name' in e.columns: raise exception.DuplicateName(name=values['name']) elif 'uuid' in e.columns: raise exception.PluginAlreadyExists(uuid=values['uuid']) else: raise e