Beispiel #1
0
 public GpuAssignAction(VM vm, GPU_group gpu_group, VGPU_type vgpuType)
     : base(vm.Connection, "Set GPU", true)
 {
     this.vm = vm;
     this.gpu_group = gpu_group;
     this.vgpuType = vgpuType;
 }
 public GpuAssignAction(VM vm, GPU_group gpu_group, VGPU_type vgpuType)
     : base(vm.Connection, "Set GPU", true)
 {
     this.vm        = vm;
     this.gpu_group = gpu_group;
     this.vgpuType  = vgpuType;
 }
Beispiel #3
0
        private void addButton_Click(object sender, EventArgs e)
        {
            using (var dialog = new AddVGPUDialog(vm, VGpus))
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    var tuple = dialog.SelectedTuple;
                    if (tuple == null)
                    {
                        return;
                    }

                    VGPU_type type = tuple.VgpuTypes[0];
                    // Set vGPU device to null. vGPU creation will check whether a valid device is assigned
                    // to the vGPU, if not then 0 is used to declare the first availabe slot in VM
                    var vGpu = new VGPU();
                    vGpu.device     = null;
                    vGpu.GPU_group  = new XenRef <GPU_group>(tuple.GpuGroup.opaque_ref);
                    vGpu.type       = new XenRef <VGPU_type>(type.opaque_ref);
                    vGpu.Connection = vm.Connection;
                    gpuGrid.Rows.Add(new VGpuDetailRow(vGpu));
                    warningsTable.SuspendLayout();
                    ShowHideWarnings();
                    warningsTable.ResumeLayout();
                }
            }
        }
Beispiel #4
0
        public VGpuDetailWithCheckBoxRow(XenRef <VGPU_type> vGpuTypeRef, VGPU_type vGpuType, bool allowed, bool isInUse)
        {
            VGpuTypeRef  = vGpuTypeRef;
            VGpuType     = vGpuType;
            this.allowed = allowed;
            this.isInUse = isInUse;

            Cells.AddRange(checkBoxCell, nameColumn, vGpusPerGpuColumn, videoRamColumn);
            SetCells();
        }
Beispiel #5
0
        public VGpuTypeRow(VGPU_type vGpuType, bool enabledType)
        {
            VGpuType    = vGpuType;
            EnabledType = enabledType;

            Cells.AddRange(ImageCell,
                           NameCell);

            UpdateDetails();
        }
Beispiel #6
0
        public VGpuDetailWithCheckBoxRow(XenRef <VGPU_type> vGpuTypeRef, VGPU_type vGpuType, bool allowed, bool isInUse)
        {
            VGpuTypeRef  = vGpuTypeRef;
            VGpuType     = vGpuType;
            this.allowed = allowed;
            IsReadOnly   = isInUse && allowed;

            SetCells();
            Cells.AddRange(checkBoxCell, nameColumn, vGpusPerGpuColumn, maxResolutionColumn, maxDisplaysColumn, videoRamColumn);
            SetupCheckBoxCell();
        }
Beispiel #7
0
        public override void PopulatePage()
        {
            currentGpuTuple = new GpuTuple(null, null, null);

            if (vm.VGPUs.Count != 0)
            {
                VGPU vgpu = Connection.Resolve(vm.VGPUs[0]);
                if (vgpu != null)
                {
                    var vgpuGroup = Connection.Resolve(vgpu.GPU_group);

                    if (Helpers.FeatureForbidden(Connection, Host.RestrictVgpu) || !vm.CanHaveVGpu())
                    {
                        if (vgpuGroup.HasPassthrough())
                        {
                            currentGpuTuple = new GpuTuple(vgpuGroup, null, null); //GPU pass-through item
                        }
                    }
                    else
                    {
                        VGPU_type vgpuType = Connection.Resolve(vgpu.type);
                        currentGpuTuple = new GpuTuple(vgpuGroup, vgpuType, null);
                    }
                }
            }

            // vGPU was introduced in Clearwater SP1
            gpu_groups = !Helpers.ClearwaterSp1OrGreater(Connection) //We used to check host.RestrictVgpu here (instead of checking the API version); this is not correct anymore, because vGPU is a licensed feature.
                 ? Connection.Cache.GPU_groups
                 : Connection.Cache.GPU_groups.Where(g => g.PGPUs.Count > 0 && g.supported_VGPU_types.Count != 0).ToArray();
            //not showing empty groups

            gpusAvailable = gpu_groups.Length > 0;

            if (gpusAvailable)
            {
                PopulateComboBox();
                ShowHideWarnings();
            }
            else
            {
                labelRubric.Text = Helpers.GetPool(Connection) == null
                                       ? Messages.GPU_RUBRIC_NO_GPUS_SERVER
                                       : Messages.GPU_RUBRIC_NO_GPUS_POOL;

                tableLayoutPanel1.Visible = false;
                warningsTable.Visible     = false;
            }
        }
Beispiel #8
0
 /// <summary>
 /// Create a GpuTuple that refers to a vGPU type which is a subitem of a GPU group
 /// </summary>
 public GpuTuple(GPU_group gpuGroup, VGPU_type vgpuType, VGPU_type[] disabledVGpuTypes)
 {
     GpuGroup  = gpuGroup;
     VgpuTypes = vgpuType == null ? null : new[] { vgpuType };
     if (vgpuType != null)
     {
         IsVgpuSubitem    = gpuGroup.HasVGpu();
         IsFractionalVgpu = !vgpuType.IsPassthrough();
         if (disabledVGpuTypes != null && disabledVGpuTypes.Select(t => t.opaque_ref).Contains(vgpuType.opaque_ref))
         {
             IsNotEnabledVgpu = true;
         }
     }
     UpdateDisplayName();
 }
Beispiel #9
0
 /// <summary>
 /// Create a GpuTuple that refers to a vGPU type which is a subitem of a GPU group
 /// </summary>
 public GpuTuple(GPU_group gpuGroup, VGPU_type vgpuType, VGPU_type[] disabledVGpuTypes)
 {
     GpuGroup  = gpuGroup;
     VgpuTypes = vgpuType == null ? null : new[] { vgpuType };
     if (vgpuType != null)
     {
         IsVgpuSubitem    = gpuGroup.supported_VGPU_types.Count > 1;
         IsFractionalVgpu = vgpuType.max_heads != 0;
         if (disabledVGpuTypes != null && disabledVGpuTypes.Select(t => t.opaque_ref).Contains(vgpuType.opaque_ref))
         {
             IsNotEnabledVgpu = true;
         }
     }
     UpdateDisplayName();
 }
Beispiel #10
0
        /// <summary>
        /// Create a GpuTuple that refers to a vGPU type which is a sub-item of a GPU group
        /// </summary>
        public GpuTuple(GPU_group gpuGroup, VGPU_type vgpuType, VGPU_type[] disabledVGpuTypes)
        {
            GpuGroup  = gpuGroup;
            VgpuTypes = vgpuType == null ? null : new[] { vgpuType };
            if (vgpuType != null)
            {
                IsVgpuSubitem = gpuGroup.HasVGpu();

                if (disabledVGpuTypes != null && disabledVGpuTypes.Select(t => t.opaque_ref).Contains(vgpuType.opaque_ref))
                {
                    Enabled = false;
                }
            }
            UpdateDisplayName();
        }
Beispiel #11
0
        public override void PopulatePage()
        {
            currentGpuTuple = new GpuTuple(null, null, null);

            if (vm.VGPUs.Count != 0)
            {
                VGPU vgpu = Connection.Resolve(vm.VGPUs[0]);
                if (vgpu != null)
                {
                    var vgpuGroup = Connection.Resolve(vgpu.GPU_group);

                    if (Helpers.FeatureForbidden(Connection, Host.RestrictVgpu) || !vm.CanHaveVGpu())
                    {
                        if (vgpuGroup.HasPassthrough())
                        {
                            currentGpuTuple = new GpuTuple(vgpuGroup, null, null); //GPU pass-through item
                        }
                    }
                    else
                    {
                        VGPU_type vgpuType = Connection.Resolve(vgpu.type);
                        currentGpuTuple = new GpuTuple(vgpuGroup, vgpuType, null);
                    }
                }
            }

            gpu_groups = Connection.Cache.GPU_groups.Where(g => g.PGPUs.Count > 0 && g.supported_VGPU_types.Count != 0).ToArray();
            //not showing empty groups

            gpusAvailable = gpu_groups.Length > 0;

            if (gpusAvailable)
            {
                PopulateComboBox();
                ShowHideWarnings();
            }
            else
            {
                labelRubric.Text = Helpers.GetPool(Connection) == null
                                       ? Messages.GPU_RUBRIC_NO_GPUS_SERVER
                                       : Messages.GPU_RUBRIC_NO_GPUS_POOL;

                tableLayoutPanel1.Visible = false;
                warningsTable.Visible     = false;
            }
        }
