]>
git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/nfs/utils.py
1 from typing
import List
, TYPE_CHECKING
6 from nfs
.module
import Module
8 EXPORT_PREFIX
: str = "export-"
9 CONF_PREFIX
: str = "conf-nfs."
10 USER_CONF_PREFIX
: str = "userconf-nfs."
13 def export_obj_name(export_id
: int) -> str:
14 """Return a rados object name for the export."""
15 return f
"{EXPORT_PREFIX}{export_id}"
18 def conf_obj_name(cluster_id
: str) -> str:
19 """Return a rados object name for the config."""
20 return f
"{CONF_PREFIX}{cluster_id}"
23 def user_conf_obj_name(cluster_id
: str) -> str:
24 """Returna a rados object name for the user config."""
25 return f
"{USER_CONF_PREFIX}{cluster_id}"
28 def available_clusters(mgr
: 'Module') -> List
[str]:
30 This method returns list of available cluster ids.
31 Service name is service_type.service_id
33 completion.result value:
34 <ServiceDescription of <NFSServiceSpec for service_name=nfs.vstart>>
35 return value: ['vstart']
37 # TODO check cephadm cluster list with rados pool conf objects
38 completion
= mgr
.describe_service(service_type
='nfs')
39 orchestrator
.raise_if_exception(completion
)
40 assert completion
.result
is not None
41 return [cluster
.spec
.service_id
for cluster
in completion
.result
42 if cluster
.spec
.service_id
]
45 def restart_nfs_service(mgr
: 'Module', cluster_id
: str) -> None:
47 This methods restarts the nfs daemons
49 completion
= mgr
.service_action(action
='restart',
50 service_name
='nfs.' + cluster_id
)
51 orchestrator
.raise_if_exception(completion
)
54 def check_fs(mgr
: 'Module', fs_name
: str) -> bool:
56 This method checks if given fs is valid
58 fs_map
= mgr
.get('fs_map')
59 return fs_name
in [fs
['mdsmap']['fs_name'] for fs
in fs_map
['filesystems']]