1 from xml.dom.minidom import Document
4 #rspec['netspec'] = {'name':'planetlab.us'}
5 #rspec['netspec']['node'] = {'name':'planetlab-1.cs.princeton.edu', 'type':'std'}
6 #rspec['netspec']['node']['ifspec'] = {'addr':'128.112.139.71', 'type':'ipv4', 'min_rate':'0', 'max_rate':'10000000'}
7 #rspec['netspec']['node'] = {'name':'planetlab-2.cs.princeton.edu', 'type':'std'}
8 #rspec['netspec']['node']['ifspec'] = {'addr':'128.112.139.72', 'type':'ipv4', 'min_rate':'0', 'max_rate':'10000000'}
9 #rspec['netspec']['node']['ifspec'] = {'addr':'128.112.139.73', 'type':'proxy', 'min_rate':'0', 'max_rate':'10000000'}
10 #rspec['netspec']['node']['ifspec'] = {'addr':'128.112.139.74', 'type':'proxy', 'min_rate':'0', 'max_rate':'10000000'}
11 #rspec['netspec'] = {'name':'planetlab.eu'}
12 #rspec['netspec']['node'] = {'name':'onelab03.onelab.eu', 'type':'std'}
13 #rspec['netspec']['node']['ifspec'] = {'addr':'128.112.139.321', 'type':'ipv4', 'min_rate':'0', 'max_rate':'10000000'}
17 # Create the minidom document
20 # <rspec> base element
21 rspec = doc.createElement("RSpec")
22 rspec.setAttribute("start_time", "1235696400")
23 rspec.setAttribute("duration", "2419200")
24 doc.appendChild(rspec)
27 networks = doc.createElement("networks")
28 rspec.appendChild(networks)
31 NetSpec = doc.createElement("NetSpec")
32 NetSpec.setAttribute("name", "plc.us")
33 networks.appendChild(NetSpec)
36 nodes = doc.createElement("nodes")
37 NetSpec.appendChild(nodes)
40 NodeSpec = doc.createElement("NodeSpec")
41 NodeSpec.setAttribute("name", "planetlab-1.cs.princeton.edu")
42 nodes.appendChild(NodeSpec)
44 # Create a <p> element
45 paragraph1 = doc.createElement("p")
46 maincard.appendChild(paragraph1)
48 ## Give the <p> elemenet some text
49 #ptext = doc.createTextNode("This is a test!")
50 #paragraph1.appendChild(ptext)
52 # Print our newly created XML
53 print doc.toprettyxml(indent=" ")