Exemplo n.º 1
0
 def register(name, email, company, phone, newsletter):
     """
     Registers the environment
     """
     SupportAgent().run()  # Execute a single heartbeat run
     client = OVSClient('monitoring.openvstorage.com',
                        443,
                        credentials=None,
                        verify=True,
                        version=1)
     task_id = client.post(
         '/support/register/',
         data={
             'cluster_id':
             EtcdConfiguration.get('/ovs/framework/cluster_id'),
             'name': name,
             'email': email,
             'company': company,
             'phone': phone,
             'newsletter': newsletter,
             'register_only': True
         })
     if task_id:
         client.wait_for_task(task_id, timeout=120)
     EtcdConfiguration.set('/ovs/framework/registered', True)
Exemplo n.º 2
0
 def get_free_license(registration_parameters):
     """
     Obtains a free license
     """
     SupportAgent().run()  # Execute a single heartbeat run
     client = OVSClient('monitoring.openvstorage.com', 443, credentials=None, verify=True)
     client.post('/support/register/',
                 data={'cluster_id': Configuration.get('ovs.support.cid'),
                       'name': registration_parameters['name'],
                       'email': registration_parameters['email'],
                       'company': registration_parameters['company'],
                       'phone': registration_parameters['phone'],
                       'newsletter': registration_parameters['newsletter']})
Exemplo n.º 3
0
 def register(name, email, company, phone, newsletter):
     """
     Registers the environment
     """
     SupportAgent().run()  # Execute a single heartbeat run
     client = OVSClient('monitoring.openvstorage.com', 443, credentials=None, verify=True, version=1)
     task_id = client.post('/support/register/',
                           data={'cluster_id': EtcdConfiguration.get('/ovs/framework/cluster_id'),
                                 'name': name,
                                 'email': email,
                                 'company': company,
                                 'phone': phone,
                                 'newsletter': newsletter,
                                 'register_only': True})
     if task_id:
         client.wait_for_task(task_id, timeout=120)
     EtcdConfiguration.set('/ovs/framework/registered', True)
        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))
Exemplo n.º 5
0
 def get_free_license(registration_parameters):
     """
     Obtains a free license
     """
     SupportAgent().run()  # Execute a single heartbeat run
     client = OVSClient('monitoring.openvstorage.com',
                        443,
                        credentials=None,
                        verify=True)
     client.post('/support/register/',
                 data={
                     'cluster_id': Configuration.get('ovs.support.cid'),
                     'name': registration_parameters['name'],
                     'email': registration_parameters['email'],
                     'company': registration_parameters['company'],
                     'phone': registration_parameters['phone'],
                     'newsletter': registration_parameters['newsletter']
                 })
        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')
Exemplo n.º 7
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
Exemplo n.º 8
0
 def _relay(_, ip, port, client_id, client_secret, version, request):
     path = '/{0}'.format(request.path.replace('/api/relay/', ''))
     method = request.META['REQUEST_METHOD'].lower()
     client = OVSClient(ip, port, credentials=(client_id, client_secret), version=version, raw_response=True)
     if not hasattr(client, method):
         return HttpResponseBadRequest, 'Method not available in relay'
     client_kwargs = {'params': request.GET}
     if method != 'get':
         client_kwargs['data'] = request.POST
     call_response = getattr(client, method)(path, **client_kwargs)
     response = HttpResponse(call_response.text,
                             content_type='application/json',
                             status=call_response.status_code)
     for header, value in call_response.headers.iteritems():
         response[header] = value
     return response