def registerCompositionAdvice(self, joinpoint): composition = joinpoint.kwargs['composition'] weave(target=composition._callCLI, advices=self.compositionCallCLIAdvice) result = joinpoint.proceed() if composition: #Now get the config for the composition and dump out. self.composition = composition configAsYaml = composition.getConfig() (dokerComposeYmlFileName, fileExists) = self.contextHelper.getTmpPathForName( name="docker-compose", extension="yml") with open(dokerComposeYmlFileName, 'w') as f: f.write(configAsYaml) self.output.write( env.get_template("html/composition-py.html").render( compose_project_name=self.composition.projectName, docker_compose_yml_file=dokerComposeYmlFileName)) self.output.write( env.get_template("html/header.html").render( text="Configuration", level=4)) self.output.write( env.get_template("html/cli.html").render(command=configAsYaml)) #Inject the graph self.output.write( env.get_template("html/header.html").render( text="Network Graph", level=4)) self.output.write(env.get_template("html/graph.html").render()) return result
def __init__(self, context, peerCompositionCallback): CallbackHelper.__init__(self, discriminator="composer") self.context = context # Store the other compositionCallback helpers for later usage. self.peerCompositionCallback = peerCompositionCallback Composition.RegisterCallbackInContext(self.context, self) # Weave advices into Directory to intercept config admins list self.directory = getDirectory(self.context) weave(target=self.directory.find_config_admins_for_org, advices=self._directory_find_config_admins_for_org_advice)
def _bind_target(self, target, ctx=None, *args, **kwargs): """Weave self.intercepts among target advices with pointcut.""" result = super(Interceptor, self)._bind_target( target=target, ctx=ctx, *args, **kwargs ) pointcut = getattr(self, Interceptor.POINTCUT) weave(result, pointcut=pointcut, advices=self.intercepts, ctx=ctx) return result
def _bind_target(self, target, ctx=None, *args, **kwargs): """Weave self.intercepts among target advices with pointcut.""" result = super(Interceptor, self)._bind_target(target=target, ctx=ctx, *args, **kwargs) pointcut = getattr(self, Interceptor.POINTCUT) weave(result, pointcut=pointcut, advices=self.intercepts, ctx=ctx) return result
def registerUserAdvice(self, joinpoint): userName = joinpoint.kwargs['userName'] newlyRegisteredUser = joinpoint.proceed() #Write out key material privateKeyAsPem = newlyRegisteredUser.getPrivateKeyAsPEM() (fileName, fileExists) = self.contextHelper.getTmpPathForName(name="dir-user-{0}-privatekey".format(userName), extension="pem") with open(fileName, 'w') as f: f.write(privateKeyAsPem) #Weave into user tags setting weave(target=newlyRegisteredUser.setTagValue, advices=self.userSetTagValueAdvice) #Now the jinja output self.output.write(env.get_template("html/user.html").render(user=newlyRegisteredUser, private_key_href=self._getLinkInfoForFile(fileName))) return newlyRegisteredUser
def pointcut(self, value): """Change of pointcut. """ pointcut = getattr(self, Interceptor.POINTCUT) # for all targets for target in self.targets: # unweave old advices unweave(target, pointcut=pointcut, advices=self.intercepts) # weave new advices with new pointcut weave(target, pointcut=value, advices=self.intercepts) # and save new pointcut setattr(self, Interceptor._POINTCUT, value)
def pointcut(self, value): """Change of pointcut. """ pointcut = getattr(self, Interceptor.POINTCUT) # for all targets for target in self.targets: # unweave old advices unweave(target, pointcut=pointcut, advices=self.intercepts) # weave new advices with new pointcut weave(target, pointcut=value, advices=self.intercepts) # and save new pointcut setattr(self, Interceptor._POINTCUT, value)
def registerCompositionAdvice(self, joinpoint): composition = joinpoint.kwargs['composition'] weave(target=composition._callCLI, advices=self.compositionCallCLIAdvice) result = joinpoint.proceed() if composition: #Now get the config for the composition and dump out. self.composition = composition configAsYaml = composition.getConfig() (dokerComposeYmlFileName, fileExists) = self.contextHelper.getTmpPathForName(name="docker-compose", extension="yml") with open(dokerComposeYmlFileName, 'w') as f: f.write(configAsYaml) self.output.write(env.get_template("html/composition-py.html").render(compose_project_name= self.composition.projectName,docker_compose_yml_file=dokerComposeYmlFileName)) self.output.write(env.get_template("html/header.html").render(text="Configuration", level=4)) self.output.write(env.get_template("html/cli.html").render(command=configAsYaml)) #Inject the graph self.output.write(env.get_template("html/header.html").render(text="Network Graph", level=4)) self.output.write(env.get_template("html/graph.html").render()) return result
def registerCompositionAdvice(self, joinpoint): composition = joinpoint.kwargs['composition'] weave(target=composition._callCLI, advices=self.compositionCallCLIAdvice) result = joinpoint.proceed() if composition: #Now get the config for the composition and dump out. self.composition = composition configAsYaml = composition.getConfig() self.output.write( env.get_template("html/header.html").render( text="Configuration", level=4)) self.output.write( env.get_template("html/cli.html").render(command=configAsYaml)) #Inject the graph self.output.write( env.get_template("html/header.html").render( text="Network Graph", level=4)) self.output.write(env.get_template("html/graph.html").render()) return result
def __init__(self, contextHelper, scenario): self.contextHelper = contextHelper self.directory = getDirectory(contextHelper.context) self.output = StringIO() self.currentStep = 0 self.composition = None #Weave advices into contextHelper weave(target=self.contextHelper.before_step, advices=self.beforeStepAdvice) weave(target=self.contextHelper.after_step, advices=self.afterStepAdvice) weave(target=self.contextHelper.after_scenario, advices=self.afterScenarioAdvice) weave(target=self.contextHelper.getBootrapHelper, advices=self.getBootstrapHelperAdvice) weave(target=self.contextHelper.registerComposition, advices=self.registerCompositionAdvice) # Weave advices into Directory weave(target=self.directory._registerOrg, advices=self.registerOrgAdvice) weave(target=self.directory._registerUser, advices=self.registerUserAdvice) weave(target=self.directory.registerOrdererAdminTuple, advices=self.registerNamedNodeAdminTupleAdvice)
def getBootstrapHelperAdvice(self, joinpoint): bootstrapHelper = joinpoint.proceed() weave(target=bootstrapHelper.signConfigItem, advices=self.bootstrapHelperSignConfigItemAdvice) return bootstrapHelper
def __init__(self, contextHelper, scenario): self.contextHelper = contextHelper self.directory = getDirectory(contextHelper.context) self.output = StringIO() self.currentStep = 0 self.composition = None #Weave advices into contextHelper weave(target=self.contextHelper.before_step, advices=self.beforeStepAdvice) weave(target=self.contextHelper.after_step, advices=self.afterStepAdvice) weave(target=self.contextHelper.after_scenario, advices=self.afterScenarioAdvice) weave(target=self.contextHelper.getBootrapHelper, advices=self.getBootstrapHelperAdvice) weave(target=self.contextHelper.registerComposition, advices=self.registerCompositionAdvice) # Weave advices into Directory weave(target=self.directory._registerOrg, advices=self.registerOrgAdvice) weave(target=self.directory._registerUser, advices=self.registerUserAdvice) weave(target=self.directory.registerOrdererAdminTuple, advices=self.registerNamedNodeAdminTupleAdvice)
def getBootstrapHelperAdvice(self, joinpoint): bootstrapHelper = joinpoint.proceed() weave(target=bootstrapHelper.signConfigItem, advices=self.bootstrapHelperSignConfigItemAdvice) return bootstrapHelper