【问题标题】:VMware VIM IPv6VMware VIM IPv6
【发布时间】:2015-01-16 14:24:07
【问题描述】:

这是基于其他帖子。 clone vm change network identity

我在构建 VM 时需要设置 IPv6 地址。我找到了属性,但它不允许我设置值。

$FirstNic.Adapter.IpV6Spec = New-Object VMware.Vim.CustomizationIPSettingsIpV6AddressSpec 
$FirstNic.Adapter.IpV6Spec.Ip = New-Object VMware.Vim.CustomizationFixedIpV6 
$FirstNic.Adapter.IpV6Spec.Ip.IpAddress = "::1"

The property 'IpAddress' cannot be found on this object. Verify that the property exists and can be set. At line:33 char:4 + $FirstNic.Adapter.IpV6Spec.Ip.IpAddress = "::1" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

这是成员:类型名称:VMware.Vim.CustomizationFixedIpV6

Name    MemberType  Definition
----        ----------  ----------
Equals      Method      bool Equals(System.Object obj)
GetHashCode     Method      int GetHashCode()
GetType     Method      type GetType()
ToString    Method      string ToString()
DynamicProperty Property    VMware.Vim.DynamicProperty[] DynamicProperty {get;set;}
DynamicType     Property    string DynamicType {get;set;}
IpAddress   Property    string IpAddress {get;set;}
SubnetMask  Property    int SubnetMask {get;set;}

【问题讨论】:

    标签: powershell vmware


    【解决方案1】:

    快速测试表明直接在VMware.Vim.CustomizationFixedIpV6 上设置该属性似乎有效。之后将其分配给VMware.Vim.CustomizationIPSettingsIpV6AddressSpec 对象似乎也有效。

    > $ip = New-Object vmware.vim.customizationfixedipv6
    > $ip.IpAddress = "::1"
    > $ipv6spec = new-object vmware.vim.customizationipsettingsipv6addressspec
    > $ipv6spec.ip = $ip
    > $ipv6spec.ip.ipaddress
    ::1
    > $ipv6spec.ip.ipaddress = "::2"
    Property 'ipaddress' cannot be found on this object; make sure it exists and is settable
    At line:1 char:1
    + $ipv6spec.ip.ipaddress = "::2"
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : PropertyAssignmentException
    

    但是VMware.Vim.CustomizationIPSettingsIpV6AddressSpecIp 属性似乎没有VMware.Vim.CustomizationFixedIpV6 作为其类型。它有VMware.Vim.CustomizationIpV6Generator

    所以我想知道这是否是类型规范/继承/等等。问题。

    【讨论】:

    • 我得到了它的一部分,我将发布。但只有网关出现。
    • $nic = 新对象 VMware.Vim.CustomizationAdapterMapping $nic.Adapter = 新对象 VMware.Vim.CustomizationIPSettings $nic.Adapter.ip = 新对象 VMware.Vim.CustomizationFixedIp $nic。 Adapter.ip.ipAddress = "192.168.1.$_" $nic.Adapter.subnetMask = "255.255.255.0" $nic.Adapter.IpV6Spec = 新对象 vmware.Vim.CustomizationIPSettingsIpV6AddressSpec $nic.Adapter.ipV6Spec.Gateway = "::$_" $ipv6 = 新对象 vmware.Vim.CustomizationFixedIpV6 $ipv6.IpAddress = "::$_" $ipv6.SubnetMask = 29 $nic.Adapter.ipV6Spec.Ip = $ipv6 $item.Spec。 nicSettingMap += $nic
    • 什么意思?该代码应该向我展示什么?为什么 IPv6 网关与 IPv6 IpAddress 相同?
    • 另外,这似乎是一个新问题,您应该将其标记为已解决。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-10-01
    • 2011-05-09
    • 2010-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多