Commit d7dfc73e authored by Dimitris Aragiorgis's avatar Dimitris Aragiorgis

pep8 fixes related to snf-deploy refactor

Signed-off-by: default avatarDimitris Aragiorgis <dimara@grnet.gr>
parent bcc59b59
......@@ -560,7 +560,6 @@ EOF
os.system(cmd)
def main():
args = parse_options()
......
......@@ -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, {}),
]
......@@ -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")
......
......@@ -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
......
......@@ -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]
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment