GENICLOUD-26: Add logging.
authorMarco Yuen <marcoy@gmail.com>
Tue, 5 Jul 2011 19:24:53 +0000 (15:24 -0400)
committerMarco Yuen <marcoy@gmail.com>
Tue, 12 Jul 2011 16:18:23 +0000 (12:18 -0400)
Implement basic logging.

plugins/euca_iptables.py

index 959e859..af4b3f7 100644 (file)
@@ -4,8 +4,30 @@
 #
 # Author: Marco Yuen <marcoy@cs.princeton.edu>
 
+import logger
+import logging
+
+def start():
+    logger.log("euca_iptables: plugin starting up...")
+
+    # Set up a separate logger for debugging/testing purposes
+    l = logging.getLogger('euca_iptables_nm_plugin')
+    fh = logging.FileHandler('/var/log/euca_iptables.log')
+    fh.setLevel(logging.DEBUG)
+    fh.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
+    l.addHandler(fh)
+    l.setLevel(logging.DEBUG)
+
 def GetSlivers(data, config=None, plc=None):
-    pass
+    l = logging.getLogger('euca_iptables_nm_plugin')
+    l.debug('Data: %r' % data)
+    l.debug('config: %r' % config)
+    l.debug('plc: %r' % plc)
+
+    # Get a list of instance -> IPs mappings
+    # if none exists, return
+    if 'euca_inst_ip' not in data:
+        return
 
 if __name__ == '__main__':
     pass