From 475ddc66b902c361e04a7cdf5f4026c9e28aed6d Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Mon, 17 Nov 2014 11:23:38 -0500 Subject: [PATCH] vos: remaddrs sub-command Introduce the vos remaddrs sub-command for removing multi-homed server entries from the vldb. The remaddrs sub-command completes the listaddrs and setaddrs command suite and allows vos changeaddr to be deprecated completely. Reviewed-on: http://gerrit.openafs.org/11606 Tested-by: BuildBot Reviewed-by: Chas Williams <3chas3@gmail.com> Reviewed-by: Daria Brashear Reviewed-by: Jeffrey Altman (cherry picked from commit d1d411576cf39c4bc55918df0eb64327718d566c) Change-Id: I427077559509c9cb658a6758d8b371b744e6c643 Reviewed-on: http://gerrit.openafs.org/12092 Reviewed-by: Mark Vitale Tested-by: BuildBot Reviewed-by: Benjamin Kaduk Reviewed-by: Stephan Wiesand --- doc/man-pages/pod1/vos.pod.in | 3 +- doc/man-pages/pod1/vos_changeaddr.pod | 4 +- doc/man-pages/pod1/vos_listaddrs.pod | 5 +- doc/man-pages/pod1/vos_remaddrs.pod | 76 ++++++++++++++++++++++++++ doc/man-pages/pod1/vos_setaddrs.pod | 3 +- src/volser/vos.c | 79 ++++++++++++++++++++++++--- 6 files changed, 157 insertions(+), 13 deletions(-) create mode 100644 doc/man-pages/pod1/vos_remaddrs.pod diff --git a/doc/man-pages/pod1/vos.pod.in b/doc/man-pages/pod1/vos.pod.in index 101a5ed4a..6204b5f88 100644 --- a/doc/man-pages/pod1/vos.pod.in +++ b/doc/man-pages/pod1/vos.pod.in @@ -61,7 +61,8 @@ and L|vos_zap(1)>. Commands to edit or display VLDB server entries: L|vos_changeaddr(1)>, L|vos_listaddrs(1)> -and L|vos_setaddrs(1)>. +L|vos_setaddrs(1)>, +and L|vos_remaddrs(1)>. =item * diff --git a/doc/man-pages/pod1/vos_changeaddr.pod b/doc/man-pages/pod1/vos_changeaddr.pod index ffe28bf93..d66a47d2f 100644 --- a/doc/man-pages/pod1/vos_changeaddr.pod +++ b/doc/man-pages/pod1/vos_changeaddr.pod @@ -26,9 +26,9 @@ The B command removes a server entry from the Volume Location Database (VLDB) when the B<-remove> flag is combined with the B<-oldaddr> argument. There must be no VLDB entries that list the machine as a site for any version of a volume (if necessary, use the B -or B command to more or remove volumes). It is appropriate to +or B command to move or remove volumes). It is appropriate to remove a VLDB server entry when removing the corresponding file server -machine from service; this is the only recommended use of the command. +machine from service. To display all VLDB server entries, use the B command. diff --git a/doc/man-pages/pod1/vos_listaddrs.pod b/doc/man-pages/pod1/vos_listaddrs.pod index 3f5d91d49..5f1ed14ae 100644 --- a/doc/man-pages/pod1/vos_listaddrs.pod +++ b/doc/man-pages/pod1/vos_listaddrs.pod @@ -138,9 +138,10 @@ None L, L, L, -L, L, -L +L, +L, +L =head1 COPYRIGHT diff --git a/doc/man-pages/pod1/vos_remaddrs.pod b/doc/man-pages/pod1/vos_remaddrs.pod new file mode 100644 index 000000000..1c1a11fee --- /dev/null +++ b/doc/man-pages/pod1/vos_remaddrs.pod @@ -0,0 +1,76 @@ +=head1 NAME + +vos_remaddrs - removes a file server machine's entry from the VLDB + +=head1 SYNOPSIS + +=for html +
+ +B S<<< B<-uuid> > >>> + S<<< [B<-cell> >] >>> [B<-noauth>] [B<-localauth>] + [B<-verbose>] [B<-encrypt>] [B<-noresolve>] + S<<< [B<-config> >] >>> + [B<-help>] + +B S<<< B<-u> > >>> + S<<< [B<-c> >] >>> + [B<-noa>] [B<-l>] [B<-v>] [B<-e>] [B<-nor>] + S<<< [B<-co> >] >>> + [B<-h>] + +=for html +
+ +=head1 DESCRIPTION + +The B command removes a server entry from the Volume Location +Database (VLDB). There must be no VLDB entries that list the machine as a site +for any version of a volume. If necessary, use the B or B +command to move or remove volumes. It is appropriate to remove a VLDB server +entry when removing the corresponding file server machine from service. + +To display all VLDB server entries, use the B command. + +=head1 OPTIONS + +=over 4 + +=item B<-uuid> > + +The unique ID as provided by the C command. + +=back + +=head1 EXAMPLES + +The following command removes the VLDB server entry for the file server +with the addresses C<192.12.107.214> and C<10.47.11.17>. + + $ vos remaddrs -uuid 008f157e-bad0-157c-0ffee-357c4d1faa77 -verbose + vos: Removing 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 file on each database +server machine. + +=head1 SEE ALSO + +L, +L, +L, +L, +L, +L + +=head1 COPYRIGHT + +Copyright 2014 Sine Nomine Associates. All Rights Reserved. + +This documentation is covered by the BSD License as written in the +doc/LICENSE file. This man page was written by Michael Meffie for +OpenAFS. diff --git a/doc/man-pages/pod1/vos_setaddrs.pod b/doc/man-pages/pod1/vos_setaddrs.pod index 8d4c84c79..78ff00ae1 100644 --- a/doc/man-pages/pod1/vos_setaddrs.pod +++ b/doc/man-pages/pod1/vos_setaddrs.pod @@ -131,7 +131,8 @@ L, L, L, L, -L +L, +L =head1 COPYRIGHT diff --git a/src/volser/vos.c b/src/volser/vos.c index 47a94f492..0366efd96 100644 --- a/src/volser/vos.c +++ b/src/volser/vos.c @@ -5321,7 +5321,7 @@ print_addrs(const bulkaddrs * addrs, afsUUID * m_uuid, int nentries, int print) { int i; - afs_uint32 *addrp; + afs_uint32 addr; char buf[1024]; if (print) { @@ -5330,14 +5330,13 @@ print_addrs(const bulkaddrs * addrs, afsUUID * m_uuid, int nentries, } /* print out the list of all the server */ - addrp = (afs_uint32 *) addrs->bulkaddrs_val; - for (i = 0; i < nentries; i++, addrp++) { - *addrp = htonl(*addrp); + for (i = 0; i < addrs->bulkaddrs_len; i++) { + addr = htonl(addrs->bulkaddrs_val[i]); if (noresolve) { char hoststr[16]; - printf("%s\n", afs_inet_ntoa_r(*addrp, hoststr)); + printf("%s\n", afs_inet_ntoa_r(addr, hoststr)); } else { - printf("%s\n", hostutil_GetNameByINet(*addrp)); + printf("%s\n", hostutil_GetNameByINet(addr)); } } @@ -5517,6 +5516,68 @@ SetAddrs(struct cmd_syndesc *as, void *arock) return 0; } +static int +RemoveAddrs(struct cmd_syndesc *as, void *arock) +{ + afs_int32 code; + ListAddrByAttributes attrs; + afsUUID uuid; + afs_int32 uniq = 0; + afs_int32 nentries = 0; + bulkaddrs addrs; + afs_uint32 ip1; + afs_uint32 ip2; + + memset(&attrs, 0, sizeof(ListAddrByAttributes)); + memset(&addrs, 0, sizeof(bulkaddrs)); + memset(&uuid, 0, sizeof(afsUUID)); + attrs.Mask = VLADDR_UUID; + + if (as->parms[0].items) { /* -uuid */ + if (afsUUID_from_string(as->parms[0].items->data, &attrs.uuid) < 0) { + fprintf(STDERR, "vos: invalid UUID '%s'\n", + as->parms[0].items->data); + return EINVAL; + } + } + + code = + ubik_VL_GetAddrsU(cstruct, UBIK_CALL_NEW, &attrs, &uuid, &uniq, + &nentries, &addrs); + if (code == VL_NOENT) { + fprintf(STDERR, "vos: UUID not found\n"); + goto out; + } + if (code != 0) { + fprintf(STDERR, "vos: could not list the server addresses\n"); + PrintError("", code); + goto out; + } + if (addrs.bulkaddrs_len == 0) { + fprintf(STDERR, "vos: no addresses found for UUID\n"); + goto out; + } + + ip2 = addrs.bulkaddrs_val[0]; /* network byte order */ + ip1 = 0xffffffff; /* indicates removal mode */ + + if (verbose) { + printf("vos: Removing UUID with hosts:\n"); + print_addrs(&addrs, &uuid, nentries, 1); + } + + code = ubik_VL_ChangeAddr(cstruct, UBIK_CALL_NEW, ip1, ip2); + if (code) { + fprintf(STDERR, "Could not remove server entry from the VLDB.\n"); + PrintError("", code); + } + + out: + xdr_free((xdrproc_t) xdr_bulkaddrs, &addrs); + return code; +} + + static int LockEntry(struct cmd_syndesc *as, void *arock) { @@ -6367,10 +6428,14 @@ main(int argc, char **argv) COMMONPARMS; ts = cmd_CreateSyntax("setaddrs", SetAddrs, NULL, - "set the list of IP address for a given UUID in the VLDB"); + "set the list of IP addresses 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"); + ts = cmd_CreateSyntax("remaddrs", RemoveAddrs, NULL, + "remove the list of IP addresses for a given UUID in the VLDB"); + cmd_AddParm(ts, "-uuid", CMD_SINGLE, 0, "uuid of server"); + COMMONPARMS; code = cmd_Dispatch(argc, argv); if (rxInitDone) { -- 2.39.5