Handling Resources in CW SSH CLI
From TDiWiki
A Resource refers to any ConsoleWorks entity, such as a Console, an Event, a Scan, a User to name a few. There are many operations that can be performed on a Resource. This article covers the usage of the general commands that can be performed on all resources.
[edit] Resource Commands
| add | - Adds a resource |
| associate | - Creates an association between two resources |
| copy | - Copies a resource |
| delete | - Deletes a resource |
| disassociate | - Removes an association between two resources |
| display | - Displays the details of a specific resource |
| edit | - Edits a specific resource |
| getAssociation | - Lists the associations for a specific resource |
| list | - Lists all of the defined resources for a specific type |
[edit] add
adds a resource
| Type | : | Specifies the type of resource to be added |
| Name | : | Specifies the name of the resource to add |
| Field=value... | : | Specifies one or more fields to set the value of |
Note: The specific fields that are required to be specified is dependent on the type of resource being added and also may be dependent on the values for those fields. To see all of the available fields for a certain resource type the command, the type, and the name and then press the Tab key.
Format:
cw> add TYPE NAME fieldname="value" fieldname="value"
Example:
cw> add GROUP MYGROUP description="my new group"
Applicable Resources:
the add command can be used to add any of the following resources:
| CONSOLE | GROUP |
| SCRIPT | EVENT |
| EVENT_OCCURRENCES | SCAN |
| SEVERITY | TIME_FRAME |
| USER | PROFILE |
| CWSCRIPT | REPORT |
| CONNECTION | CONSOLE_TYPE |
| INTELLEVENT_GROUP | LICENSE |
| PSEUDO_FILE | SESSION |
| SSHKEY | TEMPLATE |
| USAGE | REMEDIATION_HISTORY |
| EXTERNAL_ACKNOWLEGE_ACTION | EXTERNAL_AUTOMATIC_ACTION |
| EXTERNAL_PURGE_ACTION | INTERNAL_ACKNOWLEGE_ACTION |
| INTERNAL_AUTOMATIC_ACTION | INTERNAL_PURGE_ACTION |
[edit] associate
associates two resources
| Type | : | Specifies the type of association |
| Name | : | Specifies the name of the first resource |
| Name | : | Specifies the name of the second resource |
| Field=value... | : | Specifies one or more fields to change the value of |
Note: For every possible combination of resources (except for Actions) there are two ways to create the association. Remember that the order of specified resources is dependent on the type of association. See the example below. The fields parameter is optional for the associate command. To see all of the available fields for a certain resource type the command, the type, and the name and then press the Tab key.
Format:
cw> associate TYPE NAME NAME fieldname="value" fieldname="value"
Example:
cw> associate CONSOLE_TO_GROUP MYCONSOLE MYGROUP cw> associate GROUP_TO_CONSOLE MYGROUP MYCONSOLE
Applicable Resources:
the associate command can be used to create an association between any of the following combinations of resources:
| CONSOLE_TO_GROUP | CONSOLE_TO_SCAN |
| CONSOLE_TO_SCRIPT | CONSOLE_TO_EVENT |
| CONSOLE_TO_PROFILE | GROUP_TO_CONSOLE |
| SCAN_TO_CONSOLE | SCAN_TO_EVENT |
| SCAN_TO_CHILD | SCAN_TO_PARENT |
| SCRIPT_TO_CONSOLE | EVENT_TO_SCAN |
| PROFILE_TO_CONSOLE | PROFILE_TO_USER |
| USER_TO_PROFILE | EVENT_TO_ACKNOWLEDGE_ACTION |
| EVENT_TO_AUTOMATIC_ACTION | EVENT_TO_PURGE_ACTION |
[edit] copy
copies a resource
| Type | : | Specifies the type of resource |
| Name | : | Specifies the name of the resource to be copied |
| Name | : | Specifies the name of the copy |
| Field=value... | : | Specifies one or more fields to change the value of |
Note: The field parameter is optional for the copy command. To see all of the available fields for a certain resource type the command, the type, and the name and then press the Tab key.
Format:
cw> copy TYPE NAME NAME fieldname="value" fieldname="value"
Example:
cw> copy GROUP MYGROUP MYOTHERGROUP cw> copy GROUP MYGROUP MYOTHERGROUP udf1="this group was copied from MYGROUP"
Applicable Resources:
the copy command can be used to create a copy of any existing resource:
| CONSOLE | GROUP |
| SCRIPT | EVENT |
| EVENT_OCCURRENCES | SCAN |
| SEVERITY | TIME_FRAME |
| USER | PROFILE |
| CWSCRIPT | REPORT |
| CONNECTION | CONSOLE_TYPE |
| INTELLEVENT_GROUP | LICENSE |
| PSEUDO_FILE | SESSION |
| SSHKEY | TEMPLATE |
| USAGE | REMEDIATION_HISTORY |
| EXTERNAL_ACKNOWLEGE_ACTION | EXTERNAL_AUTOMATIC_ACTION |
| EXTERNAL_PURGE_ACTION | INTERNAL_ACKNOWLEGE_ACTION |
| INTERNAL_AUTOMATIC_ACTION | INTERNAL_PURGE_ACTION |
[edit] delete
deletes a resource
| Type | : | Specifies the type of resource |
| Name | : | Specifies the name of the resource |
Format:
cw> delete TYPE NAME
Example:
cw> delete GROUP MYGROUP
Applicable Resources:
the delete command can be used to remove any existing resource:
| CONSOLE | GROUP |
| SCRIPT | EVENT |
| EVENT_OCCURRENCES | SCAN |
| SEVERITY | TIME_FRAME |
| USER | PROFILE |
| CWSCRIPT | REPORT |
| CONNECTION | CONSOLE_TYPE |
| INTELLEVENT_GROUP | LICENSE |
| PSEUDO_FILE | SESSION |
| SSHKEY | TEMPLATE |
| USAGE | REMEDIATION_HISTORY |
| EXTERNAL_ACKNOWLEGE_ACTION | EXTERNAL_AUTOMATIC_ACTION |
| EXTERNAL_PURGE_ACTION | INTERNAL_ACKNOWLEGE_ACTION |
| INTERNAL_AUTOMATIC_ACTION | INTERNAL_PURGE_ACTION |
[edit] disassociate
removes an association between two resources
| Type | : | Specifies the type of association |
| Name | : | Specifies the name of the first resource |
| Name | : | Specifies the name of the second resource |
| Field=value... | : | Specifies one or more fields to change the value of |
Note: For every possible combination of resources (except for Actions) there are two ways to remove the association. Remember that the order of specified resources is dependent on the type of disassociation. See the example below. The fields parameter is optional for the disassociate command. To see all of the available fields for a certain resource type the command, the type, and the name and then press the Tab key.
Format:
cw> disassociate TYPE NAME NAME fieldname="value" fieldname="value"
Example:
cw> disassociate CONSOLE_TO_GROUP MYCONSOLE MYGROUP cw> disassociate GROUP_TO_CONSOLE MYGROUP MYCONSOLE
Applicable Resources:
the disassociate command can be used to remove an association between any of the following combinations of resources:
| CONSOLE_TO_GROUP | CONSOLE_TO_SCAN |
| CONSOLE_TO_SCRIPT | CONSOLE_TO_EVENT |
| CONSOLE_TO_PROFILE | GROUP_TO_CONSOLE |
| SCAN_TO_CONSOLE | SCAN_TO_EVENT |
| SCAN_TO_CHILD | SCAN_TO_PARENT |
| SCRIPT_TO_CONSOLE | EVENT_TO_SCAN |
| PROFILE_TO_CONSOLE | PROFILE_TO_USER |
| USER_TO_PROFILE | EVENT_TO_ACKNOWLEDGE_ACTION |
| EVENT_TO_AUTOMATIC_ACTION | EVENT_TO_PURGE_ACTION |
[edit] display
displays a resource
| Type | : | Specifies the type of resource to be displayed |
| Name | : | Specifies the name of the resource to be displayed |
| -fields (f) | : | Displays the field names rather than labels |
| -level (l) Level | : | Specifies the View Level to display (NAME, LIST, QUICK, ALL) |
| -nopage (np) | : | Prints without prompting at the end of each page |
| -page (p) | : | Pages the output, stopping at the end of each page |
Note: If no options are specified, the default display will be the field labels. With the exception of -page and -nopage, any combination of these options may be used.
Format:
cw> display TYPE NAME -fields
cw> display TYPE NAME -level LEVEL
cw> display TYPE NAME -nopage
cw> display TYPE NAME -page
Example:
cw> display GROUP MYGROUP -l ALL
Applicable Resources:
the add command can be used to add any of the following resources:
| CONSOLE | GROUP |
| SCRIPT | EVENT |
| EVENT_OCCURRENCES | SCAN |
| SEVERITY | TIME_FRAME |
| USER | PROFILE |
| CWSCRIPT | REPORT |
| CONNECTION | CONSOLE_TYPE |
| INTELLEVENT_GROUP | LICENSE |
| PSEUDO_FILE | SESSION |
| SSHKEY | TEMPLATE |
| USAGE | REMEDIATION_HISTORY |
| EXTERNAL_ACKNOWLEGE_ACTION | EXTERNAL_AUTOMATIC_ACTION |
| EXTERNAL_PURGE_ACTION | INTERNAL_ACKNOWLEGE_ACTION |
| INTERNAL_AUTOMATIC_ACTION | INTERNAL_PURGE_ACTION |
This command is useful for determining which fields need to be set when adding a new resource.
[edit] edit
edits a resource
| Type | : | Specifies the type of resource to be edited |
| Name | : | Specifies the name of the resource to edited |
| Field=value... | : | Specifies one or more fields to set the value of |
Note: To see all of the available fields for a certain resource type the command, the type, and the name and then press the Tab key.
Format:
cw> edit TYPE NAME fieldname="value" fieldname="value"
Example:
cw> edit GROUP MYGROUP description="my group of special consoles" udf1="special description goes here"
Applicable Resources:
the edit command can be used to edit any of the following resources:
| CONSOLE | GROUP |
| SCRIPT | EVENT |
| EVENT_OCCURRENCES | SCAN |
| SEVERITY | TIME_FRAME |
| USER | PROFILE |
| CWSCRIPT | REPORT |
| CONNECTION | CONSOLE_TYPE |
| INTELLEVENT_GROUP | LICENSE |
| PSEUDO_FILE | SESSION |
| SSHKEY | TEMPLATE |
| USAGE | REMEDIATION_HISTORY |
| EXTERNAL_ACKNOWLEGE_ACTION | EXTERNAL_AUTOMATIC_ACTION |
| EXTERNAL_PURGE_ACTION | INTERNAL_ACKNOWLEGE_ACTION |
| INTERNAL_AUTOMATIC_ACTION | INTERNAL_PURGE_ACTION |
[edit] getAssociation
list all the associated resources for a specific resource
| Type | : | Specifies the type of association |
| Name | : | Specifies the name of the resource |
| -field (f) Field | : | Specifies a list of fields to display |
| -nopage (np) | : | Prints without prompting at the end of each page |
| -page (p) | : | Pages the output, stopping at the end of each page |
Note: If no options are specified, the default will be displayed. With the exception of -page and -nopage, any combination of these options may be used.
Format:
cw> getAssociation TYPE NAME -field fieldname
cw> getAssociation TYPE NAME -nopage
cw> getAssociation TYPE NAME -page
Example:
cw> getAssociation CONSOLE_TO_GROUP MYCONSOLE cw> getAssociation GROUP_TO_CONSOLE tgrp -f DisplayName -f description -f statustext -f udf1
Applicable Resources:
the getAssociation command can be used to display the resources associated to a specific resource through any of the following associations:
| CONSOLE_TO_GROUP | CONSOLE_TO_SCAN |
| CONSOLE_TO_SCRIPT | CONSOLE_TO_EVENT |
| CONSOLE_TO_PROFILE | GROUP_TO_CONSOLE |
| SCAN_TO_CONSOLE | SCAN_TO_EVENT |
| SCAN_TO_CHILD | SCAN_TO_PARENT |
| SCRIPT_TO_CONSOLE | EVENT_TO_SCAN |
| PROFILE_TO_CONSOLE | PROFILE_TO_USER |
| USER_TO_PROFILE | EVENT_TO_ACKNOWLEDGE_ACTION |
| EVENT_TO_AUTOMATIC_ACTION | EVENT_TO_PURGE_ACTION |
[edit] list
list all resources of a certain type
| Type | : | Specifies the type of resource to be listed |
| -field (f) Field | : | Specifies a list of fields you would like displayed |
| -filter (x) Field=value | : | Filters to reduce the displayed resources; uses the form field=value |
| -nopage (np) | : | Prints without prompting at the end of each page |
| -page (p) | : | Pages the output, stopping at the end of each page |
| -reverse (r) | : | Sorts in descending order; only applicable when sort option is provided |
| -sort (s) Field | : | Specifies the field name to sort results by |
Note: If no options are specified, the default will be displayed. With the exception of -page and -nopage, any combination of these options may be used.
Format:
cw> list TYPE
cw> list TYPE -field fieldname -field fieldname
cw> list TYPE -filter fieldname=value
cw> list TYPE -nopage
cw> list TYPE -page
cw> list TYPE -sort fieldname
cw> list TYPE -sort fieldname -reverse
Example:
cw> list CONSOLE cw> list SEVERITY -f Severity -f color -s sort_order -r
Applicable Resources:
the list command can be used to list any of the following resources:
| CONSOLE | GROUP |
| SCRIPT | EVENT |
| EVENT_OCCURRENCES | SCAN |
| SEVERITY | TIME_FRAME |
| USER | PROFILE |
| CWSCRIPT | REPORT |
| CONNECTION | CONSOLE_TYPE |
| INTELLEVENT_GROUP | LICENSE |
| PSEUDO_FILE | SESSION |
| SSHKEY | TEMPLATE |
| USAGE | REMEDIATION_HISTORY |
| EXTERNAL_ACKNOWLEGE_ACTION | EXTERNAL_AUTOMATIC_ACTION |
| EXTERNAL_PURGE_ACTION | INTERNAL_ACKNOWLEGE_ACTION |
| INTERNAL_AUTOMATIC_ACTION | INTERNAL_PURGE_ACTION |
[edit] Document Conventions
| italics | indicates a variable value to be entered by the user |
| - | indicates an option for a command. Options are not required. |
| ( ) | indicates a shortcut for an option. ex: -f can be used instead of -field |
