Example #1
0
    def new(self, profile_dict):
        """
        @profile_dict need to contain the keys: 'plugin_type', 'plugin_name',
            'admin_settings',
        """

        try:

            # below, before _import_dict, are checked profile_type, and plugin_name
            # both of them can't be updated, are chosen at creation time,

            if not unicode(profile_dict['plugin_type']) in valid_plugin_types:
                raise InvalidInputFormat("plugin_type not recognized")

            if not PluginManager.plugin_exists(profile_dict['plugin_name']):
                raise InvalidInputFormat("plugin_name not recognized between available plugins")

            self._import_dict(profile_dict)

            self.profile_gus = idops.random_plugin_gus()
            self.creation_time = gltime.utcTimeNow()

            # the name can be updated, but need to be checked to be UNIQUE
            if self.store.find(PluginProfiles, PluginProfiles.profile_name == self.profile_name).count() >= 1:
                raise ProfileNameConflict

            plugin_info = PluginManager.get_plugin(profile_dict['plugin_name'])

            # initialize the three plugin_* fields, inherit by Plugin code
            self.plugin_name = unicode(plugin_info['plugin_name'])
            self.plugin_type = unicode(plugin_info['plugin_type'])
            self.plugin_description = unicode(plugin_info['plugin_description'])
            self.admin_fields = dict(plugin_info['admin_fields'])

            # Admin-only plugins are listed here, and they have not receiver_fields
            if self.plugin_type in [ u'fileprocess' ]:
                self.receiver_fields = []
            else:
                self.receiver_fields = plugin_info['receiver_fields']

        except KeyError, e:
            raise InvalidInputFormat("Profile creation failed (missing %s)" % e)
Example #2
0
    def newprofile(self, plugtype, plugname, profname, plugreq, desc=None, settings=None):
        """
        @param plugtype:  notification|delivery|inputfilter, already checked by the caller
        @param plugname:  plugin name, already checked the existence using GLPluginManager
        @param profname:  a profile name, used to recognize a unique profile in a list
        @param plugreq: the plugins required fields for admin and receiver.
        @param desc: a descriptive string that would be presented to the receiver
        @param settings:  the admin side configuration fields for the plugin.
        @return:
        """
        log.debug("[D] %s %s " % (__file__, __name__), "Class PluginConf", "newprofile", ptype, pname)

        store = self.getStore('newprofile')

        if store.find(PluginProfiles, PluginProfiles.profile_name == profname).count() >= 1:
            store.close()
            raise ProfileNameConflict

        newone = PluginProfiles()
        newone.profile_gus = idops.random_plugin_gus()
        newone.profile_name = profname
        newone.creation_time = gltime.utcTimeNow()
        newone.plugin_type = plugtype
        newone.plugin_name = plugname
        newone.required_fields = plugreq

        if settings:
            newone.admin_fields = settings

        if desc:
            newone.external_description = desc

        store.add(newone)

        store.commit()
        store.close()
Example #3
0
            newone.plugin_description = unicode(plugin_info['plugin_description'])
            newone.admin_fields = dict(plugin_info['admin_fields'])

            # Admin-only plugins are listed here, and they have not receiver_fields
            if newone.plugin_type in [ u'fileprocess' ]:
                newone.receiver_fields = []
            else:
                newone.receiver_fields = plugin_info['receiver_fields']

        except KeyError, e:
            raise InvalidInputFormat("Profile creation failed (missing %s)" % e)

        except TypeError, e:
            raise InvalidInputFormat("Profile creation failed (wrong %s)" % e)

        newone.profile_gus = idops.random_plugin_gus()
        newone.creation_time = gltime.utcTimeNow()

        store.add(newone)

        # build return value for the handler
        return newone._description_dict()


    @transact
    def update(self, profile_gus, profile_dict):

        store = self.getStore()

        try:
            looked_p = store.find(PluginProfiles, PluginProfiles.profile_gus == profile_gus).one()