def get_lamp_topology(): # GFR: When using the lamp@slice certificate # there's no need for credential # #slice_cred = get_slice_cred(cred_file) #body = make_UNISQueryCred_message(slice_cred) # Note that UNIS will return only the slice view for the Query All body = make_UNISQueryAll_message() try: client = SimpleClient(host=host, port=port, uri=uri, cert=cert_file, key=key_file) response = client.send_request(body, useSSL=True) except: print "Error contacting UNIS" return print response #t = create_from_xml_file(tfile) t = create_from_xml_string(response) if not t: print "Could not parse any topologies" return save_parsed_elements(t[0]) types = ['in', 'out', 'cpu', 'mem'] slices = [] for d in t[0].get_domains(): id_fields = get_urn_value(d.unis_id, 'domain').split('+') if len(id_fields) == 3 and id_fields[1] == 'slice': slices.append(id_fields[2] + '@' + id_fields[0]) for n in d.get_nodes(): for p in n.get_ports(): pa = PortAddresses.objects.filter(port__unis_id=p.unis_id, address__type='ipv4') #pn = NetworkObjectNames.objects.filter(networkobject=p) for type in types: urn = UrnStub(urn=pa[0].address.value + '-' + type, ifName=get_urn_value(p.unis_id, 'port'), ifHost=get_urn_value(n.unis_id, 'node'), ifAddress=pa[0].address.value, type=type, source='MA') urn.save() t[0].unis_id = "Topology for slice " + slices[0] t[0].save()
from django.conf import settings from periscope.topology.models import * from periscope.topology.lib.topology import create_from_xml_file from periscope.topology.lib.util import save_parsed_elements try: topo = Topology.objects.get(unis_id='terapaths-escps') topo.delete() except: print "no existing tps topo" t = create_from_xml_file(settings.PERISCOPE_ROOT + "examples/terapaths-unis-2.xml") save_parsed_elements(t[0]) PeriscopeDomainProperties.objects.all().delete() PeriscopeNodeProperties.objects.all().delete() PeriscopePortProperties.objects.all().delete() d = Domain.objects.get(unis_id='urn:ogf:network:domain=escps.lbl.gov') PeriscopeDomainProperties.objects.create(parent=d, shape=PeriscopeShape.objects.create( shape="rect", x=800, y=280, width=200, height=100, fill="lightpink", text_xdisp="10", text_ydisp="20", text_align="left" )) d = Domain.objects.get(unis_id='urn:ogf:network:domain=escps.bnl.gov') PeriscopeDomainProperties.objects.create(parent=d, shape=PeriscopeShape.objects.create( shape="rect", x=10, y=10, width=425, height=350, fill="moccasin", text_xdisp="10", text_ydisp="20", text_align="left" ))
Periscope shape properties. """ import math from django.conf import settings from periscope.topology.models import * from periscope.topology.lib.topology import create_from_xml_file from periscope.topology.lib.util import save_parsed_elements # Imports ANI's XML unis topology to Django's model if Topology.objects.all().count() == 0: topo = create_from_xml_file(settings.PERISCOPE_ROOT + "examples/anitestbed.xml") save_parsed_elements(topo[0]) # Delete all previous shape properties PeriscopeDomainProperties.objects.all().delete() PeriscopeNodeProperties.objects.all().delete() PeriscopePortProperties.objects.all().delete() d = Domain.objects.get(unis_id='urn:ogf:network:domain=testbed.es.net') PeriscopeDomainProperties.objects.create(parent=d, shape=PeriscopeShape.objects.create( shape="rect", x=5, y=5, width=1070, height=490, fill="moccasin", text_xdisp="10", text_ydisp="20", text_align="left" )) # newy-tb-rt-1