Skip to content

Commit daa6761

Browse files
committed
Merge branch 'release/5.0.1'
2 parents 92423ac + d2b40be commit daa6761

File tree

3 files changed

+45
-38
lines changed

3 files changed

+45
-38
lines changed

netfoundry/demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def main():
7373
default="AWS",
7474
required=False,
7575
help="cloud provider to host Edge Routers",
76-
choices=["AWS", "AZURE", "GCP", "ALICLOUD", "NETFOUNDRY", "OCP"]
76+
choices=["AWS", "AZURE", "GCP", "OCP"]
7777
)
7878
regions_group = parser.add_mutually_exclusive_group(required=False)
7979
regions_group.add_argument("--regions",

netfoundry/network.py

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ def __init__(self, NetworkGroup: object, network_id: str=None, network_name: str
4949

5050
def endpoints(self, typeId: str=None):
5151
if typeId is not None:
52-
# import epdb; epdb.serve()
5352
return(self.get_resources(type="endpoints", typeId=typeId))
5453
else:
5554
return(self.get_resources(type="endpoints"))
@@ -165,7 +164,7 @@ def get_edge_router_data_centers(self,provider: str=None,location_code: str=None
165164
"hostType": "ER"
166165
}
167166
if provider is not None:
168-
if provider in ["AWS", "AZURE", "GCP", "ALICLOUD", "NETFOUNDRY", "OCP"]:
167+
if provider in ["AWS", "AZURE", "GCP", "OCP"]:
169168
params['provider'] = provider
170169
else:
171170
raise Exception("ERROR: unexpected cloud provider {:s}".format(provider))
@@ -475,9 +474,13 @@ def patch_resource(self,patch):
475474
# compare the patch to the discovered, current state, adding new or updated keys to pruned_patch
476475
pruned_patch = dict()
477476
for k in patch.keys():
478-
if k not in EXCLUDED_PATCH_PROPERTIES[type] and k in before_resource.keys() and not before_resource[k] == patch[k]:
479-
pruned_patch[k] = patch[k]
480-
477+
if k not in EXCLUDED_PATCH_PROPERTIES[type] and k in before_resource.keys():
478+
if isinstance(patch[k], list):
479+
if not set(before_resource[k]) == set(patch[k]):
480+
pruned_patch[k] = list(set(patch[k]))
481+
else:
482+
if not before_resource[k] == patch[k]:
483+
pruned_patch[k] = patch[k]
481484
headers = {
482485
"authorization": "Bearer " + self.session.token
483486
}
@@ -490,6 +493,8 @@ def patch_resource(self,patch):
490493
if type == "services" and not "modelType" in pruned_patch.keys() and "model" in pruned_patch.keys():
491494
pruned_patch["modelType"] = before_resource["modelType"]
492495
try:
496+
# if type == "app-wans":
497+
# import epdb; epdb.serve()
493498
after_response = http.patch(
494499
patch['_links']['self']['href'],
495500
proxies=self.session.proxies,
@@ -786,38 +791,7 @@ def create_service_simple(self, name: str, client_host_name: str, client_port: i
786791
}
787792
if endpoints and not egress_router_id:
788793
body['modelType'] = "TunnelerToEndpoint"
789-
# parse out the elements in the list of endpoints as one of #attribute, UUID, or resolvable Endoint name
790-
bind_endpoints = list()
791-
for endpoint in endpoints:
792-
if endpoint[0:1] == '#':
793-
bind_endpoints += [endpoint]
794-
else:
795-
# strip leading @ if present and re-add later after verifying the named endpoint exists
796-
if endpoint[0:1] == '@':
797-
endpoint = endpoint[1:]
798-
799-
# if UUIDv4 then resolve to name, else verify the named endpoint exists
800-
try:
801-
UUID(endpoint, version=4) # assigned below under "else" if already a UUID
802-
except ValueError:
803-
# else assume is a name and resolve to ID
804-
try:
805-
name_lookup = self.get_resources(type="endpoints",name=endpoint)[0]
806-
endpoint_name = name_lookup['name']
807-
except Exception as e:
808-
raise Exception('ERROR: Failed to find exactly one hosting endpoint named "{}". Caught exception: {}'.format(endpoint, e))
809-
# append to list after successfully resolving name to ID
810-
else: bind_endpoints += ['@'+endpoint_name]
811-
else:
812-
try:
813-
name_lookup = self.get_resource(type="endpoint",id=endpoint)
814-
endpoint_name = name_lookup['name']
815-
except Exception as e:
816-
raise Exception('ERROR: Failed to find exactly one hosting endpoint with ID "{}". Caught exception: {}'.format(endpoint, e))
817-
else: bind_endpoints += ['@'+endpoint_name]
818-
body['model']['bindEndpointAttributes'] = bind_endpoints
819794
body['model']['serverEgress'] = server_egress
820-
821795
elif egress_router_id and not endpoints:
822796
body['modelType'] = "TunnelerToEdgeRouter"
823797
# check if UUIDv4
@@ -840,6 +814,39 @@ def create_service_simple(self, name: str, client_host_name: str, client_port: i
840814
if edge_router_attributes and not edge_router_attributes == ['#all']:
841815
eprint("WARN: overriding default service Edge Router Policy #all for new service {:s}".format(name))
842816
body['edgeRouterAttributes'] = edge_router_attributes
817+
818+
if body['modelType'] in ["TunnelerToSdk","TunnelerToEndpoint"]:
819+
# parse out the elements in the list of endpoints as one of #attribute, UUID, or resolvable Endoint name
820+
bind_endpoints = list()
821+
for endpoint in endpoints:
822+
if endpoint[0:1] == '#':
823+
bind_endpoints += [endpoint]
824+
else:
825+
# strip leading @ if present and re-add later after verifying the named endpoint exists
826+
if endpoint[0:1] == '@':
827+
endpoint = endpoint[1:]
828+
829+
# if UUIDv4 then resolve to name, else verify the named endpoint exists
830+
try:
831+
UUID(endpoint, version=4) # assigned below under "else" if already a UUID
832+
except ValueError:
833+
# else assume is a name and resolve to ID
834+
try:
835+
name_lookup = self.get_resources(type="endpoints",name=endpoint)[0]
836+
endpoint_name = name_lookup['name']
837+
except Exception as e:
838+
raise Exception('ERROR: Failed to find exactly one hosting endpoint named "{}". Caught exception: {}'.format(endpoint, e))
839+
# append to list after successfully resolving name to ID
840+
else: bind_endpoints += ['@'+endpoint_name]
841+
else:
842+
try:
843+
name_lookup = self.get_resource(type="endpoint",id=endpoint)
844+
endpoint_name = name_lookup['name']
845+
except Exception as e:
846+
raise Exception('ERROR: Failed to find exactly one hosting endpoint with ID "{}". Caught exception: {}'.format(endpoint, e))
847+
else: bind_endpoints += ['@'+endpoint_name]
848+
body['model']['bindEndpointAttributes'] = bind_endpoints
849+
843850
params = dict()
844851
# params = {
845852
# "beta": ''

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setuptools.setup(
88
name='netfoundry',
9-
version='5.0.0',
9+
version='5.0.1',
1010
py_modules=['netfoundry'],
1111
url='https://developer.netfoundry.io/guides/python/',
1212
description='Interface to the NetFoundry network-as-code orchestration Platform',

0 commit comments

Comments
 (0)