private void PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if ((e.PropertyName != "state") && (e.PropertyName != "last_updated"))
     {
         Program.Invoke(this, delegate
         {
             if (e.PropertyName == "PBDs")
             {
                 XenAPI.SR xenObject = this.xenModelObject as XenAPI.SR;
                 if (xenObject != null)
                 {
                     foreach (PBD pbd in this.xenModelObject.Connection.ResolveAll <PBD>(xenObject.PBDs))
                     {
                         pbd.PropertyChanged -= new PropertyChangedEventHandler(this.PropertyChanged);
                         pbd.PropertyChanged += new PropertyChangedEventHandler(this.PropertyChanged);
                     }
                     this.BuildList();
                 }
             }
             else
             {
                 this.BuildList();
                 //this.EnableDisableEdit();
             }
         });
     }
 }
 public MigrateVirtualDiskAction(IXenConnection connection, VDI vdi, SR sr)
     : base(connection, string.Format(Messages.ACTION_MOVING_VDI_TITLE, Helpers.GetName(vdi), Helpers.GetName(sr)))
 {
     Description = Messages.ACTION_PREPARING;
     this.vdi = vdi;
     SR = sr;
 }
Example #3
0
 private static bool CanExecute(SR sr)
 {
     return sr != null
         && !sr.HasRunningVMs()
         && sr.CanCreateWithXenCenter
         && sr.allowed_operations.Contains(storage_operations.forget)
         && !HelpersGUI.GetActionInProgress(sr);
 }
        private bool isMirrorRed(string scsiid)
        {
            XenAPI.SR  sr   = this.xenModelObject as XenAPI.SR;
            List <PBD> pbds = sr.Connection.ResolveAll <PBD>(sr.PBDs);

            if (pbds.Any <PBD>(pdb => pdb.other_config.ContainsKey("LUN1-status") && pdb.other_config["LUN1-status"].Contains("unknown") && pdb.other_config.ContainsKey("LUN1-scsiid") && pdb.other_config["LUN1-scsiid"] == scsiid ||
                               pdb.other_config.ContainsKey("LUN2-status") && pdb.other_config["LUN2-status"].Contains("unknown") && pdb.other_config.ContainsKey("LUN2-scsiid") && pdb.other_config["LUN2-scsiid"] == scsiid))
            {
                return(true);
            }
            return(false);
        }
        private bool canMirrorissciRemove()
        {
            XenAPI.SR  sr   = this.xenModelObject as XenAPI.SR;
            List <PBD> pbds = sr.Connection.ResolveAll <PBD>(sr.PBDs);

            if (pbds.Any(pbd => pbd.other_config.ContainsKey("LUN1-scsiid") && pbd.other_config["LUN1-scsiid"] == "" ||
                         pbd.other_config.ContainsKey("LUN2-scsiid") && pbd.other_config["LUN2-scsiid"] == ""))
            {
                return(false);
            }

            return(true);
        }
        private string SRSizeString(XenAPI.SR sr)
        {
            int    percent = 0;
            double ratio   = 0;

            if (sr.physical_size > 0)
            {
                ratio   = sr.physical_utilisation / (double)sr.physical_size;
                percent = (int)(100.0 * ratio);
            }
            string percentString = string.Format(Messages.DISK_PERCENT_USED, percent.ToString(), Util.DiskSizeString(sr.physical_utilisation));

            return(string.Format(Messages.SR_SIZE_USED, percentString, Util.DiskSizeString(sr.physical_size), Util.DiskSizeString(sr.virtual_allocation)));
        }
        private bool issciFaulty(string scsiid)
        {
            XenAPI.SR sr = this.xenModelObject as XenAPI.SR;

            foreach (PBD pdb in sr.Connection.ResolveAll <PBD>(sr.PBDs))
            {
                if (pdb.other_config.ContainsKey("LUN2-status") && pdb.other_config["LUN2-status"].Contains("faulty") && pdb.other_config.ContainsKey("LUN2-scsiid") && pdb.other_config["LUN2-scsiid"] == scsiid ||
                    pdb.other_config.ContainsKey("LUN1-status") && pdb.other_config["LUN1-status"].Contains("faulty") && pdb.other_config.ContainsKey("LUN1-scsiid") && pdb.other_config["LUN1-scsiid"] == scsiid)
                {
                    return(true);
                }
            }
            return(false);
        }
        private void ComposeVDIData()
        {
            m_VDIs = new List <VDIInfo>();

            var VDIs = new List <XenAPI.VDI>(Connection.Cache.VDIs);

            VDIs.Sort();

            foreach (XenAPI.VDI vdi in VDIs)
            {
                XenAPI.SR sr  = Connection.Resolve(vdi.SR);
                VDIInfo   buf = new VDIInfo(vdi.Name(), vdi.uuid, Convert.ToString(vdi.type), vdi.SizeText(), vdi.Description(), sr.Name());

                m_VDIs.Add(buf);
            }
        }
        private void ProcessRecordSuspendImageSR(string pool)
        {
            RunApiCall(() =>
            {
                string objRef = XenAPI.Pool.get_suspend_image_SR(session, pool);

                XenAPI.SR obj = null;

                if (objRef != "OpaqueRef:NULL")
                {
                    obj            = XenAPI.SR.get_record(session, objRef);
                    obj.opaque_ref = objRef;
                }

                WriteObject(obj, true);
            });
        }
        private void ProcessRecordLocalCacheSr(string host)
        {
            RunApiCall(() =>
            {
                string objRef = XenAPI.Host.get_local_cache_sr(session, host);

                XenAPI.SR obj = null;

                if (objRef != "OpaqueRef:NULL")
                {
                    obj            = XenAPI.SR.get_record(session, objRef);
                    obj.opaque_ref = objRef;
                }

                WriteObject(obj, true);
            });
        }
        private void ProcessRecordIntroduce(string sr)
        {
            if (!ShouldProcess(sr, "SR.introduce"))
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenSRActionIntroduceDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.SR.async_introduce(session, contxt.UuidParam, contxt.NameLabel, contxt.NameDescription, contxt.Type, contxt.ContentType, contxt.Shared, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(contxt.SmConfig));

                    if (PassThru)
                    {
                        XenAPI.Task taskObj = null;
                        if (taskRef != "OpaqueRef:NULL")
                        {
                            taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                            taskObj.opaque_ref = taskRef.opaque_ref;
                        }

                        WriteObject(taskObj, true);
                    }
                }
                else
                {
                    string objRef = XenAPI.SR.introduce(session, contxt.UuidParam, contxt.NameLabel, contxt.NameDescription, contxt.Type, contxt.ContentType, contxt.Shared, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(contxt.SmConfig));

                    if (PassThru)
                    {
                        XenAPI.SR obj = null;

                        if (objRef != "OpaqueRef:NULL")
                        {
                            obj            = XenAPI.SR.get_record(session, objRef);
                            obj.opaque_ref = objRef;
                        }

                        WriteObject(obj, true);
                    }
                }
            });
        }
        private void ProcessRecordSR(string pbd)
        {
            RunApiCall(() =>
            {
                string objRef = XenAPI.PBD.get_SR(session, pbd);

                XenAPI.SR obj = null;

                if (objRef != "OpaqueRef:NULL")
                {
                    obj            = XenAPI.SR.get_record(session, objRef);
                    obj.opaque_ref = objRef;
                }

                WriteObject(obj, true);
            });
        }
        private void ProcessRecordCrashDumpSR(string pool)
        {
            RunApiCall(() =>
            {
                string objRef = XenAPI.Pool.get_crash_dump_SR(session, pool);

                XenAPI.SR obj = null;

                if (objRef != "OpaqueRef:NULL")
                {
                    obj            = XenAPI.SR.get_record(session, objRef);
                    obj.opaque_ref = objRef;
                }

                WriteObject(obj, true);
            });
        }
        private bool canissciRemove()
        {
            XenAPI.SR  sr   = this.xenModelObject as XenAPI.SR;
            List <PBD> pbds = sr.Connection.ResolveAll <PBD>(sr.PBDs);

            if (pbds.Any <PBD>(pbd => pbd.other_config.ContainsKey("LUN1-status") && pbd.other_config["LUN1-status"].Contains("spare rebuilding") ||
                               pbd.other_config.ContainsKey("LUN2-status") && pbd.other_config["LUN2-status"].Contains("spare rebuilding")))
            {
                return(false);
            }
            if (pbds.Any(pbd => pbd.other_config.ContainsKey("LUN1-status") && pbd.other_config["LUN1-status"].Contains("removed") ||
                         pbd.other_config.ContainsKey("LUN2-status") && pbd.other_config["LUN2-status"].Contains("removed")))
            {
                return(false);
            }

            return(true);
        }
        private bool CanAddLUN(string scsiid)
        {
            XenAPI.SR  sr   = this.xenModelObject as XenAPI.SR;
            List <PBD> pbds = sr.Connection.ResolveAll <PBD>(sr.PBDs);

            if (pbds.Any <PBD>(pbd => pbd.other_config.ContainsKey("LUN1-status") && pbd.other_config["LUN1-status"].Contains("spare rebuilding") ||
                               pbd.other_config.ContainsKey("LUN2-status") && pbd.other_config["LUN2-status"].Contains("spare rebuilding")))
            {
                return(false);
            }
            if (pbds.Any <PBD>(pdb => pdb.other_config.ContainsKey("LUN1-status") && pdb.other_config["LUN1-status"].Contains("removed") && pdb.other_config.ContainsKey("LUN1-scsiid") && pdb.other_config["LUN1-scsiid"] == scsiid ||
                               pdb.other_config.ContainsKey("LUN2-status") && pdb.other_config["LUN2-status"].Contains("removed") && pdb.other_config.ContainsKey("LUN2-scsiid") && pdb.other_config["LUN2-scsiid"] == scsiid ||
                               !pdb.other_config.ContainsKey("LUN1-status") || !pdb.other_config.ContainsKey("LUN2-status")))
            {
                return(true);
            }

            return(false);
        }
        private bool CanAddMirrorLUN(string scsiid)
        {
            XenAPI.SR sr = this.xenModelObject as XenAPI.SR;
//            List<PBD> pbds = sr.Connection.ResolveAll<PBD>(sr.PBDs);
            if (scsiid == "")
            {
                return(true);
            }
//            if (pbds.Any<PBD>(pdb => pdb.other_config.ContainsKey("LUN1-status") && pdb.other_config["LUN1-status"].Contains("removed") && pdb.other_config.ContainsKey("LUN1-scsiid") && pdb.other_config["LUN1-scsiid"] == scsiid ||
//                    pdb.other_config.ContainsKey("LUN2-status") && pdb.other_config["LUN2-status"].Contains("removed") && pdb.other_config.ContainsKey("LUN2-scsiid") && pdb.other_config["LUN2-scsiid"] == scsiid ||
//                    !pdb.other_config.ContainsKey("LUN1-status") || !pdb.other_config.ContainsKey("LUN2-status")))
//            {
//                return true;
//            }
//            if (pbds.Any(pbd => pbd.other_config.ContainsKey("LUN1-scsiid") && pbd.other_config["LUN1-scsiid"] == "" ||
//                    pbd.other_config.ContainsKey("LUN2-scsiid") && pbd.other_config["LUN2-scsiid"] == ""))
//            {
//                return true;
//            }
            return(false);
        }
