Skip to content

Commit 1864170

Browse files
python-common: update smb service spec to use new smb constants
Update the SMBSpec class to use the new constants provided by the recently added python-common smb package. Signed-off-by: John Mulligan <[email protected]>
1 parent b99f029 commit 1864170

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

src/python-common/ceph/deployment/service_spec.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from ceph.deployment.utils import verify_positive_int, verify_non_negative_number
3636
from ceph.deployment.utils import verify_boolean, verify_enum
3737
from ceph.utils import is_hex
38+
from ceph.smb import constants as smbconst
3839

3940
ServiceSpecT = TypeVar('ServiceSpecT', bound='ServiceSpec')
4041
FuncT = TypeVar('FuncT', bound=Callable)
@@ -3315,8 +3316,8 @@ def convert_list(
33153316

33163317
class SMBSpec(ServiceSpec):
33173318
service_type = 'smb'
3318-
_valid_features = {'domain', 'clustered', 'cephfs-proxy', 'remote-control'}
3319-
_valid_service_names = {'smb', 'smbmetrics', 'ctdb', 'remote-control'}
3319+
_valid_features = smbconst.FEATURES
3320+
_valid_service_names = smbconst.SERVICES
33203321
_default_cluster_meta_obj = 'cluster.meta.json'
33213322
_default_cluster_lock_obj = 'cluster.meta.lock'
33223323

@@ -3430,23 +3431,24 @@ def validate(self) -> None:
34303431
raise ValueError(
34313432
f'invalid feature flags: {", ".join(invalid)}'
34323433
)
3433-
if 'clustered' in self.features and not self.cluster_meta_uri:
3434+
_clustered = smbconst.CLUSTERED
3435+
if _clustered in self.features and not self.cluster_meta_uri:
34343436
# derive a cluster meta uri from config uri by default (if possible)
34353437
self.cluster_meta_uri = self._derive_cluster_uri(
34363438
self.config_uri,
34373439
self._default_cluster_meta_obj,
34383440
)
3439-
if 'clustered' not in self.features and self.cluster_meta_uri:
3441+
if _clustered not in self.features and self.cluster_meta_uri:
34403442
raise ValueError(
34413443
'cluster meta uri unsupported when "clustered" feature not set'
34423444
)
3443-
if 'clustered' in self.features and not self.cluster_lock_uri:
3445+
if _clustered in self.features and not self.cluster_lock_uri:
34443446
# derive a cluster meta uri from config uri by default (if possible)
34453447
self.cluster_lock_uri = self._derive_cluster_uri(
34463448
self.config_uri,
34473449
self._default_cluster_lock_obj,
34483450
)
3449-
if 'clustered' not in self.features and self.cluster_lock_uri:
3451+
if _clustered not in self.features and self.cluster_lock_uri:
34503452
raise ValueError(
34513453
'cluster lock uri unsupported when "clustered" feature not set'
34523454
)
@@ -3465,12 +3467,7 @@ def _derive_cluster_uri(self, uri: str, objname: str) -> str:
34653467
return uri
34663468

34673469
def _default_ports(self) -> Dict[str, int]:
3468-
return {
3469-
'smb': 445,
3470-
'smbmetrics': 9922,
3471-
'ctdb': 4379,
3472-
'remote-control': 54445,
3473-
}
3470+
return dict(smbconst.DEFAULT_PORTS)
34743471

34753472
def service_ports(self) -> Dict[str, int]:
34763473
ports = self._default_ports()
@@ -3479,13 +3476,13 @@ def service_ports(self) -> Dict[str, int]:
34793476
return ports
34803477

34813478
def metrics_exporter_port(self) -> int:
3482-
return self.service_ports()['smbmetrics']
3479+
return self.service_ports()[smbconst.SMBMETRICS]
34833480

34843481
def get_port_start(self) -> List[int]:
34853482
_ports = self.service_ports()
3486-
ports = [_ports['smb'], _ports['smbmetrics']]
3487-
if 'clustered' in self.features:
3488-
ports.append(_ports['ctdb'])
3483+
ports = [_ports[smbconst.SMB], _ports[smbconst.SMBMETRICS]]
3484+
if smbconst.CLUSTERED in self.features:
3485+
ports.append(_ports[smbconst.CTDB])
34893486
return ports
34903487

34913488
def strict_cluster_ip_specs(self) -> List[Dict[str, Any]]:

0 commit comments

Comments
 (0)