Populating the CUSTOMER property in TrueSight Server Automation


To use multi-tenancy in TrueSight Server Automation - Data Warehouse, you must populate the CUSTOMER property for servers in TrueSight Server Automation. If you are adding new servers, set the default value of this property for those servers. For existing servers, either populate this property for each server manually, or use a script to update multiple servers simultaneously. When you use a script, you can populate this property for a set of servers which are named in a particular pattern or belong to a range of IP addresses.

To populate the CUSTOMER property for each server manually

  1. Open the TrueSight Server Automation console.
  2. Expand the Servers folder.
  3. Select the required server.
  4. Update the CUSTOMER property as shown in the following figure:
    Populate_Property.png

To populate the CUSTOMER property for multiple servers by running a script

  1. Group the servers by creating a server smart group.
  2. Copy the following script to a text file and save that file as fileName.nsh:

    PROFILE=$1
    USER=$2
    PASSWORD=$3
    ROLENAME=$4
    GROUP=$5
    PROPERTY=$6
    TENANT=$7

    echo "Running command: setTenantProperty.nsh $PROFILE $USER $PASSWORD $ROLENAME $GROUP $PROPERTY $TENANT"

    CONNECT=`blcred cred -acquire -profile $PROFILE -username $USER -password $PASSWORD`

    if [ $? -eq 0 ]; then
    echo "Connect output: $CONNECT"
    echo "Successfully connected to the app server"

    blcli_init
    blcli_setoption serviceProfileName $PROFILE
    blcli_setoption roleName $ROLENAME
    blcli_connect

    blcli_execute PropertyClass isPropertyDefined Class://SystemObject/Server $PROPERTY
    blcli_storeenv PROPERTY_EXISTS

    if [ "$PROPERTY_EXISTS" = "true" ]; then
    blcli_execute SmartServerGroup findGroupByQualifiedName $GROUP
    GROUP_EXISTS_RETURN_CODE=`echo $?`
    blcli_storeenv GROUP_EXISTS

    if [ $GROUP_EXISTS_RETURN_CODE = 0 ]; then
    blcli_execute Server listServersInGroup $GROUP
    blcli_storeenv SERVER_LIST

    for serverName in $SERVER_LIST
    do
    echo "Setting Property value for $PROPERTY on $serverName as $TENANT"
    blcli_execute Server setPropertyValueByName $serverName $PROPERTY $TENANT
    done
    else
    echo "ERROR: The server smart group could not be found"
    fi
    else
    echo "ERROR: The tenant property is not defined"
    fi

    blcli_destroy
    else
    echo "Connect output: $CONNECT"
    echo "ERROR: Authentication failed"
    fi
  3. Add the fileName.nsh script to the Depot folder.
  4. Create and execute an NSH Script Job.

To create a server smart group

  1. Open the TrueSight Server Automation Console.
  2. Right-click the Servers folder and select New > Server Smart Group.
  3. In the New Server Smart Group wizard, enter the name and description for the smart group.
  4. Enter the condition to group the servers.
     The following figure shows a group, ServerSmartTenant1, which contains all the servers that have names ending with clbro.com.
    SmartGroupTenant1.png
  5. Click Next, and then Finish.
     The server smart group is added to the Servers folder.

To add the script to the Depot folder on TrueSight Server Automation

  1. Right-click the Depot folder and select New Depot Folder.
  2. In the New Depot Folder wizard, enter a name for the folder, such as TenantFolder, and then click Finish.
  3. Right-click the TenantFolder folder and click New > NSHScript.
  4. In the Add NSH Script to Depot wizard, enter a name for the script.
  5. In the File Location field, browse to the location of the fileName.nsh script that you created earlier.
  6. In the Script Type field, select the Execute script once, passing the host list as a parameter to the script option.
  7. Click Next.
  8. Add the following parameters:

    Notes

    • Check the Value required at run time check box for all parameters.
    • Check the Editable check box for all parameters except the SERVER parameter.

    Parameter

    Value

    PROFILE

    Name of an existing TrueSight Server Automation Authentication Service profile

    USER

    TrueSight Server Automation user who has all the required access to the server smart group

    PASSWORD

    Password for the TrueSight Server Automation user

    ROLENAME

    Role of the TrueSight Server Automation user

    GROUP

    Full path of the server smart group starting with ‘/’
    For example, if you have created the ServerSmartTenant1 server smart group directly in the Servers folder, enter /ServerSmartTenant1.

    PROPERTY

    Name of the server property
    In this case, enter CUSTOMER.

    TENANT

    Value for the CUSTOMER property

    SERVER

    %h

  9. Click Next, and then click Finish.

To create and run the NSH Script Job

  1. Right-click the Jobs folder and click New > Job Folder.
  2. In the New Job Folder dialog box, enter a name for the folder.
  3. Click Next, and then click Finish.
  4. Right-click the new job folder and click New > NSH Script Job.
  5. In the New NSH Script Job wizard, enter a name for the job.
  6. In the NSH Script field, browse to the location of NSH Script you created in To add the script to the Depot folder on TrueSight Server Automation.
  7. Click Next.
  8. Select the ServerSmartTenant1 server smart group and move it to the Selected Server list.
  9. Click Next.
  10. Verify the values of the script parameters, and click Next.
  11. In Job Run Notifications, select the required option, and click Next.
  12. Select the Execute job now option, and click Finish.
     When the job is complete, the Status column in the right pane displays the following message:
    Completed successfully

The CUSTOMER property for the servers in the smart group is updated with the value that you provided while creating the NSH Script.

Where to go from here

Running-ETL-for-multitenancy

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*