Example #17
0
 private static bool CanExecute(SR sr)
 {
     return sr.NeedsUpgrading && !HelpersGUI.GetActionInProgress(sr);
 }
 public SrPickerLunPerVDIItemNoImageCanBeEnabled(SR sr) : base(sr, null, 0, null) { }
Example #19
0
 public FibreChannelProbeAction(Host master, SR.SRTypes srType)
     : this(master)
 {
     this.srType = srType;
 }
Example #20
0
 public SRProblem(Check check, SR sr)
     : base(check)
 {
     _sr = sr;
 }
 public SrPickerLunPerVDIItemNoImage(SR sr) : base(sr, null, 0, null) { }
Example #22
0
        private void OkButton_Click(object sender, EventArgs e)
        {
            if (SrListBox.SR == null || SelectionNull || NameTextBox.Text == "" || !connection.IsConnected)
            {
                return;
            }

            if (DontCreateVDI)
            {
                DialogResult = DialogResult.OK;
                Close();
                return;
            }
            XenAPI.SR sr = SrListBox.SR;
            if (!sr.shared && TheVM != null && TheVM.HaPriorityIsRestart())
            {
                DialogResult dialogResult;
                using (var dlg = new ThreeButtonDialog(
                           new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.NEW_SR_DIALOG_ATTACH_NON_SHARED_DISK_HA, Messages.XENCENTER),
                           ThreeButtonDialog.ButtonYes,
                           ThreeButtonDialog.ButtonNo))
                {
                    dialogResult = dlg.ShowDialog(Program.MainWindow);
                }
                if (dialogResult != DialogResult.Yes)
                {
                    return;
                }
                new HAUnprotectVMAction(TheVM).RunExternal(TheVM.Connection.Session);
            }

            VDI vdi = NewDisk();

            if (TheVM != null)
            {
                if (sr.other_config.ContainsKey("scheduler"))
                {
                    if (sr.other_config.ContainsKey("scheduler") && sr.other_config["scheduler"] == "cfq")
                    {
                        //获取原class值(优先级)
                        List <XenRef <VBD> > origin_VBDs = TheVM.VBDs;
                        foreach (VBD v in connection.ResolveAll <VBD>(origin_VBDs))
                        {
                            if (v.type == vbd_type.CD)
                            {
                                continue;
                            }
                            if (XenAPI.VBD.get_qos_algorithm_params(TheVM.Connection.Session, v.opaque_ref).ContainsKey("class"))
                            {
                                if (XenAPI.VBD.get_qos_algorithm_params(sr.Connection.Session, v.opaque_ref)["class"] != "" && XenAPI.VBD.get_qos_algorithm_params(sr.Connection.Session, v.opaque_ref)["class"] != null)
                                {
                                    _class = XenAPI.VBD.get_qos_algorithm_params(sr.Connection.Session, v.opaque_ref)["class"];
                                }
                            }
                        }
                    }
                }
            }
            if (TheVM != null)
            {
                var alreadyHasBootableDisk = HasBootableDisk(TheVM);

                Actions.DelegatedAsyncAction action = new Actions.DelegatedAsyncAction(connection,
                                                                                       string.Format(Messages.ACTION_DISK_ADDING_TITLE, NameTextBox.Text, sr.NameWithoutHost),
                                                                                       Messages.ACTION_DISK_ADDING, Messages.ACTION_DISK_ADDED,
                                                                                       delegate(XenAPI.Session session)
                {
                    // Get legitimate unused userdevice numbers
                    string[] uds = XenAPI.VM.get_allowed_VBD_devices(session, TheVM.opaque_ref);
                    if (uds.Length == 0)
                    {
                        throw new Exception(FriendlyErrorNames.VBDS_MAX_ALLOWED);
                    }
                    string ud      = uds[0];
                    string vdiref  = VDI.create(session, vdi);
                    XenAPI.VBD vbd = NewDevice();
                    vbd.VDI        = new XenAPI.XenRef <XenAPI.VDI>(vdiref);
                    vbd.VM         = new XenAPI.XenRef <XenAPI.VM>(TheVM);

                    // CA-44959: only make bootable if there aren't other bootable VBDs.
                    vbd.bootable   = ud == "0" && !alreadyHasBootableDisk;
                    vbd.userdevice = ud;
                    // Now try to plug the VBD.
                    //new XenAdmin.Actions.VbdSaveAndPlugAction(TheVM, vbd, vdi.Name, session, false, ShowMustRebootBoxCD, ShowVBDWarningBox).RunAsync();
                    new XenAdmin.Actions.VbdSaveAndPlugAction(TheVM, vbd, vdi.Name, session, false, ShowMustRebootBoxCD, ShowVBDWarningBox).RunExternal(connection.Session);
                });
                action.VM = TheVM;
                using (var dialog = new Dialogs.ActionProgressDialog(action, ProgressBarStyle.Blocks))
                {
                    dialog.ShowDialog(this);
                }
                if (!action.Succeeded)
                {
                    return;
                }
            }
            else
            {
                CreateDiskAction action = new CreateDiskAction(vdi);
                new Dialogs.ActionProgressDialog(action, ProgressBarStyle.Marquee).ShowDialog();
                if (!action.Succeeded)
                {
                    return;
                }
            }
            DialogResult = DialogResult.OK;
            Close();
            //若VM为空则不设置优先级
            //若虚拟机启用了IO功能才进行下列操作
            if (TheVM != null)
            {
                if (TheVM.other_config.ContainsKey("io_limit") || sr.other_config.ContainsKey("scheduler"))
                {
                    foreach (VBD v in connection.ResolveAll <VBD>(TheVM.VBDs))
                    {
                        if (v.type == vbd_type.CD)
                        {
                            continue;
                        }
                        if (XenAPI.VBD.get_qos_algorithm_params(connection.Session, v.opaque_ref).ContainsKey("class"))
                        {
                            XenAPI.VBD.remove_from_qos_algorithm_params(connection.Session, v.opaque_ref, "class");
                        }
                        if (XenAPI.VBD.get_qos_algorithm_params(connection.Session, v.opaque_ref).ContainsKey("sched"))
                        {
                            XenAPI.VBD.remove_from_qos_algorithm_params(connection.Session, v.opaque_ref, "sched");
                        }
                        if (XenAPI.VBD.get_qos_algorithm_type(connection.Session, v.opaque_ref) != null)
                        {
                            XenAPI.VBD.set_qos_algorithm_type(connection.Session, v.opaque_ref, "");
                        }
                        XenAPI.VBD.set_qos_algorithm_type(connection.Session, v.opaque_ref, "ionice");
                        XenAPI.VBD.add_to_qos_algorithm_params(connection.Session, v.opaque_ref, "sched", "rt");
                        XenAPI.VBD.add_to_qos_algorithm_params(connection.Session, v.opaque_ref, "class", _class);
                    }
                    if (TheVM.power_state == vm_power_state.Running)
                    {
                        io_limit();
                    }
                }
            }
        }
Example #23
0
        private void OkButton_Click(object sender, EventArgs e)
        {
            if (SrListBox.SR == null || SelectionNull || NameTextBox.Text == "" || !connection.IsConnected)
            {
                return;
            }

            if (DontCreateVDI)
            {
                DialogResult = DialogResult.OK;
                Close();
                return;
            }
            XenAPI.SR sr = SrListBox.SR;
            if (!sr.shared && TheVM != null && TheVM.HaPriorityIsRestart())
            {
                if (new ThreeButtonDialog(
                        new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.NEW_SR_DIALOG_ATTACH_NON_SHARED_DISK_HA, Messages.XENCENTER),
                        ThreeButtonDialog.ButtonYes,
                        ThreeButtonDialog.ButtonNo).ShowDialog(Program.MainWindow) != DialogResult.Yes)
                {
                    return;
                }
                new HAUnprotectVMAction(TheVM).RunExternal(TheVM.Connection.Session);
            }

            VDI vdi = NewDisk();


            if (TheVM != null)
            {
                var alreadyHasBootableDisk = HasBootableDisk(TheVM);

                Actions.DelegatedAsyncAction action = new Actions.DelegatedAsyncAction(connection,
                                                                                       string.Format(Messages.ACTION_DISK_ADDING_TITLE, NameTextBox.Text, sr.NameWithoutHost),
                                                                                       Messages.ACTION_DISK_ADDING, Messages.ACTION_DISK_ADDED,
                                                                                       delegate(XenAPI.Session session)
                {
                    // Get legitimate unused userdevice numbers
                    string[] uds = XenAPI.VM.get_allowed_VBD_devices(session, TheVM.opaque_ref);
                    if (uds.Length == 0)
                    {
                        throw new Exception(FriendlyErrorNames.VBDS_MAX_ALLOWED);
                    }
                    string ud      = uds[0];
                    string vdiref  = VDI.create(session, vdi);
                    XenAPI.VBD vbd = NewDevice();
                    vbd.VDI        = new XenAPI.XenRef <XenAPI.VDI>(vdiref);
                    vbd.VM         = new XenAPI.XenRef <XenAPI.VM>(TheVM);

                    // CA-44959: only make bootable if there aren't other bootable VBDs.
                    vbd.bootable   = ud == "0" && !alreadyHasBootableDisk;
                    vbd.userdevice = ud;

                    // Now try to plug the VBD.
                    new XenAdmin.Actions.VbdSaveAndPlugAction(TheVM, vbd, vdi.Name, session, false, ShowMustRebootBoxCD, ShowVBDWarningBox).RunAsync();
                });
                action.VM = TheVM;
                new Dialogs.ActionProgressDialog(action, ProgressBarStyle.Blocks).ShowDialog();
                if (!action.Succeeded)
                {
                    return;
                }
            }
            else
            {
                CreateDiskAction action = new CreateDiskAction(vdi);
                new Dialogs.ActionProgressDialog(action, ProgressBarStyle.Marquee).ShowDialog();
                if (!action.Succeeded)
                {
                    return;
                }
            }
            DialogResult = DialogResult.OK;
            Close();
        }
Example #24
0
 private static bool CanExecute(SR sr)
 {
     return sr != null && sr.IsDetachable() && !HelpersGUI.GetActionInProgress(sr);
 }
 public SRDeviceConfig(SR sr, Dictionary<string, string> deviceConfig)
     : this()
 {
     SR = sr;
     DeviceConfig = deviceConfig;
 }
Example #26
0
 public ForgetSRCommand(IMainWindow mainWindow, SR sr)
     : base(mainWindow, sr)
 {
 }
Example #27
0
 public ScannedDeviceInfo(SR.SRTypes type, Dictionary<string, string> deviceConfig, string srUuid)
     : this(type, deviceConfig, new List<SR.SRInfo> { new SR.SRInfo(srUuid) })
 {
 }
Example #28
0
 private static bool CanExecute(SR sr)
 {
     return sr != null && sr.SupportsTrim;
 }
Example #29
0
 public UpgradeSRCommand(IMainWindow mainWindow, SR selection)
     : base(mainWindow, selection)
 {
 }
