Example #1
0
 public Page_JobSettings(IXenObject XenModelObject)
 {
     InitializeComponent();
     this.resotreDataModel = new RestoreDataModel();
     this._xenModelObject  = XenModelObject;
     this.InitStorageGridList();
     this.InitNetworkListBox();
 }
Example #2
0
        /// <summary>
        /// update by dalei.shou on 2013/10/29, remove the code that does not make sense
        /// Each row with tag: vm.uuid|vdi.uuid
        /// </summary>
        /// <param name="vmCheckedList"></param>
        /// <param name="backup_info_list"></param>
        /// <param name="vm_name"></param>
        /// <param name="network_name"></param>
        /// <param name="restoreDataModel"></param>
        /// <param name="restore_vdi_info_list"></param>
        public void BuildRestoreInfoList(List <AgentParamDataModel> vmCheckedList, Dictionary <string, string> backup_info_list, string vm_name, string network_name, RestoreDataModel restoreDataModel, Dictionary <string, List <BackupRestoreConfig.RestoreInfo> > restore_vdi_info_list)
        {
            long restore_size = 0;

            this.DataGridView_RestoreInfo.Rows.Clear();

            int i = 0;

            foreach (AgentParamDataModel _vm in vmCheckedList)
            {
                if (!backup_info_list.ContainsKey(_vm.VMRestoreInfo))
                {
                    continue;
                }
                this.DataGridView_RestoreInfo.Rows.Add();
                this.DataGridView_RestoreInfo.Rows[i].Cells[0].Value = true;
                this.DataGridView_RestoreInfo.Rows[i].Cells[0].Tag   = "vm";
                string[] strTemp = backup_info_list[_vm.VMRestoreInfo].Split('|');
                this.DataGridView_RestoreInfo.Rows[i].DefaultCellStyle.BackColor = Color.LightGray;
                string _vm_name;
                string _os_version;
                this.ParseVMInfo(strTemp[1], out _vm_name, out _os_version);
                this.DataGridView_RestoreInfo.Rows[i].Cells[1].Value = _vm_name;
                this.DataGridView_RestoreInfo.Rows[i].Cells[2].Value = vm_name;
                this.DataGridView_RestoreInfo.Rows[i].Cells[4].Value = network_name;;
                this.DataGridView_RestoreInfo.Rows[i].Cells[5].Value = restoreDataModel.choice_sr_ip_name;
                this.DataGridView_RestoreInfo.Rows[i].Cells[6].Value = restoreDataModel.choice_sr_free_space;
                this.DataGridView_RestoreInfo.Rows[i].Tag            = string.Format("{0}|{1}", _vm.VMRestoreInfo.Substring(37, 36), _vm.VMRestoreInfo.Substring(37, 36));

                string[]        strDisk  = strTemp[0].Split('\n');
                List <DiskInfo> diskList = new List <DiskInfo>();
                DiskInfo        _disk_info;
                foreach (string item in strDisk)
                {
                    if (item.IndexOf(".Name") > 0)
                    {
                        _disk_info      = new DiskInfo();
                        _disk_info.name = item.Split('=')[1];
                        foreach (string _storage in strDisk)
                        {
                            if (_storage.IndexOf(item.Split('.')[0] + ".Storage") >= 0)
                            {
                                _disk_info.value = _storage.Split('=')[1];
                            }
                        }
                        diskList.Add(_disk_info);
                    }
                }

                if (!restore_vdi_info_list.ContainsKey(_vm.VMRestoreInfo))
                {
                    long count = 0;
                    foreach (DiskInfo _value in diskList)
                    {
                        count = count + long.Parse(_value.value);
                    }
                    this.DataGridView_RestoreInfo.Rows[i].Cells[3].Value = Util.DiskSizeString(count);
                    i++;
                    continue;
                }

                i++;

                foreach (BackupRestoreConfig.RestoreInfo info in restore_vdi_info_list[_vm.VMRestoreInfo])
                {
                    this.DataGridView_RestoreInfo.Rows.Add();
                    this.DataGridView_RestoreInfo.Rows[i].Cells[0].Value             = true;
                    this.DataGridView_RestoreInfo.Rows[i].DefaultCellStyle.BackColor = Color.LightYellow;
                    this.DataGridView_RestoreInfo.Rows[i].Cells[1].Value             = info.name;
                    this.DataGridView_RestoreInfo.Rows[i].Cells[3].Value             = Util.DiskSizeString(long.Parse(info.storage));
                    this.DataGridView_RestoreInfo.Rows[i].Cells[5].Value             = restoreDataModel.choice_sr_ip_name;
                    this.DataGridView_RestoreInfo.Rows[i].Cells[6].Value             = restoreDataModel.choice_sr_free_space;
                    this.DataGridView_RestoreInfo.Rows[i].Tag = string.Format("{0}|{1}", _vm.VMRestoreInfo.Substring(37, 36), info.uuid);
                    i++;
                }
            }

            if (restore_size > restoreDataModel.choice_sr_free_space_size)
            {
                this.Label_Warnning.Visible = true;
                base.OnPageUpdated();
            }
            else
            {
                this.Label_Warnning.Visible = false;
                base.OnPageUpdated();
            }
        }