Environment
Novell Operations Center Business Service Manager 4.7
Novell Operations Center Business Service Manager 4.5
Novell Operations Center Business Service Manager 4.5
Situation
Novell Operations Center supports combining various elements, and their conditions when modelling specific business service model. This way one or more elements (sources) can be added to another element, in order to drive this element's condition and alarms. Such modelling is usually being done interactively, using product's Java client GUI.
It might be helpful in some situations to have this specific modelling task automated, and be able to add a new source to any given element using formula script. Similarly, it might also be helpful to be able to remove an existing source from the given element using formula script.
This TID provides instructions how these tasks can be done.
It might be helpful in some situations to have this specific modelling task automated, and be able to add a new source to any given element using formula script. Similarly, it might also be helpful to be able to remove an existing source from the given element using formula script.
This TID provides instructions how these tasks can be done.
Resolution
In order to ad a new source to an element, two of element's properties should be modified: SourceElements, and Children. Datatype for both properties is from formula script perspective an array of strings. Each string holds fully distinguished name of an element, which should serve as a source, and which should drive element's condition and alarms.
Below is commented code snippet, which adds an element as a source to another element:
The logic for the source removal works the other way round: first you read the whole property as an array, next you remove selected source DName from the array, and finally you write modified property back to the element. Below is code snippet which completely removes all existing sources from the given element:
When removing all source elements it is very important to pass an array, which is really empty (i.e. array.length = 0), and not an array with an empty element, like this one:
The reason is that in the last example we in fact create an array with the string name of Enterprise root element (""), and passing such parameter as a source element would create "first class" circular reference, and for sure cause troubles to your BSM server.
It is the general rule that for both source addition and source removal you should be very careful in your scripting code, and anxiously avoid circular references, because they would for sure cause serious problems to your server, up to complete blackout. Please test your code in your development environment first, and make sure that it works as expected, before deploying it in your production!
Below is commented code snippet, which adds an element as a source to another element:
// Source: DName of the source element to be added // Element: element object which should receive a new source // (First parameter is string, second parameter is object.) function AddSourceToElement(source, element) { var newSource = formula.Root.findElement(source); // we check if the source really exists if (newSource != null) { var values = element["SourceElements"]; // reading existing elements values[values.length] = newSource.DName; // adding new DName element["SourceElements"] = values; // writing back values = element["Children"]; // reading existing elements values[values.length] = newSource.DName; // adding new DName element["Children"] = values; // writing back } } |
The logic for the source removal works the other way round: first you read the whole property as an array, next you remove selected source DName from the array, and finally you write modified property back to the element. Below is code snippet which completely removes all existing sources from the given element:
// Element: element object from which we remove all sources function RemoveAllSourcesFromElement(element) { var emptyA = new Array(); element["SourceElements"] = emptyA; element["Children"] = emptyA; } |
When removing all source elements it is very important to pass an array, which is really empty (i.e. array.length = 0), and not an array with an empty element, like this one:
var myArray = new Array(""); |
The reason is that in the last example we in fact create an array with the string name of Enterprise root element (""), and passing such parameter as a source element would create "first class" circular reference, and for sure cause troubles to your BSM server.
It is the general rule that for both source addition and source removal you should be very careful in your scripting code, and anxiously avoid circular references, because they would for sure cause serious problems to your server, up to complete blackout. Please test your code in your development environment first, and make sure that it works as expected, before deploying it in your production!