def run(self): self.parse_options() if self.opt.conf is None: print "You must specify a configuration file using the -c/--conf option." exit(1) self._check_exists_file(self.opt.conf) if self.opt.topology is None: topology_file = self.opt.conf else: self._check_exists_file(self.opt.topology) topology_file = self.opt.topology if topology_file.endswith(".json"): jsonfile = open(topology_file) topology_json = jsonfile.read() jsonfile.close() elif topology_file.endswith(".conf"): try: conf = SimpleTopologyConfig(topology_file) topology = conf.to_topology() topology_json = topology.to_json_string() except ConfigException, cfge: self._print_error("Error in topology configuration file.", cfge) exit(1)
def load_config_file(f, dummy): configf = open(f) config_txt = configf.read() if dummy: config_txt = config_txt.replace("deploy: ec2", "deploy: dummy") configf.close() topology_file = f conf = SimpleTopologyConfig(topology_file) topology = conf.to_topology() topology_json = topology.to_json_string() return config_txt, topology_json