0

我正在尝试使用 OVF 配置部署 VM,我的目标是使用 VMware guestinfo 将用户在 OVF 环境中提供的键值传递给 VM。

以下是我添加到 OVF 文件中的设置/属性

<ProductSection ovf:required="false">
            <Info>Virtual Appliance</Info>
            <Property ovf:userConfigurable="true" ovf:type="string"
                      ovf:key="guestinfo.hello" ovf:value="">
              <Label>hello</Label>
              <Description>enter some string</Description>
            </Property>
</ProductSection>
....
<VirtualHardwareSection ovf:transport="com.vmware.guestInfo">
....

部署 VM 后,我可以在 VM vApp 选项下验证 OVF 环境中的属性。这是我看到的

<?xml version="1.0" encoding="UTF-8"?>
<Environment
 xmlns="http://schemas.dmtf.org/ovf/environment/1"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:oe="http://schemas.dmtf.org/ovf/environment/1"
 xmlns:ve="http://www.vmware.com/schema/ovfenv"
 oe:id=""
 ve:vCenterId="vm-xxxx">
<PlatformSection>
  <Kind>VMware ESXi</Kind>
  <Version>6.0.0</Version>
  <Vendor>VMware, Inc.</Vendor>
  <Locale>en</Locale>
</PlatformSection>
<PropertySection>
     <Property oe:key="guestinfo.hello" oe:value="world"/>
</PropertySection>
<ve:EthernetAdapterSection>
  <ve:Adapter ve:mac="00:50:56:b2:d2:8a" ve:network="VLAN1804- 
xxx.xxx.xxx.0/25" ve:unitNumber="7"/>
  <ve:Adapter ve:mac="00:50:56:b2:83:ea" ve:network="VLAN1804- 
xxx.xxx.xxx.0/25" ve:unitNumber="8"/>
</ve:EthernetAdapterSection>
</Environment>

最后,当我登录该框并尝试使用 vmtoolsd cmd 获取 guestinfo 属性 vmtoolsd --cmd "info-get hello" 时,我得到了 No value found

我需要帮助调试这个问题。不太确定我的 OVF 配置中是否缺少某些内容。提前致谢。我感谢您的帮助!

4

1 回答 1

0

我想没有直接的方法可以专门获取密钥,但我可以vmtoolsd --cmd "info-get guestinfo.ovfenv"在我的盒子上运行并且输出是

<?xml version="1.0" encoding="UTF-8"?>
<Environment
 xmlns="http://schemas.dmtf.org/ovf/environment/1"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:oe="http://schemas.dmtf.org/ovf/environment/1"
 xmlns:ve="http://www.vmware.com/schema/ovfenv"
 oe:id=""
 ve:vCenterId="vm-xxxx">
<PlatformSection>
  <Kind>VMware ESXi</Kind>
  <Version>6.0.0</Version>
  <Vendor>VMware, Inc.</Vendor>
  <Locale>en</Locale>
</PlatformSection>
<PropertySection>
     <Property oe:key="guestinfo.hello" oe:value="world"/>
</PropertySection>
<ve:EthernetAdapterSection>
  <ve:Adapter ve:mac="00:50:56:b2:d2:8a" ve:network="VLAN1804- 
xxx.xxx.xxx.0/25" ve:unitNumber="7"/>
  <ve:Adapter ve:mac="00:50:56:b2:83:ea" ve:network="VLAN1804- 
xxx.xxx.xxx.0/25" ve:unitNumber="8"/>
</ve:EthernetAdapterSection>
</Environment>

这是我在OVF环境中看到的vcenter中的vm。假设这可能是使用 vmtools 从 vm 获取键值的一种方法

于 2019-07-25T00:43:07.917 回答