spaces after comma
[nodemanager.git] / plugins / hostmap.py
index 6a71ec2..7f47afd 100644 (file)
@@ -30,7 +30,7 @@ SUFFIX = "# ----- End -----"
 def GetSlivers(data, config=None, plc=None):
 
     if 'slivers' not in data:
-        logger.log_missing_data("hostmap.GetSlivers",'slivers')
+        logger.log_missing_data("hostmap.GetSlivers", 'slivers')
         return
 
     if 'hostname' not in data:
@@ -38,6 +38,8 @@ def GetSlivers(data, config=None, plc=None):
 
     hostname = data['hostname']
 
+    hostname_filter = ".".join(hostname.split(".")[1:])
+
     for sliver in data['slivers']:
         slicename = sliver['name']
         for tag in sliver['attributes']:
@@ -46,7 +48,8 @@ def GetSlivers(data, config=None, plc=None):
                 if not os.path.exists(fn):
                     continue
 
-                contents = file(fn,"r").read()
+                with open(fn) as f:
+                    contents = f.read()
 
                 hostmap = []
                 for index, entry in enumerate(tag["value"].split("\n")):
@@ -54,6 +57,9 @@ def GetSlivers(data, config=None, plc=None):
                     if len(parts)==2:
                        line = "%s pvt.%s private%d" % (parts[0], parts[1], index)
 
+                       if (parts[0].startswith("10.")) and (hostname_filter not in parts[1]):
+                           continue
+
                        if (index==0):
                            line = line + " headnode"
 
@@ -79,7 +85,8 @@ def GetSlivers(data, config=None, plc=None):
                     contents = contents + hostmap
 
                 try:
-                    file(fn, "w").write(contents)
+                    with open(fn, "w") as f:
+                        f.write(contents)
                 except:
                     logger.log_exc("hostmap (%s): failed to write %s" % (slicename, fn))