summaryrefslogtreecommitdiff
path: root/Probes.ipynb
blob: 3752ea8769fa8d687e36b0c1a0e94dc8748b696e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# TODO get probes\n",
    "nnodes = 15\n",
    "payload_probes = payload.copy()\n",
    "payload_probes['definitions'].append(definition)\n",
    "payload_probes['probes'] = [\n",
    "    {\n",
    "        \"type\":\"area\",\n",
    "        \"value\":\"West\",\n",
    "        \"requested\":nnodes\n",
    "    },\n",
    "    {\n",
    "        \"type\":\"area\",\n",
    "        \"value\":\"North-Central\",\n",
    "        \"requested\":nnodes\n",
    "    },\n",
    "    {\n",
    "        \"type\":\"area\",\n",
    "        \"value\":\"South-Central\",\n",
    "        \"requested\":nnodes\n",
    "    },\n",
    "    {\n",
    "        \"type\":\"area\",\n",
    "        \"value\":\"North-East\",\n",
    "        \"requested\":nnodes\n",
    "    },\n",
    "    {\n",
    "        \"type\":\"area\",\n",
    "        \"value\":\"South-East\",\n",
    "        \"requested\":nnodes\n",
    "    },\n",
    "]\n",
    "\n",
    "url = url_dns_measurements_create + '?key=' + atlas_api_key\n",
    "probe_measurement = requests.post(url, data = json.dumps(payload_probes), headers = headers)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "results = [requests.get(url_dns_measurements_get + '?id__in=' + str(id)) for id in probe_measurement.json()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "probe_ids = []\n",
    "\n",
    "for result in results:\n",
    "    for res in result.json()['results']:\n",
    "        r = requests.get(res['result'])\n",
    "    \n",
    "        for i in r.json():\n",
    "            probe_ids.append(i['prb_id'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "not_working = [13263,28836,29339,19434,25975,14812,20933,22789,25016,16491]\n",
    "new = [19634,6025,11660,22388,25182,3821,3812,20923,14384,12389]\n",
    "\n",
    "print(len(probe_ids))\n",
    "\n",
    "for id in not_working:\n",
    "    probe_ids.remove(id)\n",
    "\n",
    "print(len(probe_ids))\n",
    "\n",
    "for id in new:\n",
    "    probe_ids.append(id)\n",
    "\n",
    "print(len(probe_ids))\n",
    "\n",
    "            \n",
    "probes = [\n",
    "    {\n",
    "        \"value\": str(probe_ids)[1:-1],\n",
    "        \"type\": \"probes\",\n",
    "        \"requested\": len(probe_ids)\n",
    "    }\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# test\n",
    "payload_test = payload.copy()\n",
    "\n",
    "for item in data:\n",
    "    def_copy = definition.copy()\n",
    "    def_copy['query_type'] = \"SOA\"\n",
    "    def_copy['query_argument'] = item['domain']\n",
    "    def_copy['description'] = item['tld'] + ' test measurement'\n",
    "    \n",
    "    payload_test['definitions'].append(def_copy)\n",
    "    payload_test['probes'] = probes\n",
    "    \n",
    "# url = url_dns_measurements_create + '?key=' + atlas_api_key\n",
    "# measurement_ids = requests.post(url, data = json.dumps(payload), headers = headers)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "url = url_dns_measurements_create + '?key=' + atlas_api_key\n",
    "test_measurement_idsement_ids = requests.post(url, data = json.dumps(payload_test), headers = headers)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}