extra debug scripts
This commit is contained in:
parent
3d3c1344d9
commit
57680362f7
@ -1,4 +1,22 @@
|
|||||||
{
|
[
|
||||||
|
{
|
||||||
|
"customerName": "AlkiraEMEA_US-East2-1-vpc",
|
||||||
|
"customerRegion": "us-east-2",
|
||||||
|
"vpcId": "vpc-052769d7efd0e75eb",
|
||||||
|
"vpcOwnerId": "138319602003",
|
||||||
|
"credentialId": "b269e6d7-2b7d-45dc-9fb5-5ac1f49db139",
|
||||||
|
"segments": [
|
||||||
|
"Corporate"
|
||||||
|
],
|
||||||
|
"size": "MEDIUM",
|
||||||
|
"name": "AlkiraEMEA_US-East2-2-vpc",
|
||||||
|
"cxp": "US-EAST-2",
|
||||||
|
"group": "Users",
|
||||||
|
"billingTags": [
|
||||||
|
"333"
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
"customerName": "AlkiraEMEA_US-East2-2-vpc",
|
"customerName": "AlkiraEMEA_US-East2-2-vpc",
|
||||||
"customerRegion": "us-east-2",
|
"customerRegion": "us-east-2",
|
||||||
"vpcId": "vpc-007815b7e755ac4b3",
|
"vpcId": "vpc-007815b7e755ac4b3",
|
||||||
@ -12,6 +30,7 @@
|
|||||||
"cxp": "US-EAST-2",
|
"cxp": "US-EAST-2",
|
||||||
"group": "Users",
|
"group": "Users",
|
||||||
"billingTags": [
|
"billingTags": [
|
||||||
333
|
"333"
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
5
get.py
5
get.py
@ -95,18 +95,19 @@ r = alkira_get(s, f'/tenantnetworks/{tenantNetworkId}/connectors')
|
|||||||
data = r.json()
|
data = r.json()
|
||||||
print('# Connectors')
|
print('# Connectors')
|
||||||
print(json.dumps(data, indent=4))
|
print(json.dumps(data, indent=4))
|
||||||
|
#print(data)
|
||||||
|
|
||||||
# Get services
|
# Get services
|
||||||
logging.info('Checking services')
|
logging.info('Checking services')
|
||||||
r = alkira_get(s, f'/tenantnetworks/{tenantNetworkId}/services')
|
r = alkira_get(s, f'/tenantnetworks/{tenantNetworkId}/services')
|
||||||
data = r.json()
|
data = r.json()
|
||||||
print('# Services')
|
print('# Services')
|
||||||
print(json.dumps(data, indent=4))
|
#print(json.dumps(data, indent=4))
|
||||||
|
|
||||||
# Get Global CIDR
|
# Get Global CIDR
|
||||||
logging.info('Checking Global CIDR')
|
logging.info('Checking Global CIDR')
|
||||||
r = alkira_get(s, f'/tenantnetworks/{tenantNetworkId}/global-cidr-lists')
|
r = alkira_get(s, f'/tenantnetworks/{tenantNetworkId}/global-cidr-lists')
|
||||||
data = r.json()
|
data = r.json()
|
||||||
print('# Global CIDR')
|
print('# Global CIDR')
|
||||||
print(json.dumps(data, indent=4))
|
#print(json.dumps(data, indent=4))
|
||||||
|
|
||||||
|
55
push-debug.py
Executable file
55
push-debug.py
Executable file
@ -0,0 +1,55 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import re
|
||||||
|
import json
|
||||||
|
import time
|
||||||
|
import logging
|
||||||
|
import requests
|
||||||
|
import configparser
|
||||||
|
|
||||||
|
###############################################
|
||||||
|
|
||||||
|
CONFIG_FILE = "/Users/mischa/Alkira/xDev/alkira.cnf"
|
||||||
|
if not os.path.isfile(CONFIG_FILE):
|
||||||
|
logging.error(f"The config file {CONFIG_FILE} doesn't exist")
|
||||||
|
sys.exit(1)
|
||||||
|
config = configparser.RawConfigParser()
|
||||||
|
config.read(CONFIG_FILE)
|
||||||
|
|
||||||
|
ALKIRA_TENANT = config.get('alkira', 'ALKIRA_TENANT')
|
||||||
|
ALKIRA_USERNAME = config.get('alkira', 'ALKIRA_USERNAME')
|
||||||
|
ALKIRA_PASSWORD = config.get('alkira', 'ALKIRA_PASSWORD')
|
||||||
|
ALKIRA_BASE_URI = f'https://{ALKIRA_TENANT}/api'
|
||||||
|
|
||||||
|
###############################################
|
||||||
|
|
||||||
|
# Set default headers
|
||||||
|
headers = {'Content-Type': "application/json"}
|
||||||
|
|
||||||
|
# Authenticate
|
||||||
|
body = {'userName': ALKIRA_USERNAME,
|
||||||
|
'password': ALKIRA_PASSWORD}
|
||||||
|
url = f'{ALKIRA_BASE_URI}/login'
|
||||||
|
session = requests.session()
|
||||||
|
response = session.post(url, data=json.dumps(body), headers=headers)
|
||||||
|
|
||||||
|
# Get TenantID
|
||||||
|
url = f'{ALKIRA_BASE_URI}/tenantnetworks'
|
||||||
|
response = session.get(url, headers=headers)
|
||||||
|
data = response.json()
|
||||||
|
tenantNetworkId = data[0]['id']
|
||||||
|
tenantName = data[0]['name']
|
||||||
|
logging.info(f'Tenant Name: {tenantName}')
|
||||||
|
logging.info(f'Tenant ID: {tenantNetworkId}')
|
||||||
|
|
||||||
|
# Do Things
|
||||||
|
with open ('dump.txt', 'r') as f:
|
||||||
|
body = json.load(f)
|
||||||
|
print(json.dumps(body))
|
||||||
|
|
||||||
|
url = f'{ALKIRA_BASE_URI}/tenantnetworks/{tenantNetworkId}/awsvpcconnectors'
|
||||||
|
response = session.post(url, data=json.dumps(body), headers=headers)
|
||||||
|
print(response.status_code)
|
||||||
|
print(response.content)
|
20
push.py
20
push.py
@ -92,23 +92,9 @@ logging.info(f'Tenant ID: {tenantNetworkId}')
|
|||||||
# Push connectors
|
# Push connectors
|
||||||
logging.info('Push Connectors')
|
logging.info('Push Connectors')
|
||||||
|
|
||||||
body = {
|
with open ('dump.txt', 'r') as f:
|
||||||
"customerName": "AlkiraEMEA_US-East2-2-vpc",
|
body = json.load(f)
|
||||||
"customerRegion": "us-east-2",
|
print(json.dumps(body))
|
||||||
"vpcId": "vpc-007815b7e755ac4b3",
|
|
||||||
"vpcOwnerId": "138319602003",
|
|
||||||
"credentialId": "b269e6d7-2b7d-45dc-9fb5-5ac1f49db139",
|
|
||||||
"segments": [
|
|
||||||
"Corporate"
|
|
||||||
],
|
|
||||||
"size": "MEDIUM",
|
|
||||||
"name": "AlkiraEMEA_US-East2-2-vpc",
|
|
||||||
"cxp": "US-EAST-2",
|
|
||||||
"group": "Users",
|
|
||||||
"billingTags": [
|
|
||||||
333
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
r = alkira_post(s, f'/tenantnetworks/{tenantNetworkId}/awsvpcconnectors', body)
|
r = alkira_post(s, f'/tenantnetworks/{tenantNetworkId}/awsvpcconnectors', body)
|
||||||
data = r.json()
|
data = r.json()
|
||||||
|
7
validate-json.py
Executable file
7
validate-json.py
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
|
with open ('dump.txt', 'r') as f:
|
||||||
|
body = json.load(f)
|
||||||
|
print(body)
|
Loading…
Reference in New Issue
Block a user