// Backward compatibility for Bond.create in XenServer 6.0. public static XenRef<Bond> create(Session session, string _network, List<XenRef<PIF>> _members, string _mac, bond_mode _mode) { if (Helper.APIVersionMeets(session, API_Version.API_1_10)) System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer."); return XenRef<Bond>.Create(session.proxy.bond_create(session.uuid, (_network != null) ? _network : "", (_members != null) ? Helper.RefListToStringArray(_members) : new string[] { }, (_mac != null) ? _mac : "", bond_mode_helper.ToString(_mode)).parse()); }
public static string ToString(bond_mode x) { switch (x) { case bond_mode.balance_slb: return "balance-slb"; case bond_mode.active_backup: return "active-backup"; case bond_mode.lacp: return "lacp"; default: return "unknown"; } }
/// <param name="name_label">The name for the new network.</param> /// <param name="PIFs_on_master">The PIFs on the master representing the physical NICs that are to be bonded together.</param> /// <param name="autoplug">Whether the new network is marked AutoPlug.</param> /// <param name="mtu">The MTU for the Bond, ignored for pre cowley</param> /// <param name="bondMode">The bond mode, ignored for pre-Boston</param> public CreateBondAction(IXenConnection connection, string name_label, List<PIF> PIFs_on_master, bool autoplug, long mtu, bond_mode bondMode, Bond.hashing_algoritm hashingAlgoritm) : base(connection, string.Format(Messages.ACTION_CREATE_BOND_TITLE, name_label), string.Format(Messages.ACTION_CREATE_BOND_DESCRIPTION, name_label)) { this.name_label = name_label; this.autoplug = autoplug; this.mtu = mtu; this.bondMode = bondMode; this.hashingAlgoritm = hashingAlgoritm; Pool = Helpers.GetPoolOfOne(Connection); if (Pool == null) throw new Failure(Failure.INTERNAL_ERROR, "Pool has gone away"); Master = Connection.Resolve(Pool.master); if (Master == null) throw new Failure(Failure.INTERNAL_ERROR, "Pool master has gone away"); bostonOrGreater = Helpers.BostonOrGreater(connection); tampaOrGreater = Helpers.TampaOrGreater(connection); foreach (Host host in Connection.Cache.Hosts) AppliesTo.Add(host.opaque_ref); #region RBAC Dependencies ApiMethodsToRoleCheck.Add("host.management_reconfigure"); ApiMethodsToRoleCheck.Add("network.create"); ApiMethodsToRoleCheck.Add("network.destroy"); ApiMethodsToRoleCheck.Add("network.remove_from_other_config"); ApiMethodsToRoleCheck.Add("pif.reconfigure_ip"); ApiMethodsToRoleCheck.Add("pif.plug"); ApiMethodsToRoleCheck.Add("bond.create"); ApiMethodsToRoleCheck.Add("bond.destroy"); ApiMethodsToRoleCheck.AddRange(XenAPI.Role.CommonSessionApiList); ApiMethodsToRoleCheck.AddRange(XenAPI.Role.CommonTaskApiList); #endregion PIFs = NetworkingHelper.PIFsOnAllHosts(PIFs_on_master); // these locks will be cleared in clean() foreach (List<PIF> pifs in PIFs.Values) { foreach (PIF pif in pifs) { pif.Locked = true; } } }
/// <summary> /// Create an interface bond /// First published in XenServer 4.1. /// </summary> /// <param name="session">The session</param> /// <param name="_network">Network to add the bonded PIF to</param> /// <param name="_members">PIFs to add to this bond</param> /// <param name="_mac">The MAC address to use on the bond itself. If this parameter is the empty string then the bond will inherit its MAC address from the primary slave.</param> /// <param name="_mode">Bonding mode to use for the new bond First published in XenServer 6.0.</param> public static XenRef <Task> async_create(Session session, string _network, List <XenRef <PIF> > _members, string _mac, bond_mode _mode) { if (session.JsonRpcClient != null) { return(session.JsonRpcClient.async_bond_create(session.opaque_ref, _network, _members, _mac, _mode)); } else { return(XenRef <Task> .Create(session.proxy.async_bond_create(session.opaque_ref, _network ?? "", _members == null ? new string[] {} : Helper.RefListToStringArray(_members), _mac ?? "", bond_mode_helper.ToString(_mode)).parse())); } }