コード例 #1
0
        public void BuildList()
        {
            PcisdataGridViewExs.Rows.Clear();
            if (this.home != null)
            {
                string result = XenAPI.Host.call_plugin(home.Connection.Session, home.opaque_ref, "pvusbinfo.py", "list", null);
                UsbDeviceInfoConfig.PVUsbListResult pvusbresult = null;
                try
                {
                    pvusbresult = (UsbDeviceInfoConfig.PVUsbListResult)HalsignUtil.JsonToObject(result, typeof(UsbDeviceInfoConfig.PVUsbListResult));
                }
                catch {
                    return;
                }
                for (int i = 0; i < pvusbresult.returnvalue.Count; i++)
                {
                    PcisdataGridViewExs.Rows.Add();
                    PcisdataGridViewExs.Rows[i].Tag            = pvusbresult.returnvalue[i].id;
                    PcisdataGridViewExs.Rows[i].Cells[0].Value = string.Concat("Bus ", pvusbresult.returnvalue[i].busid);
                    PcisdataGridViewExs.Rows[i].Cells[0].Tag   = pvusbresult.returnvalue[i].pciid;
                    PcisdataGridViewExs.Rows[i].Cells[1].Value = pvusbresult.returnvalue[i].shortname + " (" + pvusbresult.returnvalue[i].longname + " )";
                    if (pvusbresult.returnvalue[i].vm != null)
                    {
                        string vmuuid = pvusbresult.returnvalue[i].vm;
                        VM     bindvm = home.Connection.Cache.VMs.First(vm => vm.uuid == vmuuid);
                        PcisdataGridViewExs.Rows[i].Cells[2].Value    = bindvm.name_label;
                        PcisdataGridViewExs.Rows[i].Cells[2].Tag      = pvusbresult.returnvalue[i].vm;
                        PcisdataGridViewExs.Rows[i].Cells[3].Value    = "pvusb";
                        PcisdataGridViewExs.Rows[i].Cells[3].ReadOnly = true;

                        ((DataGridViewButtonCellEx)(PcisdataGridViewExs.Rows[i].Cells[4])).Bind    = false;
                        ((DataGridViewButtonCellEx)(PcisdataGridViewExs.Rows[i].Cells[4])).Enabled = true;
                    }
                    else
                    {
                        VM findvm = home.Connection.Cache.VMs.FirstOrDefault(vm => vm.uuid != null &&
                                                                             vm.is_a_real_vm &&
                                                                             HalsignHelpers.IsVMShow(vm) &&
                                                                             vm.other_config.ContainsKey("pci") &&
                                                                             vm.other_config["pci"].Contains(string.Concat("0000:", pvusbresult.returnvalue[i].pciid)) &&
                                                                             vm.Home().Equals(home));
                        if (findvm == null)
                        {
                            PcisdataGridViewExs.Rows[i].Cells[3].Value = "pvusb";
                            ((DataGridViewButtonCellEx)(PcisdataGridViewExs.Rows[i].Cells[4])).Bind    = true;
                            ((DataGridViewButtonCellEx)(PcisdataGridViewExs.Rows[i].Cells[4])).Enabled = true;
                        }
                        else
                        {
                            PcisdataGridViewExs.Rows[i].Cells[2].Value    = findvm.name_label;
                            PcisdataGridViewExs.Rows[i].Cells[2].Tag      = findvm.uuid;
                            PcisdataGridViewExs.Rows[i].Cells[3].Value    = "vt-d";
                            PcisdataGridViewExs.Rows[i].Cells[3].ReadOnly = true;
                            ((DataGridViewButtonCellEx)(PcisdataGridViewExs.Rows[i].Cells[4])).Bind    = false;
                            ((DataGridViewButtonCellEx)(PcisdataGridViewExs.Rows[i].Cells[4])).Enabled = true;
                        }
                    }
                }
            }
        }
コード例 #2
0
        private bool RetrieveConfiguration(VM selectedVM)
        {
            bool result = false;

            if (selectedVM.Connection != null)
            {
                if (selectedVM.other_config.ContainsKey("halsign_br_enabled"))
                {
                    if (selectedVM.other_config["halsign_br_enabled"].Equals("True"))
                    {
                        result = true;
                    }
                    else
                    {
                        result       = false;
                        this.noSetVM = selectedVM;
                    }
                }
                else
                {
                    Pool pool = HalsignHelpers.GetPoolOfOne(selectedVM.Connection);
                    if (pool != null && pool.other_config.ContainsKey("halsign_br_enabled") && pool.other_config["halsign_br_enabled"].Equals("True"))
                    {
                        result = true;
                    }
                    else
                    {
                        this.noSetVM = selectedVM;
                    }
                }
            }
            return(result);
        }
コード例 #3
0
 public override void PageLoaded(PageLoadedDirection direction)
 {
     base.PageLoaded(direction);
     if (direction == PageLoadedDirection.Forward)
     {
         //HelpersGUI.FocusFirstControl(base.Controls);
         Host _host = null;
         if (this._xenModelObject is VM)
         {
             _host = HalsignHelpers.VMHome(this._xenModelObject as VM);
         }
         else if (this._xenModelObject is Host)
         {
             _host = this._xenModelObject as Host;
         }
         if (_host != null)
         {
             this.ServerTimeLabel.Text = Host.get_servertime(this._xenModelObject.Connection.Session, _host.opaque_ref).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss", DateTimeFormatInfo.InvariantInfo);
         }
         else
         {
             this.ServerTimeLabel.Text = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss", DateTimeFormatInfo.InvariantInfo);
         }
     }
 }
