예제 #1
0
        private void timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (!rebooting)
                return;

            ReplaceProgressStep(_upgradeVersion == null
                ? string.Format(Messages.ROLLING_UPGRADE_TIMEOUT, CurrentHost.Name())
                : string.Format(Messages.ROLLING_UPGRADE_TIMEOUT_VERSION, _upgradeVersion, CurrentHost.Name()));
        }
예제 #2
0
        protected override void RunWithSession(ref Session session)
        {
            string hostVersionBefore = CurrentHost.LongProductVersion();

            log.InfoFormat("Host '{0}' upgrading from version '{1}'", CurrentHost.Name(), hostVersionBefore);

            string value = Host.call_plugin(session, HostXenRef.opaque_ref, "prepare_host_upgrade.py", "main", _arguments);

            if (value.ToLower() == "true")
            {
                Upgrade(ref session);
            }
            else
            {
                throw new Exception(value);
            }

            Host hostAfterReboot = GetResolvedHost();

            if (hostAfterReboot == null)
            {
                log.InfoFormat("Cannot check host's version after reboot because the host '{0}' cannot be resolved", CurrentHost.Name());
            }
            else
            {
                if (Helpers.SameServerVersion(hostAfterReboot, hostVersionBefore))
                {
                    log.ErrorFormat("Host '{0}' rebooted with the same version '{1}'", hostAfterReboot.Name(), hostAfterReboot.LongProductVersion());
                    var error = new Exception(Messages.REBOOT_WITH_SAME_VERSION);
                    //when the slave reboots with the same version do not interrupt the process,
                    //so set the error without throwing it
                    if (hostAfterReboot.IsMaster())
                    {
                        throw error;
                    }
                    Error = error;
                }

                log.InfoFormat("Host '{0}' upgraded with version '{1}'", hostAfterReboot.Name(), hostAfterReboot.LongProductVersion());
            }
        }
예제 #3
0
        protected override void RunWithSession(ref Session session)
        {
            string hostVersionBefore = CurrentHost.LongProductVersion();

            string productVersion = null;

            try
            {
                var result     = Host.call_plugin(session, HostXenRef.opaque_ref, "prepare_host_upgrade.py", "getVersion", _arguments);
                var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
                var version    = (Dictionary <string, object>)serializer.DeserializeObject(result);
                productVersion = version.ContainsKey("product-version") ? (string)version["product-version"] : null;
            }
            catch (Exception exception)
            {
                log.WarnFormat("Exception while trying to get the upgrade version: {0}", exception.Message);
            }

            log.InfoFormat("Host '{0}' upgrading from version '{1}' to version '{2}'", CurrentHost.Name(), hostVersionBefore, productVersion ?? "unknown");

            string value = Host.call_plugin(session, HostXenRef.opaque_ref, "prepare_host_upgrade.py", "main", _arguments);

            if (value.ToLower() == "true")
            {
                Upgrade(ref session, productVersion);
            }
            else
            {
                throw new Exception(value);
            }

            Host hostAfterReboot = GetResolvedHost();

            if (hostAfterReboot == null)
            {
                log.InfoFormat("Cannot check host's version after reboot because the host '{0}' cannot be resolved", CurrentHost.Name());
            }
            else
            {
                if (Helpers.SameServerVersion(hostAfterReboot, hostVersionBefore))
                {
                    log.ErrorFormat("Host '{0}' rebooted with the same version '{1}'", hostAfterReboot.Name(), hostAfterReboot.LongProductVersion());
                    var error = new Exception(Messages.REBOOT_WITH_SAME_VERSION);
                    //when the slave reboots with the same version do not interrupt the process,
                    //so set the error without throwing it
                    if (hostAfterReboot.IsMaster())
                    {
                        throw error;
                    }
                    Error = error;
                }

                log.InfoFormat("Host '{0}' upgraded with version '{1}'", hostAfterReboot.Name(), hostAfterReboot.LongProductVersion());
            }
        }