Skip to content

Commit 65c32c2

Browse files
committed
Merge branch 'morpheus' into 'master'
* morpheus MB-67727 Update synopsis for enterprise-analytics-link-setup Change-Id: I6a6a636c6f32d543a0faa4d07d9dbe8e1ee6f433
2 parents 20ea1cf + 14b6f25 commit 65c32c2

7 files changed

Lines changed: 64 additions & 39 deletions

cbmgr.py

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,32 +1110,39 @@ def execute(self, opts):
11101110
services, errors = process_services(opts.services, self.enterprise, self.enterprise_analytics)
11111111
_exit_if_errors(errors)
11121112

1113-
if not self.enterprise_analytics and 'kv' not in services.split(','):
1114-
_exit_if_errors(["Cannot set up first cluster node without the data service"])
1115-
11161113
if 'ipv4' in opts.ip_family:
11171114
ip_family = 'ipv4'
11181115
elif 'ipv6' in opts.ip_family:
11191116
ip_family = 'ipv6'
11201117
ip_only = True if 'only' in opts.ip_family else False
11211118

1122-
if not self.enterprise_analytics and not opts.index_storage_mode and 'index' in services.split(','):
1123-
opts.index_storage_mode = "default"
1119+
indexer_storage = None
1120+
if not self.enterprise_analytics:
1121+
if 'kv' not in services.split(','):
1122+
_exit_if_errors(["Cannot set up first cluster node without the data service"])
11241123

1125-
default = "plasma"
1126-
if not self.enterprise:
1127-
default = "forestdb"
1124+
if not opts.index_storage_mode and 'index' in services.split(','):
1125+
opts.index_storage_mode = "default"
11281126

1129-
indexer_storage = None
1130-
if opts.index_storage_mode:
1131-
indexer_storage = index_storage_mode_to_param(opts.index_storage_mode, default)
1127+
default = "plasma"
1128+
if not self.enterprise:
1129+
default = "forestdb"
11321130

1133-
min_version, errors = self.rest.node_version()
1134-
_exit_if_errors(errors)
1131+
if opts.index_storage_mode:
1132+
indexer_storage = index_storage_mode_to_param(opts.index_storage_mode, default)
11351133

1136-
versionCheck = compare_versions(min_version, "7.2.3")
1137-
if not self.enterprise_analytics and versionCheck == -1:
1138-
_exit_if_errors(["--cluster-init can only be used against >= 7.2.3 clusters"])
1134+
min_version, errors = self.rest.node_version()
1135+
_exit_if_errors(errors)
1136+
1137+
versionCheck = compare_versions(min_version, "7.2.3")
1138+
if versionCheck == -1:
1139+
_exit_if_errors(["--cluster-init can only be used against >= 7.2.3 clusters"])
1140+
else:
1141+
settings, err = self.rest.get_analytics_settings()
1142+
_exit_if_errors(err)
1143+
if not settings.get('blobStorageScheme'):
1144+
_exit_if_errors(
1145+
["Cannot initialize cluster before running the 'setting-enterprise-analytics' command"])
11391146

11401147
if not self.enterprise and opts.notifications == "0":
11411148
_exit_if_errors(["--update-notifications can only be configured on Enterprise Edition"])
@@ -3497,21 +3504,27 @@ def __init__(self):
34973504
help="The BLOB storage endpoint")
34983505
group.add_argument("--anonymous-auth", dest="blob_storage_anonymous_auth", metavar="<0|1>",
34993506
choices=["0", "1"], help="Allow BLOB storage anonymous auth")
3507+
group.add_argument("--path-style-addressing", dest="blob_storage_path_style_addressing", metavar="<0|1>",
3508+
choices=["0", "1"], help="Use BLOB storage path style addressing")
35003509

35013510
# We disable the cluster init check so people can use '--set' before the cluster is initiaslised. See MB-66986.
35023511
@rest_initialiser(cluster_init_check=False, version_check=True)
35033512
def execute(self, opts):
35043513
if opts.set:
35053514
if not (opts.num_storage_partitions or opts.blob_storage_scheme or opts.blob_storage_bucket
35063515
or opts.blob_storage_prefix or opts.blob_storage_region or opts.blob_storage_endpoint
3507-
or opts.blob_storage_anonymous_auth):
3516+
or opts.blob_storage_anonymous_auth or opts.blob_storage_path_style_addressing):
35083517
_exit_if_errors(["At least one option (--partitions, --scheme, --bucket, --prefix, --region," +
3509-
" --endpoint, --anonymous-auth) must be specified."])
3518+
" --endpoint, --anonymous-auth, --path-style-addressing) must be specified."])
35103519

