Add funcs to remove application credential
Related-PROD: KUBV-171
Change-Id: I9d4ac73f5be1b135be998721c3e47f5fb6ac3999
diff --git a/src/com/mirantis/mk/Openstack.groovy b/src/com/mirantis/mk/Openstack.groovy
index be061f7..db54e4b 100644
--- a/src/com/mirantis/mk/Openstack.groovy
+++ b/src/com/mirantis/mk/Openstack.groovy
@@ -680,3 +680,33 @@
}
return outputTable
}
+
+/**
+ * Delete application credential
+ *
+ * @param env Connection parameters for OpenStack API endpoint
+ * @param name Name of the application credential to delete
+ */
+def deleteAppCredentialInDocker(env, name, img) {
+ def common = new com.mirantis.mk.Common()
+ common.infoMsg("Removing application credential ${name}")
+ def cmd = "openstack application credential delete ${name}"
+ runOpenstackCommandInDocker(cmd, env, img)
+}
+
+/**
+ * Check if application credential exists and delete it.
+ *
+ * @param env Connection parameters for OpenStack API endpoint
+ * @param name Name of the application credential to delete
+ **/
+def ensureAppCredentialRemovedInDocker(String name, env, img) {
+ def common = new com.mirantis.mk.Common()
+ def appCreds = runOpenstackCommandInDocker("openstack application credential list -f value -c Name", env, img).tokenize('\n')
+ if (name in appCreds) {
+ deleteAppCredentialInDocker(env, name, img)
+ common.infoMsg("Application credential ${name} has been deleted")
+ } else {
+ common.warningMsg("Application credential ${name} not found")
+ }
+}