File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -3958,7 +3958,9 @@ def command_zap_osds(ctx: CephadmContext) -> None:
39583958
39593959
39603960def get_ceph_cluster_count (ctx : CephadmContext ) -> int :
3961- return len ([c for c in os .listdir (ctx .data_dir ) if is_fsid (c )])
3961+ if os .path .isdir (ctx .data_dir ):
3962+ return len ([c for c in os .listdir (ctx .data_dir ) if is_fsid (c )])
3963+ return 0
39623964
39633965
39643966def command_rm_cluster (ctx : CephadmContext ) -> None :
Original file line number Diff line number Diff line change @@ -1501,8 +1501,14 @@ def test_extract_uid_gid_fail(self, _call):
15011501 ])
15021502 def test_get_ceph_cluster_count (self , test_input , expected ):
15031503 ctx = _cephadm .CephadmContext ()
1504- with mock .patch ('os.listdir' , return_value = test_input ):
1505- assert _cephadm .get_ceph_cluster_count (ctx ) == expected
1504+ with mock .patch ('os.path.isdir' , return_value = True ):
1505+ with mock .patch ('os.listdir' , return_value = test_input ):
1506+ assert _cephadm .get_ceph_cluster_count (ctx ) == expected
1507+
1508+ def test_get_ceph_cluster_count_missing_datadir (self ):
1509+ ctx = _cephadm .CephadmContext ()
1510+ with mock .patch ('os.path.isdir' , return_value = False ):
1511+ assert _cephadm .get_ceph_cluster_count (ctx ) == 0
15061512
15071513 def test_set_image_minimize_config (self ):
15081514 def throw_cmd (cmd ):
You can’t perform that action at this time.
0 commit comments