Example #30
0
        protected override void ProcessRecord()
        {
            GetSession();
            if (Record != null)
            {
                NameLabel       = Record.name_label;
                NameDescription = Record.name_description;
                PhysicalSize    = Record.physical_size;
                Type            = Record.type;
                ContentType     = Record.content_type;
                Shared          = Record.shared;
                SmConfig        = CommonCmdletFunctions.ConvertDictionaryToHashtable(Record.sm_config);
            }
            else if (HashTable != null)
            {
                NameLabel       = Marshalling.ParseString(HashTable, "name_label");
                NameDescription = Marshalling.ParseString(HashTable, "name_description");
                PhysicalSize    = Marshalling.ParseLong(HashTable, "physical_size");
                Type            = Marshalling.ParseString(HashTable, "type");
                ContentType     = Marshalling.ParseString(HashTable, "content_type");
                Shared          = Marshalling.ParseBool(HashTable, "shared");
                SmConfig        = (Marshalling.ParseHashTable(HashTable, "sm_config"));
            }
            if (!ShouldProcess(session.Url, "SR.create"))
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenServerCmdletDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.SR.async_create(session, XenHost, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(DeviceConfig), PhysicalSize, NameLabel, NameDescription, Type, ContentType, Shared, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(SmConfig));

                    if (PassThru)
                    {
                        XenAPI.Task taskObj = null;
                        if (taskRef != "OpaqueRef:NULL")
                        {
                            taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                            taskObj.opaque_ref = taskRef.opaque_ref;
                        }

                        WriteObject(taskObj, true);
                    }
                }
                else
                {
                    string objRef = XenAPI.SR.create(session, XenHost, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(DeviceConfig), PhysicalSize, NameLabel, NameDescription, Type, ContentType, Shared, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(SmConfig));

                    if (PassThru)
                    {
                        XenAPI.SR obj = null;

                        if (objRef != "OpaqueRef:NULL")
                        {
                            obj            = XenAPI.SR.get_record(session, objRef);
                            obj.opaque_ref = objRef;
                        }

                        WriteObject(obj, true);
                    }
                }
            });

            UpdateSessions();
        }
Example #31
0
 public DestroySRCommand(IMainWindow mainWindow, SR selection)
     : base(mainWindow, selection)
 {
 }
