Exemplo n.º 1
0
def get_sdk_adapter(service_type, check_service=False):
    """Construct an openstacksdk-brokered Adapter for a given service type.

    We expect to find a conf group whose name corresponds to the service_type's
    project according to the service-types-authority.  That conf group must
    provide ksa auth, session, and adapter options.

    :param service_type: String name of the service type for which the Adapter
                         is to be constructed.
    :param check_service: If True, we will query the endpoint to make sure the
            service is alive, raising ServiceUnavailable if it is not.
    :return: An openstack.proxy.Proxy object for the specified service_type.
    :raise: ConfGroupForServiceTypeNotFound If no conf group name could be
            found for the specified service_type.
    :raise: ServiceUnavailable if check_service is True and the service is down
    """
    confgrp = _get_conf_group(service_type)
    sess = _get_auth_and_session(confgrp)[1]
    try:
        conn = connection.Connection(
            session=sess, oslo_conf=CONF, service_types={service_type},
            strict_proxies=check_service)
    except sdk_exc.ServiceDiscoveryException as e:
        raise exception.ServiceUnavailable(
            _("The %(service_type)s service is unavailable: %(error)s") %
            {'service_type': service_type, 'error': six.text_type(e)})
    return getattr(conn, service_type)
Exemplo n.º 2
0
 def __init__(self):
     # We have to send a dummy tenant name here since the client
     # needs some tenant name, but the tenant name will not be used
     # since the extensions URL does not require it
     LOG.debug("Initializing Cisco Quantum VIF driver...")
     client = Client(HOST,
                     PORT,
                     USE_SSL,
                     format='json',
                     version=VERSION,
                     uri_prefix="",
                     tenant="dummy",
                     logger=LOG)
     request_url = "/extensions"
     data = client.do_request('GET', request_url)
     LOG.debug("Obtained supported extensions from Quantum: %s" % data)
     for ext in data['extensions']:
         name = ext['name']
         if name == CSCO_EXT_NAME:
             LOG.debug("Quantum plugin supports required \"%s\" extension"
                       "for the VIF driver." % name)
             return
     LOG.error("Quantum plugin does not support required \"%s\" extension"
               " for the VIF driver. nova-compute will quit." %
               CSCO_EXT_NAME)
     raise excp.ServiceUnavailable()
Exemplo n.º 3
0
 def _verify_setup(self):
     if CONF.hyperv.use_multipath_io:
         mpio_enabled = self._hostutils.check_server_feature(
             self._hostutils.FEATURE_MPIO)
         if not mpio_enabled:
             err_msg = _LE(
                 "Using multipath connections for iSCSI and FC disks "
                 "requires the Multipath IO Windows feature to be "
                 "enabled. MPIO must be configured to claim such devices.")
             raise exception.ServiceUnavailable(err_msg)
Exemplo n.º 4
0
 def __init__(self):
     # We have to send a dummy tenant name here since the client
     # needs some tenant name, but the tenant name will not be used
     # since the extensions URL does not require it
     client = Client(HOST,
                     PORT,
                     USE_SSL,
                     format='json',
                     action_prefix=ACTION_PREFIX_EXT,
                     tenant="dummy")
     request_url = "/extensions"
     data = client.do_request('GET', request_url)
     LOG.debug("Obtained supported extensions from Quantum: %s" % data)
     for ext in data['extensions']:
         name = ext['name']
         if name == CSCO_EXT_NAME:
             LOG.debug("Quantum plugin supports required \"%s\" extension"
                       "for the scheduler." % name)
             return
     LOG.error("Quantum plugin does not support required \"%s\" extension"
               " for the scheduler. Scheduler will quit." % CSCO_EXT_NAME)
     raise excp.ServiceUnavailable()