apama.project¶
Contains PySys extensions for projects: creating, manipulating and deploying.
ProjectHelper¶
-
class
apama.project.
ProjectHelper
(testcase, name, projectRoot=None, deployedPath=None)[source]¶ Bases:
object
Helper class for creating, manipulating and deploying Software AG Designer-compatible projects.
Creates an instance of the ProjectHelper class. You can have multiple projects in one test by overriding the parameters:
myProject=ProjectHelper(self,"my-project") myProject=ProjectHelper(self,"my-project",projectRoot='my-root-path') myProject=ProjectHelper(self,name="my-project",deployedPath='my-deployed-path')
- Parameters
testcase – The ProjectHelper should be initialized with an instance of a test, normally the one in which the helper is created.
name – the project name.
projectRoot – the directory that contains/will contain the project
deployedPath – the directory containing the deployed project, if this exists you must deploy with overwrite=True.
This class provides the ability to create, add and delete bundles, deploy and manipulate projects:
mycorrelator = CorrelatorHelper(self, name='mycorrelator') myProject = ProjectHelper(self,name="my-project") myProject.create() myProject.addBundle("onAppInitialized") myProject.addBundle("...") #copy monitor files into project ... myProject.deploy() #start the deployed application mycorrelator.start(config=myProject.deployedDir())
Additionally, you can use this command to use an existing project created with Software AG Designer or apama_project:
mycorrelator = CorrelatorHelper(self, name='mycorrelator') myProject = ProjectHelper(self,name="my-project-from-template") myProject.create(existingProject='path-to/my-project-template') #further set-up as above ... myProject.deploy() #start the deployed application mycorrelator.start(config=myProject.deployedDir())
-
addBundle
(name, instanceName=None, **kwargs)[source]¶ Adds a specific bundle to the project:
myProject = ProjectHelper(self,name="my-project") ... myProject.addBundle('onAppInitialized') myProject.addBundle('HTTP Server',instanceName='myHttpServerInstance')
Note that this command does not set any of the configuration. This must be done by the user in the test environment in the same way as a Designer or apama_project user needs to do this.
- Parameters
name – The bundlename to add to the project. apama_project list bundles can be used to get the current usable list.
instanceName – certain bundles can specify the instance name (optional).
kwargs – Allow named parameters, for example,timeout=XXX.
-
create
(existingProject=None, **kwargs)[source]¶ Creates the base project in the output directory by default or projectRoot if set in the constructor:
myProject = ProjectHelper(self,name="my-project-from-template") #create new myProject.create() #use existing, copies project into correct location name changed to the project name myProject.create(existingProject='path-to/my-project-template')
- Parameters
existingProject – The path of an existing Designer or apama_project project.
kwargs – Allow named parameters, for example, timeout=XXX.
-
deploy
(overwrite=False, dest=None, **kwargs)[source]¶ Deploys a runnable project.
Creates a <project name>-deployed directory in the output directory by default or projectRoot if set in the constructor. If you try to deploy to an existing directory, it will fail by default. Use overwrite=True to enable it:
myProject = ProjectHelper(self,name="my-project") ... #create runnable application, add 120s timeout to deployment via kwargs myProject.deploy(timeout=120) #create runnable application, allow redeployment to the same name myProject.deploy(overwrite=true) #create runnable application, set/override the deployment directory myProject.deploy(dest='path-to/my-override-dir',timeout=120)
- Parameters
dest – Override the destination directory for the deployed project.
overwrite – Remove an existing deployment with the same path (default is False).
kwargs – Allow named parameters, for example, timeout=XXX.
-
deployedDir
()[source]¶ Retrieves the deployed directory.
If the project has not been deployed then the command will return the path to <projectname>-deployed. If the deployed project was overridden at deployment then this will return that path.
-
removeBundle
(name=None, instanceName=None, **kwargs)[source]¶ Removes a specific bundle from the project:
myProject = ProjectHelper(self,name="my-project") ... myProject.removeBundle('onAppInitialized') #will remove ALL instances as well as the bundle myProject.removeBundle(name ='HTTP Server') #removes the instance but not the bundle unless it is the only instance myProject.removeBundle(instanceName='myHttpServerInstance')
Only one of the parameters should be specified.
- Parameters
name – If this is specified, all instances of that bundle will be removed.
instanceName – If this is specified, the specific instance will be removed.
kwargs – Allow named parameters, for example,timeout=XXX.