コード例 #4
0
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            lock (lockobj)
            {
                dtTable.Rows.Clear();
                if (this.home != null)
                {
                    string result = XenAPI.Host.call_plugin(home.Connection.Session, home.opaque_ref, "pvusbinfo.py", "list", null);
                    var    ret    = (UsbDeviceInfoConfig.PVUsbListResult)HalsignUtil.JsonToObject(result, typeof(UsbDeviceInfoConfig.PVUsbListResult));
                    foreach (UsbDeviceInfoConfig.USBInfo usbinfo in ret.returnvalue)
                    {
                        DataRow row = dtTable.NewRow();
                        row["id"]    = usbinfo.id;
                        row["pciid"] = usbinfo.pciid;
                        row["bus"]   = string.Concat("Bus ", usbinfo.busid);

                        row["devices"] = usbinfo.shortname + " (" + usbinfo.longname + " )";
                        if (usbinfo.vm != null)
                        {
                            XenRef <VM> vmRef  = VM.get_by_uuid(home.Connection.Session, usbinfo.vm);
                            VM          bindvm = VM.get_record(home.Connection.Session, vmRef);

                            row["vm_name"] = bindvm.name_label;
                            row["vm_uuid"] = usbinfo.vm;
                            row["usbmode"] = "pvusb";
                            row["bind"]    = false;
                            row["enabled"] = true;
                        }
                        else
                        {
                            VM findvm = home.Connection.Cache.VMs.FirstOrDefault(vm => vm.uuid != null &&
                                                                                 vm.is_a_real_vm &&
                                                                                 HalsignHelpers.IsVMShow(vm) &&
                                                                                 vm.other_config.ContainsKey("pci") &&
                                                                                 vm.other_config["pci"].Contains(string.Concat("0000:", usbinfo.pciid)) &&
                                                                                 vm.Home().Equals(home));

                            if (findvm == null)
                            {
                                row["usbmode"] = "pvusb";
                                row["bind"]    = true;
                                row["enabled"] = true;
                            }
                            else
                            {
                                row["vm_name"] = findvm.name_label;
                                row["vm_uuid"] = findvm.uuid;
                                row["usbmode"] = "vt-d";
                                row["bind"]    = false;
                                row["enabled"] = true;
                            }
                        }

                        dtTable.Rows.Add(row);
                    }
                }
            }
        }
コード例 #5
0
        private void RefreshTreeViewCore()
        {
            int index = 0;
            List <IXenConnection> xenConnectionsCopy = ConnectionsManager.XenConnectionsCopy;

            xenConnectionsCopy.Sort();
            foreach (IXenConnection connection in xenConnectionsCopy)
            {
                VM[] vMs = connection.Cache.VMs.Where(vm => vm.uuid != null).ToArray();
                Array.Sort <VM>(vMs);
                XenAPI.SR[] sRs = connection.Cache.SRs;
                Array.Sort <XenAPI.SR>(sRs);
                Pool pool = HalsignHelpers.GetPool(connection);
                if (pool != null)
                {
                    bool     flag2;
                    TreeNode parent = this.AddNode(this.BackupTreeView.Nodes[0], index, HalsignHelpers.GetName(pool), Images.GetIconFor(pool), false, pool, out flag2);
                    index++;
                    Host[] hosts = connection.Cache.Hosts;
                    Array.Sort <Host>(hosts);
                    int num2 = 0;
                    foreach (Host obj3 in hosts)
                    {
                        this.AddHostAndChildren(parent, num2, connection, vMs, sRs, obj3, false, true);
                        num2++;
                    }
                    this.AddVMsToTree(parent, ref num2, connection, vMs, null, true);
                    this.PurgeFromHere(parent, num2);
                    if (flag2)
                    {
                        parent.Expand();
                    }
                    continue;
                }
                Pool poolOfOne = HalsignHelpers.GetPoolOfOne(connection);
                Host theHost   = (poolOfOne == null) ? null : poolOfOne.Connection.Resolve <Host>(poolOfOne.master);
                if (theHost == null)
                {
                    this.AddDisconnectedNode(this.BackupTreeView.Nodes[0], index, connection);
                }
                else
                {
                    this.AddHostAndChildren(this.BackupTreeView.Nodes[0], index, connection, vMs, sRs, theHost, true, false);
                }
                index++;
            }
            this.PurgeFromHere(this.BackupTreeView.Nodes[0], index);
            if (this.BackupTreeView.Nodes[0].Nodes.Count <= 0)
            {
                this.BackupTreeView.Enabled = false;
            }
            else
            {
                this.BackupTreeView.Nodes[0].Expand();
            }
        }
コード例 #6
0
        private void AddVMsToTree(TreeNode parent, ref int index, IXenConnection connection, VM[] vms, Host TheHost, bool IsPool)
        {
            foreach (VM vm in vms)
            {
                bool is_snapshot = (!vm.is_a_template && HalsignHelpers.IsVMShow(vm) && !(vm.snapshots != null && vm.snapshots.Count > 0) && vm.allowed_operations.Count > 0);
                if (switchSnapshot)
                {
                    is_snapshot = (!vm.is_a_template && HalsignHelpers.IsVMShow(vm) && !(vm.snapshots != null && vm.snapshots.Count > 0) && vm.allowed_operations.Count > 0);
                }
                else
                {
                    is_snapshot = (!vm.is_a_template && HalsignHelpers.IsVMShow(vm) && vm.allowed_operations.Count > 0);
                }

                if (is_snapshot)
                {
                    if ((HalsignHelpers.VMHome(vm) == TheHost) || !IsPool)
                    {
                        if (!vm.name_label.StartsWith("__gui__"))
                        {
                            if (switchSnapshot)
                            {
                                bool hasParent = false;
                                foreach (VBD vbd in vm.Connection.ResolveAll <VBD>(vm.VBDs))
                                {
                                    if (HalsignHelpers.IsCDROM(vbd))
                                    {
                                        continue;
                                    }

                                    VDI vdi = vm.Connection.Resolve <VDI>(vbd.VDI);
                                    if (vdi != null) //&& vdi.Server.Show)
                                    {
                                        if (vdi.sm_config.ContainsKey("vhd-parent") && !string.IsNullOrEmpty(vdi.sm_config["vhd-parent"]))
                                        {
                                            hasParent = true;
                                            break;
                                        }
                                    }
                                }
                                if (hasParent)
                                {
                                    continue;
                                }
                            }

                            this.AddVMNode(parent, index, vm);
                            index++;
                            //vmList.Add(vm.uuid, vm);
                        }
                    }
                }
            }
        }
