"""
-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
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 = []
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:
# 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']: