commit d4f28d8fbde25c8e0f67e5a5b4ca6b001c2af34c
Author: Dimitris Aragiorgis <dimara@grnet.gr>
Date:   Wed Jan 8 20:25:57 2014 +0200

    pep8 fixes related to snf-deploy refactor
    
    Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

diff --git a/snf-deploy/snfdeploy/__init__.py b/snf-deploy/snfdeploy/__init__.py
index e3de02e..45af954 100644
--- a/snf-deploy/snfdeploy/__init__.py
+++ b/snf-deploy/snfdeploy/__init__.py
@@ -560,7 +560,6 @@ EOF
     os.system(cmd)
 
 
-
 def main():
     args = parse_options()
 
diff --git a/snf-deploy/snfdeploy/components.py b/snf-deploy/snfdeploy/components.py
index 164bf87..b95cfa5 100644
--- a/snf-deploy/snfdeploy/components.py
+++ b/snf-deploy/snfdeploy/components.py
@@ -34,6 +34,7 @@
 import datetime
 from snfdeploy.utils import debug
 
+
 class SynnefoComponent(object):
 
     REQUIRED_PACKAGES = []
@@ -86,6 +87,7 @@ class HW(SynnefoComponent):
             "apt-get update",
             ]
 
+
 class SSH(SynnefoComponent):
     def prepare(self):
         return [
@@ -234,7 +236,8 @@ class APT(SynnefoComponent):
     def prepare(self):
         return [
             "echo 'APT::Install-Suggests \"false\";' >> /etc/apt/apt.conf",
-            "curl -k https://dev.grnet.gr/files/apt-grnetdev.pub | apt-key add -",
+            "curl -k https://dev.grnet.gr/files/apt-grnetdev.pub | \
+                apt-key add -",
             ]
 
     def configure(self):
@@ -384,10 +387,9 @@ class Master(SynnefoComponent):
 
         return commands + self.restart()
 
-
     def add_node(self, node_info):
         commands = [
-            "gnt-node add --no-ssh-key-check --master-capable=yes " + \
+            "gnt-node add --no-ssh-key-check --master-capable=yes " +
               "--vm-capable=yes " + node_info.fqdn,
             ]
         return commands
@@ -400,7 +402,6 @@ class Master(SynnefoComponent):
             "gnt-group modify --disk-parameters=drbd:metavg=%s default" % vg,
             ]
 
-
     def initialize(self):
         cmd = """
         gnt-cluster init --enabled-hypervisors=kvm \
@@ -446,7 +447,6 @@ class Image(SynnefoComponent):
         return ["snf-image-update-helper -y"]
 
 
-
 class GTools(SynnefoComponent):
     REQUIRED_PACKAGES = [
         "snf-cyclades-gtools",
@@ -508,7 +508,6 @@ class Network(SynnefoComponent):
     def initialize(self):
         return ["/etc/init.d/rc.local start"]
 
-
     def restart(self):
         return ["/etc/init.d/nfdhcpd restart"]
 
@@ -643,31 +642,33 @@ class Astakos(SynnefoComponent):
             ]
 
     def set_default_quota(self):
-        return [
-            "snf-manage resource-modify --default-quota 40G pithos.diskspace",
-            "snf-manage resource-modify --default-quota 2 astakos.pending_app",
-            "snf-manage resource-modify --default-quota 4 cyclades.vm",
-            "snf-manage resource-modify --default-quota 40G cyclades.disk",
-            "snf-manage resource-modify --default-quota 16G cyclades.total_ram",
-            "snf-manage resource-modify --default-quota 8G cyclades.ram",
-            "snf-manage resource-modify --default-quota 32 cyclades.total_cpu",
-            "snf-manage resource-modify --default-quota 16 cyclades.cpu",
-            "snf-manage resource-modify --default-quota 4 cyclades.network.private",
-            "snf-manage resource-modify --default-quota 4 cyclades.floating_ip",
+        cmd = "snf-manage resource-modify --default-quota"
+        return [
+            "%s 40G pithos.diskspace" % cmd,
+            "%s 2 astakos.pending_app" % cmd,
+            "%s 4 cyclades.vm" % cmd,
+            "%s 40G cyclades.disk" % cmd,
+            "%s 16G cyclades.total_ram" % cmd,
+            "%s 8G cyclades.ram" % cmd,
+            "%s 32 cyclades.total_cpu" % cmd,
+            "%s 16 cyclades.cpu" % cmd,
+            "%s 4 cyclades.network.private" % cmd,
+            "%s 4 cyclades.floating_ip" % cmd,
             ]
 
     def modify_all_quota(self):
-        return [
-            "snf-manage user-modify -f --all --base-quota pithos.diskspace 40G",
-            "snf-manage user-modify -f --all --base-quota astakos.pending_app 2",
-            "snf-manage user-modify -f --all --base-quota cyclades.vm 4",
-            "snf-manage user-modify -f --all --base-quota cyclades.disk 40G",
-            "snf-manage user-modify -f --all --base-quota cyclades.total_ram 16G",
-            "snf-manage user-modify -f --all --base-quota cyclades.ram 8G",
-            "snf-manage user-modify -f --all --base-quota cyclades.total_cpu 32",
-            "snf-manage user-modify -f --all --base-quota cyclades.cpu 16",
-            "snf-manage user-modify -f --all --base-quota cyclades.network.private 4",
-            "snf-manage user-modify -f --all --base-quota cyclades.floating_ip 4",
+        cmd = "snf-manage user-modify -f --all --base-quota"
+        return [
+            "%s pithos.diskspace 40G" % cmd,
+            "%s astakos.pending_app 2" % cmd,
+            "%s cyclades.vm 4" % cmd,
+            "%s cyclades.disk 40G" % cmd,
+            "%s cyclades.total_ram 16G" % cmd,
+            "%s cyclades.ram 8G" % cmd,
+            "%s cyclades.total_cpu 32" % cmd,
+            "%s cyclades.cpu 16" % cmd,
+            "%s cyclades.network.private 4" % cmd,
+            "%s cyclades.floating_ip 4" % cmd,
             ]
 
     def get_services(self):
@@ -734,7 +735,6 @@ class Astakos(SynnefoComponent):
             ]
 
 
-
 class CMS(SynnefoComponent):
     REQUIRED_PACKAGES = [
         "snf-cloudcms"
@@ -860,6 +860,7 @@ class Pithos(SynnefoComponent):
             ("/etc/synnefo/webclient.conf", r2, {}),
             ]
 
+
 class Cyclades(SynnefoComponent):
     REQUIRED_PACKAGES = [
         "memcached",
@@ -870,15 +871,11 @@ class Cyclades(SynnefoComponent):
         "python-django-south",
         ]
 
-    def add_network(self, subnet=None, gw=None, ntype=None, link=None):
-        if not subnet:
-            subnet = self.env.env.synnefo_public_network_subnet
-        if not gw:
-            gw = self.env.env.synnefo_public_network_gateway
-        if not ntype:
-            ntype = self.env.env.synnefo_public_network_type
-        if not link:
-            link = self.env.env.common_bridge
+    def add_network(self):
+        subnet = self.env.env.synnefo_public_network_subnet
+        gw = self.env.env.synnefo_public_network_gateway
+        ntype = self.env.env.synnefo_public_network_type
+        link = self.env.env.common_bridge
 
         cmd = """
 snf-manage network-create --subnet={0} --gateway={1} --public \
@@ -888,17 +885,17 @@ snf-manage network-create --subnet={0} --gateway={1} --public \
 
         return [cmd]
 
-    def add_network6(self, subnet="babe::/64", gw="babe::1", ntype=None, link=None):
-        if not ntype:
-            ntype = self.env.env.synnefo_public_network_type
-        if not link:
-            link = self.env.env.common_bridge
+    def add_network6(self):
+        subnet = "babe::/64"
+        gw = "babe::1"
+        ntype = self.env.env.synnefo_public_network_type
+        link = self.env.env.common_bridge
 
-        cmd  = """
-snf-manage network-create --subnet6=babe::/64 \
-      --gateway6=babe::1 --public --dhcp=True --flavor={0} --mode=bridged \
-       --link={1} --name=IPv6PublicNetwork
-""".format(ntype, link)
+        cmd = """
+snf-manage network-create --subnet6={0} \
+      --gateway6={1} --public --dhcp=True --flavor={2} --mode=bridged \
+       --link={3} --name=IPv6PublicNetwork
+""".format(subnet, gw, ntype, link)
 
         return [cmd]
 
@@ -918,7 +915,7 @@ snf-manage network-create --subnet6=babe::/64 \
         user = self.env.env.synnefo_user
         passwd = self.env.env.synnefo_rapi_passwd
         return [
-            "snf-manage backend-add --clustername=%s --user=%s --pass=%s"  % \
+            "snf-manage backend-add --clustername=%s --user=%s --pass=%s" %
               (cluster.fqdn, user, passwd)
             ]
 
@@ -959,7 +956,8 @@ snf-manage network-create --subnet6=babe::/64 \
         return [
             "snf-manage syncdb",
             "snf-manage migrate --delete-ghost-migrations",
-            "snf-manage pool-create --type=mac-prefix --base=aa:00:0 --size=65536",
+            "snf-manage pool-create --type=mac-prefix \
+              --base=aa:00:0 --size=65536",
             "snf-manage pool-create --type=bridge --base=prv --size=20",
             "snf-manage flavor-create %s %s %s %s" % (cpu, ram, disk, storage),
             ]
@@ -970,6 +968,7 @@ snf-manage network-create --subnet6=babe::/64 \
             "/etc/init.d/snf-dispatcher restart",
             ]
 
