private void EditButton_Click(object sender, EventArgs e) { if (DisksGridView.SelectedRows.Count <= 0) { return; } DiskGridRowItem selectedItem = (DiskGridRowItem)DisksGridView.SelectedRows[0]; using (var dialog = new NewDiskDialog(Connection, Template, Affinity, SrPicker.SRPickerType.LunPerVDI, selectedItem.Disk, selectedItem.CanResize, selectedItem.MinSize, AddedVDIs) { DontCreateVDI = true }) { if (dialog.ShowDialog(ParentForm) != DialogResult.OK) { return; } selectedItem.Disk = dialog.NewDisk(); selectedItem.UpdateDetails(); UpdateStatusForEachDisk(); UpdateEnablement(); } }
private void PropertiesButton_Click(object sender, EventArgs e) { if (DisksGridView.SelectedRows.Count <= 0) { return; } DiskGridRowItem selectedItem = ((DiskGridRowItem)DisksGridView.SelectedRows[0]); NewDiskDialog dialog = new NewDiskDialog(Connection, Template, SrPicker.SRPickerType.LunPerVDI, selectedItem.Disk, Affinity, selectedItem.CanResize, selectedItem.MinSize, AddedVDIs); dialog.DontCreateVDI = true; if (dialog.ShowDialog() != DialogResult.OK) { return; } selectedItem.Disk = dialog.NewDisk(); selectedItem.UpdateDetails(); UpdateEnablement(); }
private void LoadDisks() { DisksGridView.Rows.Clear(); var rowList = new List <DataGridViewRow>(); XmlNode provision = Template.ProvisionXml(); if (provision != null) { foreach (XmlNode diskNode in provision.ChildNodes) { var device = new VBD { userdevice = diskNode.Attributes["device"].Value, bootable = diskNode.Attributes["bootable"].Value == "true", mode = vbd_mode.RW }; var diskSize = long.Parse(diskNode.Attributes["size"].Value); SR srUuid = Connection.Cache.Find_By_Uuid <SR>(diskNode.Attributes["sr"].Value); SR sr = GetBestDiskStorage(Connection, diskSize, Affinity, srUuid, out Image icon, out string tooltip); var disk = new VDI { name_label = string.Format(Messages.STRING_SPACE_STRING, SelectedName, device.userdevice), name_description = Messages.NEWVMWIZARD_STORAGEPAGE_DISK_DESCRIPTION, virtual_size = diskSize, type = (vdi_type)Enum.Parse(typeof(vdi_type), diskNode.Attributes["type"].Value), read_only = false, SR = new XenRef <SR>(sr != null ? sr.opaque_ref : Helper.NullOpaqueRef) }; var row = new DiskGridRowItem(Connection, disk, device, DiskSource.FromDefaultTemplate); row.UpdateStatus(icon, tooltip); rowList.Add(row); } } else { var vbds = Connection.ResolveAll(Template.VBDs); foreach (VBD vbd in vbds) { if (vbd.type != vbd_type.Disk) { continue; } VDI vdi = Connection.Resolve(vbd.VDI); if (vdi == null) { continue; } var sourceSr = Connection.Resolve(vdi.SR); var device = new VBD { userdevice = vbd.userdevice, bootable = vbd.bootable, mode = vbd.mode }; SR sr = GetBestDiskStorage(Connection, vdi.virtual_size, Affinity, Connection.Resolve(vdi.SR), out Image icon, out string tooltip); var disk = new VDI { name_label = vdi.name_label, name_description = vdi.name_description, virtual_size = vdi.virtual_size, type = vdi.type, read_only = vdi.read_only, sm_config = vdi.sm_config, SR = new XenRef <SR>(sr != null ? sr.opaque_ref : Helper.NullOpaqueRef) }; var row = new DiskGridRowItem(Connection, disk, device, DiskSource.FromCustomTemplate, sourceSr); row.UpdateStatus(icon, tooltip); rowList.Add(row); } } DisksGridView.Rows.AddRange(rowList.ToArray()); UpdateStatusForEachDisk(true); }