Skip to content

Commit

Permalink
Revert "Map vSphere static IPs"
Browse files Browse the repository at this point in the history
This reverts commit a586cc0.
  • Loading branch information
liranr23 committed May 27, 2024
1 parent 54378fc commit d79c28f
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 110 deletions.
18 changes: 0 additions & 18 deletions pkg/controller/plan/adapter/vsphere/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ func (r *Builder) PodEnvironment(vmRef ref.Ref, sourceSecret *core.Secret) (env
return
}

macsToIps := r.mapMacStaticIps(vm)

libvirtURL, fingerprint, err := r.getSourceDetails(vm, sourceSecret)
if err != nil {
return
Expand All @@ -211,25 +209,9 @@ func (r *Builder) PodEnvironment(vmRef ref.Ref, sourceSecret *core.Secret) (env
Value: fingerprint,
},
)
if macsToIps != "" {
env = append(env, core.EnvVar{
Name: "V2V_staticIPs",
Value: macsToIps,
})
}
return
}

func (r *Builder) mapMacStaticIps(vm *model.VM) string {
configurations := []string{}
for _, guestNetwork := range vm.GuestNetworks {
if guestNetwork.Origin == string(types.NetIpConfigInfoIpAddressOriginManual) {
configurations = append(configurations, fmt.Sprintf("%s:ip:%s", guestNetwork.MAC, guestNetwork.IP))
}
}
return strings.Join(configurations, "_")
}

