def _load_backend_info(_connection_info, _alba_backend_guid):
            client = OVSClient(ip=_connection_info['host'],
                               port=_connection_info['port'],
                               credentials=(_connection_info['username'], _connection_info['password']),
                               version=3)

            try:
                info = client.get('/alba/backends/{0}/'.format(_alba_backend_guid),
                                  params={'contents': 'local_summary'})
                with lock:
                    return_value[_alba_backend_guid].update(info['local_summary'])
            except NotFoundException:
                return_value[_alba_backend_guid]['error'] = 'backend_deleted'
            except ForbiddenException:
                return_value[_alba_backend_guid]['error'] = 'not_allowed'
            except Exception as ex:
                return_value[_alba_backend_guid]['error'] = 'unknown'
                AlbaBackend._logger.exception('Collecting remote ALBA backend information failed with error: {0}'.format(ex))
        def _load_backend_info(_connection_info, _alba_backend_guid, _exceptions):
            # '_exceptions' must be an immutable object to be usable outside the Thread functionality
            client = OVSClient(ip=_connection_info['host'],
                               port=_connection_info['port'],
                               credentials=(_connection_info['username'], _connection_info['password']),
                               version=3)

            try:
                new_guids = client.get('/alba/backends/{0}/'.format(_alba_backend_guid),
                                       params={'contents': 'linked_backend_guids'})['linked_backend_guids']
                with lock:
                    guids.update(new_guids)
            except NotFoundException:
                pass  # ALBA Backend has been deleted, we don't care we can't find the linked guids
            except ForbiddenException as fe:
                AlbaBackend._logger.exception('Collecting remote ALBA backend information failed due to permission issues. {0}'.format(fe))
                _exceptions.append('not_allowed')
            except Exception as ex:
                AlbaBackend._logger.exception('Collecting remote ALBA backend information failed with error: {0}'.format(ex))
                _exceptions.append('unknown')
예제 #3
0
 def list(self, backend_type=None, ip=None, port=None, client_id=None, client_secret=None, contents=None):
     """
     Overview of all backends (from a certain type, if given) on the local node (or a remote one)
     """
     if ip is None:
         if backend_type is None:
             return BackendList.get_backends()
         return BackendTypeList.get_backend_type_by_code(backend_type).backends
     client = OVSClient(ip, port, client_id, client_secret)
     try:
         remote_backends = client.get(
             "/backends/", params={"backend_type": backend_type, "contents": "" if contents is None else contents}
         )
     except (HTTPError, URLError):
         raise NotAcceptable("Could not load remote backends")
     backend_list = []
     for entry in remote_backends["data"]:
         backend = type("Backend", (), entry)()
         backend_list.append(backend)
     return backend_list