wrsmconf.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2001-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* This file implments the RSM Proxy.
*
* The program is controlled by its command line arguments.
* The first argument is always the name of the command to be
* executed followed by some number of options with the
* appropriate parameter values.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <libintl.h>
#include <locale.h>
#include <sys/int_fmtio.h>
#include <sys/systeminfo.h>
#include <sys/wrsmconf.h>
#include <stddef.h>
#include <errno.h>
#include "wrsmconf_msgs.h"
#define CTLRDEVNAME "/dev/wrsm%d"
#define MAX_WCI_IDS 54
extern int ErrorCount;
struct dump_info {
char host_name[WRSM_HOSTNAMELEN];
unsigned char cnode_id;
};
static void init_usage(void);
static void print_command_usage(char *command);
static int getinfo(int controller_id);
int num_members);
/* Private function in libwrsmconf */
static struct {
char *name;
char *usage;
{ "usage", "[<command>]" },
{ "replace", "-f <in-filename> [-c <controller-id>] [-h <hostname>]" },
{ "install", "[-c <controller-id>] [-w <wci-id>]" },
{ "enable", "[-c <controller-id>] [-w <wci-id>]" },
{ "info", "[-c <controller-id>]" },
{ "read", "[-c <controller-id>] -f <in-filename> [-h <hostname>]" },
{ "start", "[-c <controller-id>]" },
{ "stop", "[-c <controller-id>]" },
{ "link_disable", "-w <wci-id> -l <linkno>" },
{ "link_enable", "-w <wci-id> -l <linkno>" },
{ "check", "[-c <controller-id>] [-h <hostname>]" },
{ "msgtest", "" },
};
static char *command_name;
extern char *optarg;
extern int optind;
extern int opterr;
extern int optopt;
int
{
int controller_id = -1;
char c;
char *command;
int wci_index = 0;
int rc;
int linkno = -1;
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
command_name = argv[0];
if (argc < 2) {
return (2);
}
!= EOF) {
switch (c) {
case 'c':
break;
case 'f':
break;
case 'w':
num_wcis++;
break;
case 'h':
break;
case 'l':
break;
default:
return (1);
}
}
if (!got_controller_id) {
return (1);
}
return (1);
}
return (1);
}
if (got_hostname)
else
if (rc != 0) {
return (1);
}
if (got_controller_id &&
return (1);
}
return (1);
}
if (!got_controller_id) {
rc = wrsm_start_all_configs();
return (rc ? 1 : 0);
return (1);
}
if (!got_controller_id) {
rc = wrsm_stop_all_configs();
return (rc ? 1 : 0);
return (1);
}
if (!got_controller_id) {
return (rc ? 1 : 0);
return (1);
}
return (1);
}
if (got_hostname)
else
if (rc != 0) {
return (1);
}
if (got_controller_id &&
return (1);
}
return (1);
}
if (!got_controller_id) {
controller_id = 0;
}
wci_ids)) != 0) {
return (1);
}
if (!got_controller_id) {
controller_id = 0;
}
wci_ids)) != 0) {
return (1);
}
if (!got_controller_id) {
return (1);
}
return (1);
}
return (getinfo(controller_id));
return (topology(controller_id));
if (argc == 3) {
} else {
}
} else {
}
return (1);
}
if (got_hostname)
else
if (rc != 0) {
return (1);
}
if (got_controller_id &&
return (1);
}
return (1);
}
if (rc != 0) {
return (1);
}
return (1);
}
if (rc != 0) {
return (1);
}
(void) printf(MSG_INPUT1);
(void) printf(MSG_INPUT2);
(void) printf(MSG_INPUT3);
"hostname2");
} else {
return (1);
}
return (0);
}
void
{
gettext("-c <controller id> -f <output file name>");
gettext("[-c <controller id>] -f <input file name>");
gettext("-c <controller id> -f <output file name>");
}
void
{
int i;
init_usage();
if (private) {
(void) printf("private commands:\n");
for (i = 0; private_commands[i].name; i++) {
private_commands[i].usage);
}
}
}
static void
print_command_usage(char *command)
{
int i;
init_usage();
break;
}
}
}
}
/*
* If dump_config is called with a controller id that is less than 0,
* it scans all available controllers and prints the number of
* those which are active. If there is a valid controller-id
* argument, it gets the config data from the kernel, unparses
* it, and prints its contents.
*/
int
{
if (file_name) {
} else {
}
perror("dump");
}
return (1);
}
return (0);
}
/*
* If getinfo is called with a controller id that is less than 0,
* it prints info on all available controllers.
*/
int
getinfo(int controller_id)
{
int i;
if (controller_id < 0) {
int n;
if ((n = wrsm_get_num_controllers()) < 0) {
perror("info");
return (1);
}
for (i = 0; i < n; ++i)
if (wrsm_get_config(i, &config) == 0) {
(void) getinfo(i);
}
return (0);
}
perror("info");
return (1);
}
}
return (0);
}
void
{
int controller_index = 0;
int member_index;
if (controller_info == NULL) {
return;
}
member_index = 0;
!= NULL) {
member_index++;
}
}
}
int
{
return (-1);
return (1);
} else {
return (-1);
return (1);
} else {
return (0);
}
}
}
void
{
}
void
{
int i;
for (i = 0; i < num_members; i++) {
}
}
int
{
int num_conts;
int controller_id;
int i;
struct dump_info ***controller_info;
int cont_index = 0;
int member_index;
int total_num_members = 0;
struct dump_info **member_info;
int member_count;
if (cid == -1) {
/* get the number of controllers */
if ((num_conts = wrsm_get_num_controllers()) < 0) {
perror("topology");
return (1);
}
} else {
/* print the specific controller */
num_conts = 1;
}
/* allocate num_controllers info records to hold the needed data */
perror("topology");
return (1);
}
/* Set last pointer to NULL for easy structure traversal, redundant */
for (i = 0; i < num_conts; ++i) {
if (cid == -1)
controller_id = i;
else
controller_id = cid;
continue;
}
/*
* allocate memory for the number of members in this
* controller
*/
perror("toplogy");
return (1);
}
/*
* Set last pointer to NULL for easy structure
* traversal
*/
/*
* Allocate each member record used to hold the info
* we are after and place the appropriate controller
* info in the new dump_info structs
*/
for (member_index = 0;
member_index++) {
(struct dump_info *)
== NULL) {
perror("toplogy");
return (1);
}
->fmnodeid;
hostname);
}
cont_index++;
}
/*
* All the member info is retrieved so now we allocate space for
* a flat array for sorting
*/
perror("toplogy");
return (1);
}
/* copy the struct dump_info *'s to the one-dimensional array */
cont_index = 0;
member_count = 0;
member_index = 0;
member_info[member_count++] =
member_index++;
}
cont_index++;
}
return (0);
}
static int
{
int fd;
int rc;
const int count = 100;
if (fd == -1) {
perror("open");
return (1);
}
return (rc);
}
static int
{
int retval = 0;
int i;
if (controller_id < 0) {
int n;
if ((n = wrsm_get_num_controllers()) < 0) {
perror("info");
return (1);
}
for (i = 0; i < n; ++i) {
if (wrsm_get_config(i, &config) == 0) {
retval = 1;
}
}
}
return (retval);
}
perror("check");
return (1);
}
int ave_time;
int rc;
host_found = B_TRUE;
&ave_time);
if (rc == 0) {
(void) printf(" check of %s successful, "
ave_time);
} else {
(void) printf(" check of %s failed\n",
retval = 1;
}
}
}
if (!host_found) {
retval = 1;
}
return (retval);
}