private XenAPI.Network CreateNetworkObject() { XenAPI.Network result = new XenAPI.Network { name_label = pageName.NetworkName, name_description = pageName.NetworkDescription, managed = true }; var autoPlug = pageNetworkType.SelectedNetworkType == NetworkTypes.CHIN ? pageChinDetails.isAutomaticAddNicToVM : pageNetworkType.SelectedNetworkType == NetworkTypes.SRIOV ? pageSriovDetails.isAutomaticAddNicToVM : pageNetworkDetails.isAutomaticAddNicToVM; result.SetAutoPlug(autoPlug); if (pageNetworkType.SelectedNetworkType == NetworkTypes.CHIN) { result.MTU = pageChinDetails.MTU; } else if (pageNetworkDetails.MTU.HasValue) //Custom MTU may not be allowed if we are making a virtual network or something { result.MTU = pageNetworkDetails.MTU.Value; } return(result); }
private XenAPI.Network PopulateNewNetworkObj() { XenAPI.Network result = new XenAPI.Network(); result.name_label = pageName.NetworkName; result.name_description = pageName.NetworkDescription; result.SetAutoPlug(pageNetworkType.SelectedNetworkType == NetworkTypes.CHIN ? pageChinDetails.isAutomaticAddNicToVM : pageNetworkDetails.isAutomaticAddNicToVM); if (pageNetworkType.SelectedNetworkType == NetworkTypes.CHIN) { result.MTU = pageChinDetails.MTU; } else if (pageNetworkDetails.MTU.HasValue) //Custom MTU may not be allowed if we are making a virtual network or something { result.MTU = pageNetworkDetails.MTU.Value; } result.managed = true; return(result); }
string CreateNetwork(int lo, int hi) { log.DebugFormat("Creating network {0}...", name_label); XenAPI.Network network = new XenAPI.Network(); network.name_label = name_label; network.SetAutoPlug(autoplug); network.MTU = mtu; if (network.other_config == null) { network.other_config = new Dictionary <string, string>(); } network.other_config[XenAPI.Network.CREATE_IN_PROGRESS] = "true"; network.managed = true; RelatedTask = XenAPI.Network.async_create(Session, network); PollToCompletion(lo, hi); log.DebugFormat("Created network {0} as {1}.", name_label, Result); return(Result); }
public AsyncAction SaveSettings() { List <AsyncAction> actions = new List <AsyncAction>(); network.SetAutoPlug(autoCheckBox.Checked); bool needPlugUnplug = MtuHasChanged; if (MtuHasChanged) { network.MTU = (long)numericUpDownMTU.Value; } if (BondModeHasChanged) { List <AsyncAction> bondActions = SetBondModeActions(); if (bondActions != null && bondActions.Count > 0) { actions.AddRange(bondActions); } } if (HashingAlgorithmHasChanged) { List <AsyncAction> bondPropertiesActions = SetBondPropertiesActions(); if (bondPropertiesActions != null && bondPropertiesActions.Count > 0) { actions.AddRange(bondPropertiesActions); } } // Have the pifs changed? Just key off the first PIF bool pifsChanged = false; bool external = false; PIF new_pif = null; long vlan = -1; if (InternalToExternal) { pifsChanged = true; external = true; new_pif = NICNameToPIF((string)HostPNICList.SelectedItem); vlan = (long)this.numUpDownVLAN.Value; } else if (ExternalToInternal) { pifsChanged = true; external = false; } else if (ExternalChangedDeviceOrVlan) { pifsChanged = true; external = true; new_pif = NICNameToPIF((string)HostPNICList.SelectedItem); vlan = (long)this.numUpDownVLAN.Value; } if (pifsChanged || external) { // even if we needPlugUnplug this is ok, the network update action destroys/recreates pifs anyway // ASSUMPTION: currently we don't allow network reconfigure that leads us here if ANY VMs are attached, so there are no VIFs to plug/unplug actions.Add(new NetworkAction(network.Connection, network, pifsChanged, external, new_pif, vlan, true)); } else if (needPlugUnplug) { List <PIF> pifs = network.Connection.ResolveAll <PIF>(network.PIFs); AsyncAction a = new UnplugPlugNetworkAction(network, true); foreach (SelectedItem i in Program.MainWindow.SelectionManager.Selection) { Host h = i.XenObject as Host; if (h == null) { continue; } a.Host = h; break; } actions.Add(a); } if (actions.Count == 0) { return(null); } return (new MultipleAction(network.Connection, Messages.ACTION_SAVE_CHANGES_TITLE, Messages.ACTION_SAVE_CHANGES_IN_PROGRESS, Messages.ACTION_SAVE_CHANGES_SUCCESSFUL, actions, true)); }