コード例 #7
0
ファイル: PciBindDialog.cs プロジェクト: yimng/xenconsole
 private void BuildVMList(Host home)
 {
     VM[] vms = home.Connection.Cache.VMs.Where <VM>(vm => vm.uuid != null &&
                                                     vm.is_a_real_vm &&
                                                     HalsignHelpers.IsVMShow(vm) &&
                                                     (this.mode == "pvusb" ?
                                                      (home.Connection.Resolve(vm.resident_on) == home) : (vm.Home() == home)) &&
                                                     vm.Home() == home).ToArray();
     this.VMsComboBox.DataSource    = vms;
     this.VMsComboBox.DisplayMember = "name_label";
     this.VMsComboBox.ValueMember   = "uuid";
 }
コード例 #8
0
        private void InitStorageGridList()
        {
            VM   _xenVM   = null;
            Host _xenHost = null;

            if (this._xenModelObject is VM)
            {
                _xenVM   = this._xenModelObject as VM;
                _xenHost = HalsignHelpers.VMHome(_xenVM);
            }
            else
            {
                _xenHost = _xenModelObject as Host;
            }
            this.DataGridView_DefaultStorage.Rows.Clear();
            PBD[]         objArray = _xenHost.Connection.ResolveAll <PBD>(_xenHost.PBDs).ToArray();
            List <string> list     = new List <string>();
            int           i        = 0;

            foreach (PBD pbd in objArray)
            {
                SR sr = pbd.Connection.Resolve <SR>(pbd.SR);
                if ((sr != null) && !sr.IsToolsSR)
                {
                    int index = list.BinarySearch(sr.opaque_ref);
                    if (index < 0)
                    {
                        index = ~index;
                        list.Insert(index, sr.opaque_ref);
                        if (sr.GetSRType(false) == SR.SRTypes.lvm ||
                            sr.GetSRType(false) == SR.SRTypes.ext ||
                            sr.GetSRType(false) == SR.SRTypes.lvmoiscsi ||
                            sr.GetSRType(false) == SR.SRTypes.lvmohba ||
                            sr.GetSRType(false) == SR.SRTypes.lvmobond ||
                            sr.GetSRType(false) == SR.SRTypes.nfs ||
                            sr.GetSRType(false) == SR.SRTypes.lvmomirror)
                        {
                            String[] rowTemp = { _xenHost.name_label, _xenHost.address, sr.name_label, Util.DiskSizeString(sr.FreeSpace) };
                            this.DataGridView_DefaultStorage.Rows.Add(rowTemp);
                            this.DataGridView_DefaultStorage.Rows[i].Tag          = sr.uuid;
                            this.DataGridView_DefaultStorage.Rows[i].Cells[3].Tag = sr.FreeSpace;
                            i++;
                        }
                    }
                }
            }
        }
コード例 #9
0
 private bool ShowNetwork(XenAPI.Network network)
 {
     if (network.IsGuestInstallerNetwork)
     {
         return(false);
     }
     if (network.IsInUseBondSlave)
     {
         return(false);
     }
     if ((this.selected_host != null) && !HalsignHelpers.hostCanSeeNetwork(selected_host, network))
     {
         return(false);
     }
     if ((this.selected_host == null) && !HalsignHelpers.allHostsCanSeeNetwork(network))
     {
         return(false);
     }
     return(true);
 }
コード例 #10
0
ファイル: Page_JobSchedule.cs プロジェクト: yimng/xenconsole
        public void UpdateServerTime(IXenObject XenModelObject)
        {
            Host _host = null;

            if (XenModelObject is VM)
            {
                _host = HalsignHelpers.VMHome(XenModelObject as VM);
            }
            else if (XenModelObject is Host)
            {
                _host = XenModelObject as Host;
            }
            if (_host != null)
            {
                this.Label_Server_ScheduleTime.Text = Host.get_servertime(XenModelObject.Connection.Session, _host.opaque_ref).ToString("yyyy/MM/dd HH:mm:ss", DateTimeFormatInfo.InvariantInfo);
            }
            else
            {
                this.Label_Server_ScheduleTime.Text = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss", DateTimeFormatInfo.InvariantInfo);
            }
        }
コード例 #11
0
ファイル: ReplicationWizard.cs プロジェクト: yimng/xenconsole
        public void ReplicationEditWizard()
        {
            VM vm = this._xenModelObject as VM;

            this.repChoseVmPage.VmCheckedList.Add(vm);
            BackupRestoreConfig.BrSchedule schedule = (BackupRestoreConfig.BrSchedule)HalsignUtil.JsonToObject(vm.other_config["halsign_rep_rules"], typeof(BackupRestoreConfig.BrSchedule));
            jobs = (BackupRestoreConfig.Job)HalsignUtil.JsonToObject(vm.other_config["halsign_br_job_r"], typeof(BackupRestoreConfig.Job));
            base.RemovePage(this.repChoseVmPage);
            base.RemovePage(this.repJobSettingPage);
            base.RemovePage(this.synchronizationPage);
            base.RemovePage(this.vmSettingsPage);
            base.RemovePage(this.completePage);

            this.repJobSettingPage.JobNameText = schedule.jobName;
            string tmpvdistr = "";

            if (schedule.details.EndsWith("halsign_vdi_all"))
            {
                foreach (VBD vbd in vm.Connection.ResolveAll <VBD>(vm.VBDs))
                {
                    if (HalsignHelpers.IsCDROM(vbd))
                    {
                        continue;
                    }
                    if (vbd.type.Equals(XenAPI.vbd_type.Disk))
                    {
                        tmpvdistr += vm.Connection.Resolve <VDI>(vbd.VDI).uuid + "@";;
                    }
                }
                tmpvdistr = tmpvdistr.Substring(0, tmpvdistr.Length - 1);
                this.repChoseVmPage.vdi_expand_list.Add(vm.uuid, tmpvdistr);
            }
            else
            {
                this.repChoseVmPage.vdi_expand_list.Add(vm.uuid, schedule.details);
            }
            this.schedulePage.EditReplicationInitButton(schedule);
            this.repJobSettingPage.EditReplicationInitJobSet(schedule);
            scheduleDetails = schedule.details.Replace("|halsign_vdi_all", "");
        }
