How to create patch smart groups using BLCLI
You might find it useful to create Patch Catalog Smart Groups using the BLCLI.
As of version 8.2, no BLCLI command is available for manipulating the Patch Smart Groups, and you need to use the more generic SmartGroup commands.
For example, to create the group for a Microsoft Windows Catalog (and associated objects), run the following BLCLI commands:
blcli_execute Utility storeTargetObject pgObject
blcli_execute Condition createPropertyCondition "Class://SystemObject/Depot Object/Software/Win Depot Software/Hotfix" NAME contains "MSRT"
blcli_execute Utility storeTargetObject conditionObject
blcli_execute SmartGroup createSmartGroupWithTypeId 5017 "Patch BlackList" "Patch BlackList" NAMED_OBJECT=pgObject NAMED_OBJECT=conditionObject
blcli_execute Utility storeTargetObject groupObject
blcli_execute SmartGroup save NAMED_OBJECT=groupObject
blcli_execute Group getDBKey
blcli_storeenv groupKey
The Property Class in the createPropertyCondition command should be the Depot Object type of the objects that you want in the Patch Smart Group. Look under Depot Object/Software in the Property Dictionary for the other Property Class names.
For the Catalog Group Type Id in the getGroupByQualifiedName command, use:
Type Name | Type Id |
---|---|
AIX_CATALOG_GROUP | 7037 |
OTHER_LINUX_CATALOG_GROUP | 7035 |
RED_HAT_CATALOG_GROUP | 5020 |
SOLARIS_CATALOG_GROUP | 5021 |
WINDOWS_CATALOG_GROUP | 5022 |
For the Smart Group Type Id in the createSmartGroupWithTypeId command, use:
Type Name | Type Id |
---|---|
SMART_AIX_PATCH_CATALOG_GROUP | 5046 |
SMART_OTHER_LINUX_PATCH_CATALOG_GROUP | 5024 |
SMART_REDHAT_PATCH_CATALOG_GROUP | 5018 |
SMART_SOLARIS_PATCH_CATALOG_GROUP | 5019 |
SMART_WINDOWS_PATCH_CATALOG_GROUP | 5017 |
After the group is created, you might want to add additional conditions (for example, to include additional patches in the group). To do this, you need to iterate over your list of conditions values and feed that into the code below. This assumes you are picking off from the previous chunk and have the DBKey of the job stored as the groupKey environment variable, and that your values to feed in the conditions are stored in the values variable. Many methods can be used to feed the values in to the loop.
do
blcli_execute SmartGroup findSmartGroupByDBKey ${groupKey}
blcli_execute Utility storeTargetObject smartGroup
blcli_execute Condition createPropertyCondition "Class://SystemObject/Depot Object/Software/Win Depot Software/Hotfix" "NAME" "starts with" "${value}"
blcli_execute Utility storeTargetObject conditionObject
blcli_execute SmartGroup addCondition NAMED_OBJECT=smartGroup NAMED_OBJECT=conditionObject
blcli_execute SmartGroup save NAMED_OBJECT=groupObject
blcli_execute Group getDBKey
blcli_storeenv groupKey
done
If you need to set the Match All option, run the following commands:
blcli_execute Utility storeTargetObject smartGroup
blcli_execute SmartGroup setSignatureMatchAll NAMED_OBJECT=smartGroup true
blcli_execute SmartGroup save NAMED_OBJECT=groupObject
blcli_execute Group getDBKey
blcli_storeenv groupKey
The new Patch Smart Group under your Patch Catalog is now created.