+
 class VNC(SynnefoComponent):
     REQUIRED_PACKAGES = [
         "snf-vncauthproxy"
@@ -990,8 +989,9 @@ class Kamaki(SynnefoComponent):
     def initialize(self):
         url = "https://%s/astakos/identity/v2.0" % self.env.env.accounts.fqdn
         return [
-            "kamaki config set cloud.default.url %s" %  url,
-            "kamaki config set cloud.default.token %s" % self.env.user_auth_token,
+            "kamaki config set cloud.default.url %s" % url,
+            "kamaki config set cloud.default.token %s" %
+              self.env.user_auth_token,
             "kamaki container create images",
             ]
 
@@ -1025,12 +1025,14 @@ class Kamaki(SynnefoComponent):
             cmd
             ]
 
+
 class Burnin(SynnefoComponent):
     REQUIRED_PACKAGES = [
         "kamaki",
         "snf-tools",
         ]
 
+
 class Collectd(SynnefoComponent):
     REQUIRED_PACKAGES = [
         "collectd",
@@ -1073,6 +1075,7 @@ class Stats(SynnefoComponent):
             "/etc/init.d/apache2 restart",
             ]
 
+
 class GanetiCollectd(SynnefoComponent):
     def configure(self):
         r1 = {
@@ -1082,5 +1085,3 @@ class GanetiCollectd(SynnefoComponent):
             ("/etc/collectd/passwd", {}, {}),
             ("/etc/collectd/synnefo-ganeti.conf", r1, {}),
             ]
-
-
diff --git a/snf-deploy/snfdeploy/fabfile.py b/snf-deploy/snfdeploy/fabfile.py
index aced592..6d44ee9 100644
--- a/snf-deploy/snfdeploy/fabfile.py
+++ b/snf-deploy/snfdeploy/fabfile.py
@@ -1241,7 +1241,7 @@ def export_services():
         filename = "%s_services.json" % service
         cmd = "snf-manage service-export-%s > %s" % (service, filename)
         run(cmd)
-        try_get(filename, filename+".local")
+        try_get(filename, filename + ".local")
 
 
 @roles("accounts")
diff --git a/snf-deploy/snfdeploy/fabfile2.py b/snf-deploy/snfdeploy/fabfile2.py
index f52b9ef..f04b7cc 100644
--- a/snf-deploy/snfdeploy/fabfile2.py
+++ b/snf-deploy/snfdeploy/fabfile2.py
@@ -125,7 +125,7 @@ def update_env_with_user_info():
 def update_env_with_service_info(service="pithos"):
     result = RunComponentMethod(Astakos, "get_services")
     r = re.compile(r"(\d+)[ ]*%s[ ]*(\S+)" % service, re.M)
-    match  = r.search(result)
+    match = r.search(result)
     if env.dry_run:
         env.service_id, env.service_token = \
             ("dummy_service_id", "dummy_service_token")
@@ -144,6 +144,7 @@ def update_env_with_backend_info():
     else:
         env.backend_id, = match.groups()
 
+
 #
 #
 # Those methods act on components after their basic setup
@@ -211,6 +212,8 @@ def add_image():
     RunComponentMethod(Kamaki, "fetch_image")
     RunComponentMethod(Kamaki, "upload_image")
     RunComponentMethod(Kamaki, "register_image")
+
+
 #
 #
 # Those methods do the basic setup of a synnefo role
diff --git a/snf-deploy/snfdeploy/lib.py b/snf-deploy/snfdeploy/lib.py
index f3abcce..5b09ab3 100644
--- a/snf-deploy/snfdeploy/lib.py
+++ b/snf-deploy/snfdeploy/lib.py
@@ -170,9 +170,9 @@ class Env(object):
 
         # This is needed because "".split(",") -> ['']
         if self.cluster_nodes:
-          self.cluster_nodes = self.cluster_nodes.split(",")
+            self.cluster_nodes = self.cluster_nodes.split(",")
         else:
-          self.cluster_nodes = []
+            self.cluster_nodes = []
 
         self.cluster_hostnames = [self.node2hostname[n]
                                   for n in self.cluster_nodes]
diff --git a/snf-deploy/snfdeploy/utils.py b/snf-deploy/snfdeploy/utils.py
index dfaf27c..46ec352 100644
--- a/snf-deploy/snfdeploy/utils.py
+++ b/snf-deploy/snfdeploy/utils.py
@@ -54,9 +54,10 @@ def abort(action):
             abort = kwargs.get("abort", True)
             force = env.force
             if not abort or force:
-                 debug(env.host, "WARNING: command failed. Continuing anyway...")
+                debug(env.host,
+                      "WARNING: command failed. Continuing anyway...")
             else:
-                 fabric.utils.abort(e)
+                fabric.utils.abort(e)
     return inner
 
 
