--- /dev/null
+=head1 NAME
+
+vos_setaddrs - Set new addresses for a file server's entry in the VLDB
+
+=head1 SYNOPSIS
+
+=for html
+<div class="synopsis">
+
+B<vos setaddrs> S<<< B<-uuid> <I<UUID of server>> >>>
+ S<<< B<-host> <I<IP address>>+ >>>
+ S<<< [B<-cell> <I<cell name>>] >>> [B<-noauth>] [B<-localauth>]
+ [B<-verbose>] [B<-encrypt>] [B<-noresolve>] [B<-help>]
+
+B<vos seta> S<<< B<-u> <I<UUID of server>> >>>
+ S<<< B<-ho> <I<IP address>>+ >>>
+ S<<< [B<-c> <I<cell name>>] >>>
+ [B<-noa>] [B<-l>] [B<-v>] [B<-e>] [B<-nor>] [B<-h>]
+
+=for html
+</div>
+
+=head1 DESCRIPTION
+
+The B<vos setaddrs> command sets the IP addresses for a server entry
+in the Volume Location Database (VLDB). Specify one or serveral hosts.
+All existing hosts in the VLDB entry are replaced with the new entries
+on the command line.
+
+To display all VLDB server entries, for example to find the UUID,
+use the B<vos listaddrs> command.
+
+=head1 CAUTIONS
+
+Setting the wrong addresses will make the volumes on that file server
+unreachable from AFS clients.
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<-uuid> <I<UUID of server>>
+
+The unique ID as provided by the B<vos listaddrs> command.
+
+=item B<-host> <I<IP address>>+
+
+List of IP addresses for the file server.
+
+=item B<-cell> <I<cell name>>
+
+Names the cell in which to run the command. Do not combine this argument
+with the B<-localauth> flag. For more details, see L<vos(1)>.
+
+=item B<-noauth>
+
+Assigns the unprivileged identity C<anonymous> to the issuer. Do not
+combine this flag with the B<-localauth> flag. For more details, see
+L<vos(1)>.
+
+=item B<-localauth>
+
+Constructs a server ticket using a key from the local
+F</usr/afs/etc/KeyFile> file. The B<vos> command interpreter presents it
+to the Volume Server and Volume Location Server during mutual
+authentication. Do not combine this flag with the B<-cell> argument or
+B<-noauth> flag. For more details, see L<vos(1)>.
+
+=item B<-verbose>
+
+Produces on the standard output stream a detailed trace of the command's
+execution. If this argument is omitted, only warnings and error messages
+appear.
+
+=item B<-encrypt>
+
+Encrypts the command so that the operation's results are not transmitted
+across the network in clear text. This option is available in OpenAFS
+versions 1.4.11 or later and 1.5.60 or later.
+
+=item B<-noresolve>
+
+Shows all servers as IP addresses instead of the DNS name. Lets you
+work with IP addresses for input, without the DNS translation between
+the input and the registration of the IP address in the VLDB.
+
+=item B<-help>
+
+Prints the online help for this command. All other valid options are
+ignored.
+
+=back
+
+=head1 EXAMPLES
+
+The following command sets addresses C<192.12.107.214> and C<10.47.11.17> for the UUID 008f157e-bad0-157c-0ffee-357c4d1faa77
+
+ % vos setaddrs -uuid 008f157e-bad0-157c-0ffee-357c4d1faa77 -host 192.12.107.214 -host 10.47.11.17 -verbose
+ vos: Changed UUID with addresses:
+ UUID: 008f157e-bad0-157c-0ffee-357c4d1faa77
+ 192.12.107.214
+ 10.47.11.17
+
+=head1 PRIVILEGE REQUIRED
+
+Issuer must be listed in the F</usr/afs/etc/UserList> file on
+each database server machine.
+
+=head1 SEE ALSO
+
+L<CellServDB(5)>,
+L<UserList(5)>,
+L<sysid(5)>,
+L<fileserver(8)>,
+L<vos(1)>,
+L<vos_listaddrs(1)>
+
+=head1 COPYRIGHT
+
+KTH 2010. All Rights Reserved.
+
+This documentation is covered by the IBM Public License Version 1.0.
/*
- * Parse a server name/address and return the address in HOST BYTE order
+ * Parse a server dotted address and return the address in network byte order
*/
afs_int32
-GetServer(char *aname)
+GetServerNoresolve(char *aname)
{
- register struct hostent *th;
- afs_int32 addr;
int b1, b2, b3, b4;
- register afs_int32 code;
- char hostname[MAXHOSTCHARS];
+ afs_int32 addr;
+ afs_int32 code;
code = sscanf(aname, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
if (code == 4) {
addr = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
- addr = ntohl(addr); /* convert to host order */
- } else {
+ addr = htonl(addr); /* convert to network byte order */
+ return addr;
+ } else
+ return 0;
+}
+/*
+ * Parse a server name/address and return the address in network byte order
+ */
+afs_int32
+GetServer(char *aname)
+{
+ register struct hostent *th;
+ afs_int32 addr; /* in network byte order */
+ register afs_int32 code;
+ char hostname[MAXHOSTCHARS];
+
+ if ((addr = GetServerNoresolve(aname)) == 0) {
th = gethostbyname(aname);
if (!th)
return 0;
code = gethostname(hostname, MAXHOSTCHARS);
if (code)
return 0;
- th = gethostbyname(hostname); /* returns host byte order */
+ th = gethostbyname(hostname);
if (!th)
return 0;
memcpy(&addr, th->h_addr, sizeof(addr));
afs_int32 ip1, ip2, vcode;
int remove = 0;
- ip1 = GetServer(as->parms[0].items->data);
+ if (noresolve)
+ ip1 = GetServerNoresolve(as->parms[0].items->data);
+ else
+ ip1 = GetServer(as->parms[0].items->data);
if (!ip1) {
fprintf(STDERR, "vos: invalid host address\n");
return (EINVAL);
}
if (as->parms[1].items) {
- ip2 = GetServer(as->parms[1].items->data);
+ if (noresolve)
+ ip2 = GetServerNoresolve(as->parms[1].items->data);
+ else
+ ip2 = GetServer(as->parms[1].items->data);
if (!ip2) {
fprintf(STDERR, "vos: invalid host address\n");
return (EINVAL);
vcode = ubik_VL_ChangeAddr(cstruct, UBIK_CALL_NEW, ntohl(ip1), ntohl(ip2));
if (vcode) {
+ char hoststr1[16], hoststr2[16];
if (remove) {
+ afs_inet_ntoa_r(ip2, hoststr2);
fprintf(STDERR, "Could not remove server %s from the VLDB\n",
- as->parms[0].items->data);
+ hoststr2);
if (vcode == VL_NOENT) {
fprintf(STDERR,
"vlserver does not support the remove flag or ");
}
} else {
+ afs_inet_ntoa_r(ip1, hoststr1);
+ afs_inet_ntoa_r(ip2, hoststr2);
fprintf(STDERR, "Could not change server %s to server %s\n",
- as->parms[0].items->data, as->parms[1].items->data);
+ hoststr1, hoststr2);
}
PrintError("", vcode);
return (vcode);
return 0;
}
+
+static int
+SetAddrs(register struct cmd_syndesc *as, void *arock)
+{
+ afs_int32 vcode;
+ bulkaddrs m_addrs;
+ afsUUID askuuid;
+ afs_uint32 FS_HostAddrs_HBO[ADDRSPERSITE];
+
+ memset(&m_addrs, 0, sizeof(bulkaddrs));
+ memset(&askuuid, 0, sizeof(afsUUID));
+ if (as->parms[0].items) {
+ /* -uuid */
+ if (afsUUID_from_string(as->parms[0].items->data, &askuuid) < 0) {
+ fprintf(STDERR, "vos: invalid UUID '%s'\n",
+ as->parms[0].items->data);
+ exit(-1);
+ }
+ }
+ if (as->parms[1].items) {
+ /* -host */
+ struct cmd_item *ti;
+ struct hostent *he;
+ afs_int32 saddr;
+ int i = 0;
+
+ for (ti = as->parms[1].items; ti && i < ADDRSPERSITE; ti = ti->next) {
+
+ if (noresolve)
+ saddr = GetServerNoresolve(ti->data);
+ else
+ saddr = GetServer(ti->data);
+
+ if (!saddr) {
+ fprintf(STDERR, "vos: Can't get host info for '%s'\n",
+ ti->data);
+ exit(-1);
+ }
+ /* Convert it to host byte order */
+ FS_HostAddrs_HBO[i] = ntohl(saddr);
+ i++;
+ }
+ m_addrs.bulkaddrs_len = i;
+ m_addrs.bulkaddrs_val = FS_HostAddrs_HBO;
+ }
+
+ vcode = ubik_VL_RegisterAddrs(cstruct, 0, &askuuid, 0, &m_addrs);
+
+ if (vcode) {
+ if (vcode == VL_MULTIPADDR) {
+ fprintf(STDERR, "vos: VL_RegisterAddrs rpc failed; The IP address exists on a different server; repair it\n");
+ PrintError("", vcode);
+ return vcode;
+ } else if (vcode == RXGEN_OPCODE) {
+ fprintf(STDERR, "vlserver doesn't support VL_RegisterAddrs rpc; ignored\n");
+ PrintError("", vcode);
+ return vcode;
+ }
+ }
+ if (verbose) {
+ fprintf(STDOUT, "vos: Changed UUID with addresses:\n");
+ print_addrs(&m_addrs, &askuuid, m_addrs.bulkaddrs_len, 1);
+ }
+ return 0;
+}
+
static int
LockEntry(register struct cmd_syndesc *as, void *arock)
{
"transaction ID");
COMMONPARMS;
+ ts = cmd_CreateSyntax("setaddrs", SetAddrs, NULL,
+ "set the list of IP address for a given UUID in the VLDB");
+ cmd_AddParm(ts, "-uuid", CMD_SINGLE, 0, "uuid of server");
+ cmd_AddParm(ts, "-host", CMD_LIST, 0, "address of host");
+
+ COMMONPARMS;
code = cmd_Dispatch(argc, argv);
if (rxInitDone) {
/* Shut down the ubik_client and rx connections */