Exemple #1
0
from splunklib.searchcommands import dispatch, GeneratingCommand, Configuration, Option
import logging
import os
import sys
import log_helper
from datetime import datetime
import uuid
import json
import splunk.rest as rest
import boto3

debug_logger = log_helper.setup(logging.INFO, 'GetAWSPriceListDebug',
                                'get_aws_price_list_debug.log')

pid = os.getpid()
tstart = datetime.now()
guid = str(uuid.uuid4().hex)


def simple_request_messages_to_str(messages):
    """
    Returns a readable string from a simple request response message

    Arguments
    messages -- The simple request response message to parse
    """
    entries = []
    for message in messages:
        entries.append(message.get('text'))
    return ','.join(entries)
Exemple #2
0
import json
import logging
import splunk.admin as admin
import splunk.rest as rest
import log_helper

# Setup the handler
logger = log_helper.setup(logging.INFO, 'BaseEAIHandler', 'base_handler.log')

class BaseEAIHandler(admin.MConfigHandler):
    def get_param(self, param, default=None):
        """
        Returns value of a matched param from either POST or GET encoded values.
        Note: Returns the first entry as a param - can be multi-valued.

        Arguments
        param -- The param key to extract.
        """
        if param in self.callerArgs:
            if self.callerArgs[param][0] is not None:
                return self.callerArgs[param][0].strip()
        return default

    def get_params(self, schema, filter=None):
        """
        Returns a flattened dictionary of key/value pairs of posted allowable params.
        The EAI Admin Handler plucks name out and sets it the id instance member. This
        adds the name key back to the params dictionary returned.

        Arguments
        filter -- (default None) An optional array of param keys to extract in dictionary
Exemple #3
0
import splunk.admin as admin
import splunk_accounts_schema
import urllib
import base_eai_handler
import log_helper

if sys.platform == 'win32':
    import msvcrt

    # Binary mode is required for persistent mode on Windows.
    msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
    msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
    msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)

# Setup the handler
logger = log_helper.setup(logging.INFO, 'SplunkAccountsEAIHandler',
                          'splunk_accounts_handler.log')


class SplunkAccountsEAIHandler(base_eai_handler.BaseEAIHandler):
    def setup(self):
        # Add our supported args
        for arg in splunk_accounts_schema.ALL_FIELDS:
            self.supportedArgs.addOptArg(arg)

    def handleList(self, confInfo):
        """
        Called when user invokes the "list" action.

        Arguments
        confInfo -- The object containing the information about what is being requested.
        """
import hashlib
import base_eai_handler
import log_helper
import boto3
import json

if sys.platform == 'win32':
    import msvcrt

    # Binary mode is required for persistent mode on Windows.
    msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
    msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
    msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)

# Setup the handler
logger = log_helper.setup(logging.INFO, 'EnsembleAWSAccountsEAIHandler',
                          'ensemble_aws_accounts_handler.log')


class EnsembleAWSAccountsEAIHandler(base_eai_handler.BaseEAIHandler):
    def setup(self):
        # Add our supported args
        for arg in ensemble_aws_accounts_schema.ALL_FIELDS:
            self.supportedArgs.addOptArg(arg)

    def handleList(self, confInfo):
        """
        Called when user invokes the "list" action.

        Arguments
        confInfo -- The object containing the information about what is being requested.
        """
Exemple #5
0
import urllib
import base_eai_handler
import log_helper
import json
import boto3

if sys.platform == 'win32':
    import msvcrt

    # Binary mode is required for persistent mode on Windows.
    msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
    msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
    msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)

# Setup the handler
logger = log_helper.setup(logging.INFO, 'BulkCredentialUploadEAIHandler',
                          'bulk_credential_upload_handler.log')


class BulkCredentialUploadEAIHandler(base_eai_handler.BaseEAIHandler):
    def setup(self):
        # Add our supported args
        for arg in bulk_credential_upload_schema.ALL_FIELDS:
            self.supportedArgs.addOptArg(arg)

    def handleList(self, confInfo):
        """
        Called when user invokes the "list" action.

        Arguments
        confInfo -- The object containing the information about what is being requested.
        """
import splunk.admin as admin
import cloudformation_templates_schema
import urllib
import base_eai_handler
import log_helper

if sys.platform == 'win32':
    import msvcrt

    # Binary mode is required for persistent mode on Windows.
    msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
    msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
    msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)

# Setup the handler
logger = log_helper.setup(logging.INFO, 'CloudFormationTemplatesEAIHandler',
                          'cloudformation_templates_handler.log')


class CloudFormationTemplatesEAIHandler(base_eai_handler.BaseEAIHandler):
    def setup(self):
        # Add our supported args
        for arg in cloudformation_templates_schema.ALL_FIELDS:
            self.supportedArgs.addOptArg(arg)

    def handleList(self, confInfo):
        """
        Called when user invokes the "list" action.

        Arguments
        confInfo -- The object containing the information about what is being requested.
        """
import logging
import sys
import uuid
import splunk.admin as admin
import example_eai_handler_schema
import urllib
import re
import errno
import base_eai_handler
import log_helper
import time
from splunk.clilib.bundle_paths import make_splunkhome_path

# Setup the logger
logger = log_helper.setup(logging.INFO, 'ExampleEAIHandler',
                          'example_eai_handler.log')


class ExampleEAIHandler(base_eai_handler.BaseEAIHandler):
    def setup(self):
        # Add our supported args
        for arg in example_eai_handler_schema.ALL_FIELDS:
            self.supportedArgs.addOptArg(arg)

    def handleList(self, confInfo):
        """
        Called when user invokes the "list" action. Returns the contents of example_eai_handler.conf

        Arguments
        confInfo -- The object containing the information about what is being requested.
        """
Exemple #8
0
import organizations_schema
import boto3
import urllib3
import base_eai_handler
import log_helper

if sys.platform == 'win32':
    import msvcrt

    # Binary mode is required for persistent mode on Windows.
    msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
    msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
    msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)

# Setup the handler
logger = log_helper.setup(logging.INFO, 'OrganizationsEAIHandler',
                          'organizations_handler.log')


class OrganizationsEAIHandler(base_eai_handler.BaseEAIHandler):
    def setup(self):
        # Add our supported args
        for arg in organizations_schema.ALL_FIELDS:
            self.supportedArgs.addOptArg(arg)

    def handleList(self, confInfo):
        """
        Called when user invokes the "list" action.

        Arguments
        confInfo -- The object containing the information about what is being requested.
        """
import log_helper
import boto3
import json
import time
from datetime import datetime

if sys.platform == 'win32':
    import msvcrt

    # Binary mode is required for persistent mode on Windows.
    msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
    msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
    msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)

# Setup the handler
logger = log_helper.setup(logging.INFO, 'GrandCentralAWSAccountsEAIHandler',
                          'grand_central_aws_accounts_handler.log')


class GrandCentralAWSAccountsEAIHandler(base_eai_handler.BaseEAIHandler):
    def setup(self):
        # Add our supported args
        for arg in grand_central_aws_accounts_schema.ALL_FIELDS:
            self.supportedArgs.addOptArg(arg)

    def handleList(self, confInfo):
        """
        Called when user invokes the "list" action.

        Arguments
        confInfo -- The object containing the information about what is being requested.
        """
from splunklib.searchcommands import dispatch, GeneratingCommand, Configuration, Option
import logging
import os
import sys
import log_helper
from datetime import datetime
import uuid
import json
import splunk.rest as rest

debug_logger = log_helper.setup(logging.INFO,
                                'UpdateOrganizationAccountsDebug',
                                'update_organization_accounts_debug.log')

pid = os.getpid()
tstart = datetime.now()
guid = str(uuid.uuid4().hex)


def simple_request_messages_to_str(messages):
    """
    Returns a readable string from a simple request response message

    Arguments
    messages -- The simple request response message to parse
    """
    entries = []
    for message in messages:
        entries.append(message.get('text'))
    return ','.join(entries)