Revert OvfTransport changes;Add vApp enabled check
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			This commit is contained in:
		| @@ -3,7 +3,7 @@ type: kubernetes | |||||||
| name: 'Golang Build' | name: 'Golang Build' | ||||||
|  |  | ||||||
| environment: | environment: | ||||||
|   BINARY_VERSION: v0.5.2 |   BINARY_VERSION: v0.5.1 | ||||||
|  |  | ||||||
| clone: | clone: | ||||||
|   disable: true |   disable: true | ||||||
|   | |||||||
| @@ -28,10 +28,9 @@ var Commands struct { | |||||||
| 		Force        bool     `short:"f" long:"force"` | 		Force        bool     `short:"f" long:"force"` | ||||||
| 	} // `command:"datacenter" alias:"dc" description:"Define a Network Protocol Profile within a datacenter"` | 	} // `command:"datacenter" alias:"dc" description:"Define a Network Protocol Profile within a datacenter"` | ||||||
| 	VirtualMachine struct { | 	VirtualMachine struct { | ||||||
| 		Name                string `short:"n" long:"name" description:"Name of virtual machine" required:"true"` | 		Name       string `short:"n" long:"name" description:"Name of virtual machine" required:"true"` | ||||||
| 		Datacenter          string `long:"datacenter" description:"Name of datacenter" required:"true"` | 		Datacenter string `long:"datacenter" description:"Name of datacenter" required:"true"` | ||||||
| 		Network             string `long:"portgroup" description:"Name of network portgroup" required:"true"` | 		Network    string `long:"portgroup" description:"Name of network portgroup" required:"true"` | ||||||
| 		DisableOvfTransport bool   `long:"disableovftransport" description:"Disable the OVF transport 'VMware Tools'"` |  | ||||||
| 	} // `command:"virtualmachine" alias:"vm" description:"Configure a virtual machine for usage of Network Protocol Profiles"` | 	} // `command:"virtualmachine" alias:"vm" description:"Configure a virtual machine for usage of Network Protocol Profiles"` | ||||||
| 	GuestOS struct { | 	GuestOS struct { | ||||||
| 	} // `command:"guestos" alias:"os" description:"Configure guest OS network with allocated IP address"` | 	} // `command:"guestos" alias:"os" description:"Configure guest OS network with allocated IP address"` | ||||||
| @@ -45,7 +44,6 @@ func main() { | |||||||
| 	parser.AddCommand("vm", "", "", &Commands.VirtualMachine) | 	parser.AddCommand("vm", "", "", &Commands.VirtualMachine) | ||||||
| 	parser.AddCommand("guestos", "Configure guest OS network with allocated IP address", "", &Commands.GuestOS) | 	parser.AddCommand("guestos", "Configure guest OS network with allocated IP address", "", &Commands.GuestOS) | ||||||
| 	parser.AddCommand("os", "", "", &Commands.GuestOS) | 	parser.AddCommand("os", "", "", &Commands.GuestOS) | ||||||
|  |  | ||||||
| 	_, err := parser.Parse() | 	_, err := parser.Parse() | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type == flags.ErrHelp { | 		if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type == flags.ErrHelp { | ||||||
| @@ -73,7 +71,7 @@ func main() { | |||||||
| 	case "guestos", "os": | 	case "guestos", "os": | ||||||
| 		// TODO | 		// TODO | ||||||
| 	case "virtualmachine", "vm": | 	case "virtualmachine", "vm": | ||||||
| 		if err := hypervisor.SetVirtualMachineProperties(ctx, clt, Commands.VirtualMachine.Datacenter, Commands.VirtualMachine.Name, Commands.VirtualMachine.Network, Commands.VirtualMachine.DisableOvfTransport); err != nil { | 		if err := hypervisor.SetVirtualMachineProperties(ctx, clt, Commands.VirtualMachine.Datacenter, Commands.VirtualMachine.Name, Commands.VirtualMachine.Network); err != nil { | ||||||
| 			log.Fatalf("[ERROR] Could not apply vApp properties: %s", err) | 			log.Fatalf("[ERROR] Could not apply vApp properties: %s", err) | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -16,7 +16,7 @@ type vAPPProperty struct { | |||||||
| 	Value string | 	Value string | ||||||
| } | } | ||||||
|  |  | ||||||
| func SetVirtualMachineProperties(ctx context.Context, clt *vim25.Client, datacenter, virtualmachine, network string, disableovftransport bool) error { | func SetVirtualMachineProperties(ctx context.Context, clt *vim25.Client, datacenter, virtualmachine, network string) error { | ||||||
| 	finder := find.NewFinder(clt, true) | 	finder := find.NewFinder(clt, true) | ||||||
|  |  | ||||||
| 	dc, err := finder.Datacenter(ctx, datacenter) | 	dc, err := finder.Datacenter(ctx, datacenter) | ||||||
| @@ -36,31 +36,31 @@ func SetVirtualMachineProperties(ctx context.Context, clt *vim25.Client, datacen | |||||||
| 	vappconfig := &types.VmConfigSpec{ | 	vappconfig := &types.VmConfigSpec{ | ||||||
| 		OvfEnvironmentTransport: []string{"com.vmware.guestInfo"}, | 		OvfEnvironmentTransport: []string{"com.vmware.guestInfo"}, | ||||||
| 	} | 	} | ||||||
| 	if disableovftransport == true { |  | ||||||
| 		vappconfig = &types.VmConfigSpec{} |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	currentvappproperties := moref.Config.VAppConfig.GetVmConfigInfo().Property | 	currentvappproperties := []types.VAppPropertyInfo{} | ||||||
| 	for _, vappproperty := range currentvappproperties { | 	if moref.Config != nil { | ||||||
| 		vappconfig.Property = append(vappconfig.Property, types.VAppPropertySpec{ | 		currentvappproperties = moref.Config.VAppConfig.GetVmConfigInfo().Property | ||||||
| 			ArrayUpdateSpec: types.ArrayUpdateSpec{ | 		for _, vappproperty := range currentvappproperties { | ||||||
| 				Operation: types.ArrayUpdateOperationAdd, | 			vappconfig.Property = append(vappconfig.Property, types.VAppPropertySpec{ | ||||||
| 			}, | 				ArrayUpdateSpec: types.ArrayUpdateSpec{ | ||||||
| 			Info: &types.VAppPropertyInfo{ | 					Operation: types.ArrayUpdateOperationAdd, | ||||||
| 				Key:              vappproperty.Key, | 				}, | ||||||
| 				ClassId:          vappproperty.ClassId, | 				Info: &types.VAppPropertyInfo{ | ||||||
| 				InstanceId:       vappproperty.InstanceId, | 					Key:              vappproperty.Key, | ||||||
| 				Id:               vappproperty.Id, | 					ClassId:          vappproperty.ClassId, | ||||||
| 				Category:         vappproperty.Category, | 					InstanceId:       vappproperty.InstanceId, | ||||||
| 				Label:            vappproperty.Label, | 					Id:               vappproperty.Id, | ||||||
| 				Type:             vappproperty.Type, | 					Category:         vappproperty.Category, | ||||||
| 				TypeReference:    vappproperty.TypeReference, | 					Label:            vappproperty.Label, | ||||||
| 				UserConfigurable: vappproperty.UserConfigurable, | 					Type:             vappproperty.Type, | ||||||
| 				DefaultValue:     vappproperty.DefaultValue, | 					TypeReference:    vappproperty.TypeReference, | ||||||
| 				Value:            vappproperty.Value, | 					UserConfigurable: vappproperty.UserConfigurable, | ||||||
| 				Description:      vappproperty.Description, | 					DefaultValue:     vappproperty.DefaultValue, | ||||||
| 			}, | 					Value:            vappproperty.Value, | ||||||
| 		}) | 					Description:      vappproperty.Description, | ||||||
|  | 				}, | ||||||
|  | 			}) | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	newvappproperties := []vAPPProperty{ | 	newvappproperties := []vAPPProperty{ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user