protected override void Run()
 {
     SafeToExit  = false;
     Description = String.Format(Messages.ACTION_CHECK_DISK_SPACE_DESCRIPTION, Host.Name);
     if (!IsEnoughDiskSpace())
     {
         DiskSpaceRequirements diskSpaceRequirements = null;
         var getDiskSpaceRequirementsAction          = new GetDiskSpaceRequirementsAction(Host, fileName, fileSize, true);
         try
         {
             getDiskSpaceRequirementsAction.RunExternal(Session);
             diskSpaceRequirements = getDiskSpaceRequirementsAction.DiskSpaceRequirements;
         }
         catch (Failure failure)
         {
             log.WarnFormat("Getting disk space requirements on {0} failed with: {1}", Host.Name, failure.Message);
         }
         Exception = new NotEnoughSpaceException(Host.Name, fileName, diskSpaceRequirements);
     }
 }
 protected override void Run()
 {
     SafeToExit = false;
     Description = String.Format(Messages.ACTION_CHECK_DISK_SPACE_DESCRIPTION, Host.Name);
     if (!IsEnoughDiskSpace())
     {
         DiskSpaceRequirements diskSpaceRequirements = null;
         var getDiskSpaceRequirementsAction = new GetDiskSpaceRequirementsAction(Host, fileName, fileSize, true);
         try
         {
             getDiskSpaceRequirementsAction.RunExternal(Session);
             diskSpaceRequirements = getDiskSpaceRequirementsAction.DiskSpaceRequirements;
         }
         catch (Failure failure)
         {
             log.WarnFormat("Getting disk space requirements on {0} failed with: {1}", Host.Name, failure.Message);
         }
         Exception = new NotEnoughSpaceException(Host.Name, fileName, diskSpaceRequirements);
     }
 }
Ejemplo n.º 3
0
        private Problem FindProblem(string errorcode, string found, string required)
        {
            long requiredSpace = 0;
            long foundSpace = 0;
            long reclaimableDiskSpace = 0;

            DiskSpaceRequirements diskSpaceReq;

            switch (errorcode)
            {
                case "UPDATE_PRECHECK_FAILED_WRONG_SERVER_VERSION":
                    return new WrongServerVersion(this, Host);

                case "UPDATE_PRECHECK_FAILED_CONFLICT_PRESENT":
                    return new ConflictingUpdatePresent(this, found, Host);

                case "UPDATE_PRECHECK_FAILED_PREREQUISITE_MISSING":
                    return new PrerequisiteUpdateMissing(this, found, Host);

                case "PATCH_PRECHECK_FAILED_WRONG_SERVER_VERSION":
                    return new WrongServerVersion(this, required, Host);

                case "PATCH_PRECHECK_FAILED_OUT_OF_SPACE":
                    System.Diagnostics.Trace.Assert(Helpers.CreamOrGreater(Host.Connection));  // If not Cream or greater, we shouldn't get this error

                    long.TryParse(found, out foundSpace);
                    long.TryParse(required, out requiredSpace);
                    // get reclaimable disk space (excluding current patch)
                    try
                    {
                        var args = new Dictionary<string, string> { { "exclude", Patch.uuid } };
                        var resultReclaimable = Host.call_plugin(Host.Connection.Session, Host.opaque_ref, "disk-space", "get_reclaimable_disk_space", args);
                        reclaimableDiskSpace = Convert.ToInt64(resultReclaimable);
                    }
                    catch (Failure failure)
                    {
                        log.WarnFormat("Plugin call disk-space.get_reclaimable_disk_space on {0} failed with {1}", Host.Name, failure.Message);
                    }

                    diskSpaceReq = new DiskSpaceRequirements(DiskSpaceRequirements.OperationTypes.install, Host, Patch.Name, requiredSpace, foundSpace, reclaimableDiskSpace);

                    return new HostOutOfSpaceProblem(this, Host, Patch, diskSpaceReq);

                case "UPDATE_PRECHECK_FAILED_OUT_OF_SPACE":
                    System.Diagnostics.Trace.Assert(Helpers.ElyOrGreater(Host.Connection));  // If not Ely or greater, we shouldn't get this error
                    long.TryParse(found, out foundSpace);
                    long.TryParse(required, out requiredSpace);

                    diskSpaceReq = new DiskSpaceRequirements(DiskSpaceRequirements.OperationTypes.install, Host, Update.Name, requiredSpace, foundSpace, 0);

                    return new HostOutOfSpaceProblem(this, Host, Update, diskSpaceReq);

                case "OUT_OF_SPACE":
                    if (Helpers.CreamOrGreater(Host.Connection))
                    {
                        var action = new GetDiskSpaceRequirementsAction(Host, Patch, true);
                        try
                        {
                            action.RunExternal(action.Session);
                        }
                        catch
                        {
                            log.WarnFormat("Could not get disk space requirements");
                        }
                        if (action.Succeeded)
                            return new HostOutOfSpaceProblem(this, Host, Patch, action.DiskSpaceRequirements);
                    }
                    break;
            }
            return null;
        }
        protected override Problem RunCheck()
        {
            if (!Host.IsLive)
                return new HostNotLiveWarning(this, Host);

            if (!Host.Connection.IsConnected)
                throw new EndOfStreamException(Helpers.GetName(Host.Connection));

            if (Helpers.CreamOrGreater(Host.Connection))
            {
                var action = new GetDiskSpaceRequirementsAction(Host, size, true, DiskSpaceRequirements.OperationTypes.automatedUpdates);

                try
                {
                    action.RunExternal(action.Session);
                }
                catch
                {
                    log.WarnFormat("Could not get disk space requirements");
                }

                if (action.Succeeded && action.DiskSpaceRequirements.AvailableDiskSpace < size)
                    return new HostOutOfSpaceProblem(this, Host, action.DiskSpaceRequirements);
            }

            return null;
        }