def update(self, req, id, body): """Update vpc items.""" if not self.is_valid_body(body, 'group'): raise exc.HTTPUnprocessableEntity() ctxt = req.environ['nova.context'] action = body['group']['action'] start = body['group']['start'] end = body['group']['end'] if action == 'delete': try: client = HTTPClient(ctxt.user_name, ctxt.auth_token, bypass_url=CONF.controller_api, auth_token=ctxt.auth_token) client.put('/v1.0/group', body={'sid': start, 'did': end}) except Exception as e: LOG.error(e.message) if hasattr(objects.SinGroup, action): project_id = id or ctxt.project_id getattr(objects.SinGroup, action)(ctxt, project_id, start, end) return webob.Response(status_int=202)
def _request_timeout_handler(self, url, method, retry_count=0, **kwargs): try: # Use the original request method to do the actual work return HTTPClient.request(self, url, method, **kwargs) except Timeout: if retry_count >= 3: logger.error('nova request timed out after {} retries'.format(retry_count)) raise else: # feed back into the replaced method that supports retry_count retry_count += 1 logger.info('nova request timed out; retry {}'.format(retry_count)) return self.request(url, method, retry_count=retry_count, **kwargs)
def _request_timeout_handler(self, url, method, retry_count=0, **kwargs): try: # Use the original request method to do the actual work return HTTPClient.request(self, url, method, **kwargs) except Timeout: if retry_count >= 3: logger.error( 'nova request timed out after {} retries'.format(retry_count)) raise else: # feed back into the replaced method that supports retry_count retry_count += 1 logger.info('nova request timed out; retry {}'.format(retry_count)) return self.request(url, method, retry_count=retry_count, **kwargs)