[CVP] Fixed cleaning up cvp containers
In 'docker ps -f name=cvp' command, the name is found by the
regexp, not the whole name. So 'docker ps -f name=cvp' will find
even 'cvp-perf' container, but 'docker rm cvp' will fail if only
cvp-perf is found and 'cvp' container does not exist.
Change-Id: Ib2013f558b6ce43c75e35306ab2212a52c3a66ac
Related-Prod: PROD-34385
diff --git a/src/com/mirantis/mcp/Validate.groovy b/src/com/mirantis/mcp/Validate.groovy
index b1755b2..9c7a5b6 100644
--- a/src/com/mirantis/mcp/Validate.groovy
+++ b/src/com/mirantis/mcp/Validate.groovy
@@ -60,7 +60,7 @@
"/tmp/": "/tmp/",
"/etc/hosts": "/etc/hosts"]
params.mounts = default_mounts + params.mounts
- if ( salt.cmdRun(params.master, params.target, "docker ps -f name=${params.name} -q", false, null, false)['return'][0].values()[0] ) {
+ if ( salt.cmdRun(params.master, params.target, "docker ps -f name=^${params.name}\$ -q", false, null, false)['return'][0].values()[0] ) {
salt.cmdRun(params.master, params.target, "docker rm -f ${params.name}")
}
if (params.env_var.size() > 0) {
@@ -926,7 +926,7 @@
*/
def runCleanup(master, target, name='cvp') {
def salt = new com.mirantis.mk.Salt()
- if ( salt.cmdRun(master, target, "docker ps -f name=${name} -q", false, null, false)['return'][0].values()[0] ) {
+ if ( salt.cmdRun(master, target, "docker ps -f name=^${name}\$ -q", false, null, false)['return'][0].values()[0] ) {
salt.cmdRun(master, target, "docker rm -f ${name}")
}
}