def _create_data_source(self, ip):
        url = 'http://*****:*****@{}:{}/api/datasources'.format(ip, 3000)

        influx_conf = utils.parse_ini_file(consts.CONF_FILE)
        try:
            influx_url = influx_conf['dispatcher_influxdb']['target']
        except KeyError:
            LOG.exception('influxdb url not set in yardstick.conf')
            raise

        data = {
            "name": "yardstick",
            "type": "influxdb",
            "access": "proxy",
            "url": influx_url,
            "password": "******",
            "user": "******",
            "database": "yardstick",
            "basicAuth": True,
            "basicAuthUser": "******",
            "basicAuthPassword": "******",
            "isDefault": False,
        }
        try:
            HttpClient().post(url, data)
        except Exception:
            LOG.exception('Create datasources failed')
            raise
def _create_dashboard(ip):
    url = 'http://*****:*****@{}:{}/api/dashboards/db'.format(ip, consts.GRAFANA_PORT)
    path = os.path.join(consts.REPOS_DIR, 'dashboard', '*dashboard.json')

    for i in sorted(glob.iglob(path)):
        with open(i) as f:
            data = jsonutils.load(f)
        HttpClient().post(url, data)
    def _create_dashboard(self, ip):
        url = 'http://*****:*****@{}:{}/api/dashboards/db'.format(ip, 3000)
        path = os.path.join(consts.REPOS_DIR, 'dashboard', '*dashboard.json')

        for i in sorted(glob.iglob(path)):
            with open(i) as f:
                data = jsonutils.load(f)
            try:
                HttpClient().post(url, data)
            except Exception:
                LOG.exception('Create dashboard %s failed', i)
                raise
Exemple #4
0
def _create_data_source():
    url = 'http://*****:*****@%s:3000/api/datasources' % consts.GRAFANA_IP
    data = {
        "name": "yardstick",
        "type": "influxdb",
        "access": "proxy",
        "url": "http://%s:8086" % consts.INFLUXDB_IP,
        "password": "******",
        "user": "******",
        "database": "yardstick",
        "basicAuth": True,
        "basicAuthUser": "******",
        "basicAuthPassword": "******",
        "isDefault": False,
    }
    HttpClient().post(url, data)
Exemple #5
0
    def _create_data_source(self, ip):
        url = 'http://*****:*****@{}:{}/api/datasources'.format(ip, 3000)
        influx_conf = utils.parse_ini_file(consts.CONF_FILE).get('dispatcher_influxdb', {})

        data = {
            "name": "yardstick",
            "type": "influxdb",
            "access": "proxy",
            "url": influx_conf.get('target', ''),
            "password": influx_conf.get('password', ''),
            "user": influx_conf.get('username', ''),
            "database": "yardstick",
            "basicAuth": True,
            "basicAuthUser": "******",
            "basicAuthPassword": "******",
            "isDefault": False,
        }
        try:
            HttpClient().post(url, data)
        except Exception:
            LOG.exception('Create datasources failed')
            raise
    def _check_status(self, task_id, start):
        self._print_status(start, '[]\r')
        url = '{}?task_id={}'.format(consts.ASYNC_TASK_API, task_id)

        CHECK_STATUS_RETRY = 20
        CHECK_STATUS_DELAY = 5

        for retry in range(CHECK_STATUS_RETRY):
            response = HttpClient().get(url)
            status = response['status']

            if status:
                break

            # wait until the async task finished
            time.sleep(CHECK_STATUS_DELAY * (retry + 1))

        switcher = {0: 'Timeout', 1: 'Finished', 2: 'Error'}
        self._print_status(start, '[{}]'.format(switcher[status]))
        if status == 2:
            print(response['result'])
            sys.stdout.flush()
        return status
Exemple #7
0
def _create_dashboard():
    url = 'http://*****:*****@%s:3000/api/dashboards/db' % api_conf.GATEWAY_IP
    with open('../dashboard/ping_dashboard.json') as dashboard_json:
        data = json.load(dashboard_json)
    HttpClient().post(url, data)
 def _start_async_task(self, data):
     url = consts.ENV_ACTION_API
     return HttpClient().post(url, data)['result']['task_id']