Beispiel #12
0
        private void AddGpu(GPU_group gpuGroup, VGPU_type vGpuType, string device = "0")
        {
            if (gpuGroup == null)
            {
                return;
            }

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

            if (Helpers.FeatureForbidden(vm, Host.RestrictVgpu) || vGpuType == null)
            {
                VGPU.async_create(Session, vm.opaque_ref, gpuGroup.opaque_ref, device, other_config);
            }
            else
            {
                VGPU.async_create(Session, vm.opaque_ref, gpuGroup.opaque_ref, device,
                                  other_config, vGpuType.opaque_ref);
            }
        }
Beispiel #13
0
        private void addButton_Click(object sender, EventArgs e)
        {
            using (var dialog = new AddVGPUDialog(vm, VGpus))
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    var tuple = dialog.SelectedTuple;
                    if (tuple == null)
                    {
                        return;
                    }

                    VGPU_type type = tuple.VgpuTypes[0];
                    var       vGpu = new VGPU();
                    vGpu.GPU_group  = new XenRef <GPU_group>(tuple.GpuGroup.opaque_ref);
                    vGpu.type       = new XenRef <VGPU_type>(type.opaque_ref);
                    vGpu.Connection = vm.Connection;
                    gpuGrid.Rows.Add(new VGpuDetailRow(vGpu));
                    warningsTable.SuspendLayout();
                    ShowHideWarnings();
                    warningsTable.ResumeLayout();
                }
            }
        }
Beispiel #14
0
        public CreateVMAction(IXenConnection connection, VM template, Host copyBiosStringsFrom,
            string name, string description, InstallMethod installMethod,
            string pvArgs, VDI cd, string url, Host homeServer, long vcpus,
            long memoryDynamicMin, long memoryDynamicMax, long memoryStaticMax,
            List<DiskDescription> disks, SR fullCopySR, List<VIF> vifs, bool startAfter,
            Action<VM, bool> warningDialogHAInvalidConfig,
            Action<VMStartAbstractAction, Failure> startDiagnosisForm,
            GPU_group gpuGroup, VGPU_type vgpuType, long coresPerSocket, string cloudConfigDriveTemplateText)
            : base(connection, string.Format(Messages.CREATE_VM, name),
            string.Format(Messages.CREATE_VM_FROM_TEMPLATE, name, Helpers.GetName(template)))
        {
            Template = template;
            CopyBiosStringsFrom = copyBiosStringsFrom;
            FullCopySR = fullCopySR;
            NameLabel = name;
            NameDescription = description;
            InsMethod = installMethod;
            PvArgs = pvArgs;
            Cd = cd;
            Url = url;
            HomeServer = homeServer;
            Vcpus = vcpus;
            MemoryDynamicMin = memoryDynamicMin;
            MemoryDynamicMax = memoryDynamicMax;
            MemoryStaticMax = memoryStaticMax;
            Disks = disks;
            Vifs = vifs;
            StartAfter = startAfter;
            _warningDialogHAInvalidConfig = warningDialogHAInvalidConfig;
            _startDiagnosisForm = startDiagnosisForm;
            GpuGroup = gpuGroup;
            VgpuType = vgpuType;
            CoresPerSocket = coresPerSocket;
            this.cloudConfigDriveTemplateText = cloudConfigDriveTemplateText;

            Pool pool_of_one = Helpers.GetPoolOfOne(Connection);
            if (HomeServer != null || pool_of_one != null) // otherwise we have no where to put the action
                AppliesTo.Add(HomeServer != null ? HomeServer.opaque_ref : pool_of_one.opaque_ref);

            assignOrRemoveVgpu = (GpuGroup != null && VgpuType != null)
                             || Helpers.GpuCapability(Connection);

            #region RBAC Dependencies

            if (StartAfter)
                ApiMethodsToRoleCheck.Add("vm.start");
            if (HomeServerChanged())
                ApiMethodsToRoleCheck.Add("vm.set_affinity");
            if (Template.memory_dynamic_min != MemoryDynamicMin || Template.memory_dynamic_max != MemoryDynamicMax || Template.memory_static_max != MemoryStaticMax)
                ApiMethodsToRoleCheck.Add("vm.set_memory_limits");

            if (assignOrRemoveVgpu)
            {
                ApiMethodsToRoleCheck.Add("VGPU.destroy");
                ApiMethodsToRoleCheck.Add("VGPU.create");
            }

            ApiMethodsToRoleCheck.AddRange(StaticRBACDependencies);

            ApiMethodsToRoleCheck.AddRange(Role.CommonTaskApiList);
            ApiMethodsToRoleCheck.AddRange(Role.CommonSessionApiList);

            #endregion
        }
