summaryrefslogtreecommitdiff
path: root/ironic/conductor/utils.py
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2020-06-18 11:50:29 +0000
committerGerrit Code Review <review@openstack.org>2020-06-18 11:50:29 +0000
commit5822b2fb7d2c7a08dd29580a9ef80bb86d601992 (patch)
treeaad3e89883b13ce33c0b657bb21f510096af9c80 /ironic/conductor/utils.py
parentaea1c76c3bf9b4e1288e11c8c31c272526abb0a6 (diff)
parent64674bf0ed966c3e8f241d555b772f03e7407951 (diff)
downloadironic-5822b2fb7d2c7a08dd29580a9ef80bb86d601992.tar.gz
Merge "Block port deletions where vif is present"
Diffstat (limited to 'ironic/conductor/utils.py')
-rw-r--r--ironic/conductor/utils.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/ironic/conductor/utils.py b/ironic/conductor/utils.py
index 836409dad..35e2c94fc 100644
--- a/ironic/conductor/utils.py
+++ b/ironic/conductor/utils.py
@@ -1144,3 +1144,30 @@ def hash_password(password=''):
:param value: Value to be hashed
"""
return crypt.crypt(password, make_salt())
+
+
+def get_attached_vif(port):
+ """Get any attached vif ID for the port
+
+ :param port: The port object upon which to check for a vif
+ record.
+ :returns: Returns a tuple of the vif if found and the use of
+ the vif in the form of a string, 'tenant', 'cleaning'
+ 'provisioning', 'rescuing'.
+ :raises: InvalidState exception upon finding a port with a
+ transient state vif on the port.
+ """
+
+ tenant_vif = port.internal_info.get('tenant_vif_port_id')
+ if tenant_vif:
+ return (tenant_vif, 'tenant')
+ clean_vif = port.internal_info.get('cleaning_vif_port_id')
+ if clean_vif:
+ return (clean_vif, 'cleaning')
+ prov_vif = port.internal_info.get('provisioning_vif_port_id')
+ if prov_vif:
+ return (prov_vif, 'provisioning')
+ rescue_vif = port.internal_info.get('rescuing_vif_port_id')
+ if rescue_vif:
+ return (rescue_vif, 'rescuing')
+ return (None, None)