From 48bd46efc748dde762e22a31ef015d67748a7ce8 Mon Sep 17 00:00:00 2001 From: mischa Date: Tue, 14 Jun 2022 21:56:02 +0200 Subject: [PATCH] WIP for pushing config --- awsvpcconnectors.txt | 19 + config-20220614.txt | 880 +++++++++++++++++++++++++++++++++++++++++++ push.py | 133 +++++++ 3 files changed, 1032 insertions(+) create mode 100644 awsvpcconnectors.txt create mode 100644 config-20220614.txt create mode 100755 push.py diff --git a/awsvpcconnectors.txt b/awsvpcconnectors.txt new file mode 100644 index 0000000..ba59b9e --- /dev/null +++ b/awsvpcconnectors.txt @@ -0,0 +1,19 @@ +{ + "customerName": "AlkiraEMEA_US-East2-2-vpc", + "customerRegion": "us-east-2", + "vpcId": "vpc-007815b7e755ac4b3", + "vpcOwnerId": "138319602003", + "credentialId": "b269e6d7-2b7d-45dc-9fb5-5ac1f49db139", + "segments": [ + "Corporate" + ], + "size": "MEDIUM", + "directInterVPCCommunicationEnabled": false, + "enabled": true, + "name": "AlkiraEMEA_US-East2-2-vpc", + "cxp": "US-EAST-2", + "group": "Users", + "billingTags": [ + 333 + ], +} diff --git a/config-20220614.txt b/config-20220614.txt new file mode 100644 index 0000000..0132ae1 --- /dev/null +++ b/config-20220614.txt @@ -0,0 +1,880 @@ +# Connectors +[ + { + "id": 13090, + "tenantId": 70, + "tenantNetworkId": 53, + "name": "alkiraemea-eu-west1-2-vpc@europe-west1", + "internalName": "con-gcp_vpc-bbab13f9-8d70-4465-b7b6-6c76427f", + "cxp": "GERMANYWESTCENTRAL-AZURE-1", + "cxpId": "0de2b1c2-3544-416c-976f-98b792953e73", + "type": "GCP_VPC", + "productId": "d39eca50-9412-4d5e-a16d-b366f6f52c56", + "group": "Development", + "groupId": 17622, + "tagId": 65508, + "tags": [ + 65508 + ], + "implicitGroupId": 25560, + "segments": [ + "Pre Prod" + ], + "extraAttributes": { + "customerRegion": "europe-west1", + "vpcId": "305769359309508740", + "vpcName": "alkiraemea-eu-west1-2-vpc", + "credentialId": "f273a2dc-d8bb-4106-b66c-53398b5551b1", + "routingMode": "REGIONAL", + "gcpRouting": { + "importFromCXPOptions": { + "prefixListIds": [], + "routeImportMode": "ADVERTISE_DEFAULT_ROUTE" + } + } + }, + "groupType": "APP", + "instances": [], + "state": "PENDING", + "size": "MEDIUM", + "segmentOptions": {}, + "asn": 64522, + "docState": "ADDED", + "deletedAt": -1, + "configAvailable": false, + "billingTags": [], + "segmentIds": [ + 1638 + ], + "lastConfigUpdatedAt": 1655234944045, + "anyCPLId": 8847, + "enabled": true, + "primary": true, + "userGroups": [] + }, + { + "id": 13089, + "tenantId": 70, + "tenantNetworkId": 53, + "name": "alkiraemea-eu-west1-1-vpc@europe-west1", + "internalName": "con-gcp_vpc-450edd7c-5dd5-4e32-a416-9b3aa780", + "cxp": "GERMANYWESTCENTRAL-AZURE-1", + "cxpId": "0de2b1c2-3544-416c-976f-98b792953e73", + "type": "GCP_VPC", + "productId": "d39eca50-9412-4d5e-a16d-b366f6f52c56", + "group": "Development", + "groupId": 17622, + "tagId": 65509, + "tags": [ + 65509 + ], + "implicitGroupId": 25559, + "segments": [ + "Pre Prod" + ], + "extraAttributes": { + "customerRegion": "europe-west1", + "vpcId": "611487575275180700", + "vpcName": "alkiraemea-eu-west1-1-vpc", + "credentialId": "f273a2dc-d8bb-4106-b66c-53398b5551b1", + "routingMode": "REGIONAL", + "gcpRouting": { + "importFromCXPOptions": { + "prefixListIds": [], + "routeImportMode": "ADVERTISE_DEFAULT_ROUTE" + } + } + }, + "groupType": "APP", + "instances": [], + "state": "PENDING", + "size": "MEDIUM", + "segmentOptions": {}, + "asn": 64522, + "docState": "ADDED", + "deletedAt": -1, + "configAvailable": false, + "billingTags": [], + "segmentIds": [ + 1638 + ], + "lastConfigUpdatedAt": 1655234941736, + "anyCPLId": 8846, + "enabled": true, + "primary": true, + "userGroups": [] + }, + { + "id": 13088, + "tenantId": 70, + "tenantNetworkId": 53, + "name": "Amsterdam-PreProd", + "internalName": "con-ip_sec-6e774600-63d8-475a-a42f-a0f7c96d", + "cxp": "US-EAST-2", + "cxpId": "4e6c5c71-4e02-4f81-90c6-effbf8d50b7f", + "type": "IP_SEC", + "productId": "42afee03-8d4e-4f07-93e5-b88f672e0114", + "group": "Development", + "groupId": 17622, + "tagId": 65511, + "tags": [ + 65511 + ], + "implicitGroupId": 25558, + "segments": [ + "Pre Prod" + ], + "extraAttributes": { + "vpnMode": "ROUTE_BASED", + "routingOptions": { + "staticRouting": null, + "dynamicRouting": { + "customerGwAsn": "60131", + "bgpAuthKeyAlkira": "" + } + } + }, + "groupType": "USER", + "instances": [ + { + "id": 3790, + "tenantId": 70, + "tenantNetworkId": 53, + "connectorId": 13088, + "productId": "42afee03-8d4e-4f07-93e5-b88f672e0114", + "state": "PENDING", + "name": "Fortigate2", + "internalName": "coni-ip_sec-824d1ee9-000c-4c74-8076-bbc092c8", + "extraAttributes": { + "gatewayIpType": "STATIC", + "customerGwIp": "111.1.1.1", + "presharedKeys": [ + { + "uid": "tunnel-IP_SEC-d853fb33-6cc2-4d1e-8720-6dc83794223a", + "secret": "9e18bd16-a267-43ef-94e8-d332386e0909", + "id": 39071881, + "tunnelNo": 0 + }, + { + "uid": "tunnel-IP_SEC-f5f2b6ce-3590-49e9-b1e4-1352f3bb400c", + "secret": "ed81f101-45fc-4d1e-a171-f3700d9f339f", + "id": 74187978, + "tunnelNo": 1 + } + ] + }, + "cxp": "US-EAST-2", + "docState": "ADDED", + "deletedAt": -1, + "configAvailable": false, + "billingTags": [ + 343 + ], + "lastConfigUpdatedAt": 1655234913330, + "enableTunnelRedundancy": true, + "networkEntityType": "CONNECTOR_INSTANCE" + } + ], + "state": "PENDING", + "size": "MEDIUM", + "segmentOptions": { + "Pre Prod": { + "segmentId": 1638, + "disableInternetExit": false, + "advertiseOnPremRoutes": false + } + }, + "docState": "ADDED", + "deletedAt": -1, + "configAvailable": false, + "billingTags": [], + "segmentIds": [ + 1638 + ], + "lastConfigUpdatedAt": 1655234913460, + "anyCPLId": 8845, + "enabled": true, + "primary": true, + "userGroups": [] + }, + { + "id": 13087, + "tenantId": 70, + "tenantNetworkId": 53, + "name": "Amsterdam", + "internalName": "con-ip_sec-eedbd9d4-7b3c-4334-96a0-c9e2de0b", + "cxp": "US-EAST-2", + "cxpId": "4e6c5c71-4e02-4f81-90c6-effbf8d50b7f", + "type": "IP_SEC", + "productId": "03d59526-ad52-454b-a675-341a57a8798b", + "group": "Users", + "groupId": 19104, + "tagId": 65517, + "tags": [ + 65517 + ], + "implicitGroupId": 25555, + "segments": [ + "Corporate" + ], + "extraAttributes": { + "vpnMode": "ROUTE_BASED", + "routingOptions": { + "staticRouting": null, + "dynamicRouting": { + "customerGwAsn": "60131", + "bgpAuthKeyAlkira": "" + } + } + }, + "groupType": "USER", + "instances": [ + { + "id": 3789, + "tenantId": 70, + "tenantNetworkId": 53, + "connectorId": 13087, + "productId": "03d59526-ad52-454b-a675-341a57a8798b", + "state": "PENDING", + "name": "Fortigate", + "internalName": "coni-ip_sec-02c5bd23-12d6-416d-8b08-cdf79994", + "extraAttributes": { + "gatewayIpType": "STATIC", + "customerGwIp": "101.1.1.1", + "presharedKeys": [ + { + "uid": "tunnel-IP_SEC-c5c4dd9b-7c07-4e49-a537-ae151b9db0b8", + "secret": "79dab2f5-ad3a-44ed-9287-da65af1f467b", + "id": 77871682, + "tunnelNo": 0 + }, + { + "uid": "tunnel-IP_SEC-ba08b988-071b-4750-8e42-1d7994db5246", + "secret": "9134ffcf-37c2-48a3-ae6e-c96333522c3e", + "id": 45687122, + "tunnelNo": 1 + } + ] + }, + "cxp": "US-EAST-2", + "docState": "ADDED", + "deletedAt": -1, + "configAvailable": false, + "billingTags": [ + 333 + ], + "lastConfigUpdatedAt": 1655234826614, + "enableTunnelRedundancy": true, + "networkEntityType": "CONNECTOR_INSTANCE" + } + ], + "state": "PENDING", + "size": "LARGE", + "segmentOptions": { + "Corporate": { + "segmentId": 1636, + "disableInternetExit": false, + "advertiseOnPremRoutes": false + } + }, + "docState": "ADDED", + "deletedAt": -1, + "configAvailable": false, + "billingTags": [], + "segmentIds": [ + 1636 + ], + "lastConfigUpdatedAt": 1655234826663, + "anyCPLId": 8844, + "enabled": true, + "primary": true, + "userGroups": [] + }, + { + "id": 13086, + "tenantId": 70, + "tenantNetworkId": 53, + "name": "Internet", + "description": "", + "internalName": "con-saas-f932e08c-2749-4eae-8ecc-e2f8497d", + "cxp": "US-EAST-2", + "cxpId": "4e6c5c71-4e02-4f81-90c6-effbf8d50b7f", + "type": "SAAS", + "productId": "1e3c0b38-6d21-4ee2-9b99-0ac71e9a8a2b", + "tagId": 65518, + "tags": [ + 65518 + ], + "implicitGroupId": 25554, + "segments": [ + "Corporate" + ], + "extraAttributes": { + "trafficDistribution": { + "algorithm": "HASHING", + "algorithmAttributes": { + "keys": "DEFAULT" + } + }, + "numOfPublicIPs": 2 + }, + "groupType": "NONE", + "instances": [], + "state": "PENDING", + "size": "SMALL", + "segmentOptions": {}, + "docState": "ADDED", + "deletedAt": -1, + "configAvailable": false, + "billingTags": [], + "segmentIds": [ + 1636 + ], + "lastConfigUpdatedAt": 1655234801476, + "anyCPLId": 8843, + "enabled": true, + "primary": true, + "userGroups": [] + }, + { + "id": 13085, + "tenantId": 70, + "tenantNetworkId": 53, + "name": "AlkiraEMEA_US-East2-2-vpc", + "internalName": "con-aws_vpc-80ac45b9-07e6-457f-ab6e-0bd49639", + "cxp": "US-EAST-2", + "cxpId": "4e6c5c71-4e02-4f81-90c6-effbf8d50b7f", + "owner": "138319602003", + "type": "AWS_VPC", + "productId": "a961dc4f-b9c3-44e2-8b57-c687f9315525", + "group": "Users", + "groupId": 19104, + "tagId": 65519, + "tags": [ + 65519 + ], + "implicitGroupId": 25553, + "segments": [ + "Corporate" + ], + "extraAttributes": { + "vpcId": "vpc-007815b7e755ac4b3", + "vpcOwnerId": "138319602003", + "customerName": "AlkiraEMEA_US-East2-2-vpc", + "customerRegion": "us-east-2", + "credentialId": "b269e6d7-2b7d-45dc-9fb5-5ac1f49db139", + "vpcRouting": { + "exportToCXPOptions": { + "userInputPrefixes": [ + { + "id": null, + "value": "10.31.14.0/24", + "type": "CIDR" + } + ], + "routeExportMode": "USER_INPUT_PREFIXES" + }, + "importFromCXPOptions": { + "routeTables": [ + { + "id": "rtb-0725237d67e9c144c", + "prefixListIds": [], + "routeImportMode": "ADVERTISE_DEFAULT_ROUTE" + }, + { + "id": "rtb-052b46526e924c46e", + "prefixListIds": [], + "routeImportMode": "ADVERTISE_DEFAULT_ROUTE" + }, + { + "id": "rtb-0867b93e8e31f116a", + "prefixListIds": [], + "routeImportMode": "ADVERTISE_DEFAULT_ROUTE" + } + ] + } + }, + "superNetToSubnetPrefixes": { + "10.31.14.0/24": [ + { + "subnetId": "subnet-0247046cadba37ddf", + "prefix": "10.31.14.144/28" + }, + { + "subnetId": "subnet-078f5469a2687e68a", + "prefix": "10.31.14.128/28" + } + ] + }, + "directInterVPCCommunicationEnabled": false, + "awsVpcSelection": { + "id": "vpc-007815b7e755ac4b3", + "name": "AlkiraEMEA_US-East2-2-vpc", + "cidrs": [ + { + "prefix": "10.31.14.0/24", + "docState": "SELECTED" + } + ], + "routeTables": [ + { + "id": "rtb-0725237d67e9c144c", + "name": "AlkiraEMEA_US-East2-2-rtb-private2-us-east-2b", + "subnets": [ + { + "id": "subnet-0247046cadba37ddf", + "name": "AlkiraEMEA_US-East2-2-subnet-private2-us-east-2b", + "prefix": "10.31.14.144/28", + "supernetPrefix": "10.31.14.0/24", + "routeTableId": "rtb-0725237d67e9c144c", + "docState": "SELECTED", + "availabilityZoneName": "us-east-2b", + "availabilityZoneId": "use2-az2" + } + ], + "docState": "SELECTED", + "routes": null + }, + { + "id": "rtb-052b46526e924c46e", + "name": "AlkiraEMEA_US-East2-2-rtb-private1-us-east-2a", + "subnets": [ + { + "id": "subnet-078f5469a2687e68a", + "name": "AlkiraEMEA_US-East2-2-subnet-private1-us-east-2a", + "prefix": "10.31.14.128/28", + "supernetPrefix": "10.31.14.0/24", + "routeTableId": "rtb-052b46526e924c46e", + "docState": "SELECTED", + "availabilityZoneName": "us-east-2a", + "availabilityZoneId": "use2-az1" + } + ], + "docState": "SELECTED", + "routes": null + }, + { + "id": "rtb-0867b93e8e31f116a", + "name": null, + "subnets": [], + "docState": "AVAILABLE", + "routes": null + } + ], + "changed": false, + "ownerId": "138319602003" + } + }, + "groupType": "APP", + "instances": [], + "state": "PENDING", + "size": "MEDIUM", + "segmentOptions": {}, + "asn": 64520, + "docState": "ADDED", + "deletedAt": -1, + "configAvailable": false, + "billingTags": [ + 333 + ], + "segmentIds": [ + 1636 + ], + "lastConfigUpdatedAt": 1655234791980, + "anyCPLId": 8842, + "enabled": true, + "primary": true, + "secondaryCXPs": [], + "userGroups": [] + }, + { + "id": 13084, + "tenantId": 70, + "tenantNetworkId": 53, + "name": "AlkiraEMEA_US-East2-1-vpc", + "internalName": "con-aws_vpc-e2d1dbb5-91d3-4f18-a64b-d6b0975a", + "cxp": "US-EAST-2", + "cxpId": "4e6c5c71-4e02-4f81-90c6-effbf8d50b7f", + "owner": "138319602003", + "type": "AWS_VPC", + "productId": "a961dc4f-b9c3-44e2-8b57-c687f9315525", + "group": "Users", + "groupId": 19104, + "tagId": 65521, + "tags": [ + 65521 + ], + "implicitGroupId": 25552, + "segments": [ + "Corporate" + ], + "extraAttributes": { + "vpcId": "vpc-052769d7efd0e75eb", + "vpcOwnerId": "138319602003", + "customerName": "AlkiraEMEA_US-East2-1-vpc", + "customerRegion": "us-east-2", + "credentialId": "b269e6d7-2b7d-45dc-9fb5-5ac1f49db139", + "vpcRouting": { + "exportToCXPOptions": { + "userInputPrefixes": [ + { + "id": null, + "value": "10.31.13.0/24", + "type": "CIDR" + } + ], + "routeExportMode": "USER_INPUT_PREFIXES" + }, + "importFromCXPOptions": { + "routeTables": [ + { + "id": "rtb-007377c55bd84971a", + "prefixListIds": [], + "routeImportMode": "ADVERTISE_DEFAULT_ROUTE" + }, + { + "id": "rtb-0bab1f83d45d9a424", + "prefixListIds": [], + "routeImportMode": "ADVERTISE_DEFAULT_ROUTE" + }, + { + "id": "rtb-0ebb13fef05d78fd0", + "prefixListIds": [], + "routeImportMode": "ADVERTISE_DEFAULT_ROUTE" + } + ] + } + }, + "superNetToSubnetPrefixes": { + "10.31.13.0/24": [ + { + "subnetId": "subnet-05c55e49dc38096f1", + "prefix": "10.31.13.144/28" + }, + { + "subnetId": "subnet-0aa8735600e91f754", + "prefix": "10.31.13.128/28" + } + ] + }, + "directInterVPCCommunicationEnabled": false, + "awsVpcSelection": { + "id": "vpc-052769d7efd0e75eb", + "name": "AlkiraEMEA_US-East2-1-vpc", + "cidrs": [ + { + "prefix": "10.31.13.0/24", + "docState": "SELECTED" + } + ], + "routeTables": [ + { + "id": "rtb-007377c55bd84971a", + "name": "AlkiraEMEA_US-East2-1-rtb-private2-us-east-2b", + "subnets": [ + { + "id": "subnet-05c55e49dc38096f1", + "name": "AlkiraEMEA_US-East2-1-subnet-private2-us-east-2b", + "prefix": "10.31.13.144/28", + "supernetPrefix": "10.31.13.0/24", + "routeTableId": "rtb-007377c55bd84971a", + "docState": "SELECTED", + "availabilityZoneName": "us-east-2b", + "availabilityZoneId": "use2-az2" + } + ], + "docState": "SELECTED", + "routes": null + }, + { + "id": "rtb-0bab1f83d45d9a424", + "name": null, + "subnets": [], + "docState": "AVAILABLE", + "routes": null + }, + { + "id": "rtb-0ebb13fef05d78fd0", + "name": "AlkiraEMEA_US-East2-1-rtb-private1-us-east-2a", + "subnets": [ + { + "id": "subnet-0aa8735600e91f754", + "name": "AlkiraEMEA_US-East2-1-subnet-private1-us-east-2a", + "prefix": "10.31.13.128/28", + "supernetPrefix": "10.31.13.0/24", + "routeTableId": "rtb-0ebb13fef05d78fd0", + "docState": "SELECTED", + "availabilityZoneName": "us-east-2a", + "availabilityZoneId": "use2-az1" + } + ], + "docState": "SELECTED", + "routes": null + } + ], + "changed": false, + "ownerId": "138319602003" + } + }, + "groupType": "APP", + "instances": [], + "state": "PENDING", + "size": "MEDIUM", + "segmentOptions": {}, + "asn": 64520, + "docState": "ADDED", + "deletedAt": -1, + "configAvailable": false, + "billingTags": [ + 333 + ], + "segmentIds": [ + 1636 + ], + "lastConfigUpdatedAt": 1655234789755, + "anyCPLId": 8841, + "enabled": true, + "primary": true, + "secondaryCXPs": [], + "userGroups": [] + }, + { + "id": 13083, + "tenantId": 70, + "tenantNetworkId": 53, + "name": "AlkiraEMEA_EU-North1-2-vnet-AlkiraEMEA_Demo-4efe155c-a0d1-4807-8c32-813b7894c342", + "internalName": "con-azure_vn-05c1ceff-1dee-4fda-a1b3-8b730482", + "cxp": "US-EAST-2", + "cxpId": "4e6c5c71-4e02-4f81-90c6-effbf8d50b7f", + "type": "AZURE_VNET", + "productId": "b7cf1adb-1cd1-4526-bc06-39136868f710", + "group": "Users", + "groupId": 19104, + "tagId": 65523, + "tags": [ + 65523 + ], + "implicitGroupId": 25551, + "segments": [ + "Corporate" + ], + "extraAttributes": { + "vnetId": "/subscriptions/4efe155c-a0d1-4807-8c32-813b7894c342/resourceGroups/AlkiraEMEA_Demo/providers/Microsoft.Network/virtualNetworks/AlkiraEMEA_EU-North1-2-vnet", + "customerRegion": "northeurope", + "gatewaySubnetPrefix": "10.32.43.0/27", + "credentialId": "91f5e4cb-0fec-41a3-bf91-cf06ef3943bd", + "resourceGroupName": "AlkiraEMEA_Demo", + "nativeServices": [], + "vnetRouting": { + "exportToCXPOptions": { + "userInputPrefixes": null + }, + "importFromCXPOptions": { + "prefixListIds": [], + "routeImportMode": "ADVERTISE_DEFAULT_ROUTE", + "cidrs": null, + "subnets": null + }, + "serviceRoutes": { + "cidrs": null, + "subnets": null + } + }, + "subscriptionId": "4efe155c-a0d1-4807-8c32-813b7894c342", + "deploymentMode": "VGW", + "superNetToSubnetPrefixes": { + "10.32.42.0/23": [ + { + "subnetId": "/subscriptions/4efe155c-a0d1-4807-8c32-813b7894c342/resourceGroups/AlkiraEMEA_Demo/providers/Microsoft.Network/virtualNetworks/AlkiraEMEA_EU-North1-2-vnet/subnets/second", + "prefix": "10.32.42.128/25" + }, + { + "subnetId": "/subscriptions/4efe155c-a0d1-4807-8c32-813b7894c342/resourceGroups/AlkiraEMEA_Demo/providers/Microsoft.Network/virtualNetworks/AlkiraEMEA_EU-North1-2-vnet/subnets/default", + "prefix": "10.32.42.0/25" + } + ] + }, + "serviceTags": [] + }, + "groupType": "APP", + "instances": [], + "state": "PENDING", + "size": "LARGE", + "segmentOptions": {}, + "asn": 64521, + "docState": "ADDED", + "deletedAt": -1, + "configAvailable": false, + "billingTags": [ + 343 + ], + "segmentIds": [ + 1636 + ], + "lastConfigUpdatedAt": 1655234763460, + "anyCPLId": 8840, + "enabled": true, + "primary": true, + "secondaryCXPs": [], + "userGroups": [] + }, + { + "id": 13082, + "tenantId": 70, + "tenantNetworkId": 53, + "name": "AlkiraEMEA_EU-North1-1-vnet-AlkiraEMEA_Demo-4efe155c-a0d1-4807-8c32-813b7894c342", + "internalName": "con-azure_vn-213c1a79-030d-4f9e-8078-c1cec6e0", + "cxp": "US-EAST-2", + "cxpId": "4e6c5c71-4e02-4f81-90c6-effbf8d50b7f", + "type": "AZURE_VNET", + "productId": "b7cf1adb-1cd1-4526-bc06-39136868f710", + "group": "Users", + "groupId": 19104, + "tagId": 65524, + "tags": [ + 65524 + ], + "implicitGroupId": 25550, + "segments": [ + "Corporate" + ], + "extraAttributes": { + "vnetId": "/subscriptions/4efe155c-a0d1-4807-8c32-813b7894c342/resourceGroups/AlkiraEMEA_Demo/providers/Microsoft.Network/virtualNetworks/AlkiraEMEA_EU-North1-1-vnet", + "customerRegion": "northeurope", + "gatewaySubnetPrefix": "10.32.40.128/27", + "credentialId": "91f5e4cb-0fec-41a3-bf91-cf06ef3943bd", + "resourceGroupName": "AlkiraEMEA_Demo", + "nativeServices": [], + "vnetRouting": { + "exportToCXPOptions": { + "userInputPrefixes": null + }, + "importFromCXPOptions": { + "prefixListIds": [], + "routeImportMode": "ADVERTISE_DEFAULT_ROUTE", + "cidrs": null, + "subnets": null + }, + "serviceRoutes": { + "cidrs": null, + "subnets": null + } + }, + "subscriptionId": "4efe155c-a0d1-4807-8c32-813b7894c342", + "deploymentMode": "VGW", + "superNetToSubnetPrefixes": { + "10.32.40.0/23": [ + { + "subnetId": "/subscriptions/4efe155c-a0d1-4807-8c32-813b7894c342/resourceGroups/AlkiraEMEA_Demo/providers/Microsoft.Network/virtualNetworks/AlkiraEMEA_EU-North1-1-vnet/subnets/default", + "prefix": "10.32.40.0/25" + }, + { + "subnetId": "/subscriptions/4efe155c-a0d1-4807-8c32-813b7894c342/resourceGroups/AlkiraEMEA_Demo/providers/Microsoft.Network/virtualNetworks/AlkiraEMEA_EU-North1-1-vnet/subnets/second", + "prefix": "10.32.41.128/25" + } + ] + }, + "serviceTags": [] + }, + "groupType": "APP", + "instances": [], + "state": "PENDING", + "size": "LARGE", + "segmentOptions": {}, + "asn": 64521, + "docState": "ADDED", + "deletedAt": -1, + "configAvailable": false, + "billingTags": [ + 343 + ], + "segmentIds": [ + 1636 + ], + "lastConfigUpdatedAt": 1655234759866, + "anyCPLId": 8839, + "enabled": true, + "primary": true, + "secondaryCXPs": [], + "userGroups": [] + } +] +# Services +[ + { + "id": 1505, + "name": "PAN1", + "internalName": "svc-pan-5402ecc7-f831-4323-9a86-2436ddad", + "cxp": "US-EAST-2", + "cxpId": "4e6c5c71-4e02-4f81-90c6-effbf8d50b7f", + "segments": [ + "Corporate", + "Pre Prod", + "Prod" + ], + "segmentIds": [ + 1636, + 1637, + 1638 + ], + "tenantId": 70, + "tenantNetworkId": 53, + "metadata": {}, + "state": "PENDING", + "size": "LARGE", + "type": "PAN", + "productId": "464bd9b5-64a2-491d-99ca-9210e6abce5e", + "otherAttributes": { + "panoramaEnabled": false, + "managementSegment": 1636, + "maxInstanceCount": 1, + "minInstanceCount": 1, + "licenseType": "PAY_AS_YOU_GO", + "version": "9.1.3", + "type": "VM-300", + "credentialId": "c47a70e1-eceb-43ec-91ee-05eff490f385", + "tunnelProtocol": "IPSEC", + "bundle": "PAN_VM_300_BUNDLE_2", + "globalProtectEnabled": false, + "masterKeyEnabled": false + }, + "instances": [ + { + "id": 1859, + "name": "PAN1-instance-1", + "internalName": "svci-pan-6c1a4893-416a-4fe7-a233-102d1976", + "tenantId": 70, + "tenantNetworkId": 53, + "productId": "464bd9b5-64a2-491d-99ca-9210e6abce5e", + "otherAttributes": { + "uniqueId": "8954e4bf-9ac9-4368-92b7-5d21875cf84e", + "credentialId": "2b84c358-ecdb-48f0-a039-0390a5af114b", + "hostName": "PAN1-instance-1", + "masterKeyEnabled": false + }, + "cxp": "US-EAST-2", + "docState": "ADDED", + "state": "PENDING", + "deletedAt": -1, + "configAvailable": true, + "billingTags": [ + 333 + ], + "dormant": false, + "lastConfigUpdatedAt": 1655234862596, + "networkEntityType": "SERVICE_INSTANCE" + } + ], + "licenseType": "PAY_AS_YOU_GO", + "docState": "ADDED", + "deletedAt": -1, + "configAvailable": true, + "panWarmBootEnabled": false, + "billingTags": [ + 333 + ], + "lastConfigUpdatedAt": 1655234862596 + } +] +# Global CIDR +[] diff --git a/push.py b/push.py new file mode 100755 index 0000000..9ea9611 --- /dev/null +++ b/push.py @@ -0,0 +1,133 @@ +#!/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"} + +# Set logging.INFO to logging.DEBUG for debug information +logging.basicConfig(level=logging.INFO) +logging = logging.getLogger('AlkiraAPI') + +# Naming exceptions +service_exceptions = { + "saas": "internet", + "pan": "panfw", + "ftntfw": "ftnt-fw-", + "chkpfw": "chkp-fw-" + } + +def alkira_login(): + body = {'userName': ALKIRA_USERNAME, + 'password': ALKIRA_PASSWORD} + session = requests.session() + response = alkira_post(session, '/login', body) + return session + +def alkira_post(session, uri, body): + url = f'{ALKIRA_BASE_URI}{uri}' + try: + response = session.post(url, data=json.dumps(body), headers=headers) + response.raise_for_status() + except Exception as e: + logging.error(f'Error: {str(e)}') + sys.exit(1) + return response + +def alkira_get(session, uri): + url = f'{ALKIRA_BASE_URI}{uri}' + try: + response = session.get(url, headers=headers) + response.raise_for_status() + except Exception as e: + logging.error(f'Error: {str(e)}') + sys.exit(1) + return response + +def alkira_delete(session, uri): + url = f'{ALKIRA_BASE_URI}{uri}' + try: + response = session.delete(url, headers=headers) + response.raise_for_status() + except Exception as e: + logging.error(f'Error: {str(e)}') + sys.exit(1) + return response + +# Authenticate +s = alkira_login() +logging.debug(s) + +# Get TenantID +r = alkira_get(s, '/tenantnetworks') +data = r.json() +tenantNetworkId = data[0]['id'] +tenantName = data[0]['name'] +logging.info(f'Tenant Name: {tenantName}') +logging.info(f'Tenant ID: {tenantNetworkId}') + +# Push connectors +logging.info('Push Connectors') + +body = { + "customerName": "AlkiraEMEA_US-East2-2-vpc", + "customerRegion": "us-east-2", + "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) +data = r.json() +print(r.status_code) + +#print('# Connectors') +#print(json.dumps(data, indent=4)) + +## Get services +#logging.info('Checking services') +#r = alkira_get(s, f'/tenantnetworks/{tenantNetworkId}/services') +#data = r.json() +#print('# Services') +#print(json.dumps(data, indent=4)) +# +## Get Global CIDR +#logging.info('Checking Global CIDR') +#r = alkira_get(s, f'/tenantnetworks/{tenantNetworkId}/global-cidr-lists') +#data = r.json() +#print('# Global CIDR') +#print(json.dumps(data, indent=4)) +