func (r *Builder) getSourceDetails(vm *model.VM, sourceSecret *core.Secret) (libvirtURL liburl.URL, fingerprint string, err error) {
host, err := r.host(vm.Host)
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions pkg/controller/provider/container/vsphere/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ const (
fConnectionState = "runtime.connectionState"
fSnapshot = "snapshot"
fIsTemplate = "config.template"
fGuestNet = "guest.net"
)

// Selections
Expand Down Expand Up @@ -721,7 +720,6 @@ func (r *Collector) vmPathSet() []string {
fNumCoresPerSocket,
fMemorySize,
fDevices,
fGuestNet,
fExtraConfig,
fGuestName,
fGuestID,
Expand Down
20 changes: 0 additions & 20 deletions pkg/controller/provider/container/vsphere/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,26 +613,6 @@ func (v *VmAdapter) Apply(u types.ObjectUpdate) {
}
}
}
case fGuestNet:
if nics, cast := p.Val.(types.ArrayOfGuestNicInfo); cast {
guestNetworksList := []model.GuestNetwork{}
for _, info := range nics.GuestNicInfo {
if info.IpConfig == nil {
continue
}
for _, ip := range info.IpConfig.IpAddress {
guestNetworksList = append(guestNetworksList, model.GuestNetwork{
MAC: info.MacAddress,
IP: ip.IpAddress,
Origin: ip.Origin,
})
}
}
// when the vm goes down, we get an update with empty values - the following check keeps the previously reported data.
if len(guestNetworksList) > 0 {
v.model.GuestNetworks = guestNetworksList
}
}
case fDevices:
if devArray, cast := p.Val.(types.ArrayOfVirtualDevice); cast {
devList := []model.Device{}
Expand Down
70 changes: 31 additions & 39 deletions pkg/controller/provider/model/vsphere/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,38 +231,37 @@ type Datastore struct {

type VM struct {
Base
Folder string `sql:"d0,index(folder)"`
Host string `sql:"d0,index(host)"`
RevisionValidated int64 `sql:"d0,index(revisionValidated)"`
PolicyVersion int `sql:"d0,index(policyVersion)"`
UUID string `sql:""`
Firmware string `sql:""`
PowerState string `sql:""`
ConnectionState string `sql:""`
CpuAffinity []int32 `sql:""`
CpuHotAddEnabled bool `sql:""`
CpuHotRemoveEnabled bool `sql:""`
MemoryHotAddEnabled bool `sql:""`
FaultToleranceEnabled bool `sql:""`
CpuCount int32 `sql:""`
CoresPerSocket int32 `sql:""`
MemoryMB int32 `sql:""`
GuestName string `sql:""`
GuestID string `sql:""`
BalloonedMemory int32 `sql:""`
IpAddress string `sql:""`
NumaNodeAffinity []string `sql:""`
StorageUsed int64 `sql:""`
Snapshot Ref `sql:""`
IsTemplate bool `sql:""`
ChangeTrackingEnabled bool `sql:""`
TpmEnabled bool `sql:""`
Devices []Device `sql:""`
NICs []NIC `sql:""`
Disks []Disk `sql:""`
Networks []Ref `sql:""`
Concerns []Concern `sql:""`
GuestNetworks []GuestNetwork `sql:""`
Folder string `sql:"d0,index(folder)"`
Host string `sql:"d0,index(host)"`
RevisionValidated int64 `sql:"d0,index(revisionValidated)"`
PolicyVersion int `sql:"d0,index(policyVersion)"`
UUID string `sql:""`
Firmware string `sql:""`
PowerState string `sql:""`
ConnectionState string `sql:""`
CpuAffinity []int32 `sql:""`
CpuHotAddEnabled bool `sql:""`
CpuHotRemoveEnabled bool `sql:""`
MemoryHotAddEnabled bool `sql:""`
FaultToleranceEnabled bool `sql:""`
CpuCount int32 `sql:""`
CoresPerSocket int32 `sql:""`
MemoryMB int32 `sql:""`
GuestName string `sql:""`
GuestID string `sql:""`
BalloonedMemory int32 `sql:""`
IpAddress string `sql:""`
NumaNodeAffinity []string `sql:""`
StorageUsed int64 `sql:""`
Snapshot Ref `sql:""`
IsTemplate bool `sql:""`
ChangeTrackingEnabled bool `sql:""`
TpmEnabled bool `sql:""`
Devices []Device `sql:""`
NICs []NIC `sql:""`
Disks []Disk `sql:""`
Networks []Ref `sql:""`
Concerns []Concern `sql:""`
}

// Determine if current revision has been validated.
Expand Down Expand Up @@ -291,10 +290,3 @@ type NIC struct {
Network Ref `json:"network"`
MAC string `json:"mac"`
}

// Guest network.
type GuestNetwork struct {
MAC string `json:"mac"`
IP string `json:"ip"`
Origin string `json:"origin"`
}
48 changes: 23 additions & 25 deletions pkg/controller/provider/web/vsphere/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,30 +210,29 @@ func (r *VM1) Content(detail int) interface{} {
// VM full detail.
type VM struct {
VM1
PolicyVersion int `json:"policyVersion"`
UUID string `json:"uuid"`
Firmware string `json:"firmware"`
ConnectionState string `json:"connectionState"`
Snapshot model.Ref `json:"snapshot"`
ChangeTrackingEnabled bool `json:"changeTrackingEnabled"`
CpuAffinity []int32 `json:"cpuAffinity"`
CpuHotAddEnabled bool `json:"cpuHotAddEnabled"`
CpuHotRemoveEnabled bool `json:"cpuHotRemoveEnabled"`
MemoryHotAddEnabled bool `json:"memoryHotAddEnabled"`
FaultToleranceEnabled bool `json:"faultToleranceEnabled"`
CpuCount int32 `json:"cpuCount"`
CoresPerSocket int32 `json:"coresPerSocket"`
MemoryMB int32 `json:"memoryMB"`
GuestName string `json:"guestName"`
GuestID string `json:"guestId"`
BalloonedMemory int32 `json:"balloonedMemory"`
IpAddress string `json:"ipAddress"`
StorageUsed int64 `json:"storageUsed"`
TpmEnabled bool `json:"tpmEnabled"`
NumaNodeAffinity []string `json:"numaNodeAffinity"`
Devices []model.Device `json:"devices"`
NICs []model.NIC `json:"nics"`
GuestNetworks []model.GuestNetwork `json:"guestNetworks"`
PolicyVersion int `json:"policyVersion"`
UUID string `json:"uuid"`
Firmware string `json:"firmware"`
ConnectionState string `json:"connectionState"`
Snapshot model.Ref `json:"snapshot"`
ChangeTrackingEnabled bool `json:"changeTrackingEnabled"`
CpuAffinity []int32 `json:"cpuAffinity"`
CpuHotAddEnabled bool `json:"cpuHotAddEnabled"`
CpuHotRemoveEnabled bool `json:"cpuHotRemoveEnabled"`
MemoryHotAddEnabled bool `json:"memoryHotAddEnabled"`
FaultToleranceEnabled bool `json:"faultToleranceEnabled"`
CpuCount int32 `json:"cpuCount"`
CoresPerSocket int32 `json:"coresPerSocket"`
MemoryMB int32 `json:"memoryMB"`
GuestName string `json:"guestName"`
GuestID string `json:"guestId"`
BalloonedMemory int32 `json:"balloonedMemory"`
IpAddress string `json:"ipAddress"`
StorageUsed int64 `json:"storageUsed"`
TpmEnabled bool `json:"tpmEnabled"`
NumaNodeAffinity []string `json:"numaNodeAffinity"`
Devices []model.Device `json:"devices"`
NICs []model.NIC `json:"nics"`
}

// Build the resource using the model.
Expand Down Expand Up @@ -262,7 +261,6 @@ func (r *VM) With(m *model.VM) {
r.Devices = m.Devices
r.NumaNodeAffinity = m.NumaNodeAffinity
r.NICs = m.NICs
r.GuestNetworks = m.GuestNetworks
}

// Build self link (URI).
Expand Down
6 changes: 0 additions & 6 deletions virt-v2v/cold/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ func main() {
}
virtV2vArgs = append(virtV2vArgs, "-ip", "/etc/secret/secretKey")

if envStaticIPs := os.Getenv("V2V_staticIPs"); envStaticIPs != "" {
for _, macToIp := range strings.Split(envStaticIPs, "_") {
virtV2vArgs = append(virtV2vArgs, "--mac", macToIp)
}
}

if info, err := os.Stat(VDDK); err == nil && info.IsDir() {
virtV2vArgs = append(virtV2vArgs,
"-it", "vddk",
Expand Down

0 comments on commit d79c28f

Please sign in to comment.