def process_request(self, req): LOG.debug(_('Process request: %s'), req) if req.method != 'POST': return url = req.url if not self.handle_url(url): return prefix, info, params = self.handle_url(req.url) token = Token(username=cfg.CONF.alarm_auth.username, password=cfg.CONF.alarm_auth.password, project_name=cfg.CONF.alarm_auth.project_name, auth_url=cfg.CONF.alarm_auth.url, user_domain_name='default', project_domain_name='default') token_identity = token.create_token() req.headers['X_AUTH_TOKEN'] = token_identity # Change the body request if req.body: body_dict = dict() body_dict['trigger'] = {} body_dict['trigger'].setdefault('params', {}) # Update params in the body request body_info = jsonutils.loads(req.body) body_dict['trigger']['params']['data'] = body_info body_dict['trigger']['params']['credential'] = info[6] # Update policy and action body_dict['trigger']['policy_name'] = info[4] body_dict['trigger']['action_name'] = info[5] req.body = jsonutils.dumps(body_dict) LOG.debug('Body alarm: %s', req.body) # Need to change url because of mandatory req.environ['PATH_INFO'] = prefix + 'triggers' req.environ['QUERY_STRING'] = '' LOG.debug('alarm url in receiver: %s', req.url)
def process_request(self, req): LOG.debug('Process request: %s', req) if req.method != 'POST': return url = req.url if not self.handle_url(url): return prefix, info, params = self.handle_url(req.url) resource = 'trigger' if info[4] != 'maintenance' else 'maintenance' redirect = resource + 's' auth = cfg.CONF.keystone_authtoken alarm_auth = cfg.CONF.alarm_auth token = Token(username=alarm_auth.username, password=alarm_auth.password, project_name=alarm_auth.project_name, auth_url=auth.auth_url + '/v3', user_domain_name=alarm_auth.user_domain_name, project_domain_name=alarm_auth.project_domain_name) token_identity = token.create_token() req.headers['X_AUTH_TOKEN'] = token_identity # Change the body request if req.body: body_dict = dict() body_dict[resource] = {} body_dict[resource].setdefault('params', {}) # Update params in the body request body_info = jsonutils.loads(req.body) body_dict[resource]['params']['credential'] = info[6] if resource == 'maintenance': body_info.update( {'body': self._handle_maintenance_body(body_info)}) del body_info['reason_data'] else: # Update policy and action body_dict[resource]['policy_name'] = info[4] body_dict[resource]['action_name'] = info[5] body_dict[resource]['params']['data'] = body_info req.body = jsonutils.dump_as_bytes(body_dict) LOG.debug('Body alarm: %s', req.body) # Need to change url because of mandatory req.environ['PATH_INFO'] = prefix + redirect req.environ['QUERY_STRING'] = '' LOG.debug('alarm url in receiver: %s', req.url)