コード例 #12
0
        public BackupWizard(IXenObject XenObject)
        {
            this._xenModelObject = XenObject;
            InitializeComponent();
            base.Text = string.Format(Messages.BACKUP_VM_TITLE, HalsignHelpers.GetName(this._xenModelObject.Connection));
            this.xenChoseVmBackupPage = new BackupChoseVmPage(XenObject);
            this.scheduleBackupPage   = new BackupSchedulePage();
            this.summaryBackupPage    = new BackupSummaryPage();
            this.optionsBackupPage    = new BackupOptionsPage();
            this.completeBackupPage   = new BackupCompletePage();
            this.page_RbacWarning     = new RBACWarningPage();
            #region RBAC Warning Page Checks
            if (this._xenModelObject.Connection.Session.IsLocalSuperuser || Helpers.GetMaster(this._xenModelObject.Connection).external_auth_type == Auth.AUTH_TYPE_NONE)
            {
                //page_RbacWarning.DisableStep = true;
            }
            else
            {
                // Check to see if they can even create a VM
                RBACWarningPage.WizardPermissionCheck createCheck = new RBACWarningPage.WizardPermissionCheck(Messages.RBAC_WARNING_VM_WIZARD_BACKUP);
                foreach (RbacMethod method in StaticRBACDependencies)
                {
                    createCheck.AddApiCheck(method);
                }
                createCheck.Blocking = true;

                page_RbacWarning.AddPermissionChecks(this._xenModelObject.Connection, createCheck);

                AddPage(page_RbacWarning, 0);
            }
            #endregion
            base.AddPage(this.xenChoseVmBackupPage);
            base.AddPage(this.scheduleBackupPage);
            base.AddPage(this.optionsBackupPage);
            base.AddPage(this.summaryBackupPage);
            base.AddPage(this.completeBackupPage);
        }
コード例 #13
0
        public void BackupEditWizard()
        {
            VM vm = this._xenModelObject as VM;

            this.vmCheckedList.Add(vm);
            BackupRestoreConfig.BrSchedule schedule = (BackupRestoreConfig.BrSchedule)HalsignUtil.JsonToObject(vm.other_config["halsign_br_rules"], typeof(BackupRestoreConfig.BrSchedule));
            BackupRestoreConfig.Job        job      = (BackupRestoreConfig.Job)HalsignUtil.JsonToObject(vm.other_config["halsign_br_job_s"], typeof(BackupRestoreConfig.Job));
            base.RemovePage(this.xenChoseVmBackupPage);
            base.RemovePage(this.optionsBackupPage);
            base.RemovePage(this.summaryBackupPage);
            base.RemovePage(this.completeBackupPage);

            this.optionsBackupPage._JobNameTextBox = schedule.jobName;
            string tmpvdistr = "";

            if (schedule.details.Equals("halsign_vdi_all"))
            {
                foreach (VBD vbd in vm.Connection.ResolveAll <VBD>(vm.VBDs))
                {
                    if (HalsignHelpers.IsCDROM(vbd))
                    {
                        continue;
                    }
                    if (vbd.type.Equals(XenAPI.vbd_type.Disk))
                    {
                        tmpvdistr += vm.Connection.Resolve <VDI>(vbd.VDI).uuid + "@";;
                    }
                }
                tmpvdistr = tmpvdistr.Substring(0, tmpvdistr.Length - 1);
                this.vdi_dictionary.Add(vm.uuid, tmpvdistr);
            }
            else
            {
                this.vdi_dictionary.Add(vm.uuid, schedule.details);
            }
            this.scheduleBackupPage.EditBackupInitButton(schedule);
        }
コード例 #14
0
        private bool ShowNetwork(XenAPI.Network network)
        {
            if (network.IsGuestInstallerNetwork)
            {
                return(false);
            }
            if (network.IsInUseBondSlave)
            {
                return(false);
            }

            Host temp_host = null;

            if (this._xenModelObject is VM)
            {
                VM _xenVM = this._xenModelObject as VM;
                temp_host = HalsignHelpers.VMHome(_xenVM);
            }
            else if (this._xenModelObject is Host)
            {
                temp_host = _xenModelObject as Host;
            }
            else
            {
                temp_host = Helpers.GetMaster(this._xenModelObject.Connection);
            }

            if ((temp_host != null) && !HalsignHelpers.hostCanSeeNetwork(temp_host, network))
            {
                return(false);
            }
            if ((temp_host == null) && !HalsignHelpers.allHostsCanSeeNetwork(network))
            {
                return(false);
            }
            return(true);
        }
コード例 #15
0
        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));
                 *      }
                 *  }
                 * }**/
            }
        }
