From d1d411576cf39c4bc55918df0eb64327718d566c 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. Change-Id: I98e92e776a153591a617a5b04037c3b6139d4732 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 --- doc/man-pages/pod1/.gitignore | 1 + doc/man-pages/pod1/vos.pod.in | 3 +- doc/man-pages/pod1/vos_changeaddr.pod.in | 4 +- doc/man-pages/pod1/vos_listaddrs.pod.in | 5 +- doc/man-pages/pod1/vos_remaddrs.pod.in | 76 +++++++++++++++++++++++ doc/man-pages/pod1/vos_setaddrs.pod.in | 3 +- src/volser/vos.c | 79 +++++++++++++++++++++--- 7 files changed, 158 insertions(+), 13 deletions(-) create mode 100644 doc/man-pages/pod1/vos_remaddrs.pod.in diff --git a/doc/man-pages/pod1/.gitignore b/doc/man-pages/pod1/.gitignore index c41eb7cd7..63ac918ba 100644 --- a/doc/man-pages/pod1/.gitignore +++ b/doc/man-pages/pod1/.gitignore @@ -48,6 +48,7 @@ /vos_online.pod /vos_partinfo.pod /vos_release.pod +/vos_remaddrs.pod /vos_remove.pod /vos_remsite.pod /vos_rename.pod diff --git a/doc/man-pages/pod1/vos.pod.in b/doc/man-pages/pod1/vos.pod.in index 8ce7fd425..f0ec34acd 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.in b/doc/man-pages/pod1/vos_changeaddr.pod.in index 89459194c..fe69633df 100644 --- a/doc/man-pages/pod1/vos_changeaddr.pod.in +++ b/doc/man-pages/pod1/vos_changeaddr.pod.in @@ -30,9 +30,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.in b/doc/man-pages/pod1/vos_listaddrs.pod.in index d4f0dee17..66a6e3466 100644 --- a/doc/man-pages/pod1/vos_listaddrs.pod.in +++ b/doc/man-pages/pod1/vos_listaddrs.pod.in @@ -102,9 +102,10 @@ None L, L, L, -L, L, -L +L, +L, +L =head1 COPYRIGHT diff --git a/doc/man-pages/pod1/vos_remaddrs.pod.in b/doc/man-pages/pod1/vos_remaddrs.pod.in new file mode 100644 index 000000000..1c1a11fee --- /dev/null +++ b/doc/man-pages/pod1/vos_remaddrs.pod.in @@ -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.in b/doc/man-pages/pod1/vos_setaddrs.pod.in index 63792c1ba..eee1c1103 100644 --- a/doc/man-pages/pod1/vos_setaddrs.pod.in +++ b/doc/man-pages/pod1/vos_setaddrs.pod.in @@ -96,7 +96,8 @@ L, L, L, L, -L +L, +L =head1 COPYRIGHT diff --git a/src/volser/vos.c b/src/volser/vos.c index be2958dc0..96031b3c6 100644 --- a/src/volser/vos.c +++ b/src/volser/vos.c @@ -5319,7 +5319,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) { @@ -5328,14 +5328,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) { @@ -6267,10 +6328,14 @@ main(int argc, char **argv) COMMONPARMS; ts = cmd_CreateSyntax("setaddrs", SetAddrs, NULL, 0, - "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, 0, + "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