IBM Control Desk v7.5: Automating authorized and actual CI linking

 IBM Control Desk v7.5:
Automating authorized and actual CI
linking
Document version 1.0 December 24, 2015 Morten Moeller ([email protected]) IBM Middleware, Advanced Technology Group IBM Control Desk v7.5: Automating authorized and actual CI linking page 2 IBM Control Desk v7.5: Automating authorized and actual CI linking Introduction This document provides an overview of a solution to automate the linkage of authorized and actual CIs in an IBM Control Desk V7.5 environment. It is assumed that the reader is familiar with the basics capabilities of the Tivoli process automation environment, IBM Control Desk configuration items classifications, and can independently manage basic objects such as automation scripts, launch points, escalations, and actions. Many organizations have expressed the desire to be able to automate the linking of authorized and actual CIs in order to be able to quickly audit and synchronize authorized CIs with minimal human intervention. In the following it will be demonstrated how you can automate some of the work normally performed by the Configuration Librarian., to automating the linkage process. The automation is implemented trough escalations or reconciliation tasks and this allows you to specify the exact conditions under which the automated linkage occurs. By applying conditions and escalation points you can consider the automated linkage similar to preapproved changes: Trivial, reoccurring tasks that can be performed without specific approval because of their specific characteristics and benign nature. Linkage of authorized and actual CIs can be based on the naming rules defined in the Common Data Model, or based on custom attributes. In the following, it will be demonstrated how to automate both types of lining. For both types of linking, the following describes how to: 
Define the automation script that performs the desired action 
Create the necessary Launch Points 
Create an escalation that activates the action page i IBM Control Desk v7.5: Automating authorized and actual CI linking For more details regarding the creation, specification and use of automation script, please refer to the excellent article entitled Scripting with Maximo which is available at: https://www.ibm.com/developerworks/mydeveloperworks/groups/service/html/communityview?communi
tyUuid=a9ba1efe­b731­4317­9724­
a181d6155e3a#fullpageWidgetId=W5f281fe58c09_49c7_9fa4_e094f86b7e98&file=83c7752c­a621­
4af9­bb32­d6ba7d612ab2. In addition to automating the authorized and actual CI linkage you may be interested in automating promotion of actual CIs or the synchronization of authorized CIs. For more information on how to achieve this, please refer to Automated CI 0Promotion and Synchronization at https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/IBM%20SmartCloud%20C
ontrol%20Desk/page/SCCD751%20Automated%20CI%20Promotion%20and%20Synchronization. This article also provides additional background on managing and automation scripts and excellent guidance on how to debug your scripts.
page ii IBM Control Desk v7.5: Automating authorized and actual CI linking Table of Contents 1 CI linking ............................................................................................................................ 1 2 Naming rule based linkage ............................................................................................... 4 2.1 Defining the ZZ­LINKCI automation script ...................................................................... 5 2.2 Define input variables ..................................................................................................... 9 2.3 Create launch points ..................................................................................................... 14 2.3.1 Create the ZZ‐LINKCI‐ACT‐LP action launchpoint ................................................................. 14 2.3.2 Create the ZZ‐LINKCI‐RECONCILINK‐ONADD‐LP object launchpointError! Bookmark not defined. 3 2.4 Create the ZZ­LINKCI­ACT­GROUP ............................................................................ 17 2.5 Create the ZZ­LINKCI­ESC escalation ......................................................................... 21 2.6 Verifying naming rule based linking .............................................................................. 27 Specification attribute based linking ............................................................................. 28 3.1 Creating the reconciliation task .................................................................................... 29 3.1.1 Define the ZZ‐LINK‐NON‐DECOMMISSIONED‐CIS task filter ................................................ 30 3.1.2 Specify the ZZ‐LINKCI‐FQDN‐LR link rules ............................................................................. 32 3.1.3 Creating the ZZ‐LINKCI‐RECON‐FQDN‐RT reconciliation task ............................................... 36 3.1.4 Verifying CI and actual CI reconciliation ............................................................................... 38 3.2 Reconciliation based linking ......................................................................................... 40 3.3 Automating reconciliation based linking ....................................................................... 42 3.3.1 Defining the ZZ‐LINKCI‐RECONCILINK‐ONADD‐LP object launch point ................................ 43 4 The ZZ­LINKCI.py script.................................................................................................. 48 page iii IBM Control Desk v7.5: Automating authorized and actual CI linking 1 CI linking For many years users of IBM Control Desk and its predecessor products have benefitted from the product features that rely on the dual registration of CIs. Functions such as immediate discrepancy view and CI Audit could not have been implemented unless both the current (actual) state and the planned (authorized) state of the CIs and all their attributes and relationships are represented in the IBM Control Desk database. Ideally, the actual and authorized representation of a CI should be identical – or rather, the authorized representation should be a subset of the actual representation, but the values for all common attributes should be identical. To determine if this is the case, authorized CIs must be associated (linked) with the actual CIs that represent the same resource. This link is normally established manually by the Configuration Librarian. To link authorized and actual CIs the Configuration Librarian can one of multiple approaches: 
Linking based on naming rule attributes 
Linking based on specification attributes which may or may not be included in naming rule attributes 
Manual linking of two discrete CIs 
By synchronizing top­level authorized CIs that are associated with a promotion scope 
By promoting the actual CI associated with a promotion scope IBM Control Desk uses naming rules to generate a unique identifier for all CIs. This identifier is known as the NRSGUID or DISGUID. For each classification the combination of one or more sets of specification attributes is defined as a naming rule. The combination of the attributes referenced in each naming rule can be used to generate the NRSGUID for the CI. If the NRSGUID for an authorized CI matches the NRSGUID of an actual CI, it is assumed that the two CIs represent the same resource. In IBM Control Desk the Configuration Librarian can use the ‘Link to Actual CI’ action from a CI application to link an authorized CI to its actual CI counterpart based on the calculated NRSGUID. In the following it will be demonstrated how this action can be automated, so that IBM Control Desk automatically recognizes and links authorized and actual CI pairs that represent the same resources – if the specification attribute values are identical. page 1 IBM Control Desk v7.5: Automating authorized and actual CI linking However, in many situations authorized CIs are created prior to their physical implementation. This implies that only a few specification attributes, such as hostname, fqdn, IP address, logical name or listening port are known at the time the CI is created. Unfortunately, it is unlikely that these attributes can be used to provide a unique identifier for the CI, and therefore special measures must be applied to link an authorized CI to its actual sibling. In IBM Control Desk reconciliation tasks can be defined to reconcile authorized and actual CIs based on combinations of specification attributes, for example fqdn. Linking based on reconciliation should be used with caution, because there is no way of ensuring uniqueness of the authorized CIs. Because the fqdn is not a naming rule attribute, multiple authorized CIs can exist with the same fqdn (for example an old system that has been decommissioned, and a new system that is operational). Nevertheless, if the process of creating authorized CIs is adequately rigid to ensure uniqueness of specification attributes, reconciliation tasks can be used to identify pairs of CIs that represent the same resource. As a matter of fact, the reconciliation tasks identify situations in which multiple pairs of authorized and actual CI match, and in that case, the CIs will not be associated. Even though some of the information generated by reconciliation tasks is named ‘CI Link Results’ the reconciliation tasks themselves do not link authorized and actual CIs. Reconciliation tasks simply record the association between authorized and actual CIs by creating RECONCILINK objects in the IBM Control Desk database. In the following, it will be demonstrated how this information can be leveraged to automate the linkage of authorized and actual CIs. So far it has been assumed that there are some common attributes that can be used to identify pairs of authorized and actual CIs. If this is not the case, the Configuration Librarian can link an authorized CI to a discrete actual CI through the CI application simply by supplying the actual CI number. In doing so there are no checks and balances that ensure that the two involved CIs represent the same type of resource and no checks if they have similar specification attributes. This manual linkage is at the discretion of the Configuration Librarian, and should be used with caution. It goes without saying that automating the manual linkage is not possible ­ and not desirable. page 2 IBM Control Desk v7.5: Automating authorized and actual CI linking In some instances, the authorized CIs you which to link do not even exist. Typically only top­level authorized CIs are created prior to implementation to serve as placeholders for specification attributes. It is very common that related CIs are created through synchronization once the top­level CI and its related CIs have materialized themselves in the IT infrastructure, have been discovered by TADDM, and are loaded into the IBM Control Desk as actual CIs. At this point the actual CI that represents the same resource as the authorized placeholder CI has a number of related CIs – each of which may have its own set of related CIs. When the authorized CI is linked to the actual CI it can be synchronized. Synchronization implies that specification attributes, relationships, and related CIs of the authorized CI are updated and augmented with the values and resources represented in the linked actual CI. Related actual CIs that are not already represented as authorized CIs will be created automatically, and related the authorized CI. During synchronization, all involved authorized and actual CIs are linked automatically. The synchronization process is controlled by a promotion scope, that defines which attributes and related CIs to include in the process, The key to synchronizing authorized CIs is that the link to an actual CI has been established in advance, which is why it is attractive to be able to automate the linkage, so that synchronization can be automated as well. Finally, authorized CIs and actual CIs can be linked though the promotion process. Promotion works similar to synchronization, but does not require that the top­level CI exist. Because of this, promotion does not require that authorized and actual CIs are linked. Promotion is initiated from the actual CI, and during the process, authorized CIs that represent the same resources as the actual CI, and its related CIs, are created and linked automatically. This process is often used to create authorized CIs for resources that have been discovered, but for which no authorized have been created. In summary, authorized and actual CIs can be linked through different processes. Depending on the process that controls creation and maintenance of authorized CIs, automating the linkage may be desirable to enable automated synchronization or simply to facilitate quick audit in the IBM Control Desk user interface. page 3 IBM Control Desk v7.5: Automating authorized and actual CI linking 2 Naming rule based linkage The most accurate way of linking authorized and actual CIs is through the naming rule based process. This can be invoked manually from the Configuration Items application for unlinked CIs. The manual naming rule based linking process can be automated using an automation script that invokes the same methods as are called from the Configuration Management application. To identify authorized CIs to link, and execute the automation script, an escalation is used. The escalation point in the escalation launches an action group that references an action to invoke a launch point that executes the automation script and parses arguments to the script. The escalation schedule determines the frequency with which the condition is evaluated. For all the authorized CIs that pass the condition – for example all unkinked CIs – the escalation point invokes the members of the associated action group. The executes an automations script, and parses arguments, such as the CI that passed the escalation condition, in accordance with the launch point referenced in the action. Finally the script calls the appropriate java method to launch the naming rule based linkage. To set up the definitions within IBM Control Desk, you work your way backwards, starting by defining the automation script, the action launch point, the action group and the escalation. All of these activities must be performed by a user that is authorized to manipulate the related object types ­ or example maxadmin. page 4 IBM Control Desk v7.5: Automating authorized and actual CI linking 2.1 Defining the ZZ­LINKCI automation script To define the automation script, follow these simple steps: 1. Download the accompanying ZZ-LINKCI.py script to your local workstation. 2. From a browser on your local workstation, log in to the IBM Control Desk environment as an authorized user. 3. Launch the Automation script from GoTo > System Administration > Platform Configuration > Automation Scripts. page 5 IBM Control Desk v7.5: Automating authorized and actual CI linking 4. Create a new automation script by clicking Create > Script from the More Actions pane. 5. To specify the new automation script do the following: a. Provide the following information: Script ZZ-LINKCI Description Link CI to actual CI using naming rules page 6 IBM Control Desk v7.5: Automating authorized and actual CI linking b. To import the downloaded script, click Browse. c. Locate the previously downloaded ZZ-LINKCI.py script and click Open to transfer the file name to the Import field. If you do not see the file in the expected location, make sure that the file name filter includes All Files (*.*) page 7 IBM Control Desk v7.5: Automating authorized and actual CI linking d. When the Import a Script File field has been populated, click Import Notice that the Script Source field is populated. 6. Click Create. 7. When you see the confirmation message click Close. The ZZ­LINKCI automation script that calls the IBM Control Desk java methods to link authorized and actual CIs has now been created. Next you need to define the variables that are parsed to the script when it is invoked. page 8 IBM Control Desk v7.5: Automating authorized and actual CI linking 2.2 Define script variables The automation script you just created can perform both naming rule based and reconciliation based linking. The specific type of linking to perform is controlled by an input variable. This allows you to invoke the script to automate the linking in the following situations: 
An authorized CI is not linked to an actual CI and naming rule attributes for the pair of CIs match 
A pair of authorized and an actual CIs have been reconciled (based on specification attributes) but the authorized CI is not linked to any actual CI This implies that the automation script should be invoked through an escalation action related to CI objects that are not already linked (the ACTCINUM attributes is empty) ­ or whenever a new RECONCILINK object is created by a reconciliation task. To control the behavior of the script in these two very different situations a number of input variables are used. The input variables are all literal variables, and must be specified for each launch point. The variables and their purpose are: linkType Controls if the script should attempt to perform naming rule based linking, reconciliation based linking, or both. If you want the script to attempt to perform both types of linking, you can also specify which linking type to attempt first. isAsync Is used to control whether the naming rule based linking is performed asynchronously. Asynchronous linking will minimize the processing time of the script, and is desirable if you attempt to perform many linking operations. toEmailAddr The email address of the user who will receive an email with the linkage results if the naming rule based linking is performed asynchronously. testOnly A switch that allows you to test the script without actually performing the linking. page 9 IBM Control Desk v7.5: Automating authorized and actual CI linking To create the input variables required by the automation script, complete these steps: 1. From the Automation Scripts application open the newly created ZZ­LINKCI script, and navigate to the Variables tab. 2. To create the linkType input variable specification follow this procedure: a. In the body of the dialog click New Row. page 10 IBM Control Desk v7.5: Automating authorized and actual CI linking b. When the variable specification appears, supply the following values: Variable linkType Description Type of linking to perform Variable Type IN Binding Type LITERAL
Binding Value NamingRuleFirst
Literal Data Type ALN Override checked c. To save the action group click Save Script ( ) in the toolbar. page 11 IBM Control Desk v7.5: Automating authorized and actual CI linking 3. To create the remaining three variables, repeat the procedure in step 2 on page 10 using the variable specification values outlined in the following table. isAsync toEmailAddr testOnly Perform naming rule based Email address to send Do not perform linking asynchronously asynchronous linking results to linking Variable Type IN IN IN Binding Type LITERAL LITERAL LITERAL Literal Data Type YORN ALN YORN Binding Value N
maxadmin@<your.domain>
N
Override unchecked Unchecked Unchecked Variable Description When you assign Binding Values (default values) to the variables, consider the following usage notes related to the linkType variable: 
The linkType variable is used to determine the type of linking the script attempts. Valid options are NamingRuleOnly, ReconciliationOnly, NamingRuleFirst, and ReconciliationFirst. 
If you specify NamingRuleFirst, or ReconciliationFirst, the script will first attempt to use the specified linking type, and if it fails, the second linking type is attempted. However, if the value of isAsync is Yes, there is no way of immediately verifying the result of naming rule based linking, so reconciliation based linking will not be attempted, if the linkType is set to NamingRuleFirst. As a result, if the value of isAsync is Yes the script will operate in the same way if linkType is set to NamingRuleOnly. page 12 IBM Control Desk v7.5: Automating authorized and actual CI linking 4. When you are done, four variables should be associated with the script. 5. To return to the list of automation scripts, click List View. You have now specified the variables that will be parsed to the ZZ­LINKCI automation script when it is invoked. Next you need to define the launch points through which the script will be invoked and assign override values for the linkType variable. page 13 IBM Control Desk v7.5: Automating authorized and actual CI linking 2.3 Create an action launch point The action launch point definition is used to determine how arguments to the automation script is gathered and parsed to the script. When defining the action launch point, IBM Control Desk will also create the action that invokes the automation script. 2.3.1
Create the ZZ­LINKCI­ACT­LP action launchpoint To create the ZZ­LINKCI­ACT­LP action launch point as well as the ZZ­LINKCI­ACT action, complete these steps: 1. From the Automation Scripts application, create new action launch point by clicking Create > Script with Action Launch Point in the More Actions pane. page 14 IBM Control Desk v7.5: Automating authorized and actual CI linking 2. To specify the launch point do the following: a. In the Create Script with Action Launch Point : Step 1 of 3 dialog provide the following information: Launch Point ZZ-LINKCI-ACT-LP Description Link CI to actual CI action launch point Object CI (use the Select Value (
Action ZZ-LINKCI-ACT Description Link CI to actual CI action ) tool to locate the CI object) b. To reference the ZZ­LINKCI script you just created, click the Existing button and select the ZZ-LINKCI script using the Select Value (
) tool. c. Click Next when you are ready page 15 IBM Control Desk v7.5: Automating authorized and actual CI linking 3. In the Create Script with Action Launch Point : Step 2 of 3 dialog you can specify variables to be parsed to the script. To accept the default value for the linkType vairable (NamingRuleFirst) simply click Next. 4. In the Create Script with Action Launch Point : Step 3 of 3 dialog verify the information and click Create. 5. Click Close when you see the confirmation message. page 16 IBM Control Desk v7.5: Automating authorized and actual CI linking You have now created an action launch point and the ZZ­LINKCI­ACT action that can be used to invoke the ZZ­LINKCI automation script. Next you will create the action group that can be associated with an escalation, and add the ZZ­
LINKCI­ACT action as a member of the group. 2.4 Create the ZZ­LINKCI­ACT­GROUP To create the action group, follow this procedure: 1. Open the Actions application by navigating to GoTo > System Administration > Platform Configuration > Actions page 17 IBM Control Desk v7.5: Automating authorized and actual CI linking 2. To create an action group, click New Action (
) in the toolbar or the Common Actions pane. page 18 IBM Control Desk v7.5: Automating authorized and actual CI linking 3. To specify the action group provide the following information: Action ZZ-LINKCI-ACT-GROUP
Description Link CI and actual CI using naming rules action group Object CI (use the Select Value (
Type Action Group Accessible from ALL
page 19 ) tool to locate the CI object) IBM Control Desk v7.5: Automating authorized and actual CI linking 4. To assign a member to the group click Select Members When the Select Members dialog appears, complete these steps to identify and select the action that was created as part of the launch point creation: a. Open the filter fields by clicking Open Filter ( ). b. Enter a fragment of the name of the action you are looking for – for example ZZLINKCI in the Action filter field. Then press Enter. c. In the list of actions that is now shown in the body of the Select Members window, check checkbox in front of the ZZ­LINKCI­ACT action that you want to become the sole member of the action group. d. Click OK to assign the selected actions as members of the action group. page 20 IBM Control Desk v7.5: Automating authorized and actual CI linking 5. When you are returned to the action specification, notice that the selected actions now appear in the Members section at the bottom of the dialog. 6. To save the action group click Save Group ( ) in the toolbar. At this point you are almost done. All that is left is to create an escalation that identifies CIs to link, and invokes the action group. 2.5 Create the ZZ­LINKCI­ESC escalation To automate the linking of un­linked CIs you can define an escalation as described in the following steps: 1. Open the Escalations application by navigating to GoTo > System Configuration > Platform Configuration > Escalations. 2. Create a new escalation by clicking New Escalation (
page 21 ) in the toolbar. IBM Control Desk v7.5: Automating authorized and actual CI linking 3. Provide the following basic escalation specification values: Escalation ZZ-LINKCI-ESC Description Link CI and actualCI using naming rules Applies to CI Create Successful execution entry checked 4. Set the schedule for the escalation to every 5 minutes while you test the escalation. When you are done testing, and the automated CI linking solution is in production, consider changing the schedule to for example every 1 hour, to avoid applying unnecessary load your IBM Control Desk infrastructure. page 22 IBM Control Desk v7.5: Automating authorized and actual CI linking 5. In the Condition field, provide the following sql where clause, which selects CI, that are eligible to be linked – CIs that are not already linked, and the status is not decommissioned: actcinum is null
and
status not in (select value from maximo.synonymdomain
where domainid = 'CISTATUS' and maxvalue = 'DECOMMISSIONED' )
6. Next, you must define escalation points. In an escalation, each escalation point can be associated with specific filters – or criteria – that select only a subset of the resources identified by the escalation Condition. You can use different escalation points to react to different groups of actual CIs if you so desire. For example, to link only ComputerSystem CIs, you can add an escalation point that uses the classification of the actual CIs to include only these types of resources. You can also create an escalation point that identifies all actual CIs that have never been linked or one that reacts only on top­level CIs. For the CI linkage based on naming rules, only a single escalation point will be used. Since the linkage information most likely will be used to synchronize CIs, and only top­level CIs are eligible for synchronization, the escalation point is used to only include top­level CIs. If you want to include all CIs that are identified by the escalation condition, simply use an escalation point condition that always evaluates to true – for example 1 = 1. page 23 IBM Control Desk v7.5: Automating authorized and actual CI linking To create an escalation point that is used to link only top­level CIs identified by the escalation condition, complete these steps: a. In the Escalation Points section of the Escalation application click New Row. b. Expand the escalation point that has been created, and provide the following information: Escalation Point Condition classstructureid in
(select classstructureid from maximo.classusewith
where toplevel = 1)
Repeat? checked The escalation point condition is used to select records from the result set of the escalation condition, so only top­level CIs that are eligible for linking are returned to the actions and notifications related to the escalation point. The Repeat option is used to force the escalation to analyze all CIs identified by the escalation condition and the escalation point criteria every time it executes. This is necessary in this case to ensure that CIs are processed even if the link has been removed – for example if the linked actual CI has been deleted. page 24 IBM Control Desk v7.5: Automating authorized and actual CI linking For testing purposes you should consider appending additional criteria to the escalation point condition to limit the number of records that are processed. For example you can append and cinum like ‘TADDM%’ to work only with actual CIs for which the name starts with ‘TADDM’. Naturally you could have added the extra criteria to the escalation condition to apply the extra criteria for all escalation points. c. In the Actions tab at the bottom, use the Select Value option of the Detail Menu ( ) next to the Action Group field to select the ZZ­LINKCI­ACT­GROUP action group. Notice how the Actions section is populated with the members of the selected action group. d. If you want to, add any notifications you need to do so from the Notifications tab. 7. Click Save Escalation ( ) in the toolbar to store your definitions. page 25 IBM Control Desk v7.5: Automating authorized and actual CI linking 8. To harvest the results of your hard work all that is left for you to do is to ensure that the escalation executes by activating it. Click Activate/Deactivate Escalation in the More Actions pane to activate the escalation, and verify that the Active option has been checked. At last you are done. From this point forward, top­level authorized and actual CI pairs that are identified by comparing naming rule attributes will automatically be linked. page 26 IBM Control Desk v7.5: Automating authorized and actual CI linking 2.6 Verifying naming rule based linking To test the automated naming rule based linking, all you need to do is to ensure that a top­level authorized CI, for example a ComputerSystem CI, is unlinked, and that its actual CI sibling exists. If you cannot find any candidates, you can test the linking by deleting the Actual Configuration Item Number field for an existing CI. After the escalation has executed, the Actual Configuration Item Number field should be re­populated when you refresh the information in the Configuration Item, CI Details tab. page 27 IBM Control Desk v7.5: Automating authorized and actual CI linking 3 Reconciliation based linking If CIs do not have attributes that support naming rule based linking the only option to automate the linking is to use reconciliation based linking. Often, authorized CIs are created with only the most basic configuration specifications. These CIs rarely have information about macaddresses, manufacturer, model, serial numbers, UUIDs, or similar low­level attributes that typically are included in naming rules. Instead it is very common to find information such as hostname, fqdn, and IP address in for new CIs. These attributes are not used in standard naming rules for computer systems and application servers. To automatically link authorized and actual CIs when naming rules cannot be used, the assistance of a reconciliation task is required. Reconciliation tasks compare selected object attributes and object specification attributes between authorized and actual CIs, and if matches are found the result (including CI numbers) is stored as CI Link Results in a RECONCILINK object. The creation of a RECONCILINK object can trigger the creation of the link between the associated authorized and actual CIs. In addition, if for some reason the link between the CIs is removed, and escalation can be used to re­establish the link, based on the RECONCILINK information. page 28 IBM Control Desk v7.5: Automating authorized and actual CI linking As illustrated above, the automation script that facilitates the linkage is be invoked either when a RECONCILINK object is created, or when the escalation identifies an existing RECONCILINK object for which the associated CI pair is not linked. The script identifies the involved CIs from the RECONCILINK object and calls a standard IBM Control Desk java method to create the link. 3.1 Creating the reconciliation task Before you configure the automation script specifications required to invoke the script when the CI Link results are created by reconciliation tasks, you must define at least one reconciliation task that will generate results. In the following, an example on how to define a reconciliation task that reconciles authorized CI and actual CI pairs based on the COMPUTERSYSTEM_FQDN specification attribute is provided. Reconciliation tasks compare attributes of resources and associates (links) resources with each other if only a single matching pair is found. Once associated, the reconciliation task can be configured to also compare CI attributes and identify discrepancies – however, this function is not used in this scenario. In a reconciliation task, a task filter can be applied, to include only certain resources ­ for example CIs with a status of Operating. Specific attributes from each input resource is then compared to the target resource set, and if unique pairs of resources can be matched, a RECONCILINK object is created. This RECONCILINK object represents the association (link) between the two resources in the pair. So, to create a reconciliation task, you combine none or more Task Filters and one or more Link Rules to get the desired behavior. page 29 IBM Control Desk v7.5: Automating authorized and actual CI linking 3.1.1
Define the ZZ­LINK­NON­DECOMMISSIONED­CIS task filter To create a task filter that filters in only CIs that have a status which indicate that they should be actively managed (CIs that have not been decommissioned or archived) complete these steps: 1. Launch the Task Filter application by navigating to GoTo > Administration > Reconciliation > Task Filters. 2. Click New Task Filter (
) in the toolbar. 3. Provide the following specifications: Task Name ZZ­LINK­NON­DECOMMISSIONED­CIS Description CI status not decommissioned or archived Filter Type CI Data Set 2 ACTCI page 30 IBM Control Desk v7.5: Automating authorized and actual CI linking 4. To apply a filter clauses, complete these steps: a. Click New Row b. Set the value of the Attribute field to STATUS. c. Supply a value for the Value field that represents a non­decommissioned status – for example NOT READY. 5. Repeat step 4 above for each status code you want to include. During execution all the filter criteria will be combined by implicit or condition. 6. When you have added all the desired status codes, store your definitions by clicking Save Task Filter ( ) in the toolbar You have now created a task filter that, when applied to reconciliation task, ensures that only CIs with a non­decommissioned status will be analyzed by the reconciliation task. page 31 IBM Control Desk v7.5: Automating authorized and actual CI linking 3.1.2
Specify the ZZ­LINKCI­FQDN­LR link rules The link rules associated with a reconciliation task control how the two types of resources are compared, in order to find matches. For this particular application, the link rule(s) must compare authorized and actual CIs. For each resource link rules can reference object attributes or specification attributes related to each object. For the reconciliation task in this example the COMPUTERSYSTEM_FQDN specification attribute is used. However, you can compare any authorized CI attribute or specification attribute to any actual CI attribute of specification attribute, but keep in mind that attributes and specification attributes are determined by the classification of the resources. In practical terms this implies that the involved CIs must be classified as some sort of ComputerSystem since only these classifications reference the COMPUTERSYSTEM_FQDN specification attribute. To create the link rule that matches ComputerSystem CIs and Actual CIs complete the following steps: 1. Launch the Link Rules application by navigating to GoTo > Administration > Reconciliation > Link Rules. 2. Click New Link Rule (
) in the toolbar to create a new link rule. 3. Provide the following specifications to identify and classify the link rule: Link: ZZ-LINKCI-FQDN-LR Description Link rule matching COMPUTERSYSTEM_FQDN
Data Set 1 CI
Data Set 2
ACTUAL CI
page 32 IBM Control Desk v7.5: Automating authorized and actual CI linking 4. In the Link Clauses section, you specify which attributes to compare from which classifications. Multiple Link Clauses can be specified in the same link rule. In this example you add a unique link clause for each combination of CI and Actual CI classifications. To create a link clause that compares the COMPUTERSYSTEM_FQDN specification attribute between CI.WINDWSCOMPUTERSYSTEM CIs and SYS.WINDOWS.WINDOWSCOPUTERSYSTEM actual CIs complete these steps: a. Click New Row to add a new link clause. b. Supply the following specifications: Data Set 1 Object CISPEC Data Set 1 Class Structure <use the Select Value tool (
) to the left of the field to select the class structure that is associated with the CI.WINDOWSCOMPUTERSYSTEM classification> Data Set 1 Attribute COPUTERSYSTEM_FQDN Data Set 2 Object ACTCISPEC Data Set 2 Class Structure <use the Select Value tool (
) to the left of the field to select the class structure that is associated with the SYS.WINDOWS.WINDOWSCOMPUTERSYSTEM classification> Data Set 2 Attribute COMPUTERSYSTEM_FQDN Sequence Operator If additional clauses will be added supply and operator of OR. page 33 IBM Control Desk v7.5: Automating authorized and actual CI linking c. Click Save Link Rule ( ) in the toolbar to save the link rule, including the link clause. 5. Use the procedure outlined in step 4 above to add link clauses for the COMPUTERSYSTEM_FQDN attribute for these CI classification pairs:  CI.COMPUTERSYSTEM SYS.COMPUTERSYSTEM  CI.AIXCOMPUTERSYSTEM SYS.AIX.AIXUNITARYCOMPUTERSYSTEM  CI.HPUXCOMPUTERSYSTEM SYS.HPUX.HPUXUNITARYCOMPUTERSYSTEM  CI.LINUXUITARYCOMPUTERSYSTEM SYS.LINUX.LINUXUNITRAYCOMPUTERSYSTEM  CI.HPUXCOMPUTERSYSTEM SYS.HPUX.HPUXUNITARYCOMPUTERSYSTEM  CI.SYSTEMPCOMPUTERSYSTEM SYS.SYSTEMPCOMPUTERSYSTEM  CI.SUNCOMPUTERSYSTEM SYS.SUN.SUNSPARCUNITARYCOMPUTERSYSTEM  CI.UNITARYCOMPUTERSYSTEM SYS.UNITARYCOMPUTERSYSTEM  CI.VIRTUALCOMPUTERSYSTEM SYS.VIRTUALCOMPUTERSYSTEM page 34 IBM Control Desk v7.5: Automating authorized and actual CI linking  CI.VMWARECOMPUTERSYSTEM  CI.ZSERIESCOMPUTERSYSTEM SYS.VMWARE.VMWAREUNITARYCOMPUTERSYSTEM SYS.ZOS.ZSERIESCOMPUTERSYSTEM When you are done, you should have 12 individual link clauses in the link rule – or as many clauses that apply to your particular environment. You are now ready to assemble the reconciliation task by combining the task filter and the link rule, and applying a schedule. page 35 IBM Control Desk v7.5: Automating authorized and actual CI linking 3.1.3
Creating the ZZ­LINKCI­RECON­FQDN­RT reconciliation task The reconciliation task can now be created. To do so, complete these steps: 1. Open the Reconciliation Task application by navigating to GoTo > Administration > Reconciliation > Reconciliation Tasks. 2. Click New Reconciliation Task (
) in the toolbar to create a new task. 3. Provide the following specifications to identify and classify the link rule: Reconciliation Task ZZ-LINKCI-RECON-FQDN-RT
Description Reconcile non-decommissioned CIs and actual CIs
based on FQDN Task Filter ZZ-LINK-NON-DECOMMISSIONED-CIS Data Set 1 CI Data Set 2 ACTUAL CI
page 36 IBM Control Desk v7.5: Automating authorized and actual CI linking 4. To assign link rules, click Select Link Rule in the Link Rules section, and select the ZZ­LINKCI­FQDN­LR link rule that you just created – or a another link rule that meets your particular requirements. Notice that you can add additional link rules if you need or want to. 5. Finally, assign a schedule to the reconciliation task so that you can specify with which frequency it is executed. For example use every 5 minutes for testing, and every 1 or 2 hours in a larger production environment. 6. Click Save Reconciliation Task ( ) in the toolbar to save the reconciliation task. 7. Before the reconciliation task is executed in accordance with the schedule, it must be activated. To activate the task, click Activate/Deactivate Reconciliation Task in the More Actions pane. Notice how the Active field becomes checked. When the reconciliation task has executed, you will be able see how authorized and actual CIs are related to one another based on the fact that both COMPUTERSYSTEM_FQDN attributes contain similar values. The example reconciliation task was not configured to perform case­sensitive comparisons, but you can easily modify your reconciliation task to do this if so desired. page 37 IBM Control Desk v7.5: Automating authorized and actual CI linking 3.1.4
Verifying CI and actual CI reconciliation Reconciliation tasks that reconcile authorized and actual CIs produce two types of output. Attribute comparisons (which is not used when you only want to link CIs) and failed link attempts are stored as RECONCIRESULT objects. Successful links are stored as RECONCILINK objects. Both types of results can be accessed from the IBM Control Desk console. To see all the successful associations (links) between pairs of authorized and actual CIs, navigate to GoTo > Administration > Reconciliation > CI Link Results. When the application opens, press Enter to populate the list of reconciled CIs. Besides the CIs that are associated, you also see which link rule facilitated the reconciliation, and the last time the information was updated. page 38 IBM Control Desk v7.5: Automating authorized and actual CI linking Information about the authorized CIs that were included by a task filter, but for which no actual CI could be associated, is accessed through the CI Reconciliation Results application. If you open this application (GoTo > Administration > Reconciliation > CI Reconciliation Results) you will see a lot of result objects for the ZZ­LINKCI­RECON­FQDN­RT reconciliation task where the message indicates that “This CI has no matching ACTUAL CI”. The reconciliation task inspects all CIs with the desired status (as defined by the tasks filter) but for many CIs either the CI COMPUTERSYSTEM_FQDN specification attribute could not be found or not matching actual CI could be identified. The main reasons why the reconciliation fails is either because the classification of the CI was not included in the link rules, or the specification attribute is not related to the classification of the CI – for either the involved authorized or actual CIs. In other instances you may also see the message “This CI links to more than one ACTUAL CI”. This implies that one or more actual CIs with attributes that matches attributes of an authorized CIs were identified, and the reconciliation task could pick one from the other. This situation may also occur if multiple authorized CIs match a single actual CI. page 39 IBM Control Desk v7.5: Automating authorized and actual CI linking 3.2 Reconciliation based linking The ZZ­LINKCI automation script has been instrumented to support both naming rule based and reconciliation based linking. If the ZZ­LINKCI­ESC escalation is active, and the linkType that is specified for the ZZ­LINKCI­ACT­LP launch point has a value of NamingRuleFirst, ReconciliationOnly, or ReconciliationFirst the script will look for a CI Link Result object (RECONCILINK) for which the CINUM matches the CINUM of the CI that the script was invoked for. If a CI Link Result object is found, the CI will be linked to the actual CI referenced in the CI Link Result object. This implies that if you followed the instructions in the previous, to the letter, the ZZ­LINKCI­ESC escalation should have been executing after the first successful invocation of the reconciliation task, and if the reconciliation identified any CI pairs that were not already linked (based on naming rules) these will be linked by now. page 40 IBM Control Desk v7.5: Automating authorized and actual CI linking When you look at the Configuration Item application, there is no way to tell if naming rule or reconciliation based linking was performed. In both cases the tell­tell sign is that the Actual Configuration Item Number field is populated (in the CI Details tab), and you may see discrepancies (if any exists) highlighted in the CI Details tab. page 41 IBM Control Desk v7.5: Automating authorized and actual CI linking 3.3 Automating reconciliation based linking So far only the ZZ­LINKCI­ESC escalation triggers the automated linking of authorized and actual CIs. The frequency with which this escalation executed determines the how quickly the CIs will be linked. Once actual CI information has been imported through ITIC, you will need to wait at least on escalation cycle before you see that the CIs are linked. If the authorized CI specification attributes do not support naming rule based linking, you have to wait for the reconciliation task to execute, and then for the escalation execution before the link is established. To speed up processing you can eliminate the escalation from the processing of reconciliation based linking. By defining an object launch point that triggers the ZZ­LINKCI script when a CI Link Result object (RECONCILINK) is created, the linking can be performed as soon as the CIs are reconciled. Introducing an object based launch point does not eliminate the need for the escalation. First of all the escalation provides the means to perform naming rule based linking. Secondly, if CIs were linked based on reconciliation, and the link is manually removed, it will be reestablished by the escalation. If you do not want this behavior, you should set the value of the linkType variable on the ZZ­LINKCI­ACT­LP to
NamingRuleOnly. This will force reconciliation based linking to be performed only through the object based launch point, at the point in time when CIs are reconciled. page 42 IBM Control Desk v7.5: Automating authorized and actual CI linking 3.3.1
Defining the ZZ­LINKCI­RECONCILINK­ONADD­LP object launch point Object launch points are used to trigger automation scripts when objects are created, changed or deleted. In this situation, the launch point must react on the creation (addition) of a RECONCILINK object, so that authorized and actual CIs become linked when the reconciliation task identifies pairs of associated CIs. To create the launch point, complete these steps: 1. Launch the Automation Scripts application by navigating to GoTo > System Configuration > Platform Configuration > Automation Scripts 2. From the Select Action menu, select Create > Script with Object Launch Point page 43 IBM Control Desk v7.5: Automating authorized and actual CI linking 3. When the Create Script with Object Launch Point: Step 1 of 3 dialog appears supply the following specifications: Launch Point ZZ-LINKCI-RECONCILINK-ONADD-LP Description Link CI and actualCI when reconciliation result is
created
Object RECONCILINK Events Add? (checked) Existing (selected) Script ZZ-LINKCI
ClickNext to proceed. page 44 IBM Control Desk v7.5: Automating authorized and actual CI linking 4. In the Create Script with Object Launch Point: Step 2 of 3 dialog, overwrite the value of the linkType variable, so that the value is ReconciliationOnly. ClickNext,when you are ready. 5. In the Create Script with Object Launch Point: Step 2 of 3 dialog, simply click Create to complete the launch point definition. page 45 IBM Control Desk v7.5: Automating authorized and actual CI linking 6. When you are returned to the Automation Script application, open the ZZ­LINK automation script, and look at the detailed information for the ZZ­LINKCI­RECONCILINK­ONADD­LP launch point in the Launch Points tab. Verify that the launch point is Active, and that the value of the linkType variable is
ReconciliationOnly. You are done. The next time the reconciliation creates a new CI Link Result (RECONCILINK object) the ZZ­LINKCI script will be executed, and the associated CIs will be linked. page 46 IBM Control Desk v7.5: Automating authorized and actual CI linking 4 Summary The solution for automated authorized CI and actual CI linking presented in this document can be used as­is to link CIs in your environment. You may find, that in you environment, there are other conditions that should trigger the automated linking, for example when actual CIs are created. You may also want to extend the solution to remove active links in case they are no longer found by a reconciliation task, or key specification attributes that are part of the naming rules, have changed. Feel free to expand on the provided solution to meet your specific requirements. If you need help of guidance, do not hesitate to contact the author. page 47 IBM Control Desk v7.5: Automating authorized and actual CI linking 5 The ZZ­LINKCI.py script The following contains a listing of the ZZ­LINKCI.py script. ################## Begin Standard Header - Do not add comments here ##################
#
# File: ZZ-LinkCI.py
# Version: 1.0
# Modified: December 15 2015
#
# Developemtn Environment:
# Author:
IBM Control Desk v 7.5.3.1
Morten Moeller, IBM Middleware, Advanced Technology Group ([email protected])
#
################## End Standard Header ###############################################
'''
This script links a CI with an ctual CI using naming rules
or by inspecting RECONCILINK records.
The following launch-point input variables are required:
name
direction
type
description
---------------------------------------------------------------------------------------------------------------------linkType
IN
LITERAL
Controls the behavior of the script
Valid values: NamingRuleOnly | ReconciliationOnly | NamingRuleFirst | ReconciliationFirst
Default value: NamingRuleFirst
If the value is NamingRuleFirst or ReconciliationFirst the script will attempt to link
CIs using both naming rule and reconciliation based methods.
page 48 IBM Control Desk v7.5: Automating authorized and actual CI linking isAsync
IN
YORN
Determines if naming rule based linkng is performed in the background.
Applies only to naming rule based linking
Valid values:
Y | y | 1 | N | n | 0
Defaultvalue:
N
If the value is True (Y|y|1) reconciliation based linking will be omitted
toEmailAddr
IN
LITERAL
Email address of administrator to receive results of asynchronous linking attempts
Applies only to naming rule based linking and if isAsync is True (Y|y|1)
Defaultvalue:
testOnly
IN
YORN
None
Switch to test the script without performing linking
Valid values:
Y | y | 1 | N | n | 0
Defaultvalue:
N
If that value is True (Y|y|1) no calls will be made to maximo methods to link CIs
Invcation:
------------- Only a single CI or RECONCILINK objectis processed at each invocation of the script
- The script must be launched in the context of a CI or a RECONCILINK object
The script is intended to be invoked from an action launch point (assiociated with an escalation or a user action
in the Configuration Item appliation) or from an object launch point assciatend with the onAdd method of the
RECONCILINK object type
page 49 IBM Control Desk v7.5: Automating authorized and actual CI linking Usage notes
----------- Linkage is controlled by a number of options that are normally provided in the manual Link CI dialog for a
configuration item.
This script require that these values are provided as launch point variables.
- To simulate linking - in order to test the script = ptovide a value if Y|y|1 for the trestOnly variable
- To have the naming rule based linking performedin the background, set the value of the isAsync variable to
True (Y|y|1).
Because there is not way of varifying the result of the linking when it operates in asynchronous mode,
reconciliation based linking will be ommitted if the value of isAsync is True - even if the value of linkType
is NamingRuleFirst or ReconciliationFirst
- To send an eMail to an administrator when asynchronous linkage is used, supply the appropriate eMail ID as the
value for the toEmailAddr variable
'''
import sys
from java.util import *
from java.lang import *
from psdi.mbo import MboRemote
from psdi.mbo import MboConstants
from psdi.mbo import MboSetRemote
from psdi.mbo import Mbo, MboSet, SqlFormat
from psdi.server import MXServer
#import com.ibm.ism.cci.app.actualci.CCICIConstants
page 50 IBM Control Desk v7.5: Automating authorized and actual CI linking import com.ibm.ism.cci.app.namerules.CCINmrLinkUtil as CCINmrLinkUtil
#from psdi.app.bulletinboard import BB, BBSet
#from java.util import Calendar
class AlreadyLinked(Exception):
def __init__(self):
global interactive, msg, errorgroup, errorkey, params
msg = "The CI " + ciNum + " is aleady linked to the actual CI " +
actciNum
ZZ_LogIt("DEBUG",msg)
class LinkError(Exception):
def __init__(self,message=None):
global interactive, msg, errorgroup, errorkey, params
if message == None:
message = "An error was encountered during linking of " +
str(ciClassName) + " resource " + str(ciNum)
ZZ_LogIt("DEBUG",message)
##---------------------------------------------------------------------------------------## +++ set custom defaults +++
def setDefaults():
global
default_linkType, default_isAsync, default_toEmailAddr, default_testOnly
###########################################################################
## +++ set custom defaults +++
##
## linkType
##
Determine the behavior of the script
##
Valid options: [NamingRuleOnly|ReconciliationOnly|NamingRuleFirst|ReconciliationFirst]
default_linkType = "ReconciliationFirst"
page 51 IBM Control Desk v7.5: Automating authorized and actual CI linking ##
Execute the promotion asynchronously. Default value is 'false'.
##
Valid options: [True|False]
default_isAsync = False
##
If asynchronous execution is true, specify the email of the user to receive notification.
##
Applies only for NamingRule
based linking
#toEmailAddr = "[email protected]"
default_toEmailAddr = None
##
##
Do not perform any promotion action
##
Valid options: [True|False]
default_testOnly = False
##
###################################################################################
# log messages
###################################################################################
def ZZ_LogIt(logLevel, logMessage):
if logLevel.upper() == "INFO":
prefix = "\t--- "
elif logLevel.upper() == "ERROR":
prefix = "\t=== "
elif logLevel.upper() == "DEBUG":
prefix = "\t!!! "
elif logLevel.upper() == "FATAL":
prefix = "\t@@@ "
print prefix + logMessage
page 52 IBM Control Desk v7.5: Automating authorized and actual CI linking ##----------------------------------------------------------------------------def initializeMX():
## Initialize mx environment
global userInfo,mxs,defaultInsertSite
mxs = MXServer.getMXServer()
secServ = mxs.lookup("SECURITY")
userInfo = secServ.getSystemUserInfo()
ZZ_LogIt("INFO","Running as user:\t" + userInfo.getLoginUserName() + " (" + userInfo.getLoginID() + ")" )
mboClass = mbo.getThisMboSet().getMboSetInfo().getClassName()
mboEntity = mbo.getThisMboSet().getMboSetInfo().getEntityName()
mboLabel = mbo.getThisMboSet().getMboSetInfo().getObjectName()
return mboClass, mboEntity, mboLabel
##----------------------------------------------------------------------------def getCiDetails(ciMbo):
#global ciNum, ciClassstructureID, ciClassName, ciSet, actciNum
## Create mboSet that contains the selected CI
## (this is used in the final call to createAuthorizedCI)
ciSet = ciMbo.getThisMboSet()
ciNum = ciMbo.getString("CINUM")
actciNum = ciMbo.getString("ACTCINUM")
ciClassstructureId = ciMbo.getString("CLASSSTRUCTUREID")
page 53 IBM Control Desk v7.5: Automating authorized and actual CI linking ## Get the classname of the CI
ciClassName = findClassnameFromClassstructureid(ciClassstructureId)
ZZ_LogIt("DEBUG","Configuration Item number is: '" + str(ciNum) + "'")
ZZ_LogIt("DEBUG","Configuration Item Classstructure is: '" + str(ciClassstructureId) + "'")
ZZ_LogIt("DEBUG","Configuration Item className is: '" + str(ciClassName) + "'")
ZZ_LogIt("DEBUG","Linked Actual Configuration Item number is: '" + str(actciNum) + "'")
return ciNum, ciClassstructureId, ciClassName, actciNum
##----------------------------------------------------------------------------def findClassnameFromClassstructureid(classstructureID):
classstructureSet = mxs.getMboSet("CLASSSTRUCTURE",userInfo)
sqlf = SqlFormat("classstructureid=:1")
sqlf.setObject(1,"CLASSSTRUCTURE", "CLASSSTRUCTUREID", str(classstructureID))
classstructureSet.setWhere(sqlf.format())
classstructureSet.reset()
classstructureName = classstructureSet.getMbo(0).getString("DESCRIPTION")
return str(classstructureName)
##---------------------------------------------------------------------------------------def linkCI(ciSet,linkType, actciNum=None):
page 54 IBM Control Desk v7.5: Automating authorized and actual CI linking ## inspired by CCILinkCIBean.class
## build a vector that represents the selected CIs
## show options
ciMbo = ciSet.getMbo(0)
if linkType.upper() == "NAMINGRULEONLY":
vector = Vector()
vector.add(ciMbo)
'''
for i in range(ciSet.count()):
vector.add(ciSet.getMbo(i))
'''
linkOptions = 0L
ZZ_LogIt("DEBUG", "\t--- Linking " + str(ciClassName) + " (" + str(ciNum) + ") by calling linkAuthorizedCIs using :")
ZZ_LogIt("DEBUG", "\t\t vector:\t\t" + str(vector))
ZZ_LogIt("DEBUG", "\t\t toEmailAddr:\t\t" + str(toEmailAddr))
ZZ_LogIt("DEBUG", "\t\t linkOptions:\t\t" + str(linkOptions))
ZZ_LogIt("DEBUG", "\t\t isAsync:\t\t" + str(isAsync))
elif linkType.upper() == "RECONCILIATIONONLY":
##
setLinkToActualCI
accessModifier = 1L
ZZ_LogIt("DEBUG", "\t--- Linking " + str(ciClassName) + " (" + str(ciNum) + ") by calling setLinkToActualCI using :")
page 55 IBM Control Desk v7.5: Automating authorized and actual CI linking ZZ_LogIt("DEBUG", "\t\t actciNum:\t\t" + str(actciNum))
ZZ_LogIt("DEBUG", "\t\t accessModifier:\t" + str(accessModifier))
if testOnly:
ZZ_LogIt("DEBUG", "\n\t===========================================================")
ZZ_LogIt("DEBUG", "\t===========================================================")
ZZ_LogIt("DEBUG", "\t!!!\tTESTING.... no actions have been performed\t!!!")
ZZ_LogIt("DEBUG", "\t!!!\tTESTING.... no actions have been performed\t!!!")
ZZ_LogIt("DEBUG", "\t!!!\tTESTING.... no actions have been performed\t!!!")
ZZ_LogIt("DEBUG", "\t===========================================================")
ZZ_LogIt("DEBUG", "\t===========================================================\n")
else:
if 1==1: #try:
if linkType.upper() == "NAMINGRULEONLY":
linkUtil = CCINmrLinkUtil()
linkUtil.linkAuthorizedCIs(vector, linkOptions, toEmailAddr, isAsync)
elif linkType.upper() == "RECONCILIATIONONLY":
ciMbo.setLinkToActualCI(actciNum,accessModifier)
if isAsync == False:
ciSet.save()
ciSet.reset()
actciNum = ciSet.getMbo(0).getString("ACTCINUM")
ZZ_LogIt("INFO", "ActualCI is: " + actciNum)
if actciNum in [None,""]:
if linkType.upper() == "NAMINGRULEONLY":
msg = "Could not find any actualCI that matched the naming rules for " + ciNum
page 56 IBM Control Desk v7.5: Automating authorized and actual CI linking elif linkType.upper() == "RECONCILIATIONONLY":
msg = "Failed to link " + ciNum
raise LinkError(msg)
#except LinkError:
# pass
#########################################################################################
## MAIN
#########################################################################################
ZZ_LogIt("INFO", "\n\n\t--- ************************************************************************")
try:
action
except:
action = "unknown"
'''
try:
ondelete
except:
print "setting ondelete to False"
ondelete = False
print "onDelete:\t" + str(ondelete)
page 57 IBM Control Desk v7.5: Automating authorized and actual CI linking try:
onadd
except:
print "setting onadd to False"
onadd = False
print "onAdd:\t\t" + str(onadd)
try:
onupdate
except:
print "setting onupdate to False"
onupdate = False
print "onUpdate:\t" + str(onupdate)
'''
if ondelete:
action = "onDelete"
elif onadd:
action = "onAdd"
elif onupdate:
action = "onUpdate"
if action == "unknown":
action = "onInit"
ZZ_LogIt("INFO", "Starting: " + str(scriptName) + " as " + str(user) + " on " + mboname + " from " + str(app) + " using
" + str(action) + " defined by " + str(launchPoint))
ZZ_LogIt("INFO", "Action:\t\t\t"+str(action))
page 58 IBM Control Desk v7.5: Automating authorized and actual CI linking ZZ_LogIt("INFO", "Received\tlinkType:\t"+str(linkType))
ZZ_LogIt("INFO", "Received\tisAsync:\t"+str(isAsync))
ZZ_LogIt("INFO", "Received\ttoEmailAddr:\t"+str(toEmailAddr))
ZZ_LogIt("INFO", "Received\ttestOnly:\t"+str(testOnly))
## parse input
if isAsync in ['N','n','0']:
isAsync = False
elif isAsync in ['Y','y','1']:
isAsync = True
if testOnly in ['N','n','0']:
testOnly = False
elif testOnly in ['Y','y','1']:
testOnly = True
##=================
## Initialize
##=================
## initialize environment
try:
mboClass, mboEntity, mboLabel = initializeMX()
# initialize the maximo environment
if mboEntity == "CI":
ciMbo = mbo
ciSet = ciMbo.getThisMboSet()
page 59 IBM Control Desk v7.5: Automating authorized and actual CI linking elif mboEntity == "RECONCILINK":
ciSet = mxs.getMboSet("CI",userInfo)
sqlf = SqlFormat("cinum=:1")
sqlf.setObject(1,"CI", "CINUM", mbo.getString("CINUM"))
ciSet.setWhere(sqlf.format())
ciSet.reset()
if ciSet.isEmpty():
raise LinkError("Could not find CI for " + str(mbo.getString("RECONTYPE")) + " RECONCILINK " +
str(mbo.getString("RECONLINKID")))
else:
ciMbo = ciSet.getMbo(0)
msg = "CI contains\tCINUM:\t" + str(ciMbo.getString("CINUM")) + "\t ACTCINUM is:\t" +
str(ciMbo.getString("ACTCINUM"))
ZZ_LogIt("INFO", msg)
# get ci details
ciNum, ciClassstructureId, ciClassName, actciNum = getCiDetails(ciMbo)
# is already linked?
if actciNum not in [None,""]:
# terminate if the CI is already linked
raise AlreadyLinked
else:
actciNum = None
page 60 IBM Control Desk v7.5: Automating authorized and actual CI linking setDefaults()
# get custom defaults
# parse input variables
try:
linkType
except:
linkType = default_linkType
# determine the behavior of the script
behavior =[]
if linkType.upper() in ["NAMINGRULEONLY","NAMINGRULEFIRST","BOTH"]:
behavior.append("NamingRuleOnly")
elif linkType.upper() in ["RECONCILIATIONNLY","RECONCILIATIONFIRST","BOTH"]:
behavior.append("ReconciliationOnly")
if linkType.upper() == "NAMINGRULEFIRST":
behavior.append("ReconciliationOnly")
elif linkType.upper() == "RECONCILIATIONFIRST":
behavior.append("NamingRuleOnly")
ZZ_LogIt("INFO","Behavior is:\t" + str(behavior))
## Link CIs
for linkType in behavior:
try:
## Link CIs if action is not onDelete
if behavior == "NamingRuleOnly" and action in ["onDelete","onAdd","unknown"]:
page 61 IBM Control Desk v7.5: Automating authorized and actual CI linking ZZ_LogIt("INFO", linkType + " action " + action + " bypasses linking")
continue
elif behavior == "ReconciliationOnly" and action in ["onDelete","onUpdate","unknown"]:
ZZ_LogIt("INFO", linkType + " action " + action + " bypasses linking")
continue
else:
ZZ_LogIt("INFO", "Attempting " + str(linkType) + " linking")
if linkType.upper() == "RECONCILIATIONONLY":
##
find the RECONCILINK object related to the CI
reconMboSet = mxs.getMboSet("RECONCILINK",userInfo)
sqlf = SqlFormat("cinum=:1")
sqlf.setObject(1,"RECONCILINK", "CINUM", str(ciNum))
reconMboSet.setWhere(sqlf.format())
reconMboSet.reset()
if reconMboSet.isEmpty():
raise LinkError("Could not find RECONCILINK object for CI " + str(ciNum))
continue
else:
reconMbo = reconMboSet.getMbo(0)
actciNum = reconMbo.getString("RECONCILINK_ACTCI.ACTCINUM")
msg = "RECONCILINK contains\tCINUM:\t" + str(reconMbo.getString("CINUM")) + "\t ACTCIID:\t" +
str(reconMbo.getInt("ACTCIID"))
+ "\t ACTCINUM is:\t" + str(actciNum)
ZZ_LogIt("INFO", msg)
# perfrm the link
linkCI(ciSet,linkType,actciNum)
ciSet.save()
break
page 62 IBM Control Desk v7.5: Automating authorized and actual CI linking except LinkError:
continue
except AlreadyLinked:
pass
except LinkError:
print "linkError"
pass #print "\t$$$\tAn error occurred during linking of configuration item " + str(ciNum)
finally:
ZZ_LogIt("INFO","Ending: " + scriptName) ##+ " using " + behavior + "linking"
ZZ_LogIt("INFO","************************************************************************")
page 63