9 from topology import links
12 # Load shell with default configuration
13 sys.path.append('/usr/share/plc_api')
14 from PLC.Shell import Shell
15 plc = Shell(globals())
17 parser = optparse.OptionParser()
18 parser.add_option('-v', '--verbose', action='store_true', dest='DEBUG', default=False, help='Run in verbose mode.')
19 (options, args) = parser.parse_args()
22 def ifSpecDict(nodedict):
24 Generate ifspec dict for given node dict.
26 # ifspecattrs = ['name',
34 # Assume only 1 node network per node.
35 nodenetwork = GetNodeNetworks(nodedict['nodenetwork_ids'])[0]
36 ifspecs = {'name': nodenetwork['hostname'],
37 'addr': nodenetwork['ip'],
38 'type': nodenetwork['type'],
49 Create dict for physical topology.
51 # list of attributes in the LinkSpec
52 # (https://svn.planet-lab.org/svn/geniwrapper/trunk/rspec/model/planetlab.{ecore,xsd})
53 # linkspecattrs = ['type',
58 # 'endpoint', # <-- ifspec(S)?
61 # list of linkspecs. 1 per adjacency
63 # links maps sites. Get nodes in site, make linkspecs for each.
66 print "sites = (%s, %s) nodes = %s" %(i,j, GetNodes({'site_id':[i,j]}, ['node_id']))
67 nodeset = GetNodes({'site_id':[i,j]})
70 ifspecs.append(ifSpecDict(node))
78 'start_time': int(time()),
86 pp.pprint(linkSpecDict())
89 if __name__ == '__main__':