是否可以使用vim-cmd更改vmware快照的名称

时间:2014-10-31 09:35:00

标签: virtual-machine vmware esxi

如何使用命令行更改VMware快照的显示名称,或将一个快照移动到另一个快照? vim-cmd 实用程序在 vmsvc / 下有以下子命令,但它们似乎无法执行此操作。

snapshot.create
snapshot.dumpoption
snapshot.get
snapshot.remove
snapshot.removeall
snapshot.revert
snapshot.setoption

使用GUI,我编辑名称。我可以使用哪些命令或命令组合在命令行上实现此目的?

1 个答案:

答案 0 :(得分:1)

vim-cmd …命令不直接支持此功能,但您可以通过编辑与VM关联的 .vmsd 文件来执行此任务。例如,在服务器上:

# ls -1 /vmfs/volumes/Datastore/Debian7Generic/*[x,d]
/vmfs/volumes/Datastore/Debian7Generic/Debian7Generic.vmsd
/vmfs/volumes/Datastore/Debian7Generic/Debian7Generic.vmx

.vmx 文件是主要配置; .vmsd 文件描述了快照。后者的内容如下:

.encoding = "UTF-8"
snapshot.lastUID = "19"
snapshot.current = "12"
snapshot0.uid = "1"
snapshot0.filename = "Debian7Generic-Snapshot1.vmsn"
snapshot0.displayName = "Fresh Install"
snapshot0.type = "1"
snapshot0.createTimeHigh = "331196"
snapshot0.createTimeLow = "1387465219"
snapshot0.numDisks = "1"
snapshot0.disk0.fileName = "Debian7Generic.vmdk"
snapshot0.disk0.node = "scsi0:0"
snapshot1.uid = "7"
snapshot1.filename = "Debian7Generic-Snapshot7.vmsn"
snapshot1.parent = "1"
snapshot1.displayName = "Fresh A"
snapshot1.type = "1"
snapshot1.createTimeHigh = "331234"
snapshot1.createTimeLow = "1435772305"
snapshot1.numDisks = "1"
snapshot1.disk0.fileName = "Debian7Generic-000001.vmdk"
snapshot1.disk0.node = "scsi0:0"
…

这不是一种漂亮的方式,但您可以使用文本编辑器重命名快照,以使用 sed 编辑该文件或更自动化的方法。例如,你可以这样做:

# sed -i -e 's|snapshot0.displayName = .*|snapshot0.displayName = "A different name"|' Debian7Generic.vmsd

.encoding = "UTF-8"
snapshot.lastUID = "19"
snapshot.current = "12"
snapshot0.uid = "1"
snapshot0.filename = "Debian7Generic-Snapshot1.vmsn"
snapshot0.displayName = "A different name"
snapshot0.type = "1"
snapshot0.createTimeHigh = "331196"
snapshot0.createTimeLow = "1387465219"
snapshot0.numDisks = "1"
snapshot0.disk0.fileName = "Debian7Generic.vmdk"
snapshot0.disk0.node = "scsi0:0"
snapshot1.uid = "7"
snapshot1.filename = "Debian7Generic-Snapshot7.vmsn"
…