File tree Expand file tree Collapse file tree 2 files changed +56
-1
lines changed
Expand file tree Collapse file tree 2 files changed +56
-1
lines changed Original file line number Diff line number Diff line change @@ -411,7 +411,7 @@ def _search_resources(self, matcher: _Matcher) -> List[SMBResource]:
411411 for cluster_id in self .cluster_ids ():
412412 if (resources .Cluster , cluster_id ) in matcher :
413413 out .append (self ._cluster_entry (cluster_id ).get_cluster ())
414- for share_id in cluster_shares [ cluster_id ] :
414+ for share_id in cluster_shares . get ( cluster_id , []) :
415415 if (resources .Share , cluster_id , share_id ) in matcher :
416416 out .append (
417417 self ._share_entry (
Original file line number Diff line number Diff line change @@ -737,3 +737,58 @@ def test_show_invalid_input(tmodule):
737737 _example_cfg_1 (tmodule )
738738 with pytest .raises (smb .cli .InvalidInputValue ):
739739 tmodule .show (['ceph.smb.export' ])
740+
741+
742+ def test_show_cluster_without_shares (tmodule ):
743+ # this cluster will have no shares associated with it
744+ tmodule ._internal_store .overwrite (
745+ {
746+ 'clusters.foo' : {
747+ 'resource_type' : 'ceph.smb.cluster' ,
748+ 'cluster_id' : 'foo' ,
749+ 'auth_mode' : 'active-directory' ,
750+ 'intent' : 'present' ,
751+ 'domain_settings' : {
752+ 'realm' : 'dom1.example.com' ,
753+ 'join_sources' : [
754+ {
755+ 'source_type' : 'resource' ,
756+ 'ref' : 'foo' ,
757+ }
758+ ],
759+ },
760+ },
761+ 'join_auths.foo' : {
762+ 'resource_type' : 'ceph.smb.join.auth' ,
763+ 'auth_id' : 'foo' ,
764+ 'intent' : 'present' ,
765+ 'auth' : {
766+ 'username' : 'testadmin' ,
767+ 'password' : 'Passw0rd' ,
768+ },
769+ },
770+ }
771+ )
772+
773+ res , body , status = tmodule .show .command (['ceph.smb.cluster.foo' ])
774+ assert res == 0
775+ assert (
776+ body .strip ()
777+ == """
778+ {
779+ "resource_type": "ceph.smb.cluster",
780+ "cluster_id": "foo",
781+ "auth_mode": "active-directory",
782+ "intent": "present",
783+ "domain_settings": {
784+ "realm": "dom1.example.com",
785+ "join_sources": [
786+ {
787+ "source_type": "resource",
788+ "ref": "foo"
789+ }
790+ ]
791+ }
792+ }
793+ """ .strip ()
794+ )
You can’t perform that action at this time.
0 commit comments