Bug fix
[nodemanager.git] / plugins / planetstack-net.py
index 5ef2853..f47b63d 100644 (file)
@@ -36,7 +36,7 @@ nat_net_name = "nat-net"
 nat_net_id = None
 site_net_id = None
 
-quantum_auth_url = "http://viccidev1:5000/v2.0/"
+quantum_auth_url = None
 quantum_username = None
 quantum_password = None
 quantum_tenant_name = None
@@ -157,7 +157,7 @@ def dnsmasq_sighup(dev):
 # Enable dnsmasq for this interface.
 # It's possible that we could get by with a single instance of dnsmasq running on
 # all devices but I haven't tried it.
-def start_dnsmasq(dev, interface):
+def start_dnsmasq(dev, interface, forward_dns=True):
     if not dnsmasq_running(dev):
         # The '--dhcp-range=<IP addr>,static' argument to dnsmasq ensures that it only
         # hands out IP addresses to clients listed in the hostsfile
@@ -175,6 +175,10 @@ def start_dnsmasq(dev, interface):
                '--dhcp-no-override',
                '--dhcp-range=%s,static' % interface['ip']]
 
+        # Turn off forwarding DNS queries, only do DHCP
+        if forward_dns == False:
+            cmd.append('--port=0')
+
         try:
             logger.log('%s: starting dnsmasq on device %s' % (plugin, dev))
             subprocess.check_call(cmd)
@@ -253,7 +257,7 @@ def write_dnsmasq_hostsfile(dev, ports, net_id):
 # the nat:forward_ports field in the Port record.
 def set_up_port_forwarding(dev, ports):
     for port in ports:
-        if port['network_id'] == nat_net_id:
+        if port['network_id'] == nat_net_id and port['nat:forward_ports']:
             for fw in port['nat:forward_ports']:
                 ipaddr = port['fixed_ips'][0]['ip_address']
                 protocol = fw['l4_protocol']
@@ -279,6 +283,7 @@ def start():
     global quantum_username
     global quantum_password
     global quantum_tenant_name
+    global quantum_auth_url
 
     logger.log("%s: plugin starting up..." % plugin)
 
@@ -287,7 +292,7 @@ def start():
     quantum_username = parser.get("DEFAULT", "quantum_admin_username")
     quantum_password = parser.get("DEFAULT", "quantum_admin_password")
     quantum_tenant_name = parser.get("DEFAULT", "quantum_admin_tenant_name")
-
+    quantum_auth_url = parser.get("DEFAULT", "quantum_admin_auth_url")
 
 def GetSlivers(data, config=None, plc=None):
     global nat_net_id
@@ -345,5 +350,5 @@ def GetSlivers(data, config=None, plc=None):
             if 'OVS_BRIDGE' in tags:
                 dev = tags['OVS_BRIDGE']
             write_dnsmasq_hostsfile(dev, ports, site_net_id)
-            start_dnsmasq(dev, interface)
+            start_dnsmasq(dev, interface, forward_dns=False)