コード例 #1
0
ファイル: localapps.py プロジェクト: grefly/splunk-apps
    def handleCreate(self, confInfo):
        args = self.callerArgs.data
        
        # Sanity checking for app ID: no special chars and shorter than 100 chars
        appName = self.callerArgs.id
        if not appName or len(appName) == 0:
            raise admin.ArgValidationException(_('App folder name is not set.'))
        
        if re.search('[^A-Za-z0-9._-]', appName):
            raise admin.ArgValidationException(_('App folder name cannot contain spaces or special characters.'))
            
        if len(appName) > 100:
            raise admin.ArgValidationException(_('App folder name cannot be longer than 100 characters.'))

        kwargs = {
            'label'       : _getFieldValue(args, HTTP_POST_LABEL, appName, maxLen=100),
            'visible'     : _getFieldValue(args, HTTP_POST_VISIBLE, 'true'),
            'author'      : _getFieldValue(args, HTTP_POST_AUTHOR, '', maxLen=100),
            'description' : _getFieldValue(args, HTTP_POST_DESC, '', maxLen=500),
            'configured'  : _getFieldValue(args, HTTP_POST_CONFIGURED, '0'),
        }
        template = _getFieldValue(args, HTTP_POST_TEMPLATE, DEFAULT_TEMPLATE)
        
        try:    
            url = appbuilder.createApp(appName, template, **kwargs)
            appbuilder.addUploadAssets(appName)
        except splunk.RESTException, e:
            raise admin.InternalException(e.msg)
コード例 #2
0
    def handleCreate(self, confInfo):
        args = self.callerArgs.data

        # Sanity checking for app ID: no special chars and shorter than 100 chars
        appName = self.callerArgs.id
        if not appName or len(appName) == 0:
            raise admin.ArgValidationException(
                _('App folder name is not set.'))

        if re.search('[^A-Za-z0-9._-]', appName):
            raise admin.ArgValidationException(
                _('App folder name cannot contain spaces or special characters.'
                  ))

        if len(appName) > 100:
            raise admin.ArgValidationException(
                _('App folder name cannot be longer than 100 characters.'))

        kwargs = {
            'label': _getFieldValue(args, HTTP_POST_LABEL, appName,
                                    maxLen=100),
            'visible': _getFieldValue(args, HTTP_POST_VISIBLE, 'true'),
            'author': _getFieldValue(args, HTTP_POST_AUTHOR, '', maxLen=100),
            'description': _getFieldValue(args, HTTP_POST_DESC, '',
                                          maxLen=500),
            'configured': _getFieldValue(args, HTTP_POST_CONFIGURED, '0'),
        }
        template = _getFieldValue(args, HTTP_POST_TEMPLATE, DEFAULT_TEMPLATE)

        try:
            url = appbuilder.createApp(appName, template, **kwargs)
            appbuilder.addUploadAssets(appName)
        except splunk.RESTException, e:
            raise admin.InternalException(e.msg)
コード例 #3
0
    def handleCreate(self, confInfo):
        args = self.callerArgs.data

        # Sanity checking for app ID: no special chars and shorter than 100 chars
        appName = self.callerArgs.id
        if not appName or len(appName) == 0:
            raise admin.ArgValidationException('App folder name is not set.')

        if re.search('[^A-Za-z0-9._-]', appName):
            raise admin.ArgValidationException(
                'App folder name cannot contain spaces or special characters.')

        if len(appName) > 100:
            raise admin.ArgValidationException(
                'App folder name cannot be longer than 100 characters.')

        kwargs = {
            'label': _getFieldValue(args, HTTP_POST_LABEL, appName,
                                    maxLen=100),
            'visible': _getFieldValue(args, HTTP_POST_VISIBLE, 'true'),
            'author': _getFieldValue(args, HTTP_POST_AUTHOR, '', maxLen=100),
            'description': _getFieldValue(args, HTTP_POST_DESC, '',
                                          maxLen=500),
            'configured': _getFieldValue(args, HTTP_POST_CONFIGURED, '0'),
            'version': _getFieldValue(args, HTTP_POST_VERSION, '1.0.0')
        }
        template = _getFieldValue(args, HTTP_POST_TEMPLATE, DEFAULT_TEMPLATE)

        if re.match("^\d{1,3}\.\d{1,3}\.\d{1,3}(\s?\w[\w\d]{,9})?$",
                    kwargs['version']) is None:
            raise admin.ArgValidationException(
                "Version '%s' is invalid. Use the version format 'major.minor.patch', for example '1.0.0'."
                % kwargs['version'])

        try:
            url = appbuilder.createApp(appName, template, **kwargs)
            appbuilder.addUploadAssets(appName)
        except splunk.RESTException as e:
            raise admin.InternalException(e.msg)

        confInfo[appName].append('name', appName)
        for field in kwargs:
            confInfo[appName].append(field, kwargs[field])
コード例 #4
0
ファイル: localapps.py プロジェクト: grefly/splunk-apps
 def handleEdit(self, confInfo):
     appName = self.callerArgs.id
     appbuilder.addUploadAssets(appName)
コード例 #5
0
 def handleEdit(self, confInfo):
     appName = self.callerArgs.id
     appbuilder.addUploadAssets(appName)