From 5be1cdc40ab33d2fd1ec9dd1501e85eed6f7f914 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Tue, 12 Mar 2019 22:55:29 -0400 Subject: [PATCH] Support YAML in the client and update configfile --- client-cli/pvc.py | 16 +++++++--------- debian/control | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/client-cli/pvc.py b/client-cli/pvc.py index 5cb91548..6b536915 100755 --- a/client-cli/pvc.py +++ b/client-cli/pvc.py @@ -28,6 +28,7 @@ import subprocess import difflib import re import colorama +import yaml import client_lib.common as pvc_common import client_lib.node as pvc_node @@ -1268,23 +1269,20 @@ def cli(_zk_host): "PVC_ZOOKEEPER": Set the cluster Zookeeper address instead of using "--zookeeper". - If no PVC_ZOOKEEPER/--zookeeper is specified, attempts to load coordinators list from /etc/pvc/pvcd.conf. + If no PVC_ZOOKEEPER/--zookeeper is specified, attempts to load coordinators list from /etc/pvc/pvcd.yaml. """ - # If no zk_host was passed, try to read from /etc/pvc/pvcd.conf; otherwise fail + # If no zk_host was passed, try to read from /etc/pvc/pvcd.yaml; otherwise fail if _zk_host is None: - import configparser - try: - config_file = '/etc/pvc/pvcd.conf' - o_config = configparser.ConfigParser() - o_config.read(config_file) - _zk_host = o_config['default']['coordinators'] + cfgfile = '/etc/pvc/pvcd.yaml' + o_config = yaml.load(cfgfile) + _zk_host = o_config['pvc']['cluster']['coordinators'] except: _zk_host = None if _zk_host is None: - print('ERROR: Must specify a PVC_ZOOKEEPER value or have a coordinator set configured in /etc/pvc/pvcd.conf.') + print('ERROR: Must specify a PVC_ZOOKEEPER value or have a coordinator set configured in /etc/pvc/pvcd.yaml.') exit(1) global zk_host diff --git a/debian/control b/debian/control index 30947eea..e18bf30b 100644 --- a/debian/control +++ b/debian/control @@ -25,7 +25,7 @@ Description: Parallel Virtual Cluster common client libraries (Python 3) Package: pvc-client-cli Architecture: all -Depends: pvc-client-common +Depends: pvc-client-common, python3-yaml Description: Parallel Virtual Cluster client (Python 3) The Parallel Virtual Cluster provides a management solution for QEMU/KVM virtual clusters. .