Esempio n. 1
0
    def __restcall(self, url, method='GET', fields=None, **kwargs):
        """ Uses urllib to read a data from a webservice, if self.xml_file_data = None, else returns the local file contents

        :type url: str
        :param url: url to call
        :param kwargs:
        :return: response data
        :rtype: str
        """
        request_headers = generateRequestHeaders(
            default_headers = {
              'Content-type': 'application/json',
              'Accept': 'application/json'
            })
        (data, response_headers, code) = httpRequest(url, method=method, headers=request_headers, fields=fields, timeout=self.timeout)
        return data
Esempio n. 2
0
    def __restcall(self, url, method='GET', fields=None, **kwargs):
        """ Uses urllib to read a data from a webservice, if self.xml_file_data = None, else returns the local file contents

        :type url: str
        :param url: url to call
        :param kwargs:
        :return: response data
        :rtype: str
        """
        request_headers = generateRequestHeaders(default_headers={
            'Content-type': 'application/json',
            'Accept': 'application/json'
        })
        (data, response_headers, code) = httpRequest(url,
                                                     method=method,
                                                     headers=request_headers,
                                                     fields=fields,
                                                     timeout=self.timeout)
        return data
Esempio n. 3
0
                logger.info("Both: %s, request: %s" % (appliances, request))
        else:
            logger.info(
                "Only one appliance in configuration, running in non-HA mode")
            appliances = [self.primaryRouter]

        try:
            data = OrderedDict()
            codes = OrderedDict()
            for host in appliances:
                logger.debug("Querying host: %s" % host)
                url = host
                request_headers = generateRequestHeaders(
                    default_headers={
                        'Content-type': 'text/xml',
                        'Accept': 'text/xml'
                    },
                    auth_headers=generateBasicAuthHeader(
                        self.config['USER'], self.config['PASS']))
                logger.debug("request_headers: %s" % request_headers)
                (response, response_headers,
                 code) = httpRequest(url,
                                     method='POST',
                                     headers=request_headers,
                                     fields=request,
                                     timeout=5000,
                                     verifySsl=self.config['VERIFY_SSL'])
                logger.debug("response: %s" % response)
                data[host] = response
                logger.debug("code: %s" % code)
                codes[host] = code
Esempio n. 4
0
            else:
                logging.info("Both: %s, request: %s" % (appliances, request))
        else:
            logging.warn("Only one appliance in config!!!")
            appliances = [self.primaryRouter]

        try:
            data = OrderedDict()
            codes = OrderedDict()
            for host in appliances:
                logging.debug("Querying host: %s" % host)
                url = host
                request_headers = generateRequestHeaders(
                        default_headers={
                            'Content-type': 'text/xml',
                            'Accept': 'text/xml'
                        },
                        auth_headers=generateBasicAuthHeader(self.config['USER'], self.config['PASS'])
                )
                logging.debug("request_headers: %s" % request_headers)
                (response, response_headers, code) = httpRequest(url, method='POST', headers=request_headers,
                                                                 fields=request, timeout=5000,
                                                                 verifySsl=self.config['VERIFY_SSL'])
                logging.debug("response: %s" % response)
                data[host] = response
                logging.debug("code: %s" % code)
                codes[host] = code
            logging.debug(data)

            for k in data:
                thisreply = None