コード例 #16
0
ファイル: ReplicationWizard.cs プロジェクト: yimng/xenconsole
        protected override void FinishWizard()
        {
            List <Dictionary <string, string> >         listParam     = new List <Dictionary <string, string> >();
            List <Dictionary <string, List <string> > > listParamTemp = new List <Dictionary <string, List <string> > >();

            BackupRestoreConfig.BrSchedule schedule = new BackupRestoreConfig.BrSchedule();
            BackupRestoreConfig.Job        job      = new BackupRestoreConfig.Job();
            string str_rules   = "";
            String str_job     = "";
            string str_command = "";

            schedule.jobName = this.repJobSettingPage.JobNameText;
            job.job_name     = this.repJobSettingPage.JobNameText;
            if (this.schedulePage.NowChecked)
            {
                str_command           = "f";
                schedule.scheduleType = 0;
                job.schedule_type     = 0;
                schedule.scheduleDate = "";
            }
            if (this.schedulePage.OnceChecked)
            {
                str_command           = "y";
                schedule.scheduleType = 1;
                job.schedule_type     = 1;
                schedule.scheduleDate = this.schedulePage.StartDateText;
                schedule.scheduleTime = this.schedulePage.StartTimeText;
            }
            if (this.schedulePage.DailyChecked)
            {
                str_command           = "a";
                schedule.scheduleType = 2;
                job.schedule_type     = 2;
                schedule.scheduleDate = this.schedulePage.StartDateText;
                schedule.scheduleTime = this.schedulePage.StartTimeText;
                schedule.recur        = this.schedulePage.RecurText;
            }
            if (this.schedulePage.CircleChecked)
            {
                str_command           = "u";
                schedule.scheduleType = 4;
                job.schedule_type     = 4;
                schedule.scheduleDate = this.schedulePage.StartDateText;
                schedule.scheduleTime = this.schedulePage.StartTimeText;
                schedule.recur        = this.schedulePage.RecurText;
            }
            if (this.schedulePage.WeeklyChecked)
            {
                str_command           = "z";
                schedule.scheduleType = 3;
                job.schedule_type     = 3;
                schedule.scheduleDate = this.schedulePage.StartDateText;
                schedule.scheduleTime = this.schedulePage.StartTimeText;
                schedule.recur        = this.schedulePage.RecurText;
                List <int> listDays = new List <int>();
                if (this.schedulePage.MondayChecked)
                {
                    listDays.Add(1);
                }
                if (this.schedulePage.TuesdayChecked)
                {
                    listDays.Add(2);
                }
                if (this.schedulePage.WednesdayChecked)
                {
                    listDays.Add(3);
                }
                if (this.schedulePage.ThursdayChecked)
                {
                    listDays.Add(4);
                }
                if (this.schedulePage.FridayChecked)
                {
                    listDays.Add(5);
                }
                if (this.schedulePage.SaturdayChecked)
                {
                    listDays.Add(6);
                }
                if (this.schedulePage.SundayChecked)
                {
                    listDays.Add(0);
                }
                schedule.weeklyDays = listDays;
            }
            if (scheduleDetails != null && !scheduleDetails.Equals(""))
            {
                schedule.details = scheduleDetails;
            }
            else
            {
                schedule.details = this.repJobSettingPage.Choice_sr_ip + "|"
                                   + this.repJobSettingPage.DestUsernameText + "|" + this.repJobSettingPage.DestPasswordText + "|"
                                   + this.repJobSettingPage.VMNameText + "|" + this.repJobSettingPage.Choice_sr_uuid + "|0|"
                                   + this.repJobSettingPage.MacText + "|" + this.repJobSettingPage.NetworkValue + "|"
                                   + Helpers.GetMaster(this.repJobSettingPage.Selected_xenConnection).address + "|" + this.repJobSettingPage.Selected_xenConnection.Username + "|"
                                   + this.repJobSettingPage.Selected_xenConnection.Password + "|" + this.repJobSettingPage.Selected_host.uuid;
            }
            str_rules = HalsignUtil.ToJson(schedule);
            str_rules = str_rules.Replace("\\/", "/");


            job.host    = "";
            job.key     = "halsign_br_job_r";
            job.request = str_command + this.repJobSettingPage.JobNameText.TrimEnd().TrimStart() + "|";
            TimeSpan ts = DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1, 0, 0, 0));

            ts = new DateTime(this.schedulePage.StartDateValue.Year, this.schedulePage.StartDateValue.Month,
                              this.schedulePage.StartDateValue.Day, this.schedulePage.StartTimeValue.Hour, this.schedulePage.StartTimeValue.Minute,
                              this.schedulePage.StartTimeValue.Second).Subtract(new DateTime(1970, 1, 1, 0, 0, 0).ToLocalTime());
            if (jobs != null)
            {
                jobs.request       = str_command + jobs.request.Substring(1, jobs.request.Length - 1);
                jobs.schedule_type = job.schedule_type;
                str_job            = HalsignUtil.ToJson(jobs);
            }
            else
            {
                job.start_time         = "";
                job.progress           = -1;
                job.total_storage      = -1;
                job.modify_time        = "";
                job.pid                = -1;
                job.retry              = -1;
                job.speed              = -1;
                job.status             = 0;
                job.current_full_count = 0;
                job.expect_full_count  = 0;//this.scheduleBackupPage.IsFullBackup ? 0 : (this.scheduleBackupPage._expectFullCheckBox ? this.scheduleBackupPage._expectFullCountTextBox : 0);
                str_job                = HalsignUtil.ToJson(job);
            }


            //string a = this.repJobSettingPage.Selected_xenConnection.Hostname;

            Dictionary <string, string> _dconf = new Dictionary <string, string>();

            _dconf.Add("command", str_command);
            _dconf.Add("is_now", this.schedulePage.NowChecked.ToString());
            _dconf.Add("replication_rules", str_rules);
            _dconf.Add("replication_job", str_job);
            if (jobs != null)
            {
                _dconf.Add("replication_editjob", "true");
            }
            else
            {
                _dconf.Add("replication_editjob", "false");
            }

            foreach (VM item in this.repChoseVmPage.VmCheckedList)
            {
                Dictionary <string, string>         _dconf_param      = new Dictionary <string, string>();
                Dictionary <string, List <string> > _dconf_param_temp = new Dictionary <string, List <string> >();
                string host_ip = " ";
                if (!HalsignHelpers.VMHome(item).address.Equals(this.repJobSettingPage.Choice_sr_ip))
                {
                    host_ip = this.repJobSettingPage.Choice_sr_ip;
                }
                List <string> syncCheckedList = new List <string>();
                foreach (Dictionary <string, string> dRepChecked in this.synchronizationPage.RepCheckedList)
                {
                    if (dRepChecked.ContainsKey(item.uuid))
                    {
                        string request_expend = "";
                        if (this.repChoseVmPage.vdi_expand_list.ContainsKey(item.uuid))
                        {
                            int vdiNo = 0;
                            foreach (VBD vbd in item.Connection.ResolveAll <VBD>(item.VBDs))
                            {
                                if (HalsignHelpers.IsCDROM(vbd))
                                {
                                    continue;
                                }

                                if (vbd.type.Equals(XenAPI.vbd_type.Disk))
                                {
                                    vdiNo++;
                                }
                            }
                            if (vdiNo == this.repChoseVmPage.vdi_expand_list[item.uuid].Split('@').Length)
                            {
                                request_expend = "|" + "halsign_vdi_all";
                            }
                            else
                            {
                                request_expend = "|" + this.repChoseVmPage.vdi_expand_list[item.uuid];
                            }
                        }
                        if ("new".Equals(dRepChecked[item.uuid]))
                        {
                            syncCheckedList.Add(this.repJobSettingPage.JobNameText + "|" + item.uuid + "|" + host_ip + "|"
                                                + this.repJobSettingPage.DestUsernameText + "|" + this.repJobSettingPage.DestPasswordText + "|"
                                                + this.repJobSettingPage.VMNameText + "|" + this.repJobSettingPage.Choice_sr_uuid + "|0|"
                                                + this.repJobSettingPage.MacText + "|" + this.repJobSettingPage.NetworkValue + "|"
                                                + Helpers.GetMaster(this.repJobSettingPage.Selected_xenConnection).address + "|" + this.repJobSettingPage.Selected_xenConnection.Username + "|"
                                                + this.repJobSettingPage.Selected_xenConnection.Password + "|" + this.repJobSettingPage.Selected_host.uuid + request_expend);
                        }
                        else
                        {
                            syncCheckedList.Add(this.repJobSettingPage.JobNameText + "|" + item.uuid + "|" + host_ip + "|"
                                                + this.repJobSettingPage.DestUsernameText + "|" + this.repJobSettingPage.DestPasswordText + "|"
                                                + dRepChecked[item.uuid] + "|" + Helpers.GetMaster(this.repJobSettingPage.Selected_xenConnection).address + "|"
                                                + this.repJobSettingPage.Selected_xenConnection.Username + "|" + this.repJobSettingPage.Selected_xenConnection.Password + request_expend);
                        }
                    }
                }
                _dconf_param_temp.Add(item.uuid, syncCheckedList);
                listParamTemp.Add(_dconf_param_temp);
            }

            BackupAction action = new BackupAction(Messages.COPY_VM, BackupRestoreConfig.BackupActionKind.Replication, this._xenModelObject, this.repChoseVmPage.VmCheckedList, _dconf, listParamTemp, this.repChoseVmPage.vdi_expand_list);

            if (action != null)
            {
                ProgressBarStyle     progressBarStyle = ProgressBarStyle.Marquee;
                ActionProgressDialog dialog           = new ActionProgressDialog(action, progressBarStyle);
                dialog.ShowCancel = false;
                dialog.ShowDialog(this);
                if (!action.Succeeded || !string.IsNullOrEmpty(action.Result))
                {
                    base.FinishCanceled();
                    //Program.MainWindow.BringToFront();
                    //e.PageIndex = e.PageIndex - 1;
                }
                else
                {
                    base.FinishWizard();
                }

                if (!(this._xenModelObject is Host))
                {
                    // todo Program.MainWindow.SwitchToTab(MainWindow.Tab.BR);
                    if (this._xenModelObject is VM)
                    {
                        VM vm = this._xenModelObject as VM;
                        vm.NotifyPropertyChanged("other_config");
                    }
                }
            }
        }
