// SetInternalPort will create an internal port which will allow the OS
// to manage this switches network settings.
SetInternalPort will create an internal port which will allow the OS
to manage this switches network settings.
// SetInternalPort will create an internal port which will allow the OS // to manage this switches network settings .
func (v VirtualSwitch) SetInternalPort() error {
	externalPortAllocSettings, err := v.getSwitchExternalPortAllocSettings()
	if err != nil {
		if err != wmi.ErrNotFound {
			return errors.Wrap(err, "getSwitchExternalPortAllocSettings")
		}
	}
	var macAddress string
	if externalPortAllocSettings != "" {
		extAllocSettingsLocation, err := wmi.NewLocation(externalPortAllocSettings)
		if err != nil {
			return errors.Wrap(err, "NewLocation")
		}
		extAllocResult, err := extAllocSettingsLocation.GetResult()
		if err != nil {
			return errors.Wrap(err, "GetResult")
		}
		extPortResult, err := v.getHostResourceLocation(extAllocResult)
		if err != nil {
			return errors.Wrap(err, "getHostResourceLocation")
		}
		extResult, err := extPortResult.GetResult()
		if err != nil {
			return errors.Wrap(err, "GetResult")
		}
		mac, err := extResult.GetProperty("PermanentAddress")
		if err != nil {
			return errors.Wrap(err, "GetProperty(PermanentAddress)")
		}
		macAddress = mac.Value().(string)
	}
	internalPortText, err := v.getInternalPortAllocationText(macAddress)
	if err != nil {
		return errors.Wrap(err, "getInternalPortAllocationText")
	}
	resources := []string{
		internalPortText,
	}
	err = v.setSwitchResources(resources)
	if err != nil {
		return errors.Wrap(err, "setSwitchResources")
	}
	return nil
}
func ( v VirtualSwitch ) SetInternalPort ( ) error { externalPortAllocSettings , err := v . getSwitchExternalPortAllocSettings ( ) if err != nil { if err != wmi . ErrNotFound { return errors . Wrap ( err , " " ) } } var macAddress string if externalPortAllocSettings != " " { extAllocSettingsLocation , err := wmi . NewLocation ( externalPortAllocSettings ) if err != nil { return errors . Wrap ( err , " " ) } extAllocResult , err := extAllocSettingsLocation . GetResult ( ) if err != nil { return errors . Wrap ( err , " " ) } extPortResult , err := v . getHostResourceLocation ( extAllocResult ) if err != nil { return errors . Wrap ( err , " " ) } extResult , err := extPortResult . GetResult ( ) if err != nil { return errors . Wrap ( err , " " ) } mac , err := extResult . GetProperty ( " " ) if err != nil { return errors . Wrap ( err , " " ) } macAddress = mac . Value ( ) . ( string ) } internalPortText , err := v . getInternalPortAllocationText ( macAddress ) if err != nil { return errors . Wrap ( err , " " ) } resources := [ ] string { internalPortText , } err = v . setSwitchResources ( resources ) if err != nil { return errors . Wrap ( err , " " ) } return nil }
SetInternalPort will create an internal port which will allow the OS
to manage this switches network settings.
SetInternalPort will create an internal port which will allow the OS to manage this switches network settings .