全部操作是基于宿主机的
全部设置开启自启动
for i in `xe vm-list params=uuid --minimal|sed ‘s/,/ /g‘`;do xe vm-param-set uuid=$i other-config:auto_poweron=true;done
全部设置关闭自启动
for i in `xe vm-list params=uuid --minimal|sed ‘s/,/ /g‘`;do xe vm-param-remove uuid=$i param-name=other-config param-key="auto_poweron";done
查询全部自启动
for i in `xe vm-list params=uuid --minimal|sed ‘s/,/ /g‘`;do echo "`xe vm-list uuid=$i params=name-label --minimal `:======================:";xe vm-param-list uuid=$i | grep other-config | awk -F[\;] ‘{print $1}‘|grep auto_poweron;done
查询所有halted状态的vm
xe vm-list params=name-label power-state=halted --minimal | awk -F, ‘{for (i=1;i<=NF;i++) {printf $i"\n"}}‘ |sort
查询所有halted状态的vm的uuid
xe vm-list params=uuid power-state=halted --minimal | awk -F, ‘{for (i=1;i<=NF;i++) {printf $i"\n"}}‘
查询所有halted状态的vm的自启动
for i in `xe vm-list params=uuid power-state=halted --minimal|sed ‘s/,/ /g‘`;do echo "`xe vm-list uuid=$i params=name-label --minimal `:======================:";xe vm-param-list uuid=$i | grep other-config | awk -F[\;] ‘{print $1}‘|grep auto_poweron;done
全部关闭halted状态的vm的自启动
for i in `xe vm-list params=uuid power-state=halted --minimal|sed ‘s/,/ /g‘`;do xe vm-param-remove uuid=$i param-name=other-config param-key="auto_poweron";done
把虚拟机CentOS_6_Cat_4(197) 开启自启动
for i in `xe vm-list name-label="CentOS_6_Cat_4(197)" params=uuid --minimal|sed ‘s/,/ /g‘`;do xe vm-param-set uuid=$i other-config:auto_poweron=true;done
把未开启的虚拟机CentOS_6_Cat_4(197) 关闭自启动
for i in `xe vm-list name-label="CentOS_6_Cat_4(197)" params=uuid --minimal|sed ‘s/,/ /g‘`;do xe vm-param-remove uuid=$i param-name=other-config param-key="auto_poweron";done
查看虚拟机CentOS_6_Cat_4(197) 自启动状态
for i in `xe vm-list name-label="CentOS_6_Cat_4(197)" params=uuid --minimal|sed ‘s/,/ /g‘`;do xe vm-param-list uuid=$i | grep other-config | awk -F[\;] ‘{print $1}‘|grep auto_poweron;done
本文出自 “11416160” 博客,转载请与作者联系!
原文地址:http://11426160.blog.51cto.com/11416160/1860074