Compare commits

...

2 commits

Author SHA1 Message Date
ec2f87a79f Pipfile.lock updated 2019-10-28 15:47:24 +05:00
9a8495ddeb Issue Fixed 2019-10-28 15:42:32 +05:00
2 changed files with 33 additions and 65 deletions

40
Pipfile.lock generated
View file

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "ca9c2522bf07f03d1588afe76e9f6fc73bc1efec20d4f155d82b709efaf14a56"
"sha256": "01bd2ed801b62b47100921e0ace284388d352ad9433e70331c082550bf830e03"
},
"pipfile-spec": 6,
"requires": {
@ -18,43 +18,7 @@
"default": {
"apixu": {
"git": "https://github.com/apixu/apixu-python.git",
"ref": "master"
},
"certifi": {
"hashes": [
"sha256:59b7658e26ca9c7339e00f8f4636cdfe59d34fa37b9b04f6f9e9926b3cece1a5",
"sha256:b26104d6835d1f5e49452a26eb2ff87fe7090b89dfcaee5ea2212697e1e1d7ae"
],
"version": "==2019.3.9"
},
"chardet": {
"hashes": [
"sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae",
"sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"
],
"version": "==3.0.4"
},
"idna": {
"hashes": [
"sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407",
"sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c"
],
"version": "==2.8"
},
"requests": {
"hashes": [
"sha256:11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4",
"sha256:9cf5292fcd0f598c671cfc1e0d7d1a7f13bb8085e9a590f48c010551dc6c4b31"
],
"index": "pypi",
"version": "==2.22.0"
},
"urllib3": {
"hashes": [
"sha256:b246607a25ac80bedac05c6f282e3cdaf3afb65420fd024ac94435cabe6e18d1",
"sha256:dbe59173209418ae49d485b87d1681aefa36252ee85884c31346debd19463232"
],
"version": "==1.25.3"
"ref": "370216999346d5caf7f8dc6724b5766dcc6da25d"
}
},
"develop": {}

View file

@ -3,9 +3,10 @@ import ipaddress
import json
import urllib.request
import pprint
import requests
# RIPE_URL = "https://rest.db.ripe.net/{source}/{objecttype}/{key}"
RIPE_URL = "https://rest.db.ripe.net/ripe"
# RIPE_URL = "https://rest.db.ripe.net/ripe"
RIPE_URL = "https://rest-test.db.ripe.net/test"
class ungleichRIPE(object):
@ -33,47 +34,50 @@ class ungleichRIPE(object):
print("Sorry, {} does not look like an IPv6 network: {}".format(args.network, e))
raise
url = "{}/route6/?password={}".format(RIPE_URL, args.password)
url = "{}/route6?password={}".format(RIPE_URL, args.password)
ripe_object = {}
ripe_object['route6'] = args.network
ripe_object['origin'] = "AS209898"
ripe_object['descr'] = args.description
ripe_object['mnt-by'] = "mnt-ungleich"
ripe_object['source'] = "TEST"
ripe_attributes = [{ "name": key, "value": value } for key, value in ripe_object.items() ]
# Format according to API layout
ripe_element = {}
ripe_element['objects'] = []
ripe_element['objects'].append(
{ "object":
[
{
"attributes": {
"attribute": ripe_attributes
}
}
]
}
)
ripe_element['objects'] = {
"object": [
{
"attributes": {
"attribute": ripe_attributes
}
}
]
}
data = json.dumps(ripe_element).encode('utf-8')
# debug
pprint.pprint(ripe_element)
# pprint.pprint(ripe_element)
method = 'POST'
# method = 'POST'
# req = urllib.request.Request(url=url,
# data=data,
# method='POST',
# headers={
# "Content-Type": "application/json",
# "Accept": "application/json"
# })
# print("Adding a v6 route object at {} for {} with {} req={}".format(url, args.network, data, str(req)))
req = urllib.request.Request(url=url,
data=data,
method='POST',
headers={
"Content-Type": "application/json",
"Accept": "application/json"
})
# with urllib.request.urlopen(req) as f:
# print(f.read().decode('utf-8'))
print("Adding a v6 route object at {} for {} with {} req={}".format(url, args.network, data, str(req)))
with urllib.request.urlopen(req) as f:
print(f.read().decode('utf-8'))
r = requests.post(url, data=data, headers={
"Content-Type": "application/json",
"Accept": "application/json"
})
pprint.pprint(json.loads(r.content.decode("utf-8")))
# print(r.content.decode("utf-8"))