Quantcast
Viewing all articles
Browse latest Browse all 6649

A bug in autodeploy Apply-VMHostProfile powercli commandlet while creating answer file?

In stateless Autodeploy, I am using "Apply-VMHostProfile" powercli commandlet to apply host profile to ESX5.5 host in maintenance mode.

There are some host specific configuration which need to be applied through answer file. Host specific configurations are hostname, IP address and Subnetmask.

 

"Apply-VMHostProfile" applies host profile successfully, host profile compliance rule will pass and an answerfile will get created in vcenter5.5.

But after reboot, ESX5.5 host will not be able to apply answer file to ESX5.5 host.

 

Sample powercli script I used while applying host-profile.

 

$configuration = @{}

# Hostname

$configuration['network.GenericNetStackInstanceProfile["key-vim-profile-host-GenericNetStackInstanceProfile-defaultTcpipStack"].GenericDnsConfigProfile.HostNamePolicy.hostName'] = $host_name

# Backend IP

$configuration['network.hostPortGroup["key-vim-profile-host-HostPortgroupProfile-backend"].ipConfig.IpAddressPolicy.address'] = $backend_ip

# Backend subnet mask

$configuration['network.hostPortGroup["key-vim-profile-host-HostPortgroupProfile-backend"].ipConfig.IpAddressPolicy.subnetmask'] = $backend_netmask

# Apply-VMHostProfile commandlet

$ret = Apply-VMHostProfile -Entity $host_name -Profile $host_profile -Variable $configuration -confirm:$false

 

Below is answer file that got generated. I queried vcenter server appliance postgreSQL database to fetch result.

 

<?xml version="1.0"?>

<obj xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:vim25" versionId="5.5" xsi:type="ArrayOfProfileDeferredPolicyOptionParameter">

  <ProfileDeferredPolicyOptionParameter xsi:type="ProfileDeferredPolicyOptionParameter">

    <inputPath>

      <profilePath>network.hostPortGroup["key-vim-profile-host-HostPortgroupProfile-backend"].ipConfig</profilePath>

      <policyId>IpAddressPolicy</policyId>

    </inputPath>

    <parameter>

      <key>address</key>

      <value xsi:type="xsd:string">XXX.XXX.XXX.XXX</value>

    </parameter>

    <parameter>

      <key>subnetmask</key>

      <value xsi:type="xsd:string">YYY.YYY.YYY.YYY</value>

    </parameter>

  </ProfileDeferredPolicyOptionParameter>

  <ProfileDeferredPolicyOptionParameter xsi:type="ProfileDeferredPolicyOptionParameter">

    <inputPath>

      <profilePath>network.GenericNetStackInstanceProfile["key-vim-profile-host-GenericNetStackInstanceProfile-defaultTcpipStack"].GenericDnsConfigProfile</profilePath>

      <policyId>HostNamePolicy</policyId>

    </inputPath>

    <parameter>

      <key>hostName</key>

      <value xsi:type="xsd:string">HOSTNAME</value>

    </parameter>

  </ProfileDeferredPolicyOptionParameter>

</obj>

 

I did same experiment of associating host to hostprofile and applying host specific configuration through Vcenter web interface. Below is the answer file I got.

 

<?xml version="1.0"?>

<obj xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:vim25" versionId="5.5" xsi:type="ArrayOfProfileDeferredPolicyOptionParameter">

  <ProfileDeferredPolicyOptionParameter xsi:type="ProfileDeferredPolicyOptionParameter">

    <inputPath>

      <profilePath>network.GenericNetStackInstanceProfile["key-vim-profile-host-GenericNetStackInstanceProfile-defaultTcpipStack"].GenericDnsConfigProfile</profilePath>

      <policyId>HostNamePolicy</policyId>

    </inputPath>

    <parameter>

      <key>hostName</key>

      <value xsi:type="xsd:string">HOSTNAME</value>

    </parameter>

  </ProfileDeferredPolicyOptionParameter>

  <ProfileDeferredPolicyOptionParameter xsi:type="ProfileDeferredPolicyOptionParameter">

    <inputPath>

      <profilePath>network.hostPortGroup["key-vim-profile-host-HostPortgroupProfile-backend"].ipConfig</profilePath>

      <policyId>IpAddressPolicy</policyId>

    </inputPath>

    <parameter>

      <key>address</key>

      <value xsi:type="xsd:string">XXX.XXX.XXX.XXX</value>

    </parameter>

    <parameter>

      <key>subnetmask</key>

      <value xsi:type="xsd:string">YYY.YYY.YYY.YYY</value>

    </parameter>

  </ProfileDeferredPolicyOptionParameter>

</obj>

 

 

It can be noticed that order in which variables (hostname, IP address, subnetmask) are set are different when set through Apply-VMHostprofile and when set through Web interface.

Through Apply-VMHostprofile, order is

1) IP address

2) Subnet mask

3) HOSTNAME

 

through web interface, order is

1) HOSTNAME

2) IP address

3) Subnet mask.

 

I ditched "Apply-VMHostprofile" commandlet and used "VMware.Vim.AnswerFileOptionsCreateSpec" to create answer file in proper order and things worked fine.

ESX5.5 host was able to properly fetch answer file and apply it during subsequent reboots.

 

I suspect while converting "-Variable" option to xml file, autodeploy is not properly following order to create answer file.

Any other workaround suggestion is welcome which will help me create answer file through "Apply-VMHostprofile" commandlet.

Issue seems to be a bug with Apply-VMHostProfile powercli commandlet implementation.

 

I tried setting "[ordered]" to specify ordered HASH, It did not worked.

$configuration = [ordered]@{}

 

Thanks,


Viewing all articles
Browse latest Browse all 6649

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>