HP XC System Software Administration Guide Version 4.0

Table Of Contents
Writing gconfigure Scripts
The information in this section provides information about how to write a gconfigure script.
A sample gconfigure script is provided in the /opt/hptc/templates/gconfig.d/
gconfig_template.pl file for your reference.
The gconfigure and other configuration scripts often use the Perl Set::Node package,
which is derived from the Set::Scalar package (from Perl's CPAN) to facilitate working with
sets of nodes with the usual set operators (union, intersection, difference, and so on). In
object-oriented terms, Set::Node is a Set::Scalar.
For more information about the Set::Scalar package from which Set::Node inherits, enter
the following command to view the manpage:
# man Set::Scalar
The main difference between the Set::Scalar and Set::Node packages is that
node_set->members() returns nodes in numerically sorted order, and
scalar_set->members() returns members in random order. When order does not matter
but efficiency does matter, use node_set->unsorted_members(). Set::Node also adds the
select_by_name and select_by_attribute member functions.
Example 4-1 shows a sample gconfig script that performs client selection and client-to-server
assignments.
Example 4-1 Sample gconfig Script: Client Selection and Client-to-Server Assignment
my($service) = 'my_new_service';
sub gconfigure
{
my(@servers) = @_;
cs_reset_service($service,@servers);
1
my($client_flags) = ''; # "all selected nodes", default
2
my($assignment_flags) = ''; # "client may be assigned to itself", default
3
# Make a server set from the server list
my($serverset) = Set::Node->select_by_name(@servers);
4
# Get my client list
# Client list is "all nodes"
my($clientset) = cs_get_all_clients
5
($service,$serverset,$client_flags);
# Assign client nodes to server nodes and modify database
my(%map) = cs_assign_clients_to_servers
6
($service,$serverset,$clientset, $assignment_flags);
}
1
This instruction clears any previous client/server assignments for this service in the database.
2
The $client_flags are used by cs_get_all_clients(...) to include or to exclude
specific nodes as clients. The default is all selected nodes (that is, exclude none).
Service attributes for client selection are as follows:
sa_no_client_on_server
The clients are all nodes except for the nodes in the server set. The servers are not also
clients.
sa_clients_match_servers
The client set is exactly the same as the server set.
sa_clients_are_servers_of.service
The clients of this service are the same set as the servers of some related service.
sa_all_selected_nodes
This is the default, which is the same as the double quote character (); it means all
nodes of the HP XC system.
4.6 Customizing Services and Roles 67