Beispiel #15
0
        public CreateVMAction(IXenConnection connection, VM template, Host copyBiosStringsFrom,
                              string name, string description, InstallMethod installMethod,
                              string pvArgs, VDI cd, string url, Host homeServer, long vcpusMax, long vcpusAtStartup,
                              long memoryDynamicMin, long memoryDynamicMax, long memoryStaticMax,
                              List <DiskDescription> disks, SR fullCopySR, List <VIF> vifs, bool startAfter,
                              Action <VM, bool> warningDialogHAInvalidConfig,
                              Action <VMStartAbstractAction, Failure> startDiagnosisForm,
                              GPU_group gpuGroup, VGPU_type vgpuType, bool modifyVgpuSettings, long coresPerSocket, string cloudConfigDriveTemplateText)
            : base(connection, string.Format(Messages.CREATE_VM, name),
                   string.Format(Messages.CREATE_VM_FROM_TEMPLATE, name, Helpers.GetName(template)))
        {
            Template            = template;
            CopyBiosStringsFrom = copyBiosStringsFrom;
            FullCopySR          = fullCopySR;
            NameLabel           = name;
            NameDescription     = description;
            InsMethod           = installMethod;
            PvArgs           = pvArgs;
            Cd               = cd;
            Url              = url;
            HomeServer       = homeServer;
            VcpusMax         = vcpusMax;
            VcpusAtStartup   = vcpusAtStartup;
            MemoryDynamicMin = memoryDynamicMin;
            MemoryDynamicMax = memoryDynamicMax;
            MemoryStaticMax  = memoryStaticMax;
            Disks            = disks;
            Vifs             = vifs;
            StartAfter       = startAfter;
            _warningDialogHAInvalidConfig = warningDialogHAInvalidConfig;
            _startDiagnosisForm           = startDiagnosisForm;
            GpuGroup       = gpuGroup;
            VgpuType       = vgpuType;
            CoresPerSocket = coresPerSocket;
            this.cloudConfigDriveTemplateText = cloudConfigDriveTemplateText;

            Pool pool_of_one = Helpers.GetPoolOfOne(Connection);

            if (HomeServer != null || pool_of_one != null) // otherwise we have no where to put the action
            {
                AppliesTo.Add(HomeServer != null ? HomeServer.opaque_ref : pool_of_one.opaque_ref);
            }

            assignOrRemoveVgpu = GpuGroup != null && VgpuType != null || modifyVgpuSettings && Helpers.GpuCapability(Connection);

            #region RBAC Dependencies

            if (StartAfter)
            {
                ApiMethodsToRoleCheck.Add("vm.start");
            }
            if (HomeServerChanged())
            {
                ApiMethodsToRoleCheck.Add("vm.set_affinity");
            }
            if (Template.memory_dynamic_min != MemoryDynamicMin || Template.memory_dynamic_max != MemoryDynamicMax || Template.memory_static_max != MemoryStaticMax)
            {
                ApiMethodsToRoleCheck.Add("vm.set_memory_limits");
            }

            if (assignOrRemoveVgpu)
            {
                ApiMethodsToRoleCheck.Add("VGPU.destroy");
                ApiMethodsToRoleCheck.Add("VGPU.create");
            }

            ApiMethodsToRoleCheck.AddRange(StaticRBACDependencies);

            ApiMethodsToRoleCheck.AddRange(Role.CommonTaskApiList);
            ApiMethodsToRoleCheck.AddRange(Role.CommonSessionApiList);

            #endregion
        }
Beispiel #16
0
        private EnvelopeType _export(Session xenSession, string targetPath, string ovfname, string vmUuid)
        {
            EnvelopeType ovfEnv;

            try
            {
                auditLog.DebugFormat("Export: {0}, {1}", ovfname, targetPath);

                #region GET VM Reference
                XenRef <VM> vmRef = null;

                try
                {
                    vmRef = VM.get_by_uuid(xenSession, vmUuid);
                }
                catch
                {
                    log.WarnFormat("VM not found as uuid: {0}, trying as name-label", vmUuid);
                    vmRef = null;
                }
                if (vmRef == null)
                {
                    try
                    {
                        List <XenRef <VM> > vmRefs = VM.get_by_name_label(xenSession, vmUuid);
                        vmRef = vmRefs[0];
                        traceLog.DebugFormat("{0} VM(s) found by label {1}", vmRefs.Count, vmUuid);
                        if (vmRefs.Count > 1)
                        {
                            log.WarnFormat("Only exporting FIRST VM with name {0}", vmUuid);
                        }
                    }
                    catch
                    {
                        log.ErrorFormat(Messages.ERROR_VM_NOT_FOUND, vmUuid);
                        throw;
                    }
                }
                #endregion

                VM vm = VM.get_record(xenSession, vmRef);

                if (vm.power_state != vm_power_state.Halted && vm.power_state != vm_power_state.Suspended)
                {
                    var message = string.Format(Messages.ERROR_VM_NOT_HALTED, vm.Name());
                    OnUpdate(new XenOvfTranportEventArgs(XenOvfTranportEventType.ExportProgress, "Export", message));
                    log.Info(message);
                    throw new Exception(message);
                }

                #region CREATE ENVELOPE / ADD VIRTUAL SYSTEM
                ovfEnv = OVF.CreateEnvelope(ovfname);
                string vsId  = OVF.AddVirtualSystem(ovfEnv, vm.name_label);
                string vhsId = OVF.AddVirtualHardwareSection(ovfEnv, vsId);
                #endregion

                #region TRY TO ID OS
                XenRef <VM_guest_metrics> vmgmRef = VM.get_guest_metrics(xenSession, vmRef);
                if (!vmgmRef.opaque_ref.ToUpper().Contains("NULL"))
                {
                    VM_guest_metrics vmgm = VM_guest_metrics.get_record(xenSession, vmgmRef);
                    //VM_metrics vmm = VM_metrics.get_record(xenSession, VM.get_metrics(xenSession, vmRef));
                    if (vmgm.os_version != null && vmgm.os_version.Count > 0)
                    {
                        foreach (string key in vmgm.os_version.Keys)
                        {
                            if (key.ToLower().Equals("name"))
                            {
                                ushort osid = ValueMaps.OperatingSystem(vmgm.os_version[key]);
                                if (osid == 0xFFFF)
                                {
                                    osid = 1;
                                }                                 // change to OTHER since search failed.
                                string version = OVF.GetContentMessage("SECTION_OPERATINGSYSTEM_INFO");
                                if (vmgm.os_version.ContainsKey("major") &&
                                    vmgm.os_version.ContainsKey("minor"))
                                {
                                    version = string.Format(OVF.GetContentMessage("SECTION_OPERATINGSYSTEM_VERSION"), vmgm.os_version["major"], vmgm.os_version["minor"]);
                                }
                                string osname = (vmgm.os_version[key].Split(new [] { '|' }))[0];
                                OVF.UpdateOperatingSystemSection(ovfEnv, vsId, osname, version, osid);
                                break;
                            }
                        }
                    }
                }
                #endregion

                #region ADD VSSD
                // IS PV'd? for VirtualSystemType identification.
                string typeformat = @"{0}-{1}-{2}";
                string vmtype     = string.Format(typeformat, "hvm", "3.0", "unknown");
                if (vm.HVM_boot_policy != null && vm.HVM_boot_policy == Properties.Settings.Default.xenBootOptions)
                {
                    if (!string.IsNullOrEmpty(vm.domarch))
                    {
                        vmtype = string.Format(typeformat, vm.domarch, "3.0", "unknown");
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(vm.domarch))
                    {
                        vmtype = string.Format(typeformat, "xen", "3.0", vm.domarch);
                    }
                    else
                    {
                        vmtype = string.Format(typeformat, "xen", "3.0", "unknown");
                    }
                }
                OVF.AddVirtualSystemSettingData(ovfEnv, vsId, vhsId, vm.name_label, OVF.GetContentMessage("VSSD_CAPTION"), vm.name_description, Guid.NewGuid().ToString(), vmtype);
                #endregion

                #region ADD CPUS
                OVF.SetCPUs(ovfEnv, vsId, (ulong)vm.VCPUs_max);
                #endregion

                #region ADD MEMORY
                OVF.SetMemory(ovfEnv, vsId, (ulong)(vm.memory_dynamic_max / MB), "MB");
                #endregion

                #region ADD NETWORKS
                List <XenRef <VIF> > vifs = VM.get_VIFs(xenSession, vmRef);
                foreach (XenRef <VIF> vifref in vifs)
                {
                    VIF vif = VIF.get_record(xenSession, vifref);
                    XenRef <Network> netRef = vif.network;
                    Network          net    = Network.get_record(xenSession, netRef);

                    // Why is the following call reference using name_label where other references use uuid?
                    OVF.AddNetwork(ovfEnv, vsId, net.uuid, net.name_label, net.name_description, vif.MAC);
                }
                #endregion

                #region SET STARTUP OPTIONS
                OVF.AddStartupSection(ovfEnv, true, vsId, vm.order, vm.start_delay, vm.shutdown_delay);
                #endregion

                #region GET AND EXPORT DISKS using iSCSI
                List <XenRef <VBD> > vbdlist = VM.get_VBDs(xenSession, vmRef);
                _vdiRefs.Clear();

                int diskIndex = 0;

                foreach (XenRef <VBD> vbdref in vbdlist)
                {
                    VBD vbd = VBD.get_record(xenSession, vbdref);

                    if (vbd.type == vbd_type.CD)
                    {
                        string rasdid = OVF.AddCDROM(ovfEnv, vsId, vbd.uuid, OVF.GetContentMessage("RASD_16_CAPTION"), OVF.GetContentMessage("RASD_16_DESCRIPTION"));
                        OVF.SetTargetDeviceInRASD(ovfEnv, vsId, rasdid, vbd.userdevice);
                    }
                    else
                    {
                        try
                        {
                            XenRef <VDI> vdi = VBD.get_VDI(xenSession, vbdref);
                            if (vdi != null && !string.IsNullOrEmpty(vdi.opaque_ref) && !(vdi.opaque_ref.ToLower().Contains("null")))
                            {
                                _vdiRefs.Add(vdi);
                                VDI    lVdi = VDI.get_record(xenSession, vdi);
                                string destinationFilename = Path.Combine(targetPath, string.Format(@"{0}.vhd", lVdi.uuid));
                                string diskid = Guid.NewGuid().ToString();

                                string diskName = lVdi.name_label;

                                if (diskName == null)
                                {
                                    diskName = string.Format("{0} {1}", OVF.GetContentMessage("RASD_19_CAPTION"), diskIndex);
                                }

                                OVF.AddDisk(ovfEnv, vsId, diskid, Path.GetFileName(destinationFilename), vbd.bootable, diskName, lVdi.name_description, (ulong)lVdi.physical_utilisation, (ulong)lVdi.virtual_size);
                                OVF.SetTargetDeviceInRASD(ovfEnv, vsId, diskid, vbd.userdevice);

                                diskIndex++;
                            }
                        }
                        catch (Exception ex)
                        {
                            log.InfoFormat("Export: VBD Skipped: {0}: {1}", vbdref, ex.Message);
                        }
                    }
                }
                #endregion

                if (!MetaDataOnly)
                {
                    _copydisks(ovfEnv, ovfname, targetPath);
                }

                #region ADD XEN SPECIFICS
                if (vm.HVM_boot_params != null)
                {
                    Dictionary <string, string> _params = vm.HVM_boot_params;
                    foreach (string key in _params.Keys)
                    {
                        if (key.ToLower().Equals("order"))
                        {
                            OVF.AddOtherSystemSettingData(ovfEnv, vsId, "HVM_boot_params", _params[key], OVF.GetContentMessage("OTHER_SYSTEM_SETTING_DESCRIPTION_1"));
                        }
                    }
                }
                if (!string.IsNullOrEmpty(vm.HVM_boot_policy))
                {
                    OVF.AddOtherSystemSettingData(ovfEnv, vsId, "HVM_boot_policy", vm.HVM_boot_policy, OVF.GetContentMessage("OTHER_SYSTEM_SETTING_DESCRIPTION_2"));
                }
                if (vm.HVM_shadow_multiplier != 1.0)
                {
                    OVF.AddOtherSystemSettingData(ovfEnv, vsId, "HVM_shadow_multiplier", Convert.ToString(vm.HVM_shadow_multiplier), OVF.GetContentMessage("OTHER_SYSTEM_SETTING_DESCRIPTION_1"));
                }
                if (vm.platform != null)
                {
                    Dictionary <string, string> platform = vm.platform;
                    StringBuilder sb = new StringBuilder();
                    foreach (string key in platform.Keys)
                    {
                        sb.AppendFormat(@"{0}={1};", key, platform[key]);
                    }
                    OVF.AddOtherSystemSettingData(ovfEnv, vsId, "platform", sb.ToString(), OVF.GetContentMessage("OTHER_SYSTEM_SETTING_DESCRIPTION_3"));
                }
                if (!string.IsNullOrEmpty(vm.PV_args))
                {
                    OVF.AddOtherSystemSettingData(ovfEnv, vsId, "PV_args", vm.PV_args, OVF.GetContentMessage("OTHER_SYSTEM_SETTING_DESCRIPTION_1"));
                }
                if (!string.IsNullOrEmpty(vm.PV_bootloader))
                {
                    OVF.AddOtherSystemSettingData(ovfEnv, vsId, "PV_bootloader", vm.PV_bootloader, OVF.GetContentMessage("OTHER_SYSTEM_SETTING_DESCRIPTION_1"));
                }
                if (!string.IsNullOrEmpty(vm.PV_bootloader_args))
                {
                    OVF.AddOtherSystemSettingData(ovfEnv, vsId, "PV_bootloader_args", vm.PV_bootloader_args, OVF.GetContentMessage("OTHER_SYSTEM_SETTING_DESCRIPTION_1"));
                }
                if (!string.IsNullOrEmpty(vm.PV_kernel))
                {
                    OVF.AddOtherSystemSettingData(ovfEnv, vsId, "PV_kernel", vm.PV_kernel, OVF.GetContentMessage("OTHER_SYSTEM_SETTING_DESCRIPTION_1"));
                }
                if (!string.IsNullOrEmpty(vm.PV_legacy_args))
                {
                    OVF.AddOtherSystemSettingData(ovfEnv, vsId, "PV_legacy_args", vm.PV_legacy_args, OVF.GetContentMessage("OTHER_SYSTEM_SETTING_DESCRIPTION_1"));
                }
                if (!string.IsNullOrEmpty(vm.PV_ramdisk))
                {
                    OVF.AddOtherSystemSettingData(ovfEnv, vsId, "PV_ramdisk", vm.PV_ramdisk, OVF.GetContentMessage("OTHER_SYSTEM_SETTING_DESCRIPTION_1"));
                }

                if (vm.hardware_platform_version >= 0)
                {
                    OVF.AddOtherSystemSettingData(ovfEnv, vsId, "hardware_platform_version", vm.hardware_platform_version.ToString(), OVF.GetContentMessage("OTHER_SYSTEM_SETTING_DESCRIPTION_1"));
                }

                if (vm.HasSriovRecommendation())
                {
                    OVF.AddOtherSystemSettingData(ovfEnv, vsId, "allow_network_sriov", bool.TrueString.ToLowerInvariant(), OVF.GetContentMessage("OTHER_SYSTEM_SETTING_DESCRIPTION_1"));
                }
                if (vm.has_vendor_device)
                {
                    //serialise it with a different name to avoid it being deserialised automatically and getting the wrong type
                    OVF.AddOtherSystemSettingData(ovfEnv, vsId, "VM_has_vendor_device", vm.has_vendor_device.ToString(), OVF.GetContentMessage("OTHER_SYSTEM_SETTING_DESCRIPTION_1"));
                }

                if (vm.VGPUs.Count != 0)
                {
                    VGPU vgpu = VGPU.get_record(xenSession, vm.VGPUs[0]);

                    if (vgpu != null)
                    {
                        var vgpuGroup = GPU_group.get_record(xenSession, vgpu.GPU_group);
                        var vgpuType  = VGPU_type.get_record(xenSession, vgpu.type);

                        var sb = new StringBuilder();
                        sb.AppendFormat("GPU_types={{{0}}};",
                                        vgpuGroup.GPU_types == null || vgpuGroup.GPU_types.Length < 1
                                            ? ""
                                            : string.Join(";", vgpuGroup.GPU_types));
                        sb.AppendFormat("VGPU_type_vendor_name={0};", vgpuType.vendor_name ?? "");
                        sb.AppendFormat("VGPU_type_model_name={0};", vgpuType.model_name ?? "");
                        OVF.AddOtherSystemSettingData(ovfEnv, vsId, "vgpu", sb.ToString(), OVF.GetContentMessage("OTHER_SYSTEM_SETTING_DESCRIPTION_4"));
                    }
                }

                string pvsSiteUuid = string.Empty;
                var    allProxies  = xenSession.Connection.Cache.PVS_proxies;

                foreach (var p in allProxies.Where(p => p != null && p.VIF != null))
                {
                    var vif = xenSession.Connection.Resolve(p.VIF);
                    if (vif != null)
                    {
                        var vmFromVif = xenSession.Connection.Resolve(vif.VM);
                        if (vmFromVif != null && vmFromVif.uuid == vm.uuid)
                        {
                            var pvsSite = xenSession.Connection.Resolve(p.site);
                            if (pvsSite != null)
                            {
                                pvsSiteUuid = pvsSite.uuid;
                            }

                            break;
                        }
                    }
                }

                if (!string.IsNullOrEmpty(pvsSiteUuid))
                {
                    var sb = new StringBuilder();
                    sb.AppendFormat("PVS_SITE={{{0}}};", string.Format("uuid={0}", pvsSiteUuid));

                    OVF.AddOtherSystemSettingData(ovfEnv, vsId, "pvssite", sb.ToString(), OVF.GetContentMessage("OTHER_SYSTEM_SETTING_DESCRIPTION_5"));
                }
                #endregion

                OVF.FinalizeEnvelope(ovfEnv);
            }
            catch (Exception ex)
            {
                if (ex is OperationCanceledException)
                {
                    throw;
                }
                log.Error(Messages.ERROR_EXPORT_FAILED);
                throw new Exception(Messages.ERROR_EXPORT_FAILED, ex);
            }
            return(ovfEnv);
        }
        public VGpuDetailWithCheckBoxRow(XenRef<VGPU_type> vGpuTypeRef, VGPU_type vGpuType, bool allowed, bool isInUse)
        {
            VGpuTypeRef = vGpuTypeRef;
            VGpuType = vGpuType;
            this.allowed = allowed;
            IsReadOnly = isInUse && allowed;

            SetCells();
            Cells.AddRange(checkBoxCell, nameColumn, vGpusPerGpuColumn, maxResolutionColumn, maxDisplaysColumn, videoRamColumn);
            SetupCheckBoxCell();
        }
