Skip to content
Snippets Groups Projects
Commit 25802f00 authored by Alex Barchiesi's avatar Alex Barchiesi :circus_tent:
Browse files

Use urllib in remote-ids-fetch.py

parent 62c271c7
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,7 @@ from keystoneclient.auth.identity import v3
from keystoneclient import session
from keystoneclient.v3 import client
auth_url = '{{ admin_endpoint }}'
auth_url = '{{ admin_endpoint }}/v3'
token = '{{ token }}'
auth = v3.Token(auth_url, token)
......@@ -25,15 +25,22 @@ id = '{{ identity_provider }}'
context = ssl._create_unverified_context()
put_template = """{
"identity_provider": {
"remote_ids": %s,
"enabled": true
}
}"""
with urllib.open(remote_ids_fetch, context=context) as f:
remote_ids = list({e['entityID'] for e in json.load(f.read())})
# openstack.request('identity provider', 'set', remote_ids)
# PUT /OS-FEDERATION/identity_providers/$identity_provider
# {
# "identity_provider": {
# "remote_ids": remote_ids,
# "enabled": true
# }
# }
idp_manager.delete(id)
idp_manager.create(id, remote_ids=remote_ids, enabled=True)
# idp_manager.delete(id)
# idp_manager.create(id, remote_ids=remote_ids, enabled=True)
opener = urllib2.build_opener(urllib2.HTTPHandler)
request = urllib.request.Request(auth_url + '/OS-FEDERATION/identity_providers/' + id,
{"X-Auth-Token": token},
put_template % remote_ids)
request.get_method = lambda: 'PUT'
url = opener.open(request)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment