sh检查Openstack中是否存在图像

sh检查Openstack中是否存在图像,openstack,Openstack,有没有一种方法可以使用shell脚本检查Openstack中是否存在由下面的glance创建的名为“myimage”的图像 glance image-create --name "myimage" --disk-format qcow2 --container-format bare --is-public True --progress < myimage.qcow2 glance image create--name“myimage”--磁盘格式qcow2--container fo

有没有一种方法可以使用shell脚本检查Openstack中是否存在由下面的glance创建的名为“myimage”的图像

glance image-create --name "myimage" --disk-format qcow2 --container-format bare --is-public True --progress < myimage.qcow2
glance image create--name“myimage”--磁盘格式qcow2--container format bare--is public True--progress
您可以在shell脚本中使用此命令检查glnace中是否已经存在“myimage”

glance image-list | grep myimage
如果图像存在,它将返回匹配的图像名称,否则您将得到零结果

编辑

#!/bin/sh
image="myimage"
if glance image-list | grep $image > /dev/null
then
    echo "$image already exists"
else
    echo "$image does not exist"
fi

您可以在shell脚本中使用此命令来检查glnace中是否已经存在“myimage”

glance image-list | grep myimage
如果图像存在,它将返回匹配的图像名称,否则您将得到零结果

编辑

#!/bin/sh
image="myimage"
if glance image-list | grep $image > /dev/null
then
    echo "$image already exists"
else
    echo "$image does not exist"
fi

谢谢,因为我不熟悉它的语法,你能为检查写完整的sh脚本吗?谢谢,因为我不熟悉它的语法,你能为检查写完整的sh脚本吗?