How to use the solnlib.utils.extract_http_scheme_host_port function in solnlib

To help you get started, we’ve selected a few solnlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PaloAltoNetworks / pandevice / install / Splunk_TA_paloalto / bin / splunk_ta_paloalto_setup.py View on Github external
def handleEdit(self, confInfo):
        logger.info("start edit setup configure.")
        scheme, host, port = utils.extract_http_scheme_host_port(scc.getMgmtUri())
        conf_mgr = conf.ConfManager(self.getSessionKey(), self.appName, scheme=scheme, host=host, port=port)
        ta_conf_file = get_or_create_conf_file(conf_mgr, setup_const.myta_conf)
        customized_conf_file = get_or_create_conf_file(conf_mgr, setup_const.myta_customized_conf)
        all_origin_settings = ta_conf_file.get_all()
        all_settings = utils.escape_json_control_chars(
            self.callerArgs.data[setup_const.all_settings][0])
        all_settings = json.loads(all_settings)
        # write global and proxy settings
        self._updateGlobalSettings(setup_const.global_settings, all_settings,
                                   all_origin_settings, ta_conf_file)
        # write customized settings
        customized_conf_file = get_or_create_conf_file(conf_mgr, setup_const.myta_customized_conf)
        self._updateConfStanzas(all_settings.get(setup_const.myta_customized_settings, {}), customized_conf_file, self.encrypt_fields_customized)
        # write account credential settings
        for cred, conf_file in self.cred_confs:
            cred_conf_file = get_or_create_conf_file(conf_mgr, conf_file)
github PaloAltoNetworks / pandevice / install / Splunk_TA_paloalto / bin / splunk_ta_paloalto / solnlib / modular_input / event_writer.py View on Github external
def __init__(self, hec_input_name, session_key,
                 scheme=None, host=None, port=None, hec_uri=None,
                 hec_token=None, **context):
        super(HECEventWriter, self).__init__()
        self._session_key = session_key

        if not all([scheme, host, port]):
            scheme, host, port = get_splunkd_access_info()

        if hec_uri and hec_token:
            scheme, host, hec_port = utils.extract_http_scheme_host_port(
                hec_uri)
        else:
            hec_port, hec_token = self._get_hec_config(
                hec_input_name, session_key, scheme, host, port, **context)

        if not context.get('pool_connections'):
            context['pool_connections'] = 10

        if not context.get('pool_maxsize'):
            context['pool_maxsize'] = 10

        self._rest_client = rest_client.SplunkRestClient(hec_token,
                                                         app='-',
                                                         scheme=scheme,
                                                         host=host,
                                                         port=hec_port,
github PaloAltoNetworks / Splunk_TA_paloalto / bin / splunk_ta_paloalto / modinput_wrapper / base_modinput.py View on Github external
def _init_ckpt(self):
        if self.ckpt is None:
            if 'AOB_TEST' in os.environ:
                ckpt_dir = self.context_meta.get('checkpoint_dir', tempfile.mkdtemp())
                if not os.path.exists(ckpt_dir):
                    os.makedirs(ckpt_dir)
                self.ckpt = checkpointer.FileCheckpointer(ckpt_dir)
            else:
                if 'server_uri' not in self.context_meta:
                    raise ValueError('server_uri not found in input meta.')
                if 'session_key' not in self.context_meta:
                    raise ValueError('session_key not found in input meta.')
                dscheme, dhost, dport = sutils.extract_http_scheme_host_port(self.context_meta[
                                                                                 'server_uri'])
                self.ckpt = checkpointer.KVStoreCheckpointer(self.app + "_checkpointer",
                                                             self.context_meta['session_key'], self.app,
                                                             scheme=dscheme, host=dhost, port=dport)
github PaloAltoNetworks / pandevice / install / Splunk_TA_paloalto / bin / splunk_ta_paloalto_setup_util.py View on Github external
def __init__(self, uri, session_key, logger=None):
        self.__uri = uri
        self.__session_key = session_key
        self.__logger = logger
        self.scheme, self.host, self.port = utils.extract_http_scheme_host_port(
            self.__uri)
        self.encrypt_fields_credential = (setup_const.password,)
        self.encrypt_fields_customized = (setup_const.password,)
        self.cred_confs = (
            (setup_const.myta_credential_settings, setup_const.myta_credential_conf),)
        self.__cached_global_settings = None
github PaloAltoNetworks / Splunk_TA_paloalto / bin / splunk_ta_paloalto_setup.py View on Github external
def handleList(self, confInfo):
        logger.info("start list setup configure.")
        scheme, host, port = utils.extract_http_scheme_host_port(scc.getMgmtUri())
        conf_mgr = conf.ConfManager(self.getSessionKey(), self.appName, scheme=scheme, host=host, port=port)
        ta_conf_file = get_or_create_conf_file(conf_mgr, setup_const.myta_conf)
        # read globala and proxy settings
        all_settings = ta_conf_file.get_all()
        if not all_settings:
            all_settings = {}
        self._setNoneValues(all_settings.get(setup_const.global_settings, {}))
        # read account credential settings
        for cred, cred_conf in self.cred_confs:
            cred_conf_file = get_or_create_conf_file(conf_mgr, cred_conf)
            creds = cred_conf_file.get_all()
            if creds:
                self._setNoneValues(creds)
                all_settings.update({cred: creds})
        # customized conf
        customized_conf_file = get_or_create_conf_file(conf_mgr, setup_const.myta_customized_conf)