Last active
June 4, 2018 08:34
-
-
Save jmeridth/8561910 to your computer and use it in GitHub Desktop.
add default testing mac_address_range to quark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
HOST = "PUT YOUR IP HERE" | |
API_VERSION = "v2.0" | |
ADMIN_PASSWORD = "PUT YOUR ADMIN PASSWORD FROM YOUR DEVSTACK LOCAL.CONF HERE" | |
url = "http://%s:%s/%s/tokens" % (HOST, "5000", API_VERSION) | |
data = {'auth': {'tenantName': 'admin', 'passwordCredentials': {'username': 'admin', 'password': ADMIN_PASSWORD}}} | |
headers = {'Content-Type': 'application/json', 'Accept': 'application/json', 'User-Agent': 'python-neutronclient'} | |
r = requests.post(url, data=json.dumps(data), headers=headers) | |
content = json.loads(r.content) | |
if not content or not content.get("access"): | |
print("No content back from trying to get a token") | |
token = content["access"]["token"]["id"] | |
url = "http://%s:%s/%s/mac_address_ranges.json" % (HOST, "9696", API_VERSION) | |
headers = {'Content-Type': 'application/json', 'Accept': 'application/json', 'User-Agent': 'python-neutronclient', 'X-Auth-Token': token} | |
data = {'mac_address_range': {'cidr': 'AA:BB:CC'}} | |
r = requests.post(url, data=json.dumps(data), headers=headers) | |
content = json.loads(r.content) | |
if not content: | |
print("No content back from trying add mac address range") | |
print(content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment