Commit 95c1399b authored by Antoine Millet's avatar Antoine Millet
Browse files

Fixed bug with tags management methods on CCConf.

parent cb65d654
Loading
Loading
Loading
Loading
+9 −11
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ The schema of the json file is described below::
    {
     'password': '<client password>',
     'role': '<node|client>',
     'tags': ['tag1', 'tag2'],
     'tags': {'tag1': 'value'},
     'perms': Null
    }

@@ -30,7 +30,7 @@ u'node'
>>> conf.show('rms')
{'password': 'secret'
 'role': 'client',
 'tags': ['admin'],
 'tags': {},
 'perms': None}
>>> conf.remove_account('rms')
>>> 
@@ -55,7 +55,7 @@ class CCConf(object):

    CONF_TEMPLATE = {'password': None,
                     'type': None,
                     'tags': [],
                     'tags': {},
                     'perms': None}

    RE_SALTPW = re.compile(r'{(?P<method>[A-Z]+)}(?P<password>.+)')
@@ -222,20 +222,19 @@ class CCConf(object):
        self._set_conf(login, conf)

    @_writer
    def add_tag(self, login, tag):
    def add_tag(self, login, tag_name, tag_value):
        '''
        Add the tag to the user.

        :param login: login of the user
        :param tag: tag to add to the user
        :param tag_name: tag name to add to the user
        :param tag_value: the tag value
        :raise CCConf.UnknownAccount: if user login is unknown
        '''

        logging.debug('Added tag %s for %s account' % (login, tag))
        conf = self._get_conf(login)
        tags = set(conf['tags'])
        tags.add(tag)
        conf['tags'] = list(tags)
        conf['tags'][tag_name] = tag_value
        self._set_conf(login, conf)

    @_writer
@@ -250,9 +249,8 @@ class CCConf(object):

        logging.debug('Removed tag %s for %s account' % (login, tag))
        conf = self._get_conf(login)
        tags = set(conf['tags'])
        tags.remove(tag)
        conf['tags'] = list(tags)
        if tag in conf['tags']:
            conf['tags'][tag]
        self._set_conf(login, conf)

    @_writer