Skip to content

Commit 30f9820

Browse files
committed
Add funcs to remove application credential
Related-PROD: KUBV-171 Change-Id: I9d4ac73f5be1b135be998721c3e47f5fb6ac3999
1 parent e3b9516 commit 30f9820

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/com/mirantis/mk/Openstack.groovy

+30
Original file line numberDiff line numberDiff line change
@@ -680,3 +680,33 @@ def getKeyPairInDocker(env, name, img) {
680680
}
681681
return outputTable
682682
}
683+
684+
/**
685+
* Delete application credential
686+
*
687+
* @param env Connection parameters for OpenStack API endpoint
688+
* @param name Name of the application credential to delete
689+
*/
690+
def deleteAppCredentialInDocker(env, name, img) {
691+
def common = new com.mirantis.mk.Common()
692+
common.infoMsg("Removing application credential ${name}")
693+
def cmd = "openstack application credential delete ${name}"
694+
runOpenstackCommandInDocker(cmd, env, img)
695+
}
696+
697+
/**
698+
* Check if application credential exists and delete it.
699+
*
700+
* @param env Connection parameters for OpenStack API endpoint
701+
* @param name Name of the application credential to delete
702+
**/
703+
def ensureAppCredentialRemovedInDocker(String name, env, img) {
704+
def common = new com.mirantis.mk.Common()
705+
def appCreds = runOpenstackCommandInDocker("openstack application credential list -f value -c Name", env, img).tokenize('\n')
706+
if (name in appCreds) {
707+
deleteAppCredentialInDocker(env, name, img)
708+
common.infoMsg("Application credential ${name} has been deleted")
709+
} else {
710+
common.warningMsg("Application credential ${name} not found")
711+
}
712+
}

0 commit comments

Comments
 (0)