Commit 19fa4790 authored by Dimitris Aragiorgis's avatar Dimitris Aragiorgis

deploy: Add state dir and use it for status

Introduce new setting in [dirs] section of deploy.conf: `state`.
Override this setting with `--state-dir` option (useful when running
deploy from source).

This dir is currently used to store snf-deploy's `snf_deploy_status`
file, that shows which components on which nodes have been
installed. Do not update this file if `--dry-run` is used.

Additionally introduce `--templates-dir` option that overrides
`template` setting in [dirs] section of `deploy.conf`.

Note that override options do not modify the configuration files.
Changes are performed in the execution context of each snf-deploy
command.

To run snf-deploy from source use:

$ python setup.py develop
$ snf-deploy keygen -c conf -t files -s /tmp
$ snf-deploy all --autoconf -c conf -t files -s /tmp

Add the above setting to snf-ci's schema files.

Update Copyright dates.
Signed-off-by: default avatarDimitris Aragiorgis <dimara@grnet.gr>
parent e329c2be
......@@ -8,6 +8,8 @@ use_local_packages = True
package_url = http://builder.dev.grnet.gr/synnefo/packages/Squeeze/40/
[dirs]
# dir to store snf-deploy status
state = /var/lib/snf-deploy
# dir to find all template files used to customize setup
# in case you want to add another setting please modify the corresponding file
templates = /var/lib/snf-deploy/files
......
......@@ -8,6 +8,8 @@ use_local_packages = True
package_url = http://builder.dev.grnet.gr/synnefo/packages/Squeeze/40/
[dirs]
# dir to store snf-deploy status
state = /var/lib/snf-deploy
# dir to find all template files used to customize setup
# in case you want to add another setting please modify the corresponding file
templates = /var/lib/snf-deploy/files
......
......@@ -370,6 +370,14 @@ def parse_options():
parser.add_argument("-c", dest="confdir",
default="/etc/snf-deploy",
help="Directory to find default configuration")
parser.add_argument("-t", "--templates-dir", dest="templatesdir",
default=None,
help="Directory to find templates. Overrides"
" the one found in the deploy.conf file")
parser.add_argument("-s", "--state-dir", dest="statedir",
default=None,
help="Directory to store current state. Overrides"
" the one found in the deploy.conf")
parser.add_argument("--dry-run", dest="dry_run",
default=False, action="store_true",
help="Do not execute or write anything.")
......@@ -571,7 +579,7 @@ def main():
conf = Conf(args)
env = Env(conf)
env.status = Status(args)
env.status = Status(env)
create_dir(env.run, False)
create_dir(env.dns, False)
......
#!/usr/bin/python
# Copyright (C) 2010, 2011, 2012, 2013 GRNET S.A. All rights reserved.
# Copyright (C) 2013, 2014 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
......@@ -210,10 +210,10 @@ class Status(object):
except ConfigParser.NoSectionError:
self.config.add_section(ip)
def __init__(self, args):
def __init__(self, env):
self.config = ConfigParser.ConfigParser()
self.config.optionxform = str
self.statusfile = os.path.join(args.confdir, "status.conf")
self.statusfile = os.path.join(env.state, "snf_deploy_status")
self.config.read(self.statusfile)
def check_status(self, ip, component_class):
......@@ -255,6 +255,12 @@ class Conf(object):
for k, v in self.get_section(f, s):
if getattr(args, k, None):
self.set(f, s, k, getattr(args, k))
# Override conf file settings if
# --templates-dir and --state-dir args are passed
if args.templatesdir:
self.deploy.set("dirs", "templates", args.templatesdir)
if args.statedir:
self.deploy.set("dirs", "state", args.statedir)
if args.autoconf:
self.autoconf()
......
......@@ -203,8 +203,9 @@ def SetupSynnefoRole(role):
debug(env.host, "Base configuration already exists", c.__name__)
else:
AddSynnefoComponent(c)
env.env.status.update_status(env.host, c, "ok")
env.env.status.write_status()
if not env.dry_run:
env.env.status.update_status(env.host, c, "ok")
env.env.status.write_status()
class AddSynnefoComponent(object):
......
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