def configure(self, ctx): config = ctx.service.config if not hasattr(config, 'configure'): return configure = config.configure if hasattr(configure, 'patch'): patchConfig = configure.patch destination = ctx.service.config.install.destination #resourceDir = tempfile.gettempdir() + "/" + server.hostname + "_patch" resourceDir = self.getWorkingDir( ) + "/" + ctx.server.hostname + "_patch" try: FileUtil.cptree(patchConfig.resourceDir, resourceDir) self.modifyResources(ctx, patchConfig, resourceDir) self.info("Patch the configuration from " + patchConfig.resourceDir) ctx.platform.scp(ctx.account, ctx.server, resourceDir + "/*", destination) self.execConfigureExecute(ctx, ctx.service.config.configure) customServiceConfigPerServer = getattr(ctx.server.services, ctx.service.name) if hasattr(customServiceConfigPerServer, "configure"): self.execConfigureExecute( ctx, customServiceConfigPerServer.configure) finally: FileUtil.rmtree(resourceDir)
def testUpdateWithProperties(self): workingDir = dirname(realpath(__file__)) + "/working" FileUtil.mkdirs(workingDir) properties = {"account.dev": "dev"} source = workingDir + "/test-properties.txt" FileUtil.writeText(source, "account.dev=${account.dev}") destination = workingDir + "/test-properties-update.txt" FileUtil.updateWithProperties(source, destination, properties) content = FileUtil.readAsText(destination) self.assertEqual("account.dev=dev", content) FileUtil.rmtree(workingDir)
def testUpdateWithProperties(self): workingDir = dirname(realpath(__file__)) + "/working"; FileUtil.mkdirs(workingDir) properties = { "account.dev": "dev" } source = workingDir + "/test-properties.txt" FileUtil.writeText(source, "account.dev=${account.dev}") destination = workingDir + "/test-properties-update.txt" FileUtil.updateWithProperties(source, destination, properties) content = FileUtil.readAsText(destination) self.assertEqual("account.dev=dev", content) FileUtil.rmtree(workingDir)
def configure(self, ctx): config = ctx.service.config if not hasattr(config, 'configure'): return configure = config.configure; if hasattr(configure, 'patch'): patchConfig = configure.patch destination = ctx.service.config.install.destination #resourceDir = tempfile.gettempdir() + "/" + server.hostname + "_patch" resourceDir = self.getWorkingDir() + "/" + ctx.server.hostname + "_patch" try: FileUtil.cptree(patchConfig.resourceDir, resourceDir) self.modifyResources(ctx, patchConfig, resourceDir) self.info("Patch the configuration from " + patchConfig.resourceDir) ctx.platform.scp(ctx.account, ctx.server, resourceDir + "/*", destination) self.execConfigureExecute(ctx, ctx.service.config.configure) customServiceConfigPerServer = getattr(ctx.server.services, ctx.service.name) if hasattr(customServiceConfigPerServer, "configure"): self.execConfigureExecute(ctx, customServiceConfigPerServer.configure) finally: FileUtil.rmtree(resourceDir)