コード例 #17
0
        private void AddDisconnectedNode(TreeNode parent, int index, IXenConnection connection)
        {
            bool flag;

            this.AddNode(parent, index, HalsignHelpers.GetName(connection), Images.GetIconFor(connection), true, connection, out flag);
        }
コード例 #18
0
        private void AddVMNode(TreeNode parent, int index, VM vm)
        {
            bool flag;

            string os_name = vm.GetOSName().ToLowerInvariant();
            Icons  _icons;

            if (os_name.Contains("windows"))
            {
                _icons = Icons.Windows;
            }
            else if (os_name.Contains("debian"))
            {
                _icons = Icons.Debian;
            }
            else if (os_name.Contains("red"))
            {
                _icons = Icons.RHEL;
            }
            else if (os_name.Contains("cent"))
            {
                _icons = Icons.CentOS;
            }
            else if (os_name.Contains("oracle"))
            {
                _icons = Icons.Oracle;
            }
            else if (os_name.Contains("suse"))
            {
                _icons = Icons.SUSE;
            }
            else if (os_name.Contains("ubuntu"))
            {
                _icons = Icons.XenCenter;
            }
            else
            {
                _icons = Icons.XenCenter;
            }
            TreeNode node = this.AddNode(parent, index, vm.name_label, _icons, false, vm, out flag);

            int num = 0;

            foreach (VBD vbd in vm.Connection.ResolveAll <VBD>(vm.VBDs))
            {
                if (HalsignHelpers.IsCDROM(vbd))
                {
                    continue;
                }

                if (vbd.type.Equals(XenAPI.vbd_type.Disk))
                {
                    VDI vdi = vm.Connection.Resolve <VDI>(vbd.VDI);

                    //Add by dalei.shou on 2013/10/28, ignore the removable physical storage shown
                    SR sr = vm.Connection.Resolve <SR>(vdi.SR);
                    if (sr.IsRemovableStorage())
                    {
                        continue;
                    }

                    bool     expend;
                    TreeNode n = this.AddNode(node, num, vdi.name_label, Images.GetIconFor(vdi), false, vdi, out expend);
                    if (node.Checked == true)
                    {
                        n.Checked = true;
                    }
                    num++;
                }
            }
            if (node.Checked == true)
            {
                node.Expand();
            }
        }