Example #32
0
 protected override void ProcessRecord()
 {
     XenAPI.Session session = XenObject as XenAPI.Session;
     if (session != null)
     {
         WriteObject(new XenRef <XenAPI.Session>(session));
         return;
     }
     XenAPI.Auth auth = XenObject as XenAPI.Auth;
     if (auth != null)
     {
         WriteObject(new XenRef <XenAPI.Auth>(auth));
         return;
     }
     XenAPI.Subject subject = XenObject as XenAPI.Subject;
     if (subject != null)
     {
         WriteObject(new XenRef <XenAPI.Subject>(subject));
         return;
     }
     XenAPI.Role role = XenObject as XenAPI.Role;
     if (role != null)
     {
         WriteObject(new XenRef <XenAPI.Role>(role));
         return;
     }
     XenAPI.Task task = XenObject as XenAPI.Task;
     if (task != null)
     {
         WriteObject(new XenRef <XenAPI.Task>(task));
         return;
     }
     XenAPI.Event evt = XenObject as XenAPI.Event;
     if (evt != null)
     {
         WriteObject(new XenRef <XenAPI.Event>(evt));
         return;
     }
     XenAPI.Pool pool = XenObject as XenAPI.Pool;
     if (pool != null)
     {
         WriteObject(new XenRef <XenAPI.Pool>(pool));
         return;
     }
     XenAPI.Pool_patch pool_patch = XenObject as XenAPI.Pool_patch;
     if (pool_patch != null)
     {
         WriteObject(new XenRef <XenAPI.Pool_patch>(pool_patch));
         return;
     }
     XenAPI.Pool_update pool_update = XenObject as XenAPI.Pool_update;
     if (pool_update != null)
     {
         WriteObject(new XenRef <XenAPI.Pool_update>(pool_update));
         return;
     }
     XenAPI.VM vm = XenObject as XenAPI.VM;
     if (vm != null)
     {
         WriteObject(new XenRef <XenAPI.VM>(vm));
         return;
     }
     XenAPI.VM_metrics vm_metrics = XenObject as XenAPI.VM_metrics;
     if (vm_metrics != null)
     {
         WriteObject(new XenRef <XenAPI.VM_metrics>(vm_metrics));
         return;
     }
     XenAPI.VM_guest_metrics vm_guest_metrics = XenObject as XenAPI.VM_guest_metrics;
     if (vm_guest_metrics != null)
     {
         WriteObject(new XenRef <XenAPI.VM_guest_metrics>(vm_guest_metrics));
         return;
     }
     XenAPI.VMPP vmpp = XenObject as XenAPI.VMPP;
     if (vmpp != null)
     {
         WriteObject(new XenRef <XenAPI.VMPP>(vmpp));
         return;
     }
     XenAPI.VMSS vmss = XenObject as XenAPI.VMSS;
     if (vmss != null)
     {
         WriteObject(new XenRef <XenAPI.VMSS>(vmss));
         return;
     }
     XenAPI.VM_appliance vm_appliance = XenObject as XenAPI.VM_appliance;
     if (vm_appliance != null)
     {
         WriteObject(new XenRef <XenAPI.VM_appliance>(vm_appliance));
         return;
     }
     XenAPI.DR_task dr_task = XenObject as XenAPI.DR_task;
     if (dr_task != null)
     {
         WriteObject(new XenRef <XenAPI.DR_task>(dr_task));
         return;
     }
     XenAPI.Host host = XenObject as XenAPI.Host;
     if (host != null)
     {
         WriteObject(new XenRef <XenAPI.Host>(host));
         return;
     }
     XenAPI.Host_crashdump host_crashdump = XenObject as XenAPI.Host_crashdump;
     if (host_crashdump != null)
     {
         WriteObject(new XenRef <XenAPI.Host_crashdump>(host_crashdump));
         return;
     }
     XenAPI.Host_patch host_patch = XenObject as XenAPI.Host_patch;
     if (host_patch != null)
     {
         WriteObject(new XenRef <XenAPI.Host_patch>(host_patch));
         return;
     }
     XenAPI.Host_metrics host_metrics = XenObject as XenAPI.Host_metrics;
     if (host_metrics != null)
     {
         WriteObject(new XenRef <XenAPI.Host_metrics>(host_metrics));
         return;
     }
     XenAPI.Host_cpu host_cpu = XenObject as XenAPI.Host_cpu;
     if (host_cpu != null)
     {
         WriteObject(new XenRef <XenAPI.Host_cpu>(host_cpu));
         return;
     }
     XenAPI.Network network = XenObject as XenAPI.Network;
     if (network != null)
     {
         WriteObject(new XenRef <XenAPI.Network>(network));
         return;
     }
     XenAPI.VIF vif = XenObject as XenAPI.VIF;
     if (vif != null)
     {
         WriteObject(new XenRef <XenAPI.VIF>(vif));
         return;
     }
     XenAPI.VIF_metrics vif_metrics = XenObject as XenAPI.VIF_metrics;
     if (vif_metrics != null)
     {
         WriteObject(new XenRef <XenAPI.VIF_metrics>(vif_metrics));
         return;
     }
     XenAPI.PIF pif = XenObject as XenAPI.PIF;
     if (pif != null)
     {
         WriteObject(new XenRef <XenAPI.PIF>(pif));
         return;
     }
     XenAPI.PIF_metrics pif_metrics = XenObject as XenAPI.PIF_metrics;
     if (pif_metrics != null)
     {
         WriteObject(new XenRef <XenAPI.PIF_metrics>(pif_metrics));
         return;
     }
     XenAPI.Bond bond = XenObject as XenAPI.Bond;
     if (bond != null)
     {
         WriteObject(new XenRef <XenAPI.Bond>(bond));
         return;
     }
     XenAPI.VLAN vlan = XenObject as XenAPI.VLAN;
     if (vlan != null)
     {
         WriteObject(new XenRef <XenAPI.VLAN>(vlan));
         return;
     }
     XenAPI.SM sm = XenObject as XenAPI.SM;
     if (sm != null)
     {
         WriteObject(new XenRef <XenAPI.SM>(sm));
         return;
     }
     XenAPI.SR sr = XenObject as XenAPI.SR;
     if (sr != null)
     {
         WriteObject(new XenRef <XenAPI.SR>(sr));
         return;
     }
     XenAPI.LVHD lvhd = XenObject as XenAPI.LVHD;
     if (lvhd != null)
     {
         WriteObject(new XenRef <XenAPI.LVHD>(lvhd));
         return;
     }
     XenAPI.VDI vdi = XenObject as XenAPI.VDI;
     if (vdi != null)
     {
         WriteObject(new XenRef <XenAPI.VDI>(vdi));
         return;
     }
     XenAPI.VBD vbd = XenObject as XenAPI.VBD;
     if (vbd != null)
     {
         WriteObject(new XenRef <XenAPI.VBD>(vbd));
         return;
     }
     XenAPI.VBD_metrics vbd_metrics = XenObject as XenAPI.VBD_metrics;
     if (vbd_metrics != null)
     {
         WriteObject(new XenRef <XenAPI.VBD_metrics>(vbd_metrics));
         return;
     }
     XenAPI.PBD pbd = XenObject as XenAPI.PBD;
     if (pbd != null)
     {
         WriteObject(new XenRef <XenAPI.PBD>(pbd));
         return;
     }
     XenAPI.Crashdump crashdump = XenObject as XenAPI.Crashdump;
     if (crashdump != null)
     {
         WriteObject(new XenRef <XenAPI.Crashdump>(crashdump));
         return;
     }
     XenAPI.VTPM vtpm = XenObject as XenAPI.VTPM;
     if (vtpm != null)
     {
         WriteObject(new XenRef <XenAPI.VTPM>(vtpm));
         return;
     }
     XenAPI.Console console = XenObject as XenAPI.Console;
     if (console != null)
     {
         WriteObject(new XenRef <XenAPI.Console>(console));
         return;
     }
     XenAPI.User user = XenObject as XenAPI.User;
     if (user != null)
     {
         WriteObject(new XenRef <XenAPI.User>(user));
         return;
     }
     XenAPI.Data_source data_source = XenObject as XenAPI.Data_source;
     if (data_source != null)
     {
         WriteObject(new XenRef <XenAPI.Data_source>(data_source));
         return;
     }
     XenAPI.Blob blob = XenObject as XenAPI.Blob;
     if (blob != null)
     {
         WriteObject(new XenRef <XenAPI.Blob>(blob));
         return;
     }
     XenAPI.Message message = XenObject as XenAPI.Message;
     if (message != null)
     {
         WriteObject(new XenRef <XenAPI.Message>(message));
         return;
     }
     XenAPI.Secret secret = XenObject as XenAPI.Secret;
     if (secret != null)
     {
         WriteObject(new XenRef <XenAPI.Secret>(secret));
         return;
     }
     XenAPI.Tunnel tunnel = XenObject as XenAPI.Tunnel;
     if (tunnel != null)
     {
         WriteObject(new XenRef <XenAPI.Tunnel>(tunnel));
         return;
     }
     XenAPI.PCI pci = XenObject as XenAPI.PCI;
     if (pci != null)
     {
         WriteObject(new XenRef <XenAPI.PCI>(pci));
         return;
     }
     XenAPI.PGPU pgpu = XenObject as XenAPI.PGPU;
     if (pgpu != null)
     {
         WriteObject(new XenRef <XenAPI.PGPU>(pgpu));
         return;
     }
     XenAPI.GPU_group gpu_group = XenObject as XenAPI.GPU_group;
     if (gpu_group != null)
     {
         WriteObject(new XenRef <XenAPI.GPU_group>(gpu_group));
         return;
     }
     XenAPI.VGPU vgpu = XenObject as XenAPI.VGPU;
     if (vgpu != null)
     {
         WriteObject(new XenRef <XenAPI.VGPU>(vgpu));
         return;
     }
     XenAPI.VGPU_type vgpu_type = XenObject as XenAPI.VGPU_type;
     if (vgpu_type != null)
     {
         WriteObject(new XenRef <XenAPI.VGPU_type>(vgpu_type));
         return;
     }
     XenAPI.PVS_site pvs_site = XenObject as XenAPI.PVS_site;
     if (pvs_site != null)
     {
         WriteObject(new XenRef <XenAPI.PVS_site>(pvs_site));
         return;
     }
     XenAPI.PVS_server pvs_server = XenObject as XenAPI.PVS_server;
     if (pvs_server != null)
     {
         WriteObject(new XenRef <XenAPI.PVS_server>(pvs_server));
         return;
     }
     XenAPI.PVS_proxy pvs_proxy = XenObject as XenAPI.PVS_proxy;
     if (pvs_proxy != null)
     {
         WriteObject(new XenRef <XenAPI.PVS_proxy>(pvs_proxy));
         return;
     }
     XenAPI.PVS_cache_storage pvs_cache_storage = XenObject as XenAPI.PVS_cache_storage;
     if (pvs_cache_storage != null)
     {
         WriteObject(new XenRef <XenAPI.PVS_cache_storage>(pvs_cache_storage));
         return;
     }
     XenAPI.Feature feature = XenObject as XenAPI.Feature;
     if (feature != null)
     {
         WriteObject(new XenRef <XenAPI.Feature>(feature));
         return;
     }
     XenAPI.SDN_controller sdn_controller = XenObject as XenAPI.SDN_controller;
     if (sdn_controller != null)
     {
         WriteObject(new XenRef <XenAPI.SDN_controller>(sdn_controller));
         return;
     }
     XenAPI.Vdi_nbd_server_info vdi_nbd_server_info = XenObject as XenAPI.Vdi_nbd_server_info;
     if (vdi_nbd_server_info != null)
     {
         WriteObject(new XenRef <XenAPI.Vdi_nbd_server_info>(vdi_nbd_server_info));
         return;
     }
     XenAPI.PUSB pusb = XenObject as XenAPI.PUSB;
     if (pusb != null)
     {
         WriteObject(new XenRef <XenAPI.PUSB>(pusb));
         return;
     }
     XenAPI.USB_group usb_group = XenObject as XenAPI.USB_group;
     if (usb_group != null)
     {
         WriteObject(new XenRef <XenAPI.USB_group>(usb_group));
         return;
     }
     XenAPI.VUSB vusb = XenObject as XenAPI.VUSB;
     if (vusb != null)
     {
         WriteObject(new XenRef <XenAPI.VUSB>(vusb));
         return;
     }
 }
        private void generateStatusBox()
        {
            XenAPI.SR sr = this.xenModelObject as XenAPI.SR;
            if (sr != null)
            {
                bool flag       = (sr.IsBroken() || !sr.MultipathAOK);
                bool isDetached = sr.IsDetached;
                List <ToolStripMenuItem> contextMenuItems = new List <ToolStripMenuItem>();

                ToolStripMenuItem item = new ToolStripMenuItem(Messages.GENERAL_SR_CONTEXT_REPAIR)
                {
                    Image = Resources._000_StorageBroken_h32bit_16
                };
                item.Click += delegate
                {
                    Program.MainWindow.ShowPerConnectionWizard(this.xenModelObject.Connection, new RepairSRDialog(sr));
                };
                contextMenuItems.Add(item);
                if (flag && !isDetached)
                {
                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.state"), sr.StatusString, Status, contextMenuItems));
                }
                else
                {
                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.state"), sr.StatusString, Status));
                }
                foreach (Host host in this.xenModelObject.Connection.Cache.Hosts)
                {
                    PBD pbd = null;
                    foreach (PBD pbd2 in this.xenModelObject.Connection.ResolveAll <PBD>(host.PBDs))
                    {
                        if (!(pbd2.SR.opaque_ref != this.xenModelObject.opaque_ref))
                        {
                            pbd = pbd2;
                            break;
                        }
                    }
                    if (pbd == null)
                    {
                        if (sr.shared)
                        {
                            if (!isDetached)
                            {
                                GeneralDataList.Add(new GeneralDataStructure("  " + HalsignHelpers.TrimStringIfRequired(Helpers.GetName(host), 30), Messages.REPAIR_SR_DIALOG_CONNECTION_MISSING, Status, Color.Red, contextMenuItems));
                            }
                            else
                            {
                                GeneralDataList.Add(new GeneralDataStructure("  " + HalsignHelpers.TrimStringIfRequired(Helpers.GetName(host), 30), Messages.REPAIR_SR_DIALOG_CONNECTION_MISSING, Status, Color.Red));
                            }
                        }
                    }
                    else
                    {
                        pbd.PropertyChanged -= new PropertyChangedEventHandler(this.PropertyChanged);
                        pbd.PropertyChanged += new PropertyChangedEventHandler(this.PropertyChanged);
                        if (!pbd.currently_attached)
                        {
                            if (!isDetached)
                            {
                                GeneralDataList.Add(new GeneralDataStructure(HalsignHelpers.TrimStringIfRequired(Helpers.GetName(host), 30), pbd.StatusString, Status, Color.Red, contextMenuItems));
                            }
                            else
                            {
                                GeneralDataList.Add(new GeneralDataStructure(HalsignHelpers.TrimStringIfRequired(Helpers.GetName(host), 30), pbd.StatusString, Status, Color.Red));
                            }
                        }
                        else
                        {
                            GeneralDataList.Add(new GeneralDataStructure(HalsignHelpers.TrimStringIfRequired(Helpers.GetName(host), 30), pbd.StatusString, Status));
                        }
                    }
                    if (sr.GetSRType(true) == SR.SRTypes.lvmobond)
                    {
                        if (pbd != null)
                        {
                            String status;
                            if (pbd.other_config.ContainsKey("LUN1-status"))
                            {
                                if (pbd.other_config.TryGetValue("LUN1-status", out status))
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("LUN1"), status, Status));
                                }
                            }
                            if (pbd.other_config.ContainsKey("LUN2-status"))
                            {
                                if (pbd.other_config.TryGetValue("LUN2-status", out status))
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("LUN2"), status, Status));
                                }
                            }
                        }
                    }
                    if (sr.GetSRType(true) == SR.SRTypes.lvmomirror && !sr.other_config.ContainsKey("_type"))
                    {
                        if (pbd != null)
                        {
                            String status;
                            if (pbd.other_config.ContainsKey("LUN1-status"))
                            {
                                if (pbd.other_config.TryGetValue("LUN1-status", out status))
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("LUN1"), status, Status));
                                }
                            }
                            if (pbd.other_config.ContainsKey("LUN2-status"))
                            {
                                if (pbd.other_config.TryGetValue("LUN2-status", out status))
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("LUN2"), status, Status));
                                }
                            }
                        }
                    }
                    if (sr.GetSRType(true) == SR.SRTypes.lvmomirror && sr.other_config.ContainsKey("_type"))
                    {
                        if (pbd != null)
                        {
                            String status;
                            if (pbd.device_config.ContainsKey("SCSIid1"))
                            {
                                if (pbd.device_config.TryGetValue("SCSIid1", out status))
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("LUN1"), status, Status));
                                }
                            }
                            if (pbd.device_config.ContainsKey("SCSIid2"))
                            {
                                if (pbd.device_config.TryGetValue("SCSIid2", out status))
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("LUN2"), status, Status));
                                }
                            }
                        }
                    }
                }//foreach

                /**
                 * if (sr.GetSRType(true) == SR.SRTypes.lvmobond)
                 * {
                 *  if (sr.sm_config.ContainsKey("state"))
                 *  {
                 *      GeneralDataList.Add(new GeneralDataStructure(FriendlyName("RAID.state"), sr.sm_config["state"], Status));
                 *  }
                 *  if (sr.sm_config.ContainsKey("LUN0-status"))
                 *  {
                 *
                 *      if (sr.sm_config["LUN0-status"].Contains("removed"))
                 *      {
                 *          List<ToolStripMenuItem> ctxMenuItems = new List<ToolStripMenuItem>();
                 *          ToolStripMenuItem itm = MainWindow.NewToolStripMenuItem("Add", Resources._000_StorageBroken_h32bit_16, delegate(object sender, EventArgs e)
                 *          {
                 *              List<FibreChannelDevice> devices;
                 *              var success = LVMoBond.FiberChannelScan(this, sr.Connection, out devices);
                 *              Program.MainWindow.ShowPerConnectionWizard(this.xenModelObject.Connection, new AddLUNDialog(sr, devices));
                 *          });
                 *
                 *          ctxMenuItems.Add(itm);
                 *          GeneralDataList.Add(new GeneralDataStructure(FriendlyName("LUN1"), sr.sm_config["LUN0-status"], Status, Color.Red, ctxMenuItems));
                 *      }
                 *      else
                 *      {
                 *          String iscsiid = sr.sm_config["LUN0-scsiid"];
                 *          String mpath_enable = sr.sm_config["multipathable"];
                 *          String boundsr_dev = sr.sm_config["md_device"];
                 *          Dictionary<String, String> args = new Dictionary<string, string>();
                 *          args.Add("scsiid", iscsiid);
                 *          args.Add("mpath_enable", mpath_enable);
                 *          args.Add("boundsr_dev", boundsr_dev);
                 *          List<ToolStripMenuItem> ctxMenuItems = new List<ToolStripMenuItem>();
                 *          ToolStripMenuItem itm = MainWindow.NewToolStripMenuItem("remove", Resources._000_StorageBroken_h32bit_16, delegate(object sender, EventArgs e)
                 *          {
                 *              try
                 *              {
                 *                  AsyncAction Action = new SrRemoveLUNAction(sr.Connection, sr, args, false);
                 *                  Action.RunAsync();
                 *              }
                 *              catch (Exception ex)
                 *              {
                 *              }
                 *          });
                 *          ctxMenuItems.Add(itm);
                 *          GeneralDataList.Add(new GeneralDataStructure(FriendlyName("LUN1"), sr.sm_config["LUN0-status"], Status, ctxMenuItems));
                 *      }
                 *  }
                 *  if (sr.sm_config.ContainsKey("LUN1-status"))
                 *  {
                 *      if (sr.sm_config["LUN1-status"].Contains("removed"))
                 *      {
                 *          List<ToolStripMenuItem> ctxMenuItems = new List<ToolStripMenuItem>();
                 *          ToolStripMenuItem itm = MainWindow.NewToolStripMenuItem("Add", Resources._000_StorageBroken_h32bit_16, delegate(object sender, EventArgs e)
                 *          {
                 *              List<FibreChannelDevice> devices;
                 *              var success = LVMoBond.FiberChannelScan(this, sr.Connection, out devices);
                 *              Program.MainWindow.ShowPerConnectionWizard(this.xenModelObject.Connection, new AddLUNDialog(sr, devices));
                 *          });
                 *
                 *          ctxMenuItems.Add(itm);
                 *          GeneralDataList.Add(new GeneralDataStructure(FriendlyName("LUN2"), sr.sm_config["LUN1-status"], Status, Color.Red, ctxMenuItems));
                 *      }
                 *      else
                 *      {
                 *          String iscsiid = sr.sm_config["LUN1-scsiid"];
                 *          String mpath_enable = sr.sm_config["multipathable"];
                 *          String boundsr_dev = sr.sm_config["md_device"];
                 *          Dictionary<String, String> args = new Dictionary<string, string>();
                 *          args.Add("scsiid", iscsiid);
                 *          args.Add("mpath_enable", mpath_enable);
                 *          args.Add("boundsr_dev", boundsr_dev);
                 *          List<ToolStripMenuItem> ctxMenuItems = new List<ToolStripMenuItem>();
                 *          ToolStripMenuItem itm = MainWindow.NewToolStripMenuItem("remove", Resources._000_StorageBroken_h32bit_16, delegate(object sender, EventArgs e)
                 *          {
                 *              try
                 *              {
                 *                  AsyncAction Action = new SrRemoveLUNAction(sr.Connection, sr, args, false);
                 *                  Action.RunAsync();
                 *
                 *              }
                 *              catch(Exception ex)
                 *              {
                 *              }
                 *          });
                 *          ctxMenuItems.Add(itm);
                 *          GeneralDataList.Add(new GeneralDataStructure(FriendlyName("LUN2"), sr.sm_config["LUN1-status"], Status, ctxMenuItems));
                 *      }
                 *  }
                 * }**/
            }
        }
 private void generateMultipathBox()
 {
     XenAPI.SR xenObject = this.XenModelObject as XenAPI.SR;
     if (xenObject != null)
     {
         if (!xenObject.MultipathCapable)
         {
             GeneralDataList.Add(new GeneralDataStructure(Messages.MULTIPATH_CAPABLE, Messages.NO, Multipathing));
         }
         else if (xenObject.LunPerVDI)
         {
             Dictionary <VM, Dictionary <VDI, string> > multiPathStatusLunPerVDI = xenObject.GetMultiPathStatusLunPerVDI();
             foreach (Host host in this.XenModelObject.Connection.Cache.Hosts)
             {
                 PBD pBDFor = xenObject.GetPBDFor(host);
                 if ((pBDFor == null) || !pBDFor.MultipathActive)
                 {
                     GeneralDataList.Add(new GeneralDataStructure(host.Name, Messages.MULTIPATH_NOT_ACTIVE, Multipathing));
                 }
                 else
                 {
                     GeneralDataList.Add(new GeneralDataStructure(host.Name, Messages.MULTIPATH_ACTIVE, Multipathing));
                     foreach (KeyValuePair <VM, Dictionary <VDI, string> > pair in multiPathStatusLunPerVDI)
                     {
                         VM key = pair.Key;
                         if ((key.resident_on != null) && (key.resident_on.opaque_ref == host.opaque_ref))
                         {
                             bool flag    = false;
                             int  max     = -1;
                             int  current = -1;
                             foreach (KeyValuePair <VDI, string> pair2 in pair.Value)
                             {
                                 int num3;
                                 int num4;
                                 if (PBD.ParsePathCounts(pair2.Value, out num3, out num4))
                                 {
                                     if (!flag)
                                     {
                                         max     = num4;
                                         current = num3;
                                         flag    = true;
                                     }
                                     else if ((max != num4) || (current != num3))
                                     {
                                         flag = false;
                                         break;
                                     }
                                 }
                             }
                             if (flag)
                             {
                                 this.AddMultipathLine(string.Format("    {0}", key.Name), current, max, pBDFor.ISCSISessions);
                             }
                             else
                             {
                                 GeneralDataList.Add(new GeneralDataStructure(string.Format("    {0}", key.Name), "", Multipathing));
                                 foreach (KeyValuePair <VDI, string> pair3 in pair.Value)
                                 {
                                     int num5;
                                     int num6;
                                     if (PBD.ParsePathCounts(pair3.Value, out num5, out num6))
                                     {
                                         this.AddMultipathLine(string.Format("        {0}", pair3.Key.Name), num5, num6, pBDFor.ISCSISessions);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         else
         {
             Dictionary <PBD, Dictionary <String, String> > multiPathStatusLunPerSR = xenObject.GetMultiPathStatusLunPerSR();
             foreach (Host host2 in this.XenModelObject.Connection.Cache.Hosts)
             {
                 PBD pbd2 = xenObject.GetPBDFor(host2);
                 if ((pbd2 == null) || !multiPathStatusLunPerSR.ContainsKey(pbd2))
                 {
                     GeneralDataList.Add(new GeneralDataStructure(host2.Name, ((pbd2 != null) && pbd2.MultipathActive) ? Messages.MULTIPATH_ACTIVE : Messages.MULTIPATH_NOT_ACTIVE, Multipathing));
                 }
                 else
                 {
                     GeneralDataList.Add(new GeneralDataStructure(host2.Name, "", Multipathing));
                     foreach (String k in multiPathStatusLunPerSR[pbd2].Keys)
                     {
                         int    num7;
                         int    num8;
                         string input = multiPathStatusLunPerSR[pbd2][k];
                         PBD.ParsePathCounts(input, out num7, out num8);
                         this.AddMultipathLine(k, num7, num8, pbd2.ISCSISessions);
                     }
                 }
             }
         }
     }
 }
 internal SRWrapper(bool enabled, string reasonUnsuitable, SR sr)
 {
     this.enabled = enabled;
     this.sr = sr;
     this.ReasonUnsuitable = reasonUnsuitable;
 }
Example #36
0
 public ScannedDeviceInfo(SR.SRTypes type, Dictionary<string, string> deviceConfig, List<SR.SRInfo> srList)
 {
     Type = type;
     DeviceConfig = deviceConfig;
     SRList = srList;
 }
        private void generateGeneralBox()
        {
            GeneralDataList.Add(new GeneralDataStructure(FriendlyName("host.name_label"), Helpers.GetName(this.xenModelObject), General));
            GeneralDataList.Add(new GeneralDataStructure(FriendlyName("host.name_description"), this.xenModelObject.Description, General));
            GeneralDataList.Add(new GeneralDataStructure(Messages.FOLDER, this.xenModelObject.Path, General));
            GeneralDataList.Add(new GeneralDataStructure(Messages.TAGS, this.TagsString(), General));
            if (this.xenModelObject is XenObject <XenAPI.SR> )
            {
                XenAPI.SR xenObject = this.xenModelObject as XenAPI.SR;
                GeneralDataList.Add(new GeneralDataStructure(Messages.TYPE, xenObject.FriendlyTypeName, General));
                if ((xenObject.content_type != "iso") && (xenObject.GetSRType(false) != XenAPI.SR.SRTypes.udev))
                {
                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.size"), xenObject.SizeString, General));
                }
                if (xenObject.GetScsiID() != null && xenObject.GetScsiID().Count > 0)
                {
                    foreach (String scsiid in xenObject.GetScsiID())
                    {
                        if (xenObject.GetSRType(true) == SR.SRTypes.lvmobond)
                        {
                            if (CanAddLUN(scsiid) || isLunBondRed(scsiid))
                            {
                                List <ToolStripMenuItem> ctxMenuItems = new List <ToolStripMenuItem>();
                                ToolStripMenuItem        itm          = new ToolStripMenuItem(Messages.ADD)
                                {
                                    Image = Resources._000_StorageBroken_h32bit_16
                                };
                                itm.Click += delegate
                                {
                                    List <FibreChannelDevice> devices;
                                    var success = LVMoBond.FiberChannelScan(this, xenObject.Connection, out devices);
                                    Program.MainWindow.ShowPerConnectionWizard(this.xenModelObject.Connection, new AddLUNDialog(xenObject, devices));
                                };

                                ctxMenuItems.Add(itm);
                                GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, Color.Red, ctxMenuItems));
                            }
                            else if (canissciRemove())
                            {
                                List <ToolStripMenuItem> ctxMenuItems = new List <ToolStripMenuItem>();
                                ToolStripMenuItem        itm          = new ToolStripMenuItem(Messages.REMOVE)
                                {
                                    Image = Resources._000_StorageBroken_h32bit_16
                                };
                                itm.Click += delegate
                                {
                                    AsyncAction          Action = new SrRemoveLUNAction(xenObject.Connection, xenObject, scsiid);
                                    ActionProgressDialog dialog = new ActionProgressDialog(Action, ProgressBarStyle.Marquee)
                                    {
                                        ShowCancel = true
                                    };
                                    dialog.ShowDialog(this);
                                };
                                ctxMenuItems.Add(itm);
                                if (isLunBondRed(scsiid))
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, Color.Red, ctxMenuItems));
                                }
                                else
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, ctxMenuItems));
                                }
                            }
                            else
                            {
                                GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General));
                            }
                        }
                        else if (xenObject.GetSRType(true) == SR.SRTypes.lvmomirror && xenObject.other_config.ContainsKey("_type"))
                        {
                            if (CanAddMirrorLUN(scsiid))
                            {
                                List <ToolStripMenuItem> ctxMenuItems = new List <ToolStripMenuItem>();
                                ToolStripMenuItem        itm          = new ToolStripMenuItem(Messages.ADD)
                                {
                                    Image = Resources._000_StorageBroken_h32bit_16
                                };
                                itm.Click += delegate
                                {
                                    // Program.MainWindow.ShowPerConnectionWizard(this.xenModelObject.Connection, new AddMirrorIscsiDialog(xenObject));
                                    AddMirrorIscsiDialog dlg = new AddMirrorIscsiDialog(xenObject);
                                    dlg.ShowDialog();
                                };

                                ctxMenuItems.Add(itm);
                                if (isMirrorRed(scsiid))
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, Color.Red, ctxMenuItems));
                                }
                                else
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, ctxMenuItems));
                                }
                            }
                            else if (canMirrorissciRemove())
                            {
                                List <ToolStripMenuItem> ctxMenuItems = new List <ToolStripMenuItem>();
                                ToolStripMenuItem        itm          = new ToolStripMenuItem(Messages.REMOVE)
                                {
                                    Image = Resources._000_StorageBroken_h32bit_16
                                };
                                itm.Click += delegate
                                {
                                    AsyncAction          Action = new SrRemoveMirrorLUNAction(xenObject.Connection, xenObject, scsiid);
                                    ActionProgressDialog dialog = new ActionProgressDialog(Action, ProgressBarStyle.Marquee)
                                    {
                                        ShowCancel = true
                                    };
                                    dialog.ShowDialog(this);
                                };
                                ctxMenuItems.Add(itm);
                                if (isMirrorRed(scsiid))
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, Color.Red, ctxMenuItems));
                                }
                                else
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, ctxMenuItems));
                                }
                            }
                            else
                            {
                                GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General));
                            }
                        }
                        else if (xenObject.GetSRType(true) == SR.SRTypes.lvmomirror && !xenObject.other_config.ContainsKey("_type"))
                        {
                            if (CanAddMirrorLUN(scsiid))
                            {
                                List <ToolStripMenuItem> ctxMenuItems = new List <ToolStripMenuItem>();
                                ToolStripMenuItem        itm          = new ToolStripMenuItem(Messages.ADD)
                                {
                                    Image = Resources._000_StorageBroken_h32bit_16
                                };
                                itm.Click += delegate
                                {
                                    List <FibreChannelDevice> devices;
                                    var success = LVMoMirror.FiberChannelScan(this, xenObject.Connection, out devices);
                                    Program.MainWindow.ShowPerConnectionWizard(this.xenModelObject.Connection, new AddMirrorLUNDialog(xenObject, devices));
                                };

                                ctxMenuItems.Add(itm);
                                if (isMirrorRed(scsiid))
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, Color.Red, ctxMenuItems));
                                }
                                else
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, ctxMenuItems));
                                }
                            }
                            else if (canMirrorissciRemove())
                            {
                                List <ToolStripMenuItem> ctxMenuItems = new List <ToolStripMenuItem>();
                                ToolStripMenuItem        itm          = new ToolStripMenuItem(Messages.REMOVE)
                                {
                                    Image = Resources._000_StorageBroken_h32bit_16
                                };
                                itm.Click += delegate
                                {
                                    AsyncAction          Action = new SrRemoveMirrorLUNAction(xenObject.Connection, xenObject, scsiid);
                                    ActionProgressDialog dialog = new ActionProgressDialog(Action, ProgressBarStyle.Marquee)
                                    {
                                        ShowCancel = true
                                    };
                                    dialog.ShowDialog(this);
                                };
                                ctxMenuItems.Add(itm);
                                if (isMirrorRed(scsiid))
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, Color.Red, ctxMenuItems));
                                }
                                else
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, ctxMenuItems));
                                }
                            }
                            else
                            {
                                GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General));
                            }
                        }
                        else
                        {
                            GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General));
                        }
                    }
                }

                if ((Program.MainWindow.SelectionManager.Selection.HostAncestor == null) && (Program.MainWindow.SelectionManager.Selection.PoolAncestor == null))
                {
                    IXenObject o = Helpers.GetPool(xenObject.Connection);
                    if (o != null)
                    {
                        GeneralDataList.Add(new GeneralDataStructure(Messages.POOL, Helpers.GetName(o), General));
                    }
                    else
                    {
                        o = Helpers.GetMaster(xenObject.Connection);
                        if (o != null)
                        {
                            GeneralDataList.Add(new GeneralDataStructure(Messages.SERVER, Helpers.GetName(o), General));
                        }
                    }
                }
            }

            GeneralDataList.Add(new GeneralDataStructure(FriendlyName("host.uuid"), GetUUID(this.xenModelObject), General));
        }
Example #38
0
 public TrimSRCommand(IMainWindow mainWindow, SR sr)
     : base(mainWindow, sr)
 {
 }
Example #39
0
 public NotEnoughSpaceToSuspend(Check check, SR sr, long requiredSpace, List<VM> vms)
     : base(check, sr)
 {
     RequiredSpace = requiredSpace;
     Vms = vms;
 }
Example #40
0
 public UnsupportedStorageLinkSrIsPresentProblem(Check check, SR sr)
     : base(check, sr)
 {
 }