1 ##############################################################################
2 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
12 from oslo_serialization import jsonutils
14 from yardstick.common import constants as consts
16 logger = logging.getLogger(__name__)
19 def post(url, data={}):
20 url = '{}{}'.format(consts.BASE_URL, url)
21 data = jsonutils.dumps(data)
22 headers = {'Content-Type': 'application/json'}
24 response = requests.post(url, data=data, headers=headers)
25 result = response.json()
26 logger.debug('The result is: %s', result)
29 except Exception as e:
30 logger.exception('Failed: %s', e)
35 url = '{}{}'.format(consts.BASE_URL, url)
36 response = requests.get(url)
37 return response.json()