public CreateVIFAction(VM vm, Proxy_VIF proxyVIF) : base(vm.Connection, String.Format(Messages.ACTION_VIF_CREATING_TITLE, vm.Name())) { _proxyVIF = proxyVIF; VM = vm; XmlRpcMethods.ForEach(method => ApiMethodsToRoleCheck.Add(method)); }
/// <summary> /// Retrieves the new settings as a proxy vif object. You will need to set the VM field to use these settings in a vif action /// </summary> /// <returns></returns> public Proxy_VIF GetNewSettings() { Proxy_VIF proxyVIF = ExistingVif != null?ExistingVif.ToProxy() : new Proxy_VIF(); proxyVIF.network = new XenRef <XenAPI.Network>(SelectedNetwork.opaque_ref); proxyVIF.MAC = SelectedMac; proxyVIF.device = Device.ToString(); if (checkboxQoS.Checked) { proxyVIF.qos_algorithm_type = VIF.RATE_LIMIT_QOS_VALUE; } else if (ExistingVif != null && ExistingVif.RateLimited) { proxyVIF.qos_algorithm_type = ""; } // else ... we leave it alone. Currently we only deal with "ratelimit" and "", don't overwrite the field if it's something else // preserve this param even if we turn off qos if (!string.IsNullOrEmpty(promptTextBoxQoS.Text)) { Hashtable qos_algorithm_params = new Hashtable(); qos_algorithm_params.Add(VIF.KBPS_QOS_PARAMS_KEY, promptTextBoxQoS.Text); proxyVIF.qos_algorithm_params = qos_algorithm_params; } return(proxyVIF); }
public Proxy_VIF ToProxy() { Proxy_VIF result_ = new Proxy_VIF(); result_.uuid = (uuid != null) ? uuid : ""; result_.allowed_operations = (allowed_operations != null) ? Helper.ObjectListToStringArray(allowed_operations) : new string[] {}; result_.current_operations = Maps.convert_to_proxy_string_vif_operations(current_operations); result_.device = (device != null) ? device : ""; result_.network = (network != null) ? network : ""; result_.VM = (VM != null) ? VM : ""; result_.MAC = (MAC != null) ? MAC : ""; result_.MTU = MTU.ToString(); result_.other_config = Maps.convert_to_proxy_string_string(other_config); result_.currently_attached = currently_attached; result_.status_code = status_code.ToString(); result_.status_detail = (status_detail != null) ? status_detail : ""; result_.runtime_properties = Maps.convert_to_proxy_string_string(runtime_properties); result_.qos_algorithm_type = (qos_algorithm_type != null) ? qos_algorithm_type : ""; result_.qos_algorithm_params = Maps.convert_to_proxy_string_string(qos_algorithm_params); result_.qos_supported_algorithms = qos_supported_algorithms; result_.metrics = (metrics != null) ? metrics : ""; result_.MAC_autogenerated = MAC_autogenerated; result_.locking_mode = vif_locking_mode_helper.ToString(locking_mode); result_.ipv4_allowed = ipv4_allowed; result_.ipv6_allowed = ipv6_allowed; return(result_); }
internal void UpdateFromProxy(Proxy_VIF proxy) { uuid = proxy.uuid == null ? null : (string)proxy.uuid; allowed_operations = proxy.allowed_operations == null ? null : Helper.StringArrayToEnumList <vif_operations>(proxy.allowed_operations); current_operations = proxy.current_operations == null ? null : Maps.convert_from_proxy_string_vif_operations(proxy.current_operations); device = proxy.device == null ? null : (string)proxy.device; network = proxy.network == null ? null : XenRef <Network> .Create(proxy.network); VM = proxy.VM == null ? null : XenRef <VM> .Create(proxy.VM); MAC = proxy.MAC == null ? null : (string)proxy.MAC; MTU = proxy.MTU == null ? 0 : long.Parse((string)proxy.MTU); other_config = proxy.other_config == null ? null : Maps.convert_from_proxy_string_string(proxy.other_config); currently_attached = (bool)proxy.currently_attached; status_code = proxy.status_code == null ? 0 : long.Parse((string)proxy.status_code); status_detail = proxy.status_detail == null ? null : (string)proxy.status_detail; runtime_properties = proxy.runtime_properties == null ? null : Maps.convert_from_proxy_string_string(proxy.runtime_properties); qos_algorithm_type = proxy.qos_algorithm_type == null ? null : (string)proxy.qos_algorithm_type; qos_algorithm_params = proxy.qos_algorithm_params == null ? null : Maps.convert_from_proxy_string_string(proxy.qos_algorithm_params); qos_supported_algorithms = proxy.qos_supported_algorithms == null ? new string[] {} : (string [])proxy.qos_supported_algorithms; metrics = proxy.metrics == null ? null : XenRef <VIF_metrics> .Create(proxy.metrics); MAC_autogenerated = (bool)proxy.MAC_autogenerated; locking_mode = proxy.locking_mode == null ? (vif_locking_mode)0 : (vif_locking_mode)Helper.EnumParseDefault(typeof(vif_locking_mode), (string)proxy.locking_mode); ipv4_allowed = proxy.ipv4_allowed == null ? new string[] {} : (string [])proxy.ipv4_allowed; ipv6_allowed = proxy.ipv6_allowed == null ? new string[] {} : (string [])proxy.ipv6_allowed; }
public UpdateVIFCommand(IMainWindow mainWindow, VM vm, VIF vif, Proxy_VIF proxyVIF) : base(mainWindow, vm) { _vm = vm; _vif = vif; _proxyVIF = proxyVIF; }
/// <summary> /// Update the VIF /// </summary> /// <param name="vm"></param> /// <param name="vif"></param> /// <param name="proxyVIF"></param> public UpdateVIFAction(VM vm, VIF vif, Proxy_VIF proxyVIF) : base(vm.Connection, String.Format(Messages.ACTION_VIF_UPDATING_TITLE, vif.NetworkName(), vm.Name)) { this.vif = vif; VM = vm; this.proxyVIF = proxyVIF; Initialise(); xmlRpcMethods.ForEach(method => ApiMethodsToRoleCheck.Add(method)); }
public Response <string> create(string session, Proxy_VIF vif) { Db.Table t = proxy.db.Tables["vif"]; string opaque_ref = proxy.CreateOpaqueRef(); Db.Row r = t.Rows.Add(opaque_ref); r.PopulateFrom(DbProxy.ProxyToHashtable(typeof(Proxy_VIF), vif)); proxy.SendCreateObject("vif", opaque_ref); return(new Response <string>(opaque_ref)); }
private void AddNetworkButton_Click(object sender, EventArgs e) { if (XenObject is VM) { VM vm = (VM)_xenObject; if (NetworksGridView.Rows.Count >= vm.MaxVIFsAllowed) { using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, FriendlyErrorNames.VIFS_MAX_ALLOWED, FriendlyErrorNames.VIFS_MAX_ALLOWED_TITLE))) { dlg.ShowDialog(Program.MainWindow); } return; } Host master = Helpers.GetMaster(vm.Connection); if (master == null) { // Cache populating? return; } VIFDialog d = new VIFDialog(vm.Connection, null, VIF.GetDeviceId(vm)); if (d.ShowDialog(this) != DialogResult.OK) { return; } Proxy_VIF pVif = d.GetNewSettings(); pVif.VM = vm.opaque_ref; CreateVIFCommand action = new CreateVIFCommand(Program.MainWindow, vm, pVif); action.Execute(); } else if (XenObject is Host) { Host host = (Host)_xenObject; Program.MainWindow.ShowPerConnectionWizard(_xenObject.Connection, new NewNetworkWizard(_xenObject.Connection, null, host)); } else if (XenObject is Pool) { Pool pool = (Pool)_xenObject; Host host = pool.Connection.Resolve(pool.master); if (host != null) { Program.MainWindow.ShowPerConnectionWizard(_xenObject.Connection, new NewNetworkWizard(_xenObject.Connection, pool, host)); } } }
private void launchVmNetworkSettingsDialog() { VM vm = XenObject as VM; VIF vif = SelectedVif; if (vm == null || vif == null) { return; } int device; VIFDialog d; if (int.TryParse(vif.device, out device)) { d = new VIFDialog(vm.Connection, vif, device); } else { log.ErrorFormat("Aborting vif edit. Could not parse existing vif device to int. Value is: '{0}'", vif.device); return; } if (d.ShowDialog() != DialogResult.OK) { return; } Proxy_VIF proxyVIF = d.GetNewSettings(); UpdateVIFCommand command = new UpdateVIFCommand(Program.MainWindow, vm, vif, proxyVIF); InBuildList = true; command.Completed += new EventHandler((s, f) => Program.Invoke(this, () => { InBuildList = false; BuildList(); })); command.Execute(); }
public override string SaveChanges(Session session, string opaqueRef, VIF server) { if (opaqueRef == null) { Proxy_VIF p = this.ToProxy(); return(session.proxy.vif_create(session.uuid, p).parse()); } else { if (!Helper.AreEqual2(_other_config, server._other_config)) { VIF.set_other_config(session, opaqueRef, _other_config); } if (!Helper.AreEqual2(_qos_algorithm_type, server._qos_algorithm_type)) { VIF.set_qos_algorithm_type(session, opaqueRef, _qos_algorithm_type); } if (!Helper.AreEqual2(_qos_algorithm_params, server._qos_algorithm_params)) { VIF.set_qos_algorithm_params(session, opaqueRef, _qos_algorithm_params); } if (!Helper.AreEqual2(_locking_mode, server._locking_mode)) { VIF.set_locking_mode(session, opaqueRef, _locking_mode); } if (!Helper.AreEqual2(_ipv4_allowed, server._ipv4_allowed)) { VIF.set_ipv4_allowed(session, opaqueRef, _ipv4_allowed); } if (!Helper.AreEqual2(_ipv6_allowed, server._ipv6_allowed)) { VIF.set_ipv6_allowed(session, opaqueRef, _ipv6_allowed); } return(null); } }
public CreateVIFCommand(IMainWindow mainWindow, VM vm, Proxy_VIF proxyVIF) : base(mainWindow, vm) { _vm = vm; _proxyVIF = proxyVIF; }
/// <summary> /// Creates a new VIF from a Proxy_VIF. /// </summary> /// <param name="proxy"></param> public VIF(Proxy_VIF proxy) { this.UpdateFromProxy(proxy); }