Updated read_value to default to None

No error message is generated and the caller should check the
return status
This commit is contained in:
Paul Edwards 2020-04-08 09:20:06 +01:00
Родитель 42ceed385f
Коммит 8f9c0c312e
2 изменённых файлов: 10 добавлений и 14 удалений

Просмотреть файл

@ -22,7 +22,7 @@ class ConfigFile:
json.dump(self.data, f, indent=4)
def get_install_from_destination(self):
install_from = self.read_value("install_from", None)
install_from = self.read_value("install_from")
dest = install_from
if install_from is not None:
if self.read_value(f"resources.{install_from}.public_ip", False):
@ -97,13 +97,9 @@ class ConfigFile:
else:
res = it
except KeyError:
if default is not None:
log.debug(f"using default value ({default})")
res = default
else:
log.error("read_value : "+v+" not in config")
sys.exit(1)
log.debug(f"using default value ({default})")
res = default
log.debug("read_value (exit): "+v+"="+str(res))
return res

Просмотреть файл

@ -111,7 +111,7 @@ def do_scp(args):
sshkey="{}_id_rsa".format(adminuser)
# TODO: check ssh key exists
jumpbox = c.read_value("install_from", None)
jumpbox = c.read_value("install_from")
if jumpbox == None:
log.error(f"Missing 'install_from' property")
sys.exit(1)
@ -148,7 +148,7 @@ def do_connect(args):
else:
sshuser = args.user
jumpbox = c.read_value("install_from", None)
jumpbox = c.read_value("install_from")
if jumpbox == None:
log.error(f"Missing 'install_from' property")
sys.exit(1)
@ -234,7 +234,7 @@ def do_status(args):
adminuser = c.read_value("admin_user")
ssh_private_key="{}_id_rsa".format(adminuser)
jumpbox = c.read_value("install_from", None)
jumpbox = c.read_value("install_from")
if jumpbox == None:
log.error(f"Missing 'install_from' property")
sys.exit(1)
@ -260,7 +260,7 @@ def do_run(args):
else:
sshuser = args.user
jumpbox = c.read_value("install_from", None)
jumpbox = c.read_value("install_from")
if jumpbox == None:
log.error(f"Missing 'install_from' property")
sys.exit(1)
@ -271,7 +271,7 @@ def do_run(args):
hosts = []
if args.nodes:
for r in args.nodes.split(" "):
rtype = c.read_value(f"resources.{r}.type", None)
rtype = c.read_value(f"resources.{r}.type")
if not rtype:
log.error(f"resource {r} does not exist in config")
sys.exit(1)
@ -420,7 +420,7 @@ def do_build(args):
log.info("building install scripts")
azinstall.generate_install(config, tmpdir, adminuser, private_key_file, public_key_file)
jumpbox = c.read_value("install_from", None)
jumpbox = c.read_value("install_from")
if jumpbox == None:
log.info("nothing to install ('install_from' is not set)")
else: