def ensure_permission(self, vhost, username, perms):
        if not self.user_exists(username):
            msg = 'Cannot set permission: User %s doesn\'t exist' % username
            self.log(msg)
            return False

        if not self.vhost_exists(vhost):
            self.log('Cannot set permission: vhost %s doesn\'t exist' % vhost)
            return False

        msg = 'Setting up permissions for user %s on vhost %s'
        msg = msg % (username, vhost)
        self.log(msg)

        args = (vhost, username, perms)
        cmd = 'rabbitmqctl set_permissions -p %s %s %s' % args
        self.execute(cmd, stdout=False, sudo=True)

        return True
Ensure the given user has the given permissions on the specified vhost
dataset/ETHPy150Open python-provy/provy/provy/more/debian/messaging/rabbitmq.py/RabbitMqRole.ensure_permission