コード例 #1
0
def remote_api(aafUser):
    server_url = CONF.aaf_api.aaf_url+aafUser

    kwargs = {
        "server_url": server_url,
        "retries": CONF.aaf_api.aaf_retries,
        "username": CONF.aaf_api.username,
        "password": CONF.aaf_api.password,
        "log_debug": LOG.debug,
        "read_timeout": CONF.aaf_api.aaf_timeout,
        "cert_file": CONF.aaf_api.aaf_cert_file,
        "cert_key_file": CONF.aaf_api.aaf_cert_key_file,
        "ca_bundle_file": CONF.aaf_api.aaf_ca_bundle_file,
    }
    restReq = rest.REST(**kwargs)

    headers = {"Accept": "application/Perms+json;q=1.0;charset=utf-8;version=2.1,application/json;q=1.0;version=2.1,*/*;q=1.0"}
    rkwargs = {
        "method": 'GET',
        "path": '',
        "headers": headers,
    }
    response = restReq.request(**rkwargs)

    if response is None:
        LOG.error(_LE("No response from AAF "))
    elif response.status_code != 200:
        LOG.error(_LE("AAF request  returned HTTP "
                      "status {} {}, link: {}").
                  format(response.status_code, response.reason,
                         server_url))
    return response.content
コード例 #2
0
    def __init__(self):
        """Initializer"""

        # FIXME(jdandrea): Pass this in to init.
        self.conf = CONF

        self.base = self.conf.sdnc.server_url.rstrip('/')
        self.password = self.conf.sdnc.password
        self.timeout = self.conf.sdnc.sdnc_rest_timeout
        self.verify = False
        self.retries = self.conf.sdnc.sdnc_retries
        self.username = self.conf.sdnc.username

        kwargs = {
            "server_url": self.base,
            "retries": self.retries,
            "username": self.username,
            "password": self.password,
            "log_debug": self.conf.debug,
            "read_timeout": self.timeout,
        }
        self.rest = rest.REST(**kwargs)

        # Not sure what info from SDNC is cacheable
        self._sdnc_cache = {}
コード例 #3
0
ファイル: api.py プロジェクト: aalsudais/optf-has
    def __init__(self):
        """Initializer."""
        global MUSIC_API

        # set the urllib log level to ERROR
        logging.getLogger('urllib3').setLevel(logging.ERROR)

        LOG.info(_LI("Initializing Music API"))
        server_url = CONF.music_api.server_url.rstrip('/')
        if not server_url:
            # host/port/path are deprecated and should not be used anymore.
            # Defaults removed from oslo_config to give more incentive.

            # No more round robin either. Just take the first entry.
            host = next(iter(CONF.music_api.hostnames or []), 'controller')
            port = CONF.music_api.port or 8080
            path = CONF.music_api.path or '/MUSIC/rest'
            version = CONF.version
            server_url = 'http://{}:{}/{}'.format(host, port, version,
                                                  path.rstrip('/').lstrip('/'))

        kwargs = {
            'server_url': server_url,
            'log_debug': CONF.music_api.debug,
            'connect_timeout': CONF.music_api.connect_timeout,
            'read_timeout': CONF.music_api.read_timeout,
        }
        self.rest = rest.REST(**kwargs)

        if (CONF.music_api.music_new_version):
            MUSIC_version = CONF.music_api.music_version.split(".")

            self.rest.session.headers['content-type'] = 'application/json'
            self.rest.session.headers['X-minorVersion'] = MUSIC_version[1]
            self.rest.session.headers['X-patchVersion'] = MUSIC_version[2]
            self.rest.session.headers['ns'] = CONF.music_api.aafns
            self.rest.session.headers['userId'] = CONF.music_api.aafuser
            self.rest.session.headers['password'] = CONF.music_api.aafpass
            self.rest.session.headers[
                'Authorization'] = basic_auth_util.encode(
                    CONF.music_api.aafuser, CONF.music_api.aafpass)

        self.lock_ids = {}

        # TODO(jdandrea): Allow override at creation time.
        self.lock_timeout = CONF.music_api.lock_timeout
        self.replication_factor = CONF.music_api.replication_factor
        self.music_topology = CONF.music_api.music_topology

        # TODO(larry) make the code more generic
        self.first_datacenter_name = CONF.music_api.first_datacenter_name
        self.first_datacenter_replicas = CONF.music_api.first_datacenter_replicas
        self.second_datacenter_name = CONF.music_api.second_datacenter_name
        self.second_datacenter_replicas = CONF.music_api.second_datacenter_replicas
        self.third_datacenter_name = CONF.music_api.third_datacenter_name
        self.third_datacenter_replicas = CONF.music_api.third_datacenter_replicas

        MUSIC_API = self
コード例 #4
0
    def _init_rest_request(self):

        kwargs = {
            "server_url": self.base,
            "retries": self.retries,
            "log_debug": self.conf.debug,
            "read_timeout": self.timeout,
        }
        self.rest = rest.REST(**kwargs)
コード例 #5
0
    def _init_python_request(self):

        kwargs = {
            "server_url": self.base,
            "retries": self.retries,
            "username": self.username,
            "password": self.password,
            "read_timeout": self.timeout,
        }
        self.rest = rest.REST(**kwargs)
コード例 #6
0
    def _init_rest_request(self):

        kwargs = {
            "server_url": self.base,
            "retries": self.retries,
            "log_debug": self.conf.debug,
            "read_timeout": self.timeout,
        }
        self.rest = rest.REST(**kwargs)
        if self.conf.multicloud.enable_https_mode:
            self.rest.server_url = self.base[:4]+'s'+self.base[4:]
            self.rest.session.verify =self.conf.multicloud.certificate_authority_bundle_file