Beispiel #18
0
        private void FindGpuGroupAndVgpuType(Session xenSession, VirtualHardwareSection_Type system, out GPU_group gpuGroup, out VGPU_type vgpuType)
        {
            gpuGroup = null;
            vgpuType = null;

            var data = system.VirtualSystemOtherConfigurationData;
            if (data == null)
                return;

            var datum = data.FirstOrDefault(s => s.Name == "vgpu");
            if (datum == null)
                return;

            Match m = VGPU_REGEX.Match(datum.Value.Value);
            if (!m.Success)
                return;

            var types = m.Groups[1].Value.Split(';');

            var gpuGroups = GPU_group.get_all_records(xenSession);
            var gpuKvp = gpuGroups.FirstOrDefault(g =>
                g.Value.supported_VGPU_types.Count > 0 &&
                g.Value.GPU_types.Length == types.Length &&
                g.Value.GPU_types.Intersect(types).Count() == types.Length);

            if (gpuKvp.Equals(default(KeyValuePair<XenRef<GPU_group>, GPU_group>)))
                return;

            gpuGroup = gpuKvp.Value;
            gpuGroup.opaque_ref = gpuKvp.Key.opaque_ref;

            string vendorName = m.Groups[2].Value;
            string modelName = m.Groups[3].Value;

            var vgpuTypes = VGPU_type.get_all_records(xenSession);
            var vgpuKey = vgpuTypes.FirstOrDefault(v =>
                v.Value.vendor_name == vendorName && v.Value.model_name == modelName);

            if (vgpuKey.Equals(default(KeyValuePair<XenRef<VGPU_type>, VGPU_type>)))
                return;

            vgpuType = vgpuKey.Value;
            vgpuType.opaque_ref = vgpuKey.Key.opaque_ref;
        }
Beispiel #19
0
        public VGpuTypeRow(VGPU_type vGpuType, bool enabledType)
        {
            VGpuType = vGpuType;
            EnabledType = enabledType;

            Cells.AddRange(ImageCell,
                           NameCell);

            UpdateDetails();
        }