Code Monkey home page Code Monkey logo

Comments (3)

icnocop avatar icnocop commented on July 20, 2024

Hi @leslie-qiwa

Did you ever resolve this issue?
If so, how did you resolve it?

Thank you.

from esxi-packer-templates.

leslie-qiwa avatar leslie-qiwa commented on July 20, 2024

unfortunately, not yet.

from esxi-packer-templates.

icnocop avatar icnocop commented on July 20, 2024

I was able to resolve this issue by delaying/waiting until a connection could be established.

I got the hint from this post:
https://communities.vmware.com/t5/ESXi-Discussions/Imaging-ESX-5-1-MAC-address-issues-with-DHCP/td-p/2152927
Sleep command is critical with out this delay the script executes too fast during the boot process and script will not work at boot time,

#!/bin/sh

# When an ESX VM is cloned, vnic0 gets a new mac from the vmx's
# ethernet0.generatedAddress, but vmk0's mac is persisted in /etc/vmware/esx.conf
# vagrant uses ethernet0.generatedAddress to lookup the VM ip in
# vmnet-dhcpd-vmnet8.leases, reconfigure here if needed.

os_ver=$(uname -r | awk -F. '{print $1}')

while [ "$vnic0_mac" == "" -o "$vmk0_mac" == "" ]
do
  if [ "$os_ver" -lt 6 ] ; then
    vnic0_mac=$(esxcli --formatter csv network nic list | grep vmnic0 | awk -F, '{print $5}')
    vmk0_mac=$(esxcli --formatter csv network ip interface list | grep vmk0 | awk -F, '{print $2}')
  else
    vnic0_mac=$(esxcli --formatter csv network nic list | grep vmnic0 | awk -F, '{print $7}')
    vmk0_mac=$(esxcli --formatter csv network ip interface list | grep vmk0 | awk -F, '{print $3}')
  fi
done

if [ "$vnic0_mac" != "$vmk0_mac" ] ; then
  esxcli network ip interface remove -i vmk0

  esxcli network ip interface add -i vmk0 -M $vnic0_mac -p "Management Network"

  esxcli network ip interface ipv4 set -i vmk0 -t dhcp
fi

from esxi-packer-templates.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.