示例#1
0
    def expired(self, formset_mode=None, return_to=None, **unused):

        template_args = {
            'can_change_license':
            False,
            'return_to':
            util.make_url_internal(return_to)
            or self.make_url(['manager', 'system', 'licensing'])
        }

        free_group = None
        try:
            free_group = Group.get(
                Group.build_id('Free', namespace=None, owner=None))
            template_args['can_change_license'] = True
        except splunk.AuthorizationFailed:
            pass
        except Exception, e:
            logger.exception(e)
            template_args['controller_exception'] = e
 def expired(self, formset_mode=None, return_to=None, **unused):
     
     template_args = {
         'can_change_license': False,
         'return_to': util.make_url_internal(return_to) or self.make_url(['manager','system','licensing'])
     }
     
     free_group = None
     try:
         free_group = Group.get(Group.build_id(
             'Free',
             namespace=None,
             owner=None
         ))
         template_args['can_change_license'] = True
     except splunk.AuthorizationFailed:
         pass
     except Exception, e:
         logger.exception(e)
         template_args['controller_exception'] = e
示例#3
0
class LicensingController(BaseController):
    """
    Handle licensing messaging and modifications
    """

    #
    # attach common template args
    #

    def render_template(self, template_path, template_args={}):
        template_args['appList'] = self.get_app_manifest()
        return super(LicensingController,
                     self).render_template(template_path, template_args)

    def get_app_manifest(self):
        '''
        Returns a dict of all available apps to current user
        '''

        output = cached.getEntities('apps/local',
                                    search=['disabled=false', 'visible=true'],
                                    count=-1)

        return output

    #
    # trial -> free switching
    #

    @expose_page(methods=['GET', 'POST'])
    def expired(self, formset_mode=None, return_to=None, **unused):

        template_args = {
            'can_change_license':
            False,
            'return_to':
            util.make_url_internal(return_to)
            or self.make_url(['manager', 'system', 'licensing'])
        }

        free_group = None
        try:
            free_group = Group.get(
                Group.build_id('Free', namespace=None, owner=None))
            template_args['can_change_license'] = True
        except splunk.AuthorizationFailed:
            pass
        except Exception, e:
            logger.exception(e)
            template_args['controller_exception'] = e

        if cherrypy.request.method == 'POST' and free_group:

            if formset_mode == 'free':
                try:
                    free_group = Group.get(
                        Group.build_id('Free', namespace=None, owner=None))
                    free_group.is_active = True
                    free_group.save()

                    template_args['is_success'] = True

                except Exception, e:
                    logger.exception(e)
                    template_args['controller_exception'] = e

            elif formset_mode == 'add_license':

                return self.redirect_to_url(
                    ['manager', 'system', 'licensing', 'licenses', 'new'],
                    _qs={
                        'return_to':
                        self.make_url(['manager', 'system', 'licensing'])
                    })