The JSON server has been modified to return the version number
in all responses. The UI has been modified to keep the version
obtained during env operation and check the version returned
in subsequent operations. If the version changes the UI will
reload itself.

Ticket #946

This can be tested using the lite server:

1. Run lite server.
2. Open the UI.
3. Change the VERSION in ipapython/version.py.
4. Restart lite server.
5. Click any link on the UI, the UI should reload.

--
Endi S. Dewata
From 7257205352187458c2820c5881421ab8cc161aca Mon Sep 17 00:00:00 2001
From: Endi Sukma Dewata <edew...@redhat.com>
Date: Tue, 20 Dec 2011 19:45:57 -0600
Subject: [PATCH] Reload UI on server upgrade.

The JSON server has been modified to return the version number
in all responses. The UI has been modified to keep the version
obtained during env operation and check the version returned
in subsequent operations. If the version changes the UI will
reload itself.

Ticket #946
---
 install/ui/ipa.js      |    4 ++++
 ipalib/constants.py    |    3 +++
 ipaserver/rpcserver.py |    2 ++
 3 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/install/ui/ipa.js b/install/ui/ipa.js
index 080f4836d03f59ba5657265f40e040f06a64f1a0..23a5e4287fefa5b206d073f2a11313db04d161b1 100644
--- a/install/ui/ipa.js
+++ b/install/ui/ipa.js
@@ -128,6 +128,7 @@ var IPA = function() {
             method: 'env',
             on_success: function(data, text_status, xhr) {
                 that.env = data.result;
+                that.version = that.env.version;
             }
         }));
 
@@ -420,6 +421,9 @@ IPA.command = function(spec) {
                     message: data ? xhr.statusText : IPA.get_message('errors.no_response', 'No response')
                 });
 
+            } else if (IPA.version && data.version && IPA.version !== data.version) {
+                window.location.reload();
+
             } else if (IPA.principal && data.principal && IPA.principal !== data.principal) {
                 window.location.reload();
 
diff --git a/ipalib/constants.py b/ipalib/constants.py
index 96cf3ba604d0a53e687a76d01ab0b9b7b3e185fb..d984bbc2049000506fc0095d085f8ad79b33ff93 100644
--- a/ipalib/constants.py
+++ b/ipalib/constants.py
@@ -22,6 +22,7 @@
 All constants centralised in one file.
 """
 import socket
+from ipapython.version import VERSION
 try:
     FQDN = socket.getfqdn()
 except:
@@ -63,6 +64,8 @@ CONFIG_SECTION = 'global'
 # This is a tuple instead of a dict so that it is immutable.
 # To create a dict with this config, just "d = dict(DEFAULT_CONFIG)".
 DEFAULT_CONFIG = (
+    ('version', VERSION),
+
     # Domain, realm, basedn:
     ('domain', 'example.com'),
     ('realm', 'EXAMPLE.COM'),
diff --git a/ipaserver/rpcserver.py b/ipaserver/rpcserver.py
index 2bfb8ea60b0c4bbb136f5d11c8528470a75abcf4..26850db55969a4de2f1d6d5da319f092a36cfe9a 100644
--- a/ipaserver/rpcserver.py
+++ b/ipaserver/rpcserver.py
@@ -33,6 +33,7 @@ from ipalib.rpc import xml_dumps, xml_loads
 from ipalib.util import make_repr
 from ipalib.compat import json
 from wsgiref.util import shift_path_info
+from ipapython.version import VERSION
 import base64
 import os
 import string
@@ -470,6 +471,7 @@ class jsonserver(WSGIExecutioner):
             error=error,
             id=_id,
             principal=unicode(context.principal),
+            version=unicode(VERSION),
         )
         response = json_encode_binary(response)
         return json.dumps(response, sort_keys=True, indent=4)
-- 
1.7.5.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to