def get_session(self):
     """Return a keystoneauth session based on the auth credentials."""
     if self._keystone_session is None:
         if not self._auth:
             raise exceptions.ConfigException(
                 "Problem with auth parameters")
         (verify, cert) = self.get_requests_verify_args()
         # Turn off urllib3 warnings about insecure certs if we have
         # explicitly configured requests to tell it we do not want
         # cert verification
         if not verify:
             self.log.debug(
                 "Turning off SSL warnings for {full_name}"
                 " since verify=False".format(full_name=self.full_name))
         requestsexceptions.squelch_warnings(insecure_requests=not verify)
         self._keystone_session = self._session_constructor(
             auth=self._auth,
             verify=verify,
             cert=cert,
             timeout=self.config['api_timeout'],
             discovery_cache=self._discovery_cache)
         self.insert_user_agent()
         # Using old keystoneauth with new os-client-config fails if
         # we pass in app_name and app_version. Those are not essential,
         # nor a reason to bump our minimum, so just test for the session
         # having the attribute post creation and set them then.
         if hasattr(self._keystone_session, 'app_name'):
             self._keystone_session.app_name = self._app_name
         if hasattr(self._keystone_session, 'app_version'):
             self._keystone_session.app_version = self._app_version
     return self._keystone_session
Esempio n. 2
0
 def get_session(self):
     """Return a keystoneauth session based on the auth credentials."""
     if self._keystone_session is None:
         if not self._auth:
             raise exceptions.ConfigException(
                 "Problem with auth parameters")
         (verify, cert) = self.get_requests_verify_args()
         # Turn off urllib3 warnings about insecure certs if we have
         # explicitly configured requests to tell it we do not want
         # cert verification
         if not verify:
             self.log.debug(
                 "Turning off SSL warnings for {full_name}"
                 " since verify=False".format(full_name=self.full_name))
         requestsexceptions.squelch_warnings(insecure_requests=not verify)
         self._keystone_session = self._session_constructor(
             auth=self._auth,
             verify=verify,
             cert=cert,
             timeout=self.config.get('api_timeout'),
             collect_timing=self.config.get('timing'),
             discovery_cache=self._discovery_cache)
         self.insert_user_agent()
         # Using old keystoneauth with new os-client-config fails if
         # we pass in app_name and app_version. Those are not essential,
         # nor a reason to bump our minimum, so just test for the session
         # having the attribute post creation and set them then.
         if hasattr(self._keystone_session, 'app_name'):
             self._keystone_session.app_name = self._app_name
         if hasattr(self._keystone_session, 'app_version'):
             self._keystone_session.app_version = self._app_version
     return self._keystone_session
Esempio n. 3
0
 def get_session(self):
     """Return a keystoneauth session based on the auth credentials."""
     if self._keystone_session is None:
         if not self._auth:
             raise exceptions.OpenStackConfigException(
                 "Problem with auth parameters")
         (verify, cert) = self.get_requests_verify_args()
         # Turn off urllib3 warnings about insecure certs if we have
         # explicitly configured requests to tell it we do not want
         # cert verification
         if not verify:
             self.log.debug("Turning off SSL warnings for {cloud}:{region}"
                            " since verify=False".format(
                                cloud=self.name, region=self.region))
         requestsexceptions.squelch_warnings(insecure_requests=not verify)
         self._keystone_session = self._session_constructor(
             auth=self._auth,
             verify=verify,
             cert=cert,
             timeout=self.config['api_timeout'])
         if hasattr(self._keystone_session, 'additional_user_agent'):
             self._keystone_session.additional_user_agent.append(
                 ('os-client-config', os_client_config.__version__))
         # Using old keystoneauth with new os-client-config fails if
         # we pass in app_name and app_version. Those are not essential,
         # nor a reason to bump our minimum, so just test for the session
         # having the attribute post creation and set them then.
         if hasattr(self._keystone_session, 'app_name'):
             self._keystone_session.app_name = self._app_name
         if hasattr(self._keystone_session, 'app_version'):
             self._keystone_session.app_version = self._app_version
     return self._keystone_session
def main():
    requestsexceptions.squelch_warnings()
    yaml.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
                         construct_yaml_map)

    yaml.add_representer(OrderedDict, project_representer,
                         Dumper=IndentedDumper)

    data = yaml.load(open('openstack_catalog/web/static/assets.yaml'))

    assets = []
    for a in data['assets']:
        url = a.get('attributes', {}).get('url')
        if not a.get('active', True) or not url:
            assets.append(a)
            continue

        r = requests.head(url, allow_redirects=True)
        if r.status_code != 200:
            a['active'] = False
        else:
            hash_url = a.get('hash_url')
            if hash_url:
                hashes = get_hashes(hash_url)
                filename = url.split("/")[-1]
                a['attributes']['hash'] = hashes.get(filename, 'unknown')

        assets.append(a)

    output = {'assets': assets}
    with open('openstack_catalog/web/static/assets.yaml', 'w') as out:
        out.write(yaml.dump(output, default_flow_style=False,
                            Dumper=IndentedDumper, width=80,
                            indent=2))
