Improve comments
authorAndy Bavier <acb@cs.princeton.edu>
Tue, 1 Oct 2013 14:59:05 +0000 (10:59 -0400)
committerAndy Bavier <acb@cs.princeton.edu>
Tue, 1 Oct 2013 14:59:05 +0000 (10:59 -0400)
plugins/planetstack-net.py

index 1a686d4..5ef2853 100644 (file)
@@ -1,10 +1,10 @@
 """
-This plugin sets up the NAT interfaces for PlanetStack. It processes
-each interface that has a 'nat' tag set.
+This plugin sets up dnsmasq and iptables to support the "Private-Nat"
+and "Public" network models for OpenCloud.  It communicates with OvS
+on the local node and Quantum to gather information about the virtual
+interfaces instantiated by Quantum.  It uses this information to:
 
-It communicates with OvS on the local node and Quantum to gather
-information about devices.  It uses this information to:
-* add the Quantum-assigned IP address to the interface via dnsmasq
+* add the Quantum-assigned IP address to the vif via dnsmasq
 * set up port forwarding rules through the NAT using iptables
 
 The iptables configuration uses a chain called 'planetstack-net' to
@@ -207,18 +207,9 @@ def convert_ovs_output_to_dict(out):
 
     return records
 
-# Do all processing associated with Quantum ports.  It first gets a
-# list of local VM interfaces and then queries Quantum to get Port
-# records for these interfaces.  Then for all interfaces on the NAT
-# network it does the following:
-#
-# 1) Generates a dhcp-hostsfile for dnsmasq.  The purpose is to make
-# sure that the IP address assigned by Quantum appears on NAT
-# interface.
-#
-# 2) Sets up iptables rules in the 'planetstack-net' chain based on 
-# the nat:forward_ports field in the Port record.  
 
+# Get a list of local VM interfaces and then query Quantum to get
+# Port records for these interfaces.
 def get_local_quantum_ports():
     ports = []
 
@@ -243,8 +234,9 @@ def get_local_quantum_ports():
     return ports
 
 
+# Generate a dhcp-hostsfile for dnsmasq.  The purpose is to make sure
+# that the IP address assigned by Quantum appears on NAT interface.
 def write_dnsmasq_hostsfile(dev, ports, net_id):
-    # Write relevant entries to dnsmasq hostsfile
     logger.log("%s: Writing hostsfile for %s" % (plugin, dev))
     f = open(get_hostsfile(dev), 'w')
     for port in ports:
@@ -257,8 +249,9 @@ def write_dnsmasq_hostsfile(dev, ports, net_id):
     # Send SIGHUP to dnsmasq to make it re-read hostsfile
     dnsmasq_sighup(dev)
 
+# Set up iptables rules in the 'planetstack-net' chain based on
+# the nat:forward_ports field in the Port record.
 def set_up_port_forwarding(dev, ports):
-    # Set up iptables rules for port forwarding
     for port in ports:
         if port['network_id'] == nat_net_id:
             for fw in port['nat:forward_ports']: