We need to develop a Linux bash script to import/export Ensemble's namespaces.

Hi!

We need to use a bash script under Linux in order to export a namespace's clases (*.cls), project (*.prj), *.inc and all related stuff (except generated and mapped clases). All these elements must be stored on a XML file.

We need to use a bash script under Linux to import and compile previously exported XML file (from Studio, Management Portal, or Export Script) .

Can anyone help us to develop them?
Thanks in advance!

  • 0
  • 0
  • 544
  • 3
  • 2

Answers

Hi Mario,

I guess you need to run some routine to export/import your classes from a Linux shell.

You can use operating system authentication when opening a terminal session:

- Allow "Operating System authentication" in System > Security Management > Authentication/CSP Session Options

- Allow "Operating System authentication" System > Security Management > Services > Terminal
- Create a user in cache with the same username as the user in Linux that will run the bash script.

 

Then you can just invoke a routine / classmethod from your linux shell and use $system.OBJ.Export / Import to export or import classes, include files, etc.

You should also think about using Ens.Director to stop / start production or business hosts as needed.
For instance:

[cacheowner@demo tmp]$ whoami
cacheowner
[cacheowner@demo tmp]$ ccontrol session HSEX15 "##class(Test.MyClass).Run()"
Run!
Exporting to XML started on 12/23/2015 16:25:57
Exporting routine: Test.MyInclude.inc
Export finished successfully.

Where:
Class Test.MyClass Extends %RegisteredObject
{
ClassMethod Run() As %Status
{
set ret = $$$OK
try {
write "Run!",!
do $system.OBJ.Export("Test.MyInclude.inc","/tmp/include.xml")
} catch ex {
set ret = ex.AsStatus()
do $system.Status.DisplayError(ret)
}
quit ret
}
}

Anyway, you can check out the Ensemble production deployment capabilities:
http://docs.intersystems.com/ens20152/csp/docbook/DocBook.UI.Page.cls?KEY=EGDV_deploying

Comments

Great! We'll take this into account to develop our scripts.

Thank you very much, guys!

Have a nice day!

Maybe if need not just import sources from xml, but some more actions. And anyway one more interesting way to deploy your code, is using Installer Manifest. With this manifest, you can just import your code to any namespace, or before it, create namespace, csp-applications, do some configurations for your application. For further information see documentation.

In our project we use manifest for build project, and for deploy on a new servers.

I lean toward the manifest solution: By explicitly creating configuration changes in code, one avoids the problems of having to import and export the changes which carries the risk of missing something and also the risk of propagating a change unintentionally.


I prefer using configuration exports for detecting out-of-band changes to configuration and triggering a corrective workflow where needed; this allows for the [hopefully] rare cases where not all changes should be propagated between environments.