Ejemplo n.º 1
1
        protected override void Run()
        {
            // check the xstools sr is present, if not try and repair it
            foreach(SR sr in VM.Connection.Cache.SRs)
            {
                if (sr.IsToolsSR && sr.IsBroken())
                {
                    try
                    {
                        SrRepairAction action = new SrRepairAction(sr.Connection, sr,false);
                        action.RunExternal(Session);
                    }
                    catch (Failure)
                    {
                        _xsToolsNotFound();
                    }
                }

            }

            // Check the version (if any) of the PV tools already on this host...
            VM_guest_metrics guestMetrics = Connection.Resolve(VM.guest_metrics);
            if (guestMetrics != null && guestMetrics.PV_drivers_up_to_date)
            {
                this.Description = Messages.INSTALLTOOLS_EXIST;
                return;
            }

            // Check that the VM has a cd-rom...
            XenAPI.VBD cdrom = VM.FindVMCDROM();
            if (cdrom == null)
            {
                Description = Messages.INSTALLTOOLS_COULDNOTFIND_CD;
                return;
            }

            // Find the tools ISO...
            XenAPI.VDI winIso = findWinISO(_searchHiddenIsOs);
            if (winIso == null)
            {
                // Could not find the windows PV drivers ISO.
                Description = Messages.INSTALLTOOLS_COULDNOTFIND_WIN;
                return;
            }

            Description = Messages.INSTALLTOOLS_STARTING;

            // Eject anything that's currently in the cd-rom...
            if (!cdrom.empty)
            {
                XenAPI.VBD.eject(Session, cdrom.opaque_ref);
            }

            // Insert the tools ISO...
            XenAPI.VBD.insert(Session, cdrom.opaque_ref, winIso.opaque_ref);

            // done(ish)...
            Description = Messages.INSTALLTOOLS_DONE;
        }
        protected override void Run()
        {
            // check the xstools sr is present, if not try and repair it
            foreach(SR sr in VM.Connection.Cache.SRs)
            {
                if (sr.IsToolsSR && sr.IsBroken())
                {
                    try
                    {
                        SrRepairAction action = new SrRepairAction(sr.Connection, sr,false);
                        action.RunExternal(Session);
                    }
                    catch (Failure)
                    {
                        throw;
                    }
                }

            }

            // Check that the VM has a cd-rom...
            XenAPI.VBD cdrom = VM.FindVMCDROM();
            if (cdrom == null)
            {
                Description = Messages.UPGRADEVM_COULDNOTFIND_CD;
                return;
            }

            // Find the tools ISO...
            XenAPI.VDI winIso = findWinISO(_searchHiddenIsOs);
            if (winIso == null)
            {
                // Could not find the windows PV drivers ISO.
                Description = Messages.UPGRADEVM_COULDNOTFIND_ISO;
                return;
            }

            Description = Messages.UPGRADEVM_ISO_STARTING;

            // Eject anything that's currently in the cd-rom...
            if (!cdrom.empty)
            {
                XenAPI.VBD.eject(Session, cdrom.opaque_ref);
            }

            // Insert the ISO...
            XenAPI.VBD.insert(Session, cdrom.opaque_ref, winIso.opaque_ref);

            //Setting Upgrading persisted status on the VM
            VM.ClientToGuestValue = VM.ClientToGuestMessage.INITIALIZING;

            // TODO this (sleep and setting go to console) is here for now (setting go to console, but this will not be needed later
            //
            // waiting for the installer's message
            System.Threading.Thread.Sleep(15000);

            if (! new VM.GuestToClientMessage[] {VM.GuestToClientMessage.DONE, VM.GuestToClientMessage.ERROR, VM.GuestToClientMessage.RUNNING, VM.GuestToClientMessage.STARTED }
                .Contains(VM.GuestToClientValue))
            {
                if (VM.ClientToGuestValue == XenAPI.VM.ClientToGuestMessage.INITIALIZING)
                VM.ClientToGuestValue = XenAPI.VM.ClientToGuestMessage.GOTOCONSOLE;
            }

            Description = Messages.UPGRADEVM_ISO_DONE;
        }
Ejemplo n.º 3
0
        protected override void Run()
        {
            // check the xstools sr is present, if not try and repair it
            foreach (SR sr in VM.Connection.Cache.SRs)
            {
                if (sr.IsToolsSR && sr.IsBroken())
                {
                    try
                    {
                        SrRepairAction action = new SrRepairAction(sr.Connection, sr, false);
                        action.RunExternal(Session);
                    }
                    catch (Failure)
                    {
                        _xsToolsNotFound();
                    }
                }
            }

            // Check the version (if any) of the PV tools already on this host...
            VM_guest_metrics guestMetrics = Connection.Resolve(VM.guest_metrics);

            if (guestMetrics != null && !VM.HasNewVirtualisationStates && guestMetrics.PV_drivers_up_to_date)
            {
                this.Description = Messages.INSTALLTOOLS_EXIST;
                return;
            }

            // Check that the VM has a cd-rom...
            XenAPI.VBD cdrom = VM.FindVMCDROM();
            if (cdrom == null)
            {
                Description = Messages.INSTALLTOOLS_COULDNOTFIND_CD;
                return;
            }

            // Find the tools ISO...
            XenAPI.VDI winIso = findWinISO(_searchHiddenIsOs);
            if (winIso == null)
            {
                // Could not find the windows PV drivers ISO.
                Description = Messages.INSTALLTOOLS_COULDNOTFIND_WIN;
                return;
            }

            Description = Messages.INSTALLTOOLS_STARTING;

            // Eject anything that's currently in the cd-rom...
            if (!cdrom.empty)
            {
                XenAPI.VBD.eject(Session, cdrom.opaque_ref);
            }

            // Insert the tools ISO...
            XenAPI.VBD.insert(Session, cdrom.opaque_ref, winIso.opaque_ref);

            // done(ish)...
            Description = Messages.INSTALLTOOLS_DONE;
        }