]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/nfs/cluster.py
import ceph quincy 17.2.4
[ceph.git] / ceph / src / pybind / mgr / nfs / cluster.py
index 1d80544113243a58b6a721c9c7fbec764eda14b1..61bc477727baa5ba2d5e80c4697d512e7c4f4e23 100644 (file)
@@ -1,3 +1,4 @@
+import ipaddress
 import logging
 import json
 import re
@@ -103,7 +104,13 @@ class NFSCluster:
             ingress: Optional[bool] = None,
             port: Optional[int] = None,
     ) -> Tuple[int, str, str]:
+
         try:
+            if virtual_ip:
+                # validate virtual_ip value: ip_address throws a ValueError
+                # exception in case it's not a valid ipv4 or ipv6 address
+                ip = virtual_ip.split('/')[0]
+                ipaddress.ip_address(ip)
             if virtual_ip and not ingress:
                 raise NFSInvalidOperation('virtual_ip can only be provided with ingress enabled')
             if not virtual_ip and ingress: