This seems to be a fairly frequent questions and a more thorough article would hopefully give an overview for how to do this as well as give some ideas for how to approach other similar needs.
There are 2 project packages attached to the article that should be treated as an example for how to create a Workflow project to change asset owner. These projects are not supported by Symantec Technical Support and I would strongly advise to revise, improve and thoroughly test these project if you plan to use these in production - input validation, exception handling etc. would be good things to add.
Here is the train of thought while creating these projects. I will assume some basic knowledge about creating Integration and Webform type projects and point out only the relevant settings.
Note: This article is written focusing on SMP 8.0 HF1 due to the change in ResourceModel service (added SaveDataClassLight and SaveDataClassRowsLight operations) that allow doing all this with normal Workflow means.
For SMP versions up to and including 8.0 saving changes to data class will have to be done with a separate component - either SQL Query component writing directly to SMP database or a custom-built component that would be able to call ResourceModel method with undefined field types.
How is asset owner stored in CMDB?
First, it is important to know how asset owner is stored in SMP CMDB database. It is stored there in two places:
- "Asset User Owners" or "Asset Department Owners" association between asset and user/department. Note that only one of these is used, not both at the same time.
- "Ownership_Details" dataclass
The "Ownership_Details" dataclass extends the ownership resource associations and the current implementation of Symantec Management Console UI uses this dataclass data as primary data in some places instead of using ownership associations.
In addition to this, we need to know the GUIDs of the resource association types and the data class:
- ED35A8D1-BF60-4771-9DDE-092C146C485A - Asset User Owners resource association type (Parent - Asset, Child - User)
- 1466E770-4413-4517-A89D-6599B8A7F144 - Asset Department Owners resource association type (Parent - Asset, Child - Department)
- 0CD0318B-AD51-4D38-8EA3-2612D12189DE - Ownership Details data class
What do we need to do in the project?
The sequence of actions to be performed to update asset owner should be the following:
- Break existing association
- Create new Association
- Update "Ownership_Details" dataclass with Owner GUID/Computer GUID from previous action.
There are no components in out-of-box Workflow server to perform these actions, so we need a different approach. There are web services on SMP that expose different parts of SMP and Solutions' functionality. In this case, the web service we need is Resource Model because this contains operations to work with CMDB resources.
Creating the Integration library with the components we need:
Lets create a new Integration project and add a 'Web Service Caller Generator':
- Use this as URL: http://[smpservername]/Altiris/NSWebService/resourcemodel.asmx?wsdl
- Check 'HTTP Authentication' (some the operations we will use will require authentication) and enter credentials that have access (we will need these to complete the generator wizard)
- In the next page it would probably be best to set 'Default URL Generation' to 'Use and populate project property'
- On the page to select components to be generated make sure to select SaveDataClassRowsLightComponent, FormAssociationComponent and BreakAssociationComponent.
This should be sufficient for the needs of this project. Finish the wizard, save and compile the integration library.
Creating a webform to change asset owner:
First, click Import Components and add the integration library we just created.
Based on the list of actions to be performed, the components we need are:
- Form Builder (to enter Asset ID and User ID)
- Break Association Component
- Form Association Component
- Save Data Class Rows Light Component
When we put these in the project and start configuring them, we will see that additional components are needed:
- Create SMP Credentials (to generate an authentication token to use in generated components in Security tab)
- Single/Multiple Value Mapping components to prepare Data Class data for using in Save Data Class Rows Light Component.
Here is how the resulting project looks like:
Create SMP Credentials and Form Builder components do not have special configuration - former can just use default SMP profile for credentials and Form Builder needs to have two Textboxes - For Asset GUID and User GUID (both from SMP database). With some effort, search and verification logic can be built but for a sample project using GUIDs will do.
Break Association Component removes existing association because Form Association Component cannot create second association of the same type. The parameters in it should be:
- Relationship Type GUID - I used ED35A8D1-BF60-4771-9DDE-092C146C485A (Asset User Owner). The second owner association type - Asset Department Owners (see above) can be used here as well, then working with Department GUIDs instead of User GUIDs in the rest of the project.
- Relationship Parent GUID - GUID of the asset the owner is set for. Use the appropriate output variable from the Form.
- Relationship Child GUID - GUID of the current owner. Getting this correctly would require additional logic to determine the current owner and using this here but there currently appears to be a flaw in the web service in the way that GUID here is checked to be a User in CMDB but it is not verified to be the actual owner. Exploiting that flaw, we can set this to the User GUID output variable from the Form.
Form Association Component is a direct counterpart of the previous component - it created an association between two resources. Parameters are the same as previous:
- Relationship Type GUID - same ED35A8D1-BF60-4771-9DDE-092C146C485A (Asset User Owner).
- Relationship Parent GUID - GUID of the asset you want to change owner for. Use the appropriate output variable from the Form.
- Relationship Child GUID - GUID of the user you want to set as an owner. Use the appropriate output variable from the Form.
Due to the complexity of Data Class data types, it was better to split the data preparation to 3 separate components:
1. Single Value Mapping Component:
- Target Type: DataClassFieldDataLight
- Data Mapping:
FieldName - ConstantMappingAssignment: Owner
Value - ProcessMappingAssignment: user GUID variable
2. Multiple Value Mapping Component:
- Source Array Type: DataClassFieldDataLight
- Create item For Each:
Array Data Sources: both Process Variables and Constant Values
Array From Process Variables: add the output variable from previous Single Value Mapping Component
Constant Values: Field Name - Ownership Percentage; Value - 100
- Target Type: DataClassFieldDataLight
- Target Mapping Definition:
FieldName - ProcessMappingAssignment: (Source)DataClassFieldDataLight.FieldName
Value - ProcessMappingAssignment: (Source)DataClassFieldDataLight.Value
3. Single Value Mapping Component:
- Target Type: DataClassRowDataLight
- Mapping Definition:
DataElements - ProcessMappingAssignment: to the output variable from previous Multiple Value Mapping Component
Now we have all the variables needed for Save Data Class Rows Light Component, its parameters are simple:
- Resource GUID: the GUID of the asset from the Form
- Data Class GUID: 0CD0318B-AD51-4D38-8EA3-2612D12189DE - Ownership Details data class
- Data Rows: Use the output variable from the last Single Value Mapping Component
- Action: Should be for auditing note in SMP, has no effect on functionality
- Partial Update: Better set to False for our purposes
This is it, the project will be able to change an owner of the asset based on GUIDs of both.
How do I test this project?
Input Data to enter into the form of the project, GUIDs for the items can be found Symantec Management Console, using Computers as a simple asset to check here:
- For computer, in Manage > Computers view as 'Computer ID' in the 'General' section of the top right pane.
- For user, in Manage > Users right-click on the user and select Resource Manager or Properties, there is GUID listed.
Alternatively, if you feel more at home with the database, the CMDB database has vAsset and vUser views that can be queried for GUIDs.
To verify the output, we need to check two different places to make sure both association and data class with the info got changed:
- Go to Manage > Computers, right-click on the computer and select Resource Manager. In the bottom of the left pane there is a 'Resource associations' section that should include 'Asset User Owners' showing the user owner was changed to.
- Go to Manage > Computers, right-click on the computer and select Edit. At the bottom of the 'Edit configuration item' window, second to last section is 'Asset Owners' that should have the user owner was changed to and matching the user in 1.
Alternatively, this can be queried from CMDB database. Here is the query, GUIDs with x-s should be replaced with the Computer GUID:
SELECT * FROM ResourceAssociation
SELECT * FROM Inv_Ownership_Details
WHERE _ResourceGuid = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'