Searching the Help
To search for information in the Help, type a word or phrase in the Search box. When you enter a group of words, OR is inferred. You can use Boolean operators to refine your search.
Results returned are case insensitive. However, results ranking takes case into account and assigns higher scores to case matches. Therefore, a search for "cats" followed by a search for "Cats" would return the same number of Help topics, but the order in which the topics are listed would be different.
Search for | Example | Results |
---|---|---|
A single word | cat
|
Topics that contain the word "cat". You will also find its grammatical variations, such as "cats". |
A phrase. You can specify that the search results contain a specific phrase. |
"cat food" (quotation marks) |
Topics that contain the literal phrase "cat food" and all its grammatical variations. Without the quotation marks, the query is equivalent to specifying an OR operator, which finds topics with one of the individual words instead of the phrase. |
Search for | Operator | Example |
---|---|---|
Two or more words in the same topic |
|
|
Either word in a topic |
|
|
Topics that do not contain a specific word or phrase |
|
|
Topics that contain one string and do not contain another | ^ (caret) |
cat ^ mouse
|
A combination of search types | ( ) parentheses |
|
SA CLI method tutorial
This topic introduces you to the SA CLI methods with examples you can try in your own environment. After completing this tutorial, you should be able to run SA CLI methods, examine the self
file of an SA object, and create a script that invokes SA CLI methods on multiple servers.
Before starting the tutorial, you need the following capabilities:
- You can log on to the SA Client.
- Your SA user has Read & Write permissions on at least one managed server. Typically assigned by a security administrator, permissions are discussed in the Server Automation Administration Guide on the HPE SSO portal.
- Your SA user has all OGSH permissions on the same managed server. For information on these permissions, see the “aaa Utility” section in the Server Automation Using Guide on the HPE SSO portal.
- You are familiar with the OGSH and the OGFS. If these features are new to you, before proceeding with this tutorial, see the Global Shell section inthe Server Automation Using Guide on the HPE SSO portal.
The example commands in this tutorial operate on a Windows server named abc.example.com
. This server belongs to a server group named All Windows Servers. When trying out these commands, substitute abc.example.com
with the host name of the managed server you have permission to access.
- Open an OGSH session.
You can open a Global Shell session from within the SA Client. From the Actions menu, select Global Shell. You can also open an OGSH session from a terminal client running on your desktop. For instructions, see Opening a Global Shell Session section in the Server Automation Using Guide on the HPE SSO portal. - List the SA CLI methods for a server.
Themethod
subdirectory of a specific server contains executable files—the methods you can run for that server. The following example lists the SA CLI methods for theabc.example.com
server:$ cd /opsw/Server/@/abc.example.com/method
$ ls -1
addDeviceGroups
attachPolicies
attachVirtualColumn
checkDuplex
clearCustAttrs
...
These methods have instance context – they act on a specific server instance (in this case,abc.example.com
). The server instance can be inferred from the path of the method. Methods with static context are discussed in step 5. - Run an SA CLI method without parameters.
To display the public server groups thatabc.example.com
belongs to, invoke thegetDeviceGroups
method:$ cd /opsw/Server/@/abc.example.com/method
$ ./getDeviceGroups
Accounting App
All Windows Servers
Visalia Vendors - Run a method with a parameter.
Command-line parameters for methods are indicated by name-value pairs, separated by white space characters. In the following invocation ofsetCustomer
, the parameter name iscustomer
and the value is 20039. The:i
at the end of the parameter name is an ID format specifier, which is discussed in a later step.
The following method invocation changes the customer of theabc.example.com
server from Opsware to C39. The ID of customer C39 is 20039.$ cd /opsw/Server/@/abc.example.com
$ cat attr/customer ; echo
Opsware
$ method/setCustomer customer:i=20039
$ cat attr/customer ; echo
C39 - List the static context methods for managed servers.
Static context methods reside under the/opsw/api
directory. These methods are not limited to a specific instance of an object.
To list the static methods for servers, enter the following commands:$ cd /opsw/api/com/opsware/server/ServerService/method
$ ls
The methods listed are the same as those displayed in step 2. - Run a method with the
self
parameter.
This step invokesgetDeviceGroups
as a static context method. Unlike the instance context method shown in step 3, the static context method requires theself
parameter to identify the server instance.
For example, suppose that theabc.example.com
server has an ID of 530039. To list the groups of this server, enter the following commands:$ cd /opsw/api/com/opsware/server/ServerService/method
$ ./getDeviceGroups self:i=530039
Accounting App
All Windows Servers
Visalia Vendors
Compare this invocation ofgetDeviceGroups
with the invocation in step 3 that demonstrates instance context. Both invocations run the same underlying method in the API and return the same results. - Examine the
self
file of a server.
Within SA, each managed server is an object. However, OGFS is a file system, not an object model. Theself
file provides access to various representations of an SA object. These representations are the ID, name, and structure.
The default representation for a server is its name. For example, to display the name of a server, enter the following commands:$ cd /opsw/Server/@/abc.example.com
$ cat self ; echo
abc.example.com
If you know the ID of a server, you can get the name from theself
file, as in the following example:$ cat /opsw/.Server.ID/530039/self ; echo
abc.example.com -
Indicate an ID format specifier on a
self
file.
To select a particular representation of theself
file, enter a period, then the file name, followed by the format specifier. For example, the followingcat
command includes the format specifier (:i
) to display the server ID:
$ cd /opsw/Server/@/abc.example.com
$ cat .self:i ; echo
com.opsware.server.ServerRef:530039
This output shows that the ID ofabc.example.com
is 530039. Thecom.opsware.server.ServerRef
is the class name of a server reference, the corresponding object in the SA API.Note The leading period is required with format specifiers on files and method return values, but is not indicated with method parameters.
- Indicate the structure format specifier.
The structure format specifier (:s
) indicates the attributes of a complex object. The attributes are displayed as name-value pairs, all enclosed in curly braces. Structure formats are used to specify method parameters on the command-line that are complex objects. For an example method call, see Complex objects and arrays as parameters.
The following example displaysabc.example.com
with the structure format:$ cd /opsw/Server/@/abc.example.com
$ cat .self:s ; echo
{
managementIP="192.168.8.217"
modifiedBy="spujare"
manufacturer="DELL COMPUTER CORPORATION"
use="UNKNOWN"
discoveredDate=1149012848000
origin="ASSIMILATED"
osSPVersion="SP4"
locale="English_United States.1252"
reporting=false
netBIOSName=
previousSWReg=1150673874000
osFlavor="Windows 2000 Advanced Server"
. . .
The attributes of a server are also represented by the files in theattr
directory, for example:$ pwd
/opsw/Server/@/abc.example.com
$ cat attr/osFlavor ; echo
Windows 2000 Advanced Server - Create a script that invokes an SA CLI method.
The example script shown in this step iterates through the servers of the public server group named All Windows Servers. On each server, the script runs thegetCommCheckTime
SA CLI method.
First, return to your home directory in the OGFS:$ cd
$ cd public/bin
Next, run thevi
editor:$ vi
Invi
, insert the following lines to create abash
script:#!/bin/bash
# iterate_time.sh
METHOD_DIR="/opsw/api/com/opsware/server/ServerService/method"
GROUP_NAME="All Windows Servers"
cd "/opsw/Group/Public/$GROUP_NAME/@/Server"
for SERVER_NAME in *
do
SERVER_ID=`cat $SERVER_NAME/.self:i`
echo $SERVER_NAME
$METHOD_DIR/getCommCheckTime self:i=$SERVER_ID
echo
echo
done
Save the file invi
, naming it iterate_time.sh. Quitvi
.
Change the permissions of iterate_time.sh with chmod, and then run it:$ chmod 755 iterate_time.sh
$ ./iterate_time.sh
abc.example.com
2006/06/20 16:46:56.000
. . .
We welcome your comments!
To open the configured email client on this computer, open an email window.
Otherwise, copy the information below to a web mail client, and send this email to hpe_sa_docs@hpe.com.
Help Topic ID:
Product:
Topic Title:
Feedback: