]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/nfs: move ingress vs virtual_ip check to cluster interface
authorSage Weil <sage@newdream.net>
Tue, 18 May 2021 22:02:25 +0000 (18:02 -0400)
committerSage Weil <sage@newdream.net>
Thu, 3 Jun 2021 12:40:16 +0000 (07:40 -0500)
Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit f2e78bf2e3009eb67a2e7ef06336371eddee7573)

src/pybind/mgr/nfs/cluster.py
src/pybind/mgr/nfs/module.py

index 1f9e4db3e51277e2cb917360d113ccf32b506e00..aac469412b2f55adc1f93754fc65e40dd0900b9c 100644 (file)
@@ -2,7 +2,7 @@ import logging
 import socket
 import json
 import re
-from typing import cast, Dict, List, Any, Union
+from typing import cast, Dict, List, Any, Union, Optional
 
 from ceph.deployment.service_spec import NFSServiceSpec, PlacementSpec, IngressSpec
 from cephadm.utils import resolve_ip
@@ -89,8 +89,16 @@ class NFSCluster:
                  f"{self.pool_ns}")
 
     @cluster_setter
-    def create_nfs_cluster(self, cluster_id, placement, virtual_ip):
+    def create_nfs_cluster(self,
+                           cluster_id: str,
+                           placement: Optional[str],
+                           virtual_ip: Optional[str],
+                           ingress: Optional[bool] = None):
         try:
+            if virtual_ip and not ingress:
+                raise NFSInvalidOperation('virtual_ip can only be provided with ingress enabled')
+            if not virtual_ip and ingress:
+                raise NFSInvalidOperation('ingress currently requires a virtual_ip')
             invalid_str = re.search('[^A-Za-z0-9-_.]', cluster_id)
             if invalid_str:
                 raise NFSInvalidOperation(f"cluster id {cluster_id} is invalid. "
@@ -143,7 +151,7 @@ class NFSCluster:
                             "ip": cluster.ip or resolve_ip(cluster.hostname),
                             "port": cluster.ports[0]
                             })
-                except OrchestratorError:
+                except orchestrator.OrchestratorError:
                     continue
 
         r: Dict[str, Any] = {
index 164c9f133aa22b2308284505e066bf2f6b8b380c..5bd1e9260e88140a7123dbe5199b1c827513efe4 100644 (file)
@@ -70,14 +70,8 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
                                 ingress: Optional[bool]=None,
                                 virtual_ip: Optional[str]=None) -> Tuple[int, str, str]:
         """Create an NFS Cluster"""
-        if virtual_ip and not ingress:
-            return (-errno.EINVAL, '',
-                    '--virtual-ip can only be provided with --ingress')
-        if ingress and not virtual_ip:
-            return (-errno.EINVAL, '',
-                    '--ingress current requires --virtual-ip')
         return self.nfs.create_nfs_cluster(cluster_id=clusterid, placement=placement,
-                                           virtual_ip=virtual_ip)
+                                           virtual_ip=virtual_ip, ingress=ingress)
 
     @CLICommand('nfs cluster rm', perm='rw')
     def _cmd_nfs_cluster_rm(self, clusterid: str) -> Tuple[int, str, str]: