commit c59f7e0f1f03fb2734a76070b4b8f71c7fe1e880
Author: Christos Stavrakakis <cstavr@grnet.gr>
Date:   Fri Feb 8 11:35:19 2013 +0200

    Fix pep8 issues

diff --git a/snf-cyclades-app/synnefo/logic/management/commands/reconcile-servers.py b/snf-cyclades-app/synnefo/logic/management/commands/reconcile-servers.py
index 5c09a1a..0287d26 100644
--- a/snf-cyclades-app/synnefo/logic/management/commands/reconcile-servers.py
+++ b/snf-cyclades-app/synnefo/logic/management/commands/reconcile-servers.py
@@ -84,8 +84,8 @@ class Command(BaseCommand):
                     dest='fix_build_errors', default=False,
                     help='Fix (remove) instances with build errors'),
         make_option('--fix-unsynced-nics', action='store_true',
-                     dest='fix_unsynced_nics', default=False,
-                     help='Fix unsynced nics between DB and Ganeti'),
+                    dest='fix_unsynced_nics', default=False,
+                    help='Fix unsynced nics between DB and Ganeti'),
         make_option('--fix-all', action='store_true', dest='fix_all',
                     default=False, help='Enable all --fix-* arguments'),
         make_option('--backend-id', default=None, dest='backend-id',
@@ -160,8 +160,9 @@ class Command(BaseCommand):
         if options['detect_build_errors']:
             build_errors = reconciliation.instances_with_build_errors(D, G)
             if len(build_errors) > 0:
-                print >> sys.stderr, "The os for the following server IDs was "\
-                                     "not build successfully:"
+                msg = "The os for the following server IDs was not build"\
+                      " successfully:"
+                print >> sys.stderr, msg
                 print "    " + "\n    ".join(
                     ["%d" % x for x in build_errors])
             elif verbosity == 2:
@@ -172,13 +173,15 @@ class Command(BaseCommand):
                 if not nics:
                     print ''.ljust(18) + 'None'
                 for index, info in nics.items():
-                    print ''.ljust(18) + 'nic/' + str(index) + ': MAC: %s, IP: %s, Network: %s' % \
-                      (info['mac'], info['ipv4'], info['network'])
+                    print ''.ljust(18) + 'nic/' + str(index) +\
+                          ': MAC: %s, IP: %s, Network: %s' % \
+                          (info['mac'], info['ipv4'], info['network'])
 
             unsynced_nics = reconciliation.unsynced_nics(DBNics, GNics)
             if len(unsynced_nics) > 0:
-                print >> sys.stderr, "The NICs of servers with the following IDs "\
-                                     "are unsynced:"
+                msg = "The NICs of the servers with the following IDs are"\
+                      " unsynced:"
+                print >> sys.stderr, msg
                 for id, nics in unsynced_nics.items():
                     print ''.ljust(2) + '%6d:' % id
                     print ''.ljust(8) + '%8s:' % 'DB'
@@ -233,19 +236,20 @@ class Command(BaseCommand):
             print >> sys.stderr, "    ...done"
 
         if options['fix_build_errors'] and len(build_errors) > 0:
-            print >> sys.stderr, "Setting the state of %d build-errors VMs:" % \
-                len(build_errors)
+            print >> sys.stderr, "Setting the state of %d build-errors VMs:" %\
+                                 len(build_errors)
             for id in build_errors:
                 vm = VirtualMachine.objects.get(pk=id)
                 event_time = datetime.datetime.now()
-                backend_mod.process_op_status(vm=vm, etime=event_time, jobid=-0,
+                backend_mod.process_op_status(
+                    vm=vm, etime=event_time, jobid=-0,
                     opcode="OP_INSTANCE_CREATE", status='error',
                     logmsg='Reconciliation: simulated Ganeti event')
             print >> sys.stderr, "    ...done"
 
         if options['fix_unsynced_nics'] and len(unsynced_nics) > 0:
             print >> sys.stderr, "Setting the nics of %d out-of-sync VMs:" % \
-                                  len(unsynced_nics)
+                                 len(unsynced_nics)
             for id, nics in unsynced_nics.items():
                 vm = VirtualMachine.objects.get(pk=id)
                 nics = nics[1]  # Ganeti nics
diff --git a/snf-cyclades-gtools/synnefo/ganeti/hook.py b/snf-cyclades-gtools/synnefo/ganeti/hook.py
index 69248b9..39a408e 100644
--- a/snf-cyclades-gtools/synnefo/ganeti/hook.py
+++ b/snf-cyclades-gtools/synnefo/ganeti/hook.py
@@ -78,7 +78,7 @@ def ganeti_net_status(logger, environ):
         if env.startswith("GANETI_INSTANCE_NIC"):
             s = env.replace("GANETI_INSTANCE_NIC", "").split('_', 1)
             if len(s) == 2 and s[0].isdigit() and\
-               s[1] in ('MAC', 'IP', 'BRIDGE', 'NETWORK'):
+                    s[1] in ('MAC', 'IP', 'BRIDGE', 'NETWORK'):
                 index = int(s[0])
                 key = key_to_attr[s[1]]
 
@@ -119,12 +119,14 @@ def ganeti_net_status(logger, environ):
     ganeti_nic_count = int(environ['GANETI_INSTANCE_NIC_COUNT'])
     if len(indexes) != ganeti_nic_count:
         logger.error("I have %d NICs, Ganeti says number of NICs is %d",
-            len(indexes), ganeti_nic_count)
+                     len(indexes), ganeti_nic_count)
         raise Exception("Inconsistent number of NICs in Ganeti environment")
 
     if indexes != range(0, len(indexes)):
-        logger.error("Ganeti NIC indexes are not consecutive starting at zero.");
-        logger.error("NIC indexes are: %s. Environment is: %s", indexes, environ)
+        msg = "Ganeti NIC indexes are not consecutive starting at zero."
+        logger.error(msg)
+        msg = "NIC indexes are: %s. Environment is: %s" % (indexes, environ)
+        logger.error(msg)
         raise Exception("Unexpected inconsistency in the Ganeti environment")
 
     # Construct the notification
@@ -193,7 +195,9 @@ class PostStartHook(GanetiHook):
     def run(self):
         if self.on_master():
             notifs = []
-            notifs.append(("net", ganeti_net_status(self.logger, self.environ)))
+            notifs.append(("net",
+                           ganeti_net_status(self.logger, self.environ))
+                          )
 
             self.publish_msgs(notifs)
 
@@ -214,15 +218,17 @@ def main():
         op = os.environ['GANETI_HOOKS_PATH']
         phase = os.environ['GANETI_HOOKS_PHASE']
     except KeyError:
-        raise Exception("Environment missing one of: " \
-            "GANETI_INSTANCE_NAME, GANETI_HOOKS_PATH, GANETI_HOOKS_PHASE")
+        raise Exception("Environment missing one of: "
+                        "GANETI_INSTANCE_NAME, GANETI_HOOKS_PATH,"
+                        " GANETI_HOOKS_PHASE")
 
     prefix = instance.split('-')[0]
 
     # FIXME: The hooks should only run for Synnefo instances.
     # Uncomment the following lines for a shared Ganeti deployment.
     # Currently, the following code is commented out because multiple
-    # backend prefixes are used in the same Ganeti installation during development.
+    # backend prefixes are used in the same Ganeti installation during
+    # development.
     #if not instance.startswith(settings.BACKEND_PREFIX_ID):
     #    logger.warning("Ignoring non-Synnefo instance %s", instance)
     #    return 0
@@ -238,7 +244,8 @@ def main():
     try:
         hook = hooks[(op, phase)](logger, os.environ, instance, prefix)
     except KeyError:
-        raise Exception("No hook found for operation = '%s', phase = '%s'" % (op, phase))
+        raise Exception("No hook found for operation = '%s', phase = '%s'" %
+                        (op, phase))
     return hook.run()
 
 if __name__ == "__main__":
