return private and nat addresses
diff --git a/xos/core/views/legacyapi.py b/xos/core/views/legacyapi.py
index 43b444c..5216351 100644
--- a/xos/core/views/legacyapi.py
+++ b/xos/core/views/legacyapi.py
@@ -146,7 +146,7 @@
return sites
-def GetInterfaces(slicename, node_ids):
+def GetInterfaces(slicename, node_ids, return_nat=False, return_private=False):
interfaces = []
ps_slices = Slice.objects.filter(name=slicename)
for ps_slice in ps_slices:
@@ -165,6 +165,28 @@
if (template.visibility=="public") and (template.translation=="none"):
ip=networkSliver.ip
+ if return_nat:
+ ip = None
+ for networkSliver in ps_sliver.networkslivers.all():
+ if (not networkSliver.ip):
+ continue
+ template = networkSliver.network.template
+ if (template.visibility=="private") and (template.translation=="NAT"):
+ ip=networkSliver.ip
+ if not ip:
+ continue
+
+ if return_private:
+ ip = None
+ for networkSliver in ps_sliver.networkslivers.all():
+ if (not networkSliver.ip):
+ continue
+ template = networkSliver.network.template
+ if (template.visibility=="private") and (template.translation=="none"):
+ ip=networkSliver.ip
+ if not ip:
+ continue
+
interface = {"node_id": node_id,
"ip": ip,
"broadcast": None,
@@ -197,6 +219,7 @@
perhost = {}
allinterfaces = {}
hostipmap = {}
+ hostnatmap = {}
nodes = []
if len(slices)==1:
slice = slices[0]
@@ -216,6 +239,18 @@
if interface['is_primary']:
hostipmap[nodemap[interface['node_id']]] = interface['ip']
+ hostnatmap = {}
+ interfaces = GetInterfaces(slice["planetstack_name"], node_ids, return_nat=True)
+ for interface in interfaces:
+ interface['interface_tags'] = []
+ hostnatmap[nodemap[interface['node_id']]] = interface['ip']
+
+ hostprivmap = {}
+ interfaces = GetInterfaces(slice["planetstack_name"], node_ids, return_private=True)
+ for interface in interfaces:
+ interface['interface_tags'] = []
+ hostprivmap[nodemap[interface['node_id']]] = interface['ip']
+
for nid in node_ids:
sliver_tags = GetTags(slicename,nid)
perhost[nodemap[nid]] = sliver_tags
@@ -234,6 +269,8 @@
'configuration': node_sliver_tags,
'allconfigurations':perhost,
'hostipmap':hostipmap,
+ 'hostnatmap':hostnatmap,
+ 'hostprivmap':hostprivmap,
'slivers': slivers,
'interfaces': allinterfaces,
'sites': sites,