35113520
if opts.blob_storage_anonymous_auth == "0":
35123521
opts.blob_storage_anonymous_auth = "false"
35133522
if opts.blob_storage_anonymous_auth == "1":
35143523
opts.blob_storage_anonymous_auth = "true"
3524+
if opts.blob_storage_path_style_addressing == "0":
3525+
opts.blob_storage_path_style_addressing = "false"
3526+
if opts.blob_storage_path_style_addressing == "1":
3527+
opts.blob_storage_path_style_addressing = "true"
35153528

35163529
_, errors = self.rest.set_enterprise_analytics_settings(opts)
35173530
_exit_if_errors(errors)

cluster_manager.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def get_cluster_type(self):
271271
return None, None, errors
272272

273273
isEnterprise = data["isEnterprise"]
274-
isEnterpriseAnalytics = "prodName" in data and data["prodName"] == "Enterprise Analytics"
274+
isEnterpriseAnalytics = "prod" in data and data["prod"] == "analytics"
275275

276276
return isEnterprise, isEnterpriseAnalytics, None
277277

@@ -2944,6 +2944,8 @@ def set_enterprise_analytics_settings(self, opts):
29442944
params["blobStorageEndpoint"] = opts.blob_storage_endpoint
29452945
if opts.blob_storage_anonymous_auth:
29462946
params["blobStorageAnonymousAuth"] = opts.blob_storage_anonymous_auth
2947+
if opts.blob_storage_path_style_addressing:
2948+
params["blobStoragePathStyleAddressing"] = opts.blob_storage_path_style_addressing
29472949

29482950
return self._post_form_encoded(url, params)
29492951

docs/modules/cli/pages/cbcli/couchbase-cli-enterprise-analytics-link-setup.adoc

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,7 @@ Manage Enterprise Analytics links
1515
_couchbase-cli enterprise-analytics-link-setup_ [--cluster <cluster>] [--username <username>]
1616
[--password <password>] [--client-cert <path>] [--client-cert-password <password>]
1717
[--client-key <path>] [--client-key-password <password>] [--create] [--delete]
18-
[--edit] [--list] [--dataverse <name>] [--scope <name>] [--name <name>] [--type <type>]
19-
[--hostname <hostname>] [--link-username <username>] [--link-password <password>]
20-
[--user-certificate <path>] [--user-key <path>] [--user-key-passphrase <path>]
21-
[--certificate <path>] [--encryption <type>] [--access-key-id <id>]
22-
[--secret-access-key <key>] [--session-token <token>] [--region <region>]
23-
[--service-endpoint <url>] [--account-name <id>] [--account-key <key>]
24-
[--shared-access-signature <token>] [--managed-identity-id <id>] [--client-id <id>]
25-
[--tenant-id <id>] [--client-secret <key>] [--client-certificate <key>]
26-
[--client-certificate-password <key>] [--endpoint <url>] [--application-default-credentials]
27-
[--json-credentials <key>]
18+
[--edit] [--list] [--name <name>] [--link-details <json>] [--link-details-path <path>]
2819

2920
== DESCRIPTION
3021

docs/modules/cli/pages/cbcli/couchbase-cli-setting-enterprise-analytics.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ include::{partialsdir}/cbcli/part-common-options.adoc[]
4949
--anonymous-auth <0|1>::
5050
Allow BLOB storage anonymous auth
5151

52+
--path-style-addressing <0|1>::
53+
Use BLOB storage path style addressing
54+
5255
include::{partialsdir}/cbcli/part-host-formats.adoc[]
5356

5457
include::{partialsdir}/cbcli/part-certificate-authentication.adoc[]

test/mock_server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,15 @@ def get_pools(rest_params=None, server_args=None, path="", endpoint_match=None):
283283
'pools': [{'streamingUri': '/poolsStreaming/default?uuid=5f8b140987f4e46c950e3fa82e7fcb48',
284284
'name': 'default', 'uri': '/pools/default?uuid=5f8b140987f4e46c950e3fa82e7fcb48'}],
285285
'isEnterprise': enterprise,
286-
'prodName': "Enterprise Analytics" if enterprise_analytics else None,
286+
'prod': "analytics" if enterprise_analytics else None,
287287
'componentsVersion': {'kernel': '2.16.4', 'ale': version, 'ssl': '5.3.3',
288288
'os_mon': '2.2.14', 'stdlib': '1.19.4', 'inets': '5.9.8',
289289
'public_key': '0.21', 'ns_server': version, 'crypto': '3.2', 'asn1': '2.0.4',
290290
'lhttpc': '1.3.0', 'sasl': '2.3.4'}, 'implementationVersion': version,
291291
'isAdminCreds': is_admin, 'isROAdminCreds': False}
292292

293293
response_no_init = {'uuid': [], 'settings': [], 'pools': [], 'isEnterprise': enterprise,
294-
'prodName': "Enterprise Analytics" if enterprise_analytics else None,
294+
'prod': "analytics" if enterprise_analytics else None,
295295
'componentsVersion': {'kernel': '5.4.3.2', 'ale': version, 'ssl': '8.2.6.2', 'os_mon': '2.4.4',
296296
'stdlib': '3.4.5', 'inets': '6.5.2.4', 'public_key': '1.5.2',
297297
'ns_server': version, 'crypto': '4.2.2.2', 'asn1': '5.0.5.1',

test/test_cli.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5357,14 +5357,30 @@ def test_anonymous_auth(self):
53575357
self.assertIn('POST:/settings/analytics', self.server.trace)
53585358
self.rest_parameter_match(['blobStorageAnonymousAuth=true'])
53595359

5360+
def test_path_style_addressing(self):
5361+
self.no_error_run(self.command + ['--set', '--path-style-addressing', '1'], self.server_args)
5362+
self.assertIn('POST:/settings/analytics', self.server.trace)
5363+
self.rest_parameter_match(['blobStoragePathStyleAddressing=true'])
5364+
53605365
def test_all_flags(self):
53615366
self.no_error_run(self.command + ['--set', '--partitions', '7', '--scheme', 's3', '--bucket', 'aaa',
53625367
'--prefix', 'aaa', '--region', 'aaa', '--endpoint', 'aaa',
5363-
'--anonymous-auth', '1',], self.server_args)
5368+
'--anonymous-auth', '1', '--path-style-addressing', '1',], self.server_args)
53645369
self.assertIn('POST:/settings/analytics', self.server.trace)
53655370
self.rest_parameter_match(['numStoragePartitions=7', 'blobStorageScheme=s3', 'blobStorageBucket=aaa',
53665371
'blobStoragePrefix=aaa', 'blobStorageRegion=aaa', 'blobStorageEndpoint=aaa',
5367-
'blobStorageAnonymousAuth=true'])
5372+
'blobStorageAnonymousAuth=true', 'blobStoragePathStyleAddressing=true'])
5373+
5374+
def test_all_flags_uninitialised(self):
5375+
server_args = self.server_args
5376+
server_args['init'] = False
5377+
self.no_error_run(self.command + ['--set', '--partitions', '7', '--scheme', 's3', '--bucket', 'aaa',
5378+
'--prefix', 'aaa', '--region', 'aaa', '--endpoint', 'aaa',
5379+
'--anonymous-auth', '1', '--path-style-addressing', '1',], server_args)
5380+
self.assertIn('POST:/settings/analytics', self.server.trace)
5381+
self.rest_parameter_match(['numStoragePartitions=7', 'blobStorageScheme=s3', 'blobStorageBucket=aaa',
5382+
'blobStoragePrefix=aaa', 'blobStorageRegion=aaa', 'blobStorageEndpoint=aaa',
5383+
'blobStorageAnonymousAuth=true', 'blobStoragePathStyleAddressing=true'])
53685384

53695385
def test_all_flags_uninitialised(self):
53705386
server_args = self.server_args

test/test_cluster_manager.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,28 +255,28 @@ def test_get_cluster_type(self):
255255
"Enterprise_and_Analytics": {
256256
"pools_response": (200, {
257257
"isEnterprise": True,
258-
"prodName": "Enterprise Analytics"
258+
"prod": "analytics"
259259
}),
260260
"expected": (True, True, None)
261261
},
262262
"Enterprise_NoneAnalytics": {
263263
"pools_response": (200, {
264264
"isEnterprise": True,
265-
"prodName": None
265+
"prod": None
266266
}),
267267
"expected": (True, False, None)
268268
},
269-
"Enterprise_MissingProdNameField": {
269+
"Enterprise_MissingProdField": {
270270
"pools_response": (200, {
271271
"isEnterprise": True
272-
# prodName field is missing, should default to False
272+
# prod field is missing, should default to False
273273
}),
274274
"expected": (True, False, None)
275275
},
276-
"NonEnterprise_MissingProdNameField": {
276+
"NonEnterprise_MissingProdField": {
277277
"pools_response": (200, {
278278
"isEnterprise": False
279-
# prodName field is missing, should default to False
279+
# prod field is missing, should default to False
280280
}),
281281
"expected": (False, False, None)
282282
},

0 commit comments

Comments
 (0)