Question
Markus Suonpää · Jul 1

How to access Production items through Objectscript?

How do I access items and their settings of production by using Objectscript? I have already tried making SQL queries to Ens_Config.Production table and using methods in Ens.Director and EnsPortal.Utils classes but I just can't get a hang of it.

The unfortunate reason, why I need to do this, is that our environments (DEV, QA and PROD) have gone in really bad shape over the years and now the software development is just pure agony since environments are not in sync. Comparing different environments is also extremely difficult since it is hard to even tell which classes are in use. The idea was to go through all the items in production class, label "archived" business hosts which are disabled and list classes that they are using. Maybe even removing these unused hosts and classes automatically. This way it would be easier to compare environments and make necessary changes to accomplish CI/CD pipelines one day.

Does anyone have any ideas how this could be done? Ens.Director class's method getProductionItems() seems quite obvious but I don't know how to use it.

Thanks already! 

Product version: IRIS 2020.1
0
0 256
Discussion (9)1
Log in or sign up to continue

Interesting question. I looked in Documentation and found a CreateDocumentation classMethod. I tried to test it with this code. I got an error in my Production. Let me know if this helps you. I will look at getProductionItems() next...

ClassMethod CreateDocumentation(
pProduction As %String = "",
pIntro As %Boolean = 1,
pFormat As %String,
Output LogFileName As %String,
Output URL As %String,
Output BookName As %String,
PDFFileName As %String,
PDFRenderer As %String,
ByRef Params As %String,
pAllSettings As %Boolean = 0) As %Status
{
Set tSC = $$$OK
If (pProduction = "") {
Set pProduction = ##class(Ens.Director).GetActiveProductionName()
}
Try {
Set tSC = ##class(%SYS.Ensemble).CreateDocumentation(pProduction,pIntro,$G(pFormat),.LogFileName,.URL,.BookName,$G(PDFFileName),$G(PDFRenderer),.Params,pAllSettings)
Catch {
Set tSC = ##class(%SYS.Ensemble).CreateDocumentation(pProduction,pIntro,$G(pFormat),.LogFileName,.URL,.BookName,$G(PDFFileName),$G(PDFRenderer),.Params)
}
Do $System.Status.DisplayError(tSC)
ZW
Quit tSC
}
 

I have tried using getProductionItems() using this code:

ClassMethod GetProductionItems(
pProd As %String,
pDefinition As %String,
pAutoAdd As %String) As %Status
{
Set tSC = $$$OK
If ($Get(pProd) = "") {
Set pProd = ##class(Ens.Director).GetActiveProductionName()
}
Set tProduction = ##class(Ens.Config.Production).%OpenId(pProd)
Set tSC = ##class(Ens.Director).getProductionItems(tProduction,.pDefinition,.pAutoAdd)
ZW
Quit tSC
}
 

There is a light weight, no-install, mini-version of this for comparing differences in the IRIS platform in your web-browser.

Will give an idea whether you wish to invest time into this approach: https://alexatwoodhead.github.io/ompare/index.html

I can look to make the reporting side of the main project runnable in a docker container if will be an easier experience. In addition to Properties, Methods, Parameters the main project does drill down into real code diffs Methods, routines and XData.

For production setting comparison I use the SQL projection comparison feature.

Thanks everyone for your answers! I will take a closer look at these, especially those built apps and tools.