Esempio n. 5
0
 def get_session(self):
     """Return a keystoneauth session based on the auth credentials."""
     if self._keystone_session is None:
         if not self._auth:
             raise exceptions.OpenStackConfigException(
                 "Problem with auth parameters")
         (verify, cert) = self.get_requests_verify_args()
         # Turn off urllib3 warnings about insecure certs if we have
         # explicitly configured requests to tell it we do not want
         # cert verification
         if not verify:
             self.log.debug("Turning off SSL warnings for {cloud}:{region}"
                            " since verify=False".format(
                                cloud=self.name, region=self.region))
         requestsexceptions.squelch_warnings(insecure_requests=not verify)
         self._keystone_session = self._session_constructor(
             auth=self._auth,
             app_name=self._app_name,
             app_version=self._app_version,
             verify=verify,
             cert=cert,
             timeout=self.config['api_timeout'])
         if hasattr(self._keystone_session, 'additional_user_agent'):
             self._keystone_session.additional_user_agent.append(
                 ('os-client-config', os_client_config.__version__))
     return self._keystone_session
def main():
    requestsexceptions.squelch_warnings()
    data = yaml.load(open('openstack_catalog/web/static/assets.yaml'))

    assets = {}
    for a in data['assets']:
        url = a.get('attributes', {}).get('url')
        if url:
            r = requests.head(url, allow_redirects=True)
            if r.status_code != 200:
                assets[a['name']] = {'active': False}

    with open('openstack_catalog/web/static/assets_dead.yaml', 'w') as out:
        out.write(yaml.safe_dump({"assets": assets}))
Esempio n. 7
0
 def get_session(self):
     """Return a keystoneauth session based on the auth credentials."""
     if self._keystone_session is None:
         if not self._auth:
             raise exceptions.OpenStackConfigException(
                 "Problem with auth parameters")
         (verify, cert) = self.get_requests_verify_args()
         # Turn off urllib3 warnings about insecure certs if we have
         # explicitly configured requests to tell it we do not want
         # cert verification
         if not verify:
             self.log.debug("Turning off SSL warnings for {cloud}:{region}"
                            " since verify=False".format(
                                cloud=self.name, region=self.region))
         requestsexceptions.squelch_warnings(insecure_requests=not verify)
         self._keystone_session = session.Session(
             auth=self._auth,
             verify=verify,
             cert=cert,
             timeout=self.config['api_timeout'])
     return self._keystone_session
 def get_session(self):
     """Return a keystoneauth session based on the auth credentials."""
     if self._keystone_session is None:
         if not self._auth:
             raise exceptions.OpenStackConfigException(
                 "Problem with auth parameters")
         (verify, cert) = self.get_requests_verify_args()
         # Turn off urllib3 warnings about insecure certs if we have
         # explicitly configured requests to tell it we do not want
         # cert verification
         if not verify:
             self.log.debug(
                 "Turning off SSL warnings for {cloud}:{region}"
                 " since verify=False".format(
                     cloud=self.name, region=self.region))
         requestsexceptions.squelch_warnings(insecure_requests=not verify)
         self._keystone_session = session.Session(
             auth=self._auth,
             verify=verify,
             cert=cert,
             timeout=self.config['api_timeout'])
     return self._keystone_session
def main():
    requestsexceptions.squelch_warnings()
    yaml.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
                         construct_yaml_map)

    yaml.add_representer(OrderedDict,
                         project_representer,
                         Dumper=IndentedDumper)

    data = yaml.load(open('openstack_catalog/web/static/assets.yaml'))

    assets = []
    for a in data['assets']:
        url = a.get('attributes', {}).get('url')
        if not a.get('active', True) or not url:
            assets.append(a)
            continue

        r = requests.head(url, allow_redirects=True)
        if r.status_code != 200:
            a['active'] = False
        else:
            hash_url = a.get('hash_url')
            if hash_url:
                hashes = get_hashes(hash_url)
                filename = url.split("/")[-1]
                a['attributes']['hash'] = hashes.get(filename, 'unknown')

        assets.append(a)

    output = {'assets': assets}
    with open('openstack_catalog/web/static/assets.yaml', 'w') as out:
        out.write(
            yaml.dump(output,
                      default_flow_style=False,
                      Dumper=IndentedDumper,
                      width=80,
                      indent=2))
Esempio n. 10
0
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

import os
import sys

sys.path.append(os.path.dirname(__file__))

import openstackdocstheme

# Avoid unactionable warnings
import requestsexceptions
requestsexceptions.squelch_warnings(requestsexceptions.InsecureRequestWarning)

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath('.'))

# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['ext.remote']
Esempio n. 11
0
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

import os
import sys

sys.path.append(os.path.dirname(__file__))

import openstackdocstheme

# Avoid unactionable warnings
import requestsexceptions
requestsexceptions.squelch_warnings(requestsexceptions.InsecureRequestWarning)

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath('.'))

# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['ext.remote']