コード例 #19
0
        /// <summary>
        /// 1. Check that how many VDIs were checked for replication
        /// 2. Check whether the vms on destination host have the same amount of vdis on destination host
        /// 3. Check whether the vdis have key "src_vdi_uuid"
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="index"></param>
        /// <param name="vms"></param>
        private void AddVmsToTree(TreeNode parent, ref int index, List <VM> vms)
        {
            VM[] vMs =
                this.selected_xenConnection.Cache.VMs.Where(
                    vm =>
                    (vm.uuid != null && vm.is_a_real_vm && HalsignHelpers.VMHome(vm) != null &&
                     HalsignHelpers.VMHome(vm) == this.selected_host)).ToArray();

            foreach (VM vm in vms)
            {
                TreeNode nodeSelectedVM = this.AddVMNodes(parent, index, vm);
                TreeNode newNode        = new TreeNode(Messages.NEW_REPLICATION);
                newNode.ImageIndex         = 999;
                newNode.SelectedImageIndex = 999;
                newNode.Tag     = "new";
                newNode.Checked = true;
                nodeSelectedVM.Nodes.Add(newNode);
                List <string> sourceVdiList = this.vdiCheckedDic[vm.uuid].Split(new string[] { "@" }, StringSplitOptions.RemoveEmptyEntries).ToList <string>();

                foreach (VM tempVm in vMs)
                {
                    bool isOperationAllowed = (!tempVm.is_a_template && HalsignHelpers.IsVMShow(tempVm) && tempVm.allowed_operations.Count > 0);
                    if (isOperationAllowed)
                    {
                        List <VDI> destVdiList = new List <VDI>();
                        foreach (VBD vbd in tempVm.Connection.ResolveAll <VBD>(tempVm.VBDs).ToArray())
                        {
                            if (HalsignHelpers.IsCDROM(vbd))
                            {
                                continue;
                            }
                            VDI vdi = tempVm.Connection.Resolve(vbd.VDI);
                            SR  sr  = tempVm.Connection.Resolve(vdi.SR);
                            if (vdi != null && vdi.Show(true) && !string.IsNullOrEmpty(vdi.uuid) && (sr != null && sr.uuid == this.selected_sr_uuid))
                            {
                                if (null != vdi.uuid && !vdi.uuid.Equals(""))
                                {
                                    destVdiList.Add(vdi);
                                }
                            }
                        }
                        if (sourceVdiList.Count == destVdiList.Count)
                        {
                            int vdiiNo = 0;
                            foreach (VDI vdii in destVdiList)
                            {
                                if (vdii.other_config.ContainsKey("src_vdi_uuid"))
                                {
                                    foreach (string uuid in sourceVdiList)
                                    {
                                        if (vdii.other_config["src_vdi_uuid"].Equals(uuid))
                                        {
                                            vdiiNo++;
                                        }
                                    }
                                }
                            }
                            if (vdiiNo == destVdiList.Count)
                            {
                                TreeNode nodeTemp = new TreeNode(tempVm.name_label);
                                nodeTemp.ImageIndex         = 999;
                                nodeTemp.SelectedImageIndex = 999;
                                nodeTemp.Tag = new ReplicatedVmState(tempVm.uuid, tempVm.power_state == vm_power_state.Running);
                                nodeSelectedVM.Nodes.Add(nodeTemp);
                            }
                        }
                    }
                }
                index++;
            }
        }
コード例 #20
0
        protected override void UpdateWizardContent(XenTabPage senderPage)
        {
            System.Type type = senderPage.GetType();
            if (type == typeof(BackupChoseVmPage))
            {
                Host _host = null;
                if (this._xenModelObject is VM)
                {
                    _host = HalsignHelpers.VMHome(this._xenModelObject as VM);
                }
                else if (this._xenModelObject is Host)
                {
                    _host = this._xenModelObject as Host;
                }
                if (_host != null)
                {
                    this.scheduleBackupPage.ServerDateText = Host.get_servertime(this._xenModelObject.Connection.Session, _host.opaque_ref).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss", DateTimeFormatInfo.InvariantInfo);
                }
                else
                {
                    this.scheduleBackupPage.ServerDateText = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss", DateTimeFormatInfo.InvariantInfo);
                }
            }
            else if (type == typeof(BackupOptionsPage))
            {
                this.summaryBackupPage._JobNameLable(this.optionsBackupPage._JobNameTextBox);
                if (String.IsNullOrEmpty(this.scheduleBackupPage._StrScheduleType))
                {
                    if (this.scheduleBackupPage.IsFullBackup)
                    {
                        this.summaryBackupPage._ScheduleTypeLabel(Messages.FULL_BACKUP_NOW);
                    }
                    else
                    {
                        this.summaryBackupPage._ScheduleTypeLabel(Messages.BACKUP_IMMEDIATELY);
                    }
                }
                else
                {
                    if (this.scheduleBackupPage.IsFullBackup)
                    {
                        this.summaryBackupPage._ScheduleTypeLabel(Messages.FULL_BACKUP_ONCE);
                    }
                    else if (this.scheduleBackupPage._StrScheduleType.Equals("Once"))
                    {
                        this.summaryBackupPage._ScheduleTypeLabel(Messages.BACKUP_ONCE);
                    }
                    else
                    {
                        if (this.scheduleBackupPage._StrScheduleType.Equals("Daily"))
                        {
                            this.summaryBackupPage._ScheduleTypeLabel(Messages.BACKUP_DAILY);
                        }
                        else if (this.scheduleBackupPage._StrScheduleType.Equals("Weekly"))
                        {
                            this.summaryBackupPage._ScheduleTypeLabel(Messages.BACKUP_WEEKLY);
                        }
                        else
                        {
                            this.summaryBackupPage._ScheduleTypeLabel(Messages.BACKUP_CIRCLE);
                        }

                        if (this.scheduleBackupPage._expectFullCheckBox)
                        {
                            this.summaryBackupPage.Options = string.Format(Messages.FULL_BACKUP_RECURS_EVERY, this.scheduleBackupPage._expectFullCountTextBox);
                        }
                    }
                    //this.summaryBackupPage._ScheduleTypeLabel(this.scheduleBackupPage._StrScheduleType);
                }
            }
        }
