Skip to content

Commit c8e6d63

Browse files
committed
MB-46825 Limit the output size of hostname for alternate address
Change-Id: Ib8bb9cb0ff8c4f0382f136e6eb093090ae7aa8ad Reviewed-on: http://review.couchbase.org/c/couchbase-cli/+/157006 Well-Formed: Restriction Checker Tested-by: Build Bot <build@couchbase.com> Reviewed-by: Carlos Gonzalez <carlos.gonzalez@couchbase.com>
1 parent 984e361 commit c8e6d63

4 files changed

Lines changed: 58 additions & 43 deletions

File tree

cbmgr.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4420,8 +4420,9 @@ def execute(self, opts):
44204420
if 'ports' in node['alternateAddresses']['external']:
44214421
for port in node['alternateAddresses']['external']['ports'].keys():
44224422
port_names.add(port)
4423-
print('{:20}{:20}{}'.format('Hostname', 'Alternate Address', 'Ports (Primary/Alternate)'))
4424-
print('{:40}'.format(' '), end='')
4423+
# Limiting the display of hostnames to 42, same length as a IPv6 address
4424+
print('{:43}{:43}{}'.format('Hostname', 'Alternate Address', 'Ports (Primary/Alternate)'))
4425+
print('{:86}'.format(' '), end='')
44254426
port_names = sorted(port_names)
44264427
for port in port_names:
44274428
column_size = len(port) + 1
@@ -4432,11 +4433,17 @@ def execute(self, opts):
44324433
for node in add:
44334434
if 'alternateAddresses' in node:
44344435
# For cluster_run and single node clusters there is no hostname
4435-
try:
4436-
print(f'{node["hostname"]:20}{node["alternateAddresses"]["external"]["hostname"]:20}', end='')
4437-
except KeyError:
4436+
if 'hostname' in node:
4437+
host = node["hostname"]
4438+
else:
44384439
host = 'UNKNOWN'
4439-
print(f'{host:20}{node["alternateAddresses"]["external"]["hostname"]:20}', end='')
4440+
# Limiting the display of hostnames to 42 chars, same length as IPv6 address
4441+
if len(host) > 42:
4442+
host = host[:40] + '..'
4443+
alternateAddresses = node["alternateAddresses"]["external"]["hostname"]
4444+
if len(alternateAddresses) > 42:
4445+
alternateAddresses = alternateAddresses[:40] + '..'
4446+
print(f'{host:43}{alternateAddresses:43}', end='')
44404447
for port in port_names:
44414448
column_size = len(port) + 1
44424449
if column_size < 11:

docs/generated/doc/couchbase-cli/couchbase-cli-setting-alternate-address.html

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8">
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7-
<meta name="generator" content="Asciidoctor 2.0.10">
7+
<meta name="generator" content="Asciidoctor 2.0.15">
88
<meta name="description" content="Modify alternate addresses">
99
<meta name="author" content="Couchbase">
1010
<title>couchbase-cli-settings-alternate-address(1)</title>
@@ -49,7 +49,7 @@
4949
table{border-collapse:collapse;border-spacing:0}
5050
*,*::before,*::after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}
5151
html,body{font-size:100%}
52-
body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;font-weight:400;font-style:normal;line-height:1;position:relative;cursor:auto;tab-size:4;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}
52+
body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;font-weight:400;font-style:normal;line-height:1;position:relative;cursor:auto;tab-size:4;word-wrap:anywhere;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}
5353
a:hover{cursor:pointer}
5454
img,object,embed{max-width:100%;height:auto}
5555
object,embed{height:100%}
@@ -64,10 +64,8 @@
6464
img,object,svg{display:inline-block;vertical-align:middle}
6565
textarea{height:auto;min-height:50px}
6666
select{width:100%}
67-
.center{margin-left:auto;margin-right:auto}
68-
.stretch{width:100%}
6967
.subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em}
70-
div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0;direction:ltr}
68+
div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0}
7169
a{color:#2156a5;text-decoration:underline;line-height:inherit}
7270
a:hover,a:focus{color:#1d4b8f}
7371
a img{border:0}
@@ -98,28 +96,28 @@
9896
abbr,acronym{text-transform:uppercase;font-size:90%;color:rgba(0,0,0,.8);border-bottom:1px dotted #ddd;cursor:help}
9997
abbr{text-transform:none}
10098
blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd}
101-
blockquote cite{display:block;font-size:.9375em;color:rgba(0,0,0,.6)}
102-
blockquote cite::before{content:"\2014 \0020"}
103-
blockquote cite a,blockquote cite a:visited{color:rgba(0,0,0,.6)}
10499
blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)}
105100
@media screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2}
106101
h1{font-size:2.75em}
107102
h2{font-size:2.3125em}
108103
h3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em}
109104
h4{font-size:1.4375em}}
110-
table{background:#fff;margin-bottom:1.25em;border:solid 1px #dedede}
105+
table{background:#fff;margin-bottom:1.25em;border:solid 1px #dedede;word-wrap:normal}
111106
table thead,table tfoot{background:#f7f8f7}
112107
table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left}
113108
table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)}
114109
table tr.even,table tr.alt{background:#f8f8f7}
115-
table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{display:table-cell;line-height:1.6}
110+
table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{line-height:1.6}
116111
h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em}
117112
h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400}
113+
.center{margin-left:auto;margin-right:auto}
114+
.stretch{width:100%}
118115
.clearfix::before,.clearfix::after,.float-group::before,.float-group::after{content:" ";display:table}
119116
.clearfix::after,.float-group::after{clear:both}
120-
:not(pre):not([class^=L])>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background:#f7f7f8;-webkit-border-radius:4px;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed;word-wrap:break-word}
121-
:not(pre)>code.nobreak{word-wrap:normal}
122-
:not(pre)>code.nowrap{white-space:nowrap}
117+
:not(pre).nobreak{word-wrap:normal}
118+
:not(pre).nowrap{white-space:nowrap}
119+
:not(pre).pre-wrap{white-space:pre-wrap}
120+
:not(pre):not([class^=L])>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background:#f7f7f8;-webkit-border-radius:4px;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed}
123121
pre{color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;line-height:1.45;text-rendering:optimizeSpeed}
124122
pre code,pre pre{color:inherit;font-size:inherit;line-height:inherit}
125123
pre>code{display:block}
@@ -184,7 +182,7 @@
184182
#content #toc{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px}
185183
#content #toc>:first-child{margin-top:0}
186184
#content #toc>:last-child{margin-bottom:0}
187-
#footer{max-width:100%;background:rgba(0,0,0,.8);padding:1.25em}
185+
#footer{max-width:none;background:rgba(0,0,0,.8);padding:1.25em}
188186
#footer-text{color:rgba(255,255,255,.8);line-height:1.44}
189187
#content{margin-bottom:.625em}
190188
.sect1{padding-bottom:.625em}
@@ -207,7 +205,7 @@
207205
.admonitionblock>table td.icon{text-align:center;width:80px}
208206
.admonitionblock>table td.icon img{max-width:none}
209207
.admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase}
210-
.admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #dddddf;color:rgba(0,0,0,.6)}
208+
.admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #dddddf;color:rgba(0,0,0,.6);word-wrap:anywhere}
211209
.admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0}
212210
.exampleblock>.content{border-style:solid;border-width:1px;border-color:#e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;-webkit-border-radius:4px;border-radius:4px}
213211
.exampleblock>.content>:first-child{margin-top:0}
@@ -217,7 +215,7 @@
217215
.sidebarblock>:last-child{margin-bottom:0}
218216
.sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center}
219217
.exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0}
220-
.literalblock pre,.listingblock>.content>pre{-webkit-border-radius:4px;border-radius:4px;word-wrap:break-word;overflow-x:auto;padding:1em;font-size:.8125em}
218+
.literalblock pre,.listingblock>.content>pre{-webkit-border-radius:4px;border-radius:4px;overflow-x:auto;padding:1em;font-size:.8125em}
221219
@media screen and (min-width:768px){.literalblock pre,.listingblock>.content>pre{font-size:.90625em}}
222220
@media screen and (min-width:1280px){.literalblock pre,.listingblock>.content>pre{font-size:1em}}
223221
.literalblock pre,.listingblock>.content>pre:not(.highlight),.listingblock>.content>pre[class="highlight"],.listingblock>.content>pre[class^="highlight "]{background:#f7f7f8}
@@ -262,22 +260,21 @@
262260
.quoteblock.excerpt>blockquote,.quoteblock .quoteblock{padding:0 0 .25em 1em;border-left:.25em solid #dddddf}
263261
.quoteblock.excerpt,.quoteblock .quoteblock{margin-left:0}
264262
.quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{color:inherit;font-size:1.0625rem}
265-
.quoteblock.excerpt .attribution,.quoteblock .quoteblock .attribution{color:inherit;text-align:left;margin-right:0}
266-
table.tableblock{max-width:100%;border-collapse:separate}
263+
.quoteblock.excerpt .attribution,.quoteblock .quoteblock .attribution{color:inherit;font-size:.85rem;text-align:left;margin-right:0}
267264
p.tableblock:last-child{margin-bottom:0}
265+
td.tableblock>.content{margin-bottom:1.25em;word-wrap:anywhere}
268266
td.tableblock>.content>:last-child{margin-bottom:-1.25em}
269-
td.tableblock>.content>:last-child.sidebarblock{margin-bottom:0}
270267
table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede}
271-
table.grid-all>thead>tr>.tableblock,table.grid-all>tbody>tr>.tableblock{border-width:0 1px 1px 0}
272-
table.grid-all>tfoot>tr>.tableblock{border-width:1px 1px 0 0}
273-
table.grid-cols>*>tr>.tableblock{border-width:0 1px 0 0}
274-
table.grid-rows>thead>tr>.tableblock,table.grid-rows>tbody>tr>.tableblock{border-width:0 0 1px}
275-
table.grid-rows>tfoot>tr>.tableblock{border-width:1px 0 0}
276-
table.grid-all>*>tr>.tableblock:last-child,table.grid-cols>*>tr>.tableblock:last-child{border-right-width:0}
277-
table.grid-all>tbody>tr:last-child>.tableblock,table.grid-all>thead:last-child>tr>.tableblock,table.grid-rows>tbody>tr:last-child>.tableblock,table.grid-rows>thead:last-child>tr>.tableblock{border-bottom-width:0}
268+
table.grid-all>*>tr>*{border-width:1px}
269+
table.grid-cols>*>tr>*{border-width:0 1px}
270+
table.grid-rows>*>tr>*{border-width:1px 0}
278271
table.frame-all{border-width:1px}
272+
table.frame-ends{border-width:1px 0}
279273
table.frame-sides{border-width:0 1px}
280-
table.frame-topbot,table.frame-ends{border-width:1px 0}
274+
table.frame-none>colgroup+*>:first-child>*,table.frame-sides>colgroup+*>:first-child>*{border-top-width:0}
275+
table.frame-none>:last-child>:last-child>*,table.frame-sides>:last-child>:last-child>*{border-bottom-width:0}
276+
table.frame-none>*>tr>:first-child,table.frame-ends>*>tr>:first-child{border-left-width:0}
277+
table.frame-none>*>tr>:last-child,table.frame-ends>*>tr>:last-child{border-right-width:0}
281278
table.stripes-all tr,table.stripes-odd tr:nth-of-type(odd),table.stripes-even tr:nth-of-type(even),table.stripes-hover tr:hover{background:#f8f8f7}
282279
th.halign-left,td.halign-left{text-align:left}
283280
th.halign-right,td.halign-right{text-align:right}
@@ -286,7 +283,7 @@
286283
th.valign-bottom,td.valign-bottom{vertical-align:bottom}
287284
th.valign-middle,td.valign-middle{vertical-align:middle}
288285
table thead th,table tfoot th{font-weight:bold}
289-
tbody tr th{display:table-cell;line-height:1.6;background:#f7f8f7}
286+
tbody tr th{background:#f7f8f7}
290287
tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold}
291288
p.tableblock>code:only-child{background:none;padding:0}
292289
p.tableblock{font-size:1em}
@@ -315,6 +312,7 @@
315312
.hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none}
316313
td.hdlist1,td.hdlist2{vertical-align:top;padding:0 .625em}
317314
td.hdlist1{font-weight:bold;padding-bottom:1.25em}
315+
td.hdlist2{word-wrap:anywhere}
318316
.literalblock+.colist,.listingblock+.colist{margin-top:-.5em}
319317
.colist td:not([class]):first-child{padding:.4em .75em 0;line-height:1;vertical-align:top}
320318
.colist td:not([class]):first-child img{max-width:none}
@@ -387,7 +385,7 @@
387385
.admonitionblock td.icon .icon-warning::before{content:"\f071";color:#bf6900}
388386
.admonitionblock td.icon .icon-caution::before{content:"\f06d";color:#bf3400}
389387
.admonitionblock td.icon .icon-important::before{content:"\f06a";color:#bf0000}
390-
.conum[data-value]{display:inline-block;color:#fff!important;background:rgba(0,0,0,.8);-webkit-border-radius:100px;border-radius:100px;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
388+
.conum[data-value]{display:inline-block;color:#fff!important;background:rgba(0,0,0,.8);-webkit-border-radius:50%;border-radius:50%;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
391389
.conum[data-value] *{color:#fff!important}
392390
.conum[data-value]+b{display:none}
393391
.conum[data-value]::after{content:attr(data-value)}
@@ -414,6 +412,7 @@
414412
svg{max-width:100%}
415413
p,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3}
416414
h2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid}
415+
#header,#content,#footnotes,#footer{max-width:none}
417416
#toc,.sidebarblock,.exampleblock>.content{background:none!important}
418417
#toc{border-bottom:1px solid #dddddf!important;padding-bottom:0!important}
419418
body.book #header{text-align:center}
@@ -497,7 +496,9 @@ <h2 id="_options">OPTIONS</h2>
497496
</dd>
498497
<dt class="hdlist1">--list</dt>
499498
<dd>
500-
<p>Show current alternate addresses</p>
499+
<p>Show current alternate addresses. Please note only the first 43 characters hostname and
500+
alternate address are displayed. The full hostnames are shown in the json output
501+
(-o json).</p>
501502
</dd>
502503
<dt class="hdlist1">--set</dt>
503504
<dd>

docs/generated/man/man1/couchbase-cli-setting-alternate-address.1

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
'\" t
22
.\" Title: couchbase-cli-settings-alternate-address
33
.\" Author: Couchbase
4-
.\" Generator: Asciidoctor 2.0.10
5-
.\" Date: 2021-04-22
4+
.\" Generator: Asciidoctor 2.0.15
5+
.\" Date: 2021-07-06
66
.\" Manual: Couchbase CLI Manual
77
.\" Source: Couchbase CLI 1.0.0
88
.\" Language: English
99
.\"
10-
.TH "COUCHBASE\-CLI\-SETTING\-ALTERNATE\-ADDRESS" "1" "2021-04-22" "Couchbase CLI 1.0.0" "Couchbase CLI Manual"
10+
.TH "COUCHBASE\-CLI\-SETTING\-ALTERNATE\-ADDRESS" "1" "2021-07-06" "Couchbase CLI 1.0.0" "Couchbase CLI Manual"
1111
.ie \n(.g .ds Aq \(aq
1212
.el .ds Aq '
1313
.ss \n[.ss] 0
@@ -28,10 +28,9 @@
2828
. LINKSTYLE blue R < >
2929
.\}
3030
.SH "NAME"
31-
couchbase\-cli\-setting\-alternate\-address \- Modify alternate addresses
31+
couchbase-cli-setting-alternate-address \- Modify alternate addresses
3232
.SH "SYNOPSIS"
3333
.sp
34-
.sp
3534
.nf
3635
\fIcouchbase\-cli setting\-alternate\-address\fP [\-\-cluster <url>] [\-\-username <user>]
3736
[\-\-password <password>] [\-\-list] [\-\-set] [\-\-remove] [\-\-hostname <host>]
@@ -70,7 +69,9 @@ environment variable CB_REST_PASSWORD.
7069
.sp
7170
\-\-list
7271
.RS 4
73-
Show current alternate addresses
72+
Show current alternate addresses. Please note only the first 43 characters hostname and
73+
alternate address are displayed. The full hostnames are shown in the json output
74+
(\-o json).
7475
.RE
7576
.sp
7677
\-\-set
@@ -147,9 +148,11 @@ following command:
147148
.sp
148149
.if n .RS 4
149150
.nf
151+
.fam C
150152
$ couchbase\-cli setting\-alternate\-address \-c 192.168.1.5:8091 \-\-username Administrator \(rs
151153
\-\-password password \-\-set \-\-node 192.168.1.5 \-\-hostname 10.10.10.10 \(rs
152154
\-\-ports mgmt=1100,capi=2000,capiSSL=3000
155+
.fam
153156
.fi
154157
.if n .RE
155158
.sp
@@ -158,8 +161,10 @@ follows:
158161
.sp
159162
.if n .RS 4
160163
.nf
164+
.fam C
161165
$ couchbase\-cli setting\-alternate\-address \-c 192.168.1.5:8091 \-\-username Administrator \(rs
162166
\-\-password password \-\-list
167+
.fam
163168
.fi
164169
.if n .RE
165170
.SH "DISCUSSION"

docs/modules/cli/pages/cbcli/couchbase-cli-setting-alternate-address.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ agent tries to connect via a NAT'd environment such as the cloud or kubernetes.
2727
include::{partialsdir}/cbcli/part-common-options.adoc[]
2828

2929
--list::
30-
Show current alternate addresses
30+
Show current alternate addresses. Please note only the first 43 characters hostname and
31+
alternate address are displayed. The full hostnames are shown in the json output
32+
(-o json).
3133

3234
--set::
3335
Set alternate address for the node specified in the -c/--cluster option.

0 commit comments

Comments
 (0)