Esempio n. 1
0
        protected override AsyncAction CreateAction(out bool cancelled)
        {
            Program.AssertOnEventThread();
            cancelled = false;

            if (!sr.shared)
            {
                return(null);
            }

            if (device_config == null) //no device config, we need to run the New SR wizard
            {
                NewSRWizard wizard = new NewSRWizard(pool.Connection, sr, true);
                wizard.ShowDialog(Program.MainWindow);
                return(wizard.FinalAction);
            }

            Host master = pool.Connection.Resolve(pool.master);

            if (master == null)
            {
                return(null);
            }

            ScannedDeviceInfo deviceInfo = new ScannedDeviceInfo(sr.GetSRType(true), device_config, sr.uuid);

            return(new DrTaskCreateAction(pool.Connection, deviceInfo));
        }
        protected override AsyncAction CreateAction(out bool cancelled)
        {
            Program.AssertOnEventThread();
            cancelled = false;

            if (EmptySRDeviceConfigList)
            {
                return(null);
            }

            Host master = pool.Connection.Resolve(pool.master);

            if (master == null)
            {
                return(null);
            }

            List <AsyncAction> subActions = new List <AsyncAction>();

            foreach (SRDeviceConfig item in srDeviceConfigList)
            {
                if (item.DeviceConfig == null)
                {
                    continue;
                }

                ScannedDeviceInfo deviceInfo = new ScannedDeviceInfo(item.SR.GetSRType(true),
                                                                     item.DeviceConfig,
                                                                     item.SR.uuid);
                subActions.Add(new DrTaskCreateAction(pool.Connection, deviceInfo));
            }

            if (subActions.Count == 0)
            {
                return(null);
            }

            return(subActions.Count == 1
                       ? subActions[0]
                       : new ParallelAction(pool.Connection, Messages.ACTION_MULTIPLE_DR_TASK_CREATE_TITLE,
                                            Messages.ACTION_MULTIPLE_DR_TASK_CREATE_START,
                                            Messages.ACTION_MULTIPLE_DR_TASK_CREATE_END, subActions));
        }
Esempio n. 3
0
        private List <AsyncAction> GetActions(Host master, bool disasterRecoveryTask)
        {
            // Now we need to decide what to do.
            // This will be one off create, introduce, reattach

            List <AsyncAction> finalActions = new List <AsyncAction>();

            actionSrDescriptorDict.Clear();

            foreach (var srDescriptor in m_srWizardType.SrDescriptors)
            {
                var srType = srDescriptor is FibreChannelDescriptor ? (srDescriptor as FibreChannelDescriptor).SrType : m_srWizardType.Type;
                if (String.IsNullOrEmpty(srDescriptor.UUID))
                {
                    // Don't need to show any warning, as the only destructive creates
                    // are in iSCSI and HBA, where they show their own warning
                    finalActions.Add(new SrCreateAction(xenConnection, master,
                                                        srDescriptor.Name,
                                                        srDescriptor.Description,
                                                        srType,
                                                        m_srWizardType.ContentType,
                                                        srDescriptor.DeviceConfig,
                                                        srDescriptor.SMConfig));
                }
                else if (_srToReattach == null || _srToReattach.Connection != xenConnection)
                {
                    // introduce
                    if (disasterRecoveryTask &&
                        (_srToReattach == null || SR.SupportsDatabaseReplication(xenConnection, _srToReattach)))
                    {
                        // "Find existing SRs" or "Attach SR needed for DR" cases
                        ScannedDeviceInfo deviceInfo = new ScannedDeviceInfo(srType,
                                                                             srDescriptor.DeviceConfig,
                                                                             srDescriptor.UUID);
                        finalActions.Add(new DrTaskCreateAction(xenConnection, deviceInfo));
                    }
                    else
                    {
                        finalActions.Add(new SrIntroduceAction(xenConnection,
                                                               srDescriptor.UUID,
                                                               srDescriptor.Name,
                                                               srDescriptor.Description,
                                                               srType,
                                                               m_srWizardType.ContentType,
                                                               srDescriptor.DeviceConfig));
                    }
                }
                else
                {
                    // Reattach
                    if (disasterRecoveryTask && SR.SupportsDatabaseReplication(xenConnection, _srToReattach))
                    {
                        // "Attach SR needed for DR" case
                        ScannedDeviceInfo deviceInfo = new ScannedDeviceInfo(_srToReattach.GetSRType(true),
                                                                             srDescriptor.DeviceConfig,
                                                                             _srToReattach.uuid);
                        finalActions.Add(new DrTaskCreateAction(xenConnection, deviceInfo));
                    }
                    else
                    {
                        finalActions.Add(new SrReattachAction(_srToReattach,
                                                              srDescriptor.Name,
                                                              srDescriptor.Description,
                                                              srDescriptor.DeviceConfig));
                    }
                }

                AsyncAction action = finalActions.Last();
                if (!actionSrDescriptorDict.ContainsKey(action))
                {
                    actionSrDescriptorDict.Add(action, srDescriptor);
                }
            }

            return(finalActions);
        }