/// <summary> /// /// </summary> /// <param name="bond"></param> public DestroyBondAction(Bond bond) : base(bond.Connection, string.Format(Messages.ACTION_DESTROY_BOND_TITLE, bond.Name), string.Format(Messages.ACTION_DESTROY_BOND_DESCRIPTION, bond.Name)) { #region RBAC Dependencies ApiMethodsToRoleCheck.Add("host.management_reconfigure"); ApiMethodsToRoleCheck.Add("network.destroy"); ApiMethodsToRoleCheck.Add("vif.plug"); ApiMethodsToRoleCheck.Add("vif.unplug"); ApiMethodsToRoleCheck.Add("pif.reconfigure_ip"); ApiMethodsToRoleCheck.Add("pif.plug"); ApiMethodsToRoleCheck.Add("bond.destroy"); ApiMethodsToRoleCheck.AddRange(XenAPI.Role.CommonSessionApiList); ApiMethodsToRoleCheck.AddRange(XenAPI.Role.CommonTaskApiList); #endregion Name = bond.Name; Pool = Helpers.GetPoolOfOne(Connection); foreach (Host host in Connection.Cache.Hosts) { Bond b = NetworkingHelper.FindBond(host, bond); if (b != null) { Bonds.Add(b); b.Locked = true; PIF master = Connection.Resolve(b.master); if (master != null) { Masters.Add(master); master.Locked = true; List <PIF> slaves = Connection.ResolveAll(b.slaves); NetworkingHelper.Sort(slaves); foreach (PIF pif in slaves) { Slaves.Add(pif); pif.Locked = true; } FirstSlaves[master] = Connection.Resolve(b.primary_slave); if (!FirstSlaves.ContainsKey(master) && slaves.Count != 0) { FirstSlaves[master] = slaves[0]; } } AppliesTo.Add(host.opaque_ref); } } PIF master_master = Connection.Resolve(bond.master); if (master_master != null) { Network = Connection.Resolve(master_master.network); Network.Locked = true; } }