def deploy(self, mode, deploy_path, app, templates): """ Called from within App.deploy """ success = True deps = self.deployments if mode not in deps: raise Exception("service {0} does not support {1} deployment"\ .format(self.full_name, mode)) service_params = app.get_app_params().copy() service_params.update( namespace_params("service", self.parameters.copy())) dep_json = json.loads(fill_template_string(deps[mode], service_params)) comps = self.components for comp in dep_json["components"]: comp_name = comp["name"] for deployment in comp["deployments"]: dep_type = deployment["type"] dep_params = deployment.get("parameters", {}).copy() dep_params.update(comp.get("parameters", {})) # TODO: perhaps this should be done in a cleaner way? dep_params["name"] = comp_name dep_params[ "image-name"] = MainSettings.REGISTRY_NAME + "/" + self.full_name + "-" + comp_name final_params = dict( service_params.items() + namespace_params("component", dep_params).items()) debug_log(self.TAG, "final_params: {0}".format(final_params)) filled_comp = fill_template_string(comps[comp_name + ".json"], final_params) final_params["containers"] = filled_comp filled_template = fill_template_string( templates[dep_type + ".json"], final_params) with open( os.path.join(deploy_path, comp_name + "-" + dep_type + ".json"), "w+") as df: df.write(filled_template) return success
def get_app_params(self): # TODO some of these should be moved into some sort of a Defaults class (config file?) return namespace_params("app", { "name": self.name, "id": self.app_id, "notebooks-image": REGISTRY_NAME + "/" + self.name, "notebooks-port": 8888 })
def get_app_params(self): # TODO some of these should be moved into some sort of a Defaults class (config file?) return namespace_params("app", { "name": self.name, "id": self.app_id, "notebooks-image": MainSettings.REGISTRY_NAME + "/" + self.name, "notebooks-port": 8888 })
def deploy(self, mode, deploy_path, app, templates): """ Called from within App.deploy """ success = True deps = self.deployments if mode not in deps: raise Exception("service {0} does not support {1} deployment"\ .format(self.full_name, mode)) service_params = app.get_app_params().copy() service_params.update(namespace_params("service", self.parameters.copy())) dep_json = json.loads(fill_template_string(deps[mode], service_params)) comps = self.components for comp in dep_json["components"]: comp_name = comp["name"] for deployment in comp["deployments"]: dep_type = deployment["type"] dep_params = deployment.get("parameters", {}).copy() dep_params.update(comp.get("parameters", {})) # TODO: perhaps this should be done in a cleaner way? dep_params["name"] = comp_name dep_params["image-name"] = REGISTRY_NAME + "/" + self.full_name + "-" + comp_name final_params = dict(service_params.items() + namespace_params("component", dep_params).items()) print("final_params: {0}".format(final_params)) filled_comp = fill_template_string(comps[comp_name + ".json"], final_params) final_params["containers"] = filled_comp filled_template = fill_template_string(templates[dep_type + ".json"], final_params) with open(os.path.join(deploy_path, comp_name + "-" + dep_type + ".json"), "w+") as df: df.write(filled_template) return success