def slate_deploy(): module_root = get_module_root() print(f"Module root: {module_root}") conf_path = f'{module_root}conf' print(f"conf_path: {conf_path}") plan_path = f'{module_root}plan' print(f"plan_path: {plan_path}") env = 'docker' apply_kube = True plan_format = 'yaml' vars_conf_path = f'{conf_path}/{env}/slate-vars.conf' storage_conf_path = f'{conf_path}/{env}/slate-storage.conf' pv_conf_path = f'{conf_path}/slate-pv.conf' pvc_conf_path = f'{conf_path}/slate-pvc.conf' deploy_file_path = f'{conf_path}/slate-deploy.conf' confs = [ vars_conf_path, storage_conf_path, pv_conf_path, pvc_conf_path, deploy_file_path ] included = wrap_included(confs) print(f'\nincluded: {included}') conf = Cf.parse_string(included) storage_plan = HOCONConverter.convert(conf.storage, plan_format, 2) pv_plan = HOCONConverter.convert(conf.pv, plan_format, 2) pvc_plan = HOCONConverter.convert(conf.pvc, plan_format, 2) deploy_plan = HOCONConverter.convert(conf.deploy, plan_format, 2) print(f'\n{storage_plan}') print(f'\n{pv_plan}') print(f'\n{pvc_plan}') print(f'\n{deploy_plan}') plans1 = [(f'{plan_path}/slate-storage.{plan_format}', storage_plan), (f'{plan_path}/slate-pv.{plan_format}', pv_plan), (f'{plan_path}/slate-pvc.{plan_format}', pvc_plan), (f'{plan_path}/slate-deploy.{plan_format}', deploy_plan)] plan(plans1) for pl in plans1: os.system(f"kubectl apply -f {pl[0]};") # Observe the pods created init_observe_pods(deploy_tuple=('slate', f'{plan_path}/slate-deploy.{plan_format}'), use_minikube_repo=False, callback=slate_deploy_init_callback, init=False)
def _test_convert(self, input, expected_output, format): with tempfile.NamedTemporaryFile('w') as fdin: fdin.write(input) fdin.flush() with tempfile.NamedTemporaryFile('r') as fdout: HOCONConverter.convert(fdin.name, fdout.name, format) with open(fdout.name) as fdi: converted = fdi.read() assert [line.strip() for line in expected_output.split('\n') if line.strip()]\ == [line.strip() for line in converted.split('\n') if line.strip()]
def run(self, df): #return df.agg(['mean', 'min', 'max']) rConfigTree = ConfigFactory.parse_file( 'defaultLeaderboardResponse.conf').get("LeaderboardComprehensive") r = HOCONConverter.convert(rConfigTree, 'json') print(r) return r
def plan(self): for res in self.ordered_kube_resources: plan = Hc.convert(self.conf[res], self.plan_format.value, 2) logging.info(f'\n{plan}') self.plans.append(plan) if not os.path.exists(self.plan_dir): os.makedirs(self.plan_dir) plan_path = self.to_plan_path(res=res) with open(plan_path, 'wt') as file_out: file_out.write(plan) self.plan_paths.append(plan_path)
def json_string_config(conf): lines = HOCONConverter.convert(conf, indent=1) return ' '.join(lines)
def dump_config(conf, filename, output_format='hocon'): lines = HOCONConverter.convert(conf, output_format, indent=4) with open(filename, 'w') as fh: fh.writelines(lines)