コード例 #21
0
ファイル: RestoreWizard.cs プロジェクト: yimng/xenconsole
        /// <summary>
        /// Update by Dalei.Shou on 2013/8/16, remove the last "|0" parameter
        /// </summary>
        private void ScheduleRestoreJob()
        {
            int rowCount = this.page_VMSettings.DataGridViewRestoreInfo.RowCount;

            for (int i = 0; i < this.page_VMSettings.DataGridViewRestoreInfo.RowCount; i++)
            {
                if (this.page_VMSettings.DataGridViewRestoreInfo.Rows[i].Cells[0].Value.ToString().ToLowerInvariant() == "true")
                {
                    string[] uuidTag = this.page_VMSettings.DataGridViewRestoreInfo.Rows[i].Tag.ToString().Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                    if (!restore_vdi_list.ContainsKey(uuidTag[0]))
                    {
                        restore_vdi_list.Add(uuidTag[0], uuidTag[1]);
                    }
                    else
                    {
                        string temp = string.Concat(restore_vdi_list[uuidTag[0]], "@", uuidTag[1]);
                        restore_vdi_list[uuidTag[0]] = temp;
                    }
                }
            }
            List <string> list = new List <string>();
            List <Dictionary <string, string> > listSchedule = new List <Dictionary <string, string> >();
            string schedule     = "";
            int    milliseconds = 0;

            foreach (AgentParamDataModel item in this.vmCheckedList)
            {
                string uuid_spend = "|";
                if (restore_vdi_list.ContainsKey(item.VMRestoreInfo.Substring(37, 36)))
                {
                    int l = restore_vdi_list[item.VMRestoreInfo.Substring(37, 36)].Split('@').Length;
                    if (l == 1)
                    {
                        uuid_spend += "halsign_vdi_all";
                    }
                    else
                    {
                        if (l - 1 == restore_vdi_info_list[item.VMRestoreInfo].Count)
                        {
                            uuid_spend += "halsign_vdi_all";
                        }
                        else if (l - 1 < restore_vdi_info_list[item.VMRestoreInfo].Count)
                        {
                            for (int y = 1; y < l; y++)
                            {
                                if (y == 1)
                                {
                                    uuid_spend = uuid_spend + restore_vdi_list[item.VMRestoreInfo.Substring(37, 36)].Split('@')[y];
                                }
                                else
                                {
                                    uuid_spend = uuid_spend + "@" +
                                                 restore_vdi_list[item.VMRestoreInfo.Substring(37, 36)].Split('@')[y];
                                }
                            }
                        }
                    }
                }

                list.Add(this.restore_job_name.TrimEnd().TrimStart() + "|" + this.set_storage_ip.Trim() + "|"
                         + this.set_storage_username + "|" + this.set_storage_password + "|" + item.RootPath + "|" +
                         item.VMRestoreInfo + "|"
                         + this.restore_vm_name + "|" + this.restoreDataModel.choice_sr_uuid + "|"
                         + (this._isBackupNetworkSettingChecked ? "1" : "0") + "|" +
                         (this._isNewMacAddressChecked ? "1" : "0")
                         + "|" + this.restore_network_uuid + uuid_spend);

                if (this._isOnceScheduleChecked)
                {
                    Dictionary <string, string> dconfTemp = new Dictionary <string, string>();
                    BackupRestoreConfig.Job     job       = new BackupRestoreConfig.Job();
                    job.job_name = this.restore_job_name.TrimEnd().TrimStart();

                    if (this._xenModelObject is VM)
                    {
                        VM _xenVM = this._xenModelObject as VM;
                        job.host = HalsignHelpers.VMHome(_xenVM).uuid;
                    }
                    else if (this._xenModelObject is Host)
                    {
                        Host _xenHost = _xenModelObject as Host;
                        job.host = _xenHost.uuid;
                    }
                    else
                    {
                        job.host = Helpers.GetMaster(this._xenModelObject.Connection).uuid;
                    }

                    TimeSpan ts = DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1, 0, 0, 0, 0));
                    job.key = "halsign_br_job_s_" + (Math.Floor(ts.TotalMilliseconds) + milliseconds++);

                    job.request = "o" + this.restore_job_name.TrimEnd().TrimStart() + "|" + this.set_storage_ip.Trim() +
                                  "|" + this.set_storage_username + "|" + this.set_storage_password + "|" +
                                  item.RootPath +
                                  "|" + item.VMRestoreInfo + "|" + restore_vm_name + "|" +
                                  this.restoreDataModel.choice_sr_uuid + "|"
                                  + (this._isBackupNetworkSettingChecked ? "1" : "0") + "|" +
                                  (this._isNewMacAddressChecked ? "1" : "0") + "|" + this.restore_network_uuid +
                                  uuid_spend;
                    ts = new DateTime(this.scheduleDate.Year, this.scheduleDate.Month, this.scheduleDate.Day, this.scheduleTime.Hour, this.scheduleTime.Minute,
                                      this.scheduleTime.Second).Subtract(new DateTime(1970, 1, 1, 0, 0, 0).ToLocalTime());
                    job.start_time    = Math.Floor(ts.TotalSeconds).ToString();
                    job.progress      = -1;
                    job.total_storage = -1;
                    job.modify_time   = "";
                    job.pid           = -1;
                    job.retry         = -1;
                    job.speed         = -1;
                    job.status        = 0;
                    schedule          = HalsignUtil.ToJson(job);
                    schedule          = schedule.Replace("\\/", "/");
                    dconfTemp.Add("schedule", schedule);
                    dconfTemp.Add("config_name", job.key);
                    listSchedule.Add(dconfTemp);
                }
            }

            BackupAction action = new BackupAction(_Message, BackupRestoreConfig.BackupActionKind.Restore, this._xenModelObject, list, listSchedule);

            if (action != null)
            {
                ProgressBarStyle     progressBarStyle = ProgressBarStyle.Marquee;
                ActionProgressDialog dialog           = new ActionProgressDialog(action, progressBarStyle);
                dialog.ShowCancel = false;
                dialog.ShowDialog(this);
                try
                {
                    if (!string.IsNullOrEmpty(action.Result))
                    {
                        Program.MainWindow.BringToFront();
                    }
                }
                catch
                {
                    Program.MainWindow.BringToFront();
                }
            }
        }