How to use the solnlib.utils.retry 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 / solnlib / user_access.py View on Github external
    @retry(exceptions=[binding.HTTPError])
    def register_capabilities(self, capabilities):
        '''Register app capabilities.

        :param capabilities: App capabilities, example: {
            'object_type1': {
            'read': 'read_app_object_type1',
            'write': 'write_app_object_type1',
            'delete': 'delete_app_object_type1'},
            'object_type2': {
            'read': 'read_app_object_type2',
            'write': 'write_app_object_type2',
            'delete': 'delete_app_object_type2'},
            ...}
        :type capabilities: ``dict``
        '''
github PaloAltoNetworks / pandevice / install / Splunk_TA_paloalto / bin / splunk_ta_paloalto / solnlib / modular_input / event_writer.py View on Github external
    @retry(exceptions=[binding.HTTPError])
    def _get_hec_config(self, hec_input_name, session_key,
                        scheme, host, port, **context):
        hc = HECConfig(
            session_key, scheme=scheme, host=host, port=port, **context)
        settings = hc.get_settings()
        if utils.is_true(settings.get('disabled')):
            # Enable HEC input
            logging.info('Enabling HEC')
            settings['disabled'] = '0'
            settings['enableSSL'] = context.get('hec_enablessl', '1')
            settings['port'] = context.get('hec_port', '8088')
            hc.update_settings(settings)

        hec_input = hc.get_input(hec_input_name)
        if not hec_input:
            # Create HEC input
github PaloAltoNetworks / pandevice / install / Splunk_TA_paloalto / bin / splunk_ta_paloalto / solnlib / credentials.py View on Github external
    @retry(exceptions=[binding.HTTPError])
    def delete_password(self, user):
        '''Delete password.

        :param user: User name.
        :type user: ``string``

        :raises CredentialNotExistException: If password of realm:user
            doesn't exist.

        Usage::

           >>> from solnlib import credentials
           >>> cm = credentials.CredentialManager(session_key,
                                                  'Splunk_TA_test',
                                                  realm='realm_test')
           >>> cm.delete_password('testuser1')
github PaloAltoNetworks / pandevice / install / Splunk_TA_paloalto / bin / splunk_ta_paloalto / solnlib / credentials.py View on Github external
@retry(exceptions=[binding.HTTPError])
def get_session_key(username, password,
                    scheme=None, host=None, port=None, **context):
    '''Get splunkd access token.

    :param username: The Splunk account username, which is used to
        authenticate the Splunk instance.
    :type username: ``string``
    :param password: The Splunk account password.
    :type password: ``string``
    :param scheme: (optional) The access scheme, default is None.
    :type scheme: ``string``
    :param host: (optional) The host name, default is None.
    :type host: ``string``
    :param port: (optional) The port number, default is None.
    :type port: ``integer``
    :returns: Splunk session key.
github PaloAltoNetworks / pandevice / install / Splunk_TA_paloalto / bin / splunk_ta_paloalto / solnlib / user_access.py View on Github external
    @retry(exceptions=[binding.HTTPError])
    def capabilities_are_registered(self):
        '''Check if app capabilities are registered.

        :returns: True if app capabilities are registered else
            False.
        :rtype: ``bool``
        '''

        try:
            self._collection_data.query_by_id(self._app)
        except binding.HTTPError as e:
            if e.status != 404:
                raise

            return False
github PaloAltoNetworks / pandevice / install / Splunk_TA_paloalto / bin / splunk_ta_paloalto / solnlib / modular_input / checkpointer.py View on Github external
    @retry(exceptions=[binding.HTTPError])
    def delete(self, key):
        try:
            self._collection_data.delete_by_id(key)
        except binding.HTTPError as e:
            if e.status != 404:
                logging.error(
                    'Delete checkpoint failed: %s.', traceback.format_exc(e))
                raise
github PaloAltoNetworks / pandevice / install / Splunk_TA_paloalto / bin / splunk_ta_paloalto / solnlib / acl.py View on Github external
    @retry(exceptions=[binding.HTTPError])
    def update(self, path, owner=None, perms_read=None, perms_write=None):
        '''Update ACL of /servicesNS/{`owner`}/{`app`}/{`path`}.

        If the ACL is per-entity (ends in /acl), owner can be reassigned. If
        the acl is endpoint-level (ends in _acl), owner will be ignored. The
        'sharing' setting is always retrieved from the current.

        :param path: Path of ACL relative to /servicesNS/{owner}/{app}. MUST
            end with /acl or /_acl indicating whether the permission is applied
            at the per-entity level or endpoint level respectively.
        :type path: ``string``
        :param owner: (optional) New owner of ACL, default is `nobody`.
        :type owner: ``string``
        :param perms_read: (optional) List of roles (['*'] for all roles). If
            unspecified we will POST with current (if available) perms.read,
            default is None.
github PaloAltoNetworks / pandevice / install / Splunk_TA_paloalto / bin / splunk_ta_paloalto / solnlib / hec_config.py View on Github external
    @retry(exceptions=[binding.HTTPError])
    def update_settings(self, settings):
        '''Update http data input global settings.

        :param settings: Http global setting like: {
            'enableSSL': 1,
            'disabled': 0,
            'useDeploymentServer': 0,
            'port': 8088}
        :type settings: ``dict``
        '''

        res = self._do_get_input(self.input_type)
        res.update(**settings)
github PaloAltoNetworks / pandevice / install / Splunk_TA_paloalto / bin / splunk_ta_paloalto / solnlib / conf_manager.py View on Github external
    @retry(exceptions=[binding.HTTPError])
    def update(self, stanza_name, stanza, encrypt_keys=None):
        '''Update stanza.

        It will try to encrypt the credential automatically fist if
        encrypt_keys are not None else keep stanza untouched.

        :param stanza_name: Stanza name.
        :type stanza_name: ``string``
        :param stanza: Stanza to update, like: {
            'k1': 1,
            'k2': 2}.
        :type stanza: ``dict``
        :param encrypt_keys: Fields name to encrypt.
        :type encrypt_keys: ``list``

        Usage::
github PaloAltoNetworks / pandevice / install / Splunk_TA_paloalto / bin / splunk_ta_paloalto / solnlib / time_parser.py View on Github external
    @retry(exceptions=[binding.HTTPError])
    def to_seconds(self, time_str):
        '''Parse `time_str` and convert to seconds since epoch.

        :param time_str: ISO8601 format timestamp, example:
            2011-07-06T21:54:23.000-07:00.
        :type time_str: ``string``
        :returns: Seconds since epoch.
        :rtype: ``float``
        '''

        try:
            response = self._rest_client.get(
                self.URL, output_mode='json',
                time=time_str, output_time_format='%s').body.read()
        except binding.HTTPError as e:
            if e.status != 400: