From aee89701e994336f2618d2e396a2d6b8319f5882 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Mon, 23 Apr 2012 18:50:38 +0530 Subject: [PATCH] CS-14596: check existence of config file before loading Check whether the config file to load cloudstack config is avvailable in the specified path. --- tools/marvin/marvin/configGenerator.py | 2 +- tools/marvin/marvin/deployDataCenter.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/marvin/marvin/configGenerator.py b/tools/marvin/marvin/configGenerator.py index ba639ff9882..7967ab43ccd 100644 --- a/tools/marvin/marvin/configGenerator.py +++ b/tools/marvin/marvin/configGenerator.py @@ -380,7 +380,7 @@ def generate_setup_config(config, file=None): def get_setup_config(file): if not os.path.exists(file): - return None + raise IOError("config file %s not found. please specify a valid config file"%file) config = cloudstackConfiguration() fp = open(file, 'r') config = json.load(fp) diff --git a/tools/marvin/marvin/deployDataCenter.py b/tools/marvin/marvin/deployDataCenter.py index aa40b00fba8..39b5e4e6f26 100644 --- a/tools/marvin/marvin/deployDataCenter.py +++ b/tools/marvin/marvin/deployDataCenter.py @@ -15,6 +15,7 @@ import configGenerator import cloudstackException import cloudstackTestClient import sys +import os import logging from cloudstackAPI import * from optparse import OptionParser @@ -22,6 +23,8 @@ from optparse import OptionParser class deployDataCenters(): def __init__(self, cfgFile): + if not os.path.exists(cfgFile): + raise IOError("config file %s not found. please specify a valid config file"%cfgFile) self.configFile = cfgFile def addHosts(self, hosts, zoneId, podId, clusterId, hypervisor):