Commit 1120919e authored by Anael Beutot's avatar Anael Beutot
Browse files

Check method name conflicts in plugins

parent b490571b
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -7,6 +7,8 @@ from cloudcontrol.common.client.tags import Tag
from cloudcontrol.common.jobs import Job
from cloudcontrol.common.tql.db.helpers import taggify

from cloudcontrol.node.exc import PluginError


logger = logging.getLogger(__name__)

@@ -68,7 +70,10 @@ class Plugin(object):

    def _decorator_method(self, name=None):
        def decorator(func):
            self.methods[func.__name__ if name is None else name] = func
            register_name = func.__name__ if name is None else name
            if register_name in self.methods:
                raise PluginError('Already defined method %s' % register_name)
            self.methods[register_name] = func
            return func
        return decorator