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!
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...
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
}
This question comes-up a lot on community and there are some previous posts on it. Have a look at this thread, and in particular this response.
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
}
Looking great! I will definitely try this.
Just what the doctor ordered. Thanks!
There is a tool ("ompare") on the InterSystems Open Exchange for comparing environments. You might find that it does a lot of what you need.
https://openexchange.intersystems.com/package/ompare
(The author is @Alex Woodhead )
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.
Hi, Markus, I put an app together inspired by your question. You can find it in Open Exchange and it is participating in Full Stack Contest:
https://openexchange.intersystems.com/package/interoperability-manager
https://openexchange.intersystems.com/contest/24
Thanks everyone for your answers! I will take a closer look at these, especially those built apps and tools.