diff --git a/XenModel/ServerDBs/DbProxy.cs b/XenModel/ServerDBs/DbProxy.cs index f29a9ca3a..b792fbbc9 100644 --- a/XenModel/ServerDBs/DbProxy.cs +++ b/XenModel/ServerDBs/DbProxy.cs @@ -348,9 +348,9 @@ namespace XenAdmin.ServerDBs case "get_allowed_operations": return new Response(new string[0]); - case "get_gui_config": + case "get_health_check_config": string uuid1 = (string)args[1]; - return new Response(get_gui_config(pmi.TypeName, uuid1, true)); + return new Response(get_health_check_config(pmi.TypeName, uuid1, true)); } @@ -512,7 +512,7 @@ namespace XenAdmin.ServerDBs return result; } - public Object get_gui_config(String clazz, String opaqueRef, bool makeResponse) + public Object get_health_check_config(String clazz, String opaqueRef, bool makeResponse) { Db.Table table = db.Tables[clazz]; @@ -523,7 +523,7 @@ namespace XenAdmin.ServerDBs throw new Exception(Failure.OBJECT_NO_LONGER_EXISTS); } - return table.Rows[opaqueRef].Props["gui_config"].XapiObjectValue; + return table.Rows[opaqueRef].Props["health_check_config"].XapiObjectValue; } private void edit_record(EditTypes editType, string clazz, string opaqueRef, string field, params object[] args) diff --git a/XenServerHealthCheck/RequestUploadTask.cs b/XenServerHealthCheck/RequestUploadTask.cs index 22e6d511b..be72d17c2 100755 --- a/XenServerHealthCheck/RequestUploadTask.cs +++ b/XenServerHealthCheck/RequestUploadTask.cs @@ -84,16 +84,16 @@ namespace XenServerHealthCheck string newUploadLock = System.Configuration.ConfigurationManager.AppSettings["UUID"]; newUploadLock += "|" + DateTime.UtcNow.ToString(); config[CallHomeSettings.UPLOAD_LOCK] = newUploadLock; - Pool.set_gui_config(session, connection.Cache.Pools[0].opaque_ref, config); + Pool.set_health_check_config(session, connection.Cache.Pools[0].opaque_ref, config); System.Threading.Thread.Sleep(SleepForLockConfirm); - config = Pool.get_gui_config(session, connection.Cache.Pools[0].opaque_ref); + config = Pool.get_health_check_config(session, connection.Cache.Pools[0].opaque_ref); return config[CallHomeSettings.UPLOAD_LOCK] == newUploadLock; } public static bool Request(IXenConnection connection, Session session) { bool needRetry = false; - Dictionary config = Pool.get_gui_config(session, connection.Cache.Pools[0].opaque_ref); + Dictionary config = Pool.get_health_check_config(session, connection.Cache.Pools[0].opaque_ref); if (BoolKey(config, CallHomeSettings.STATUS) == false) { log.InfoFormat("Will not report for XenServer {0} that was not Enroll", connection.Hostname); @@ -190,7 +190,7 @@ namespace XenServerHealthCheck private static int DemandTimeOutMinutes = 30; public static bool OnDemandRequest(IXenConnection connection, Session session) { - Dictionary config = Pool.get_gui_config(session, connection.Cache.Pools[0].opaque_ref); + Dictionary config = Pool.get_health_check_config(session, connection.Cache.Pools[0].opaque_ref); if (BoolKey(config, CallHomeSettings.STATUS) == false) { log.InfoFormat("Will not report on demand for XenServer {0} that was not Enroll", connection.Hostname); diff --git a/XenServerHealthCheckTests/RequestUploadTaskTests.cs b/XenServerHealthCheckTests/RequestUploadTaskTests.cs index 8438d092c..0d62e8f92 100755 --- a/XenServerHealthCheckTests/RequestUploadTaskTests.cs +++ b/XenServerHealthCheckTests/RequestUploadTaskTests.cs @@ -45,20 +45,20 @@ namespace XenServerHealthCheckTests //1. If XenServer has not enroll, lock will not been set. config = cleanStack(); config[CallHomeSettings.STATUS] = "false"; - Pool.set_gui_config(_session, connection.Cache.Pools[0].opaque_ref, config); + Pool.set_health_check_config(_session, connection.Cache.Pools[0].opaque_ref, config); Assert.IsFalse(RequestUploadTask.Request(connection, _session)); //2.If the lock has already set by current service and not due, the lock should not been set again. config = cleanStack(); config[CallHomeSettings.UPLOAD_LOCK] = UUID + "|" + DateTime.UtcNow.ToString(); - Pool.set_gui_config(_session, connection.Cache.Pools[0].opaque_ref, config); + Pool.set_health_check_config(_session, connection.Cache.Pools[0].opaque_ref, config); Assert.IsFalse(RequestUploadTask.Request(connection, _session)); //3. If the lock already due or no one set the lock, but current schedule DayOfWeek and TimeOfDay is not correct, the lock should not been set. config = cleanStack(); config[CallHomeSettings.UPLOAD_LOCK] = UUID + "|" + DateTime.UtcNow.Subtract(TimeSpan.FromDays(14)).ToString(); - Pool.set_gui_config(_session, connection.Cache.Pools[0].opaque_ref, config); + Pool.set_health_check_config(_session, connection.Cache.Pools[0].opaque_ref, config); Assert.IsFalse(RequestUploadTask.Request(connection, _session)); //4. For lock due or not set by others and schedule meet, lock should be set. @@ -66,13 +66,13 @@ namespace XenServerHealthCheckTests config[CallHomeSettings.UPLOAD_LOCK] = UUID + "|" + DateTime.UtcNow.Subtract(TimeSpan.FromDays(14)).ToString(); config[CallHomeSettings.DAY_OF_WEEK] = DateTime.UtcNow.DayOfWeek.ToString(); config[CallHomeSettings.TIME_OF_DAY] = DateTime.UtcNow.Hour.ToString(); - Pool.set_gui_config(_session, connection.Cache.Pools[0].opaque_ref, config); + Pool.set_health_check_config(_session, connection.Cache.Pools[0].opaque_ref, config); Assert.IsTrue(RequestUploadTask.Request(connection, _session)); //5. For Lock set by other service and not due, the lock should not been set by us. config = cleanStack(); config[CallHomeSettings.UPLOAD_LOCK] = "test2-test2" + "|" + DateTime.UtcNow.ToString(); - Pool.set_gui_config(_session, connection.Cache.Pools[0].opaque_ref, config); + Pool.set_health_check_config(_session, connection.Cache.Pools[0].opaque_ref, config); Assert.IsFalse(RequestUploadTask.Request(connection, _session)); //6. For Lock set by other service but already due, the lock can be set by current service @@ -80,33 +80,33 @@ namespace XenServerHealthCheckTests config[CallHomeSettings.UPLOAD_LOCK] = "test2-test2" + "|" + DateTime.UtcNow.Subtract(TimeSpan.FromDays(14)).ToString(); config[CallHomeSettings.DAY_OF_WEEK] = DateTime.UtcNow.DayOfWeek.ToString(); config[CallHomeSettings.TIME_OF_DAY] = DateTime.UtcNow.Hour.ToString(); - Pool.set_gui_config(_session, connection.Cache.Pools[0].opaque_ref, config); + Pool.set_health_check_config(_session, connection.Cache.Pools[0].opaque_ref, config); Assert.IsTrue(RequestUploadTask.Request(connection, _session)); //7 Check LastFailedUpload is not empty and > LastSuccessfulUpload && INTERVAL_IN_DAYS using default, lock can be set config = cleanStack(); config[CallHomeSettings.LAST_SUCCESSFUL_UPLOAD] = DateTime.UtcNow.Subtract(TimeSpan.FromDays(14)).ToString(); config[CallHomeSettings.LAST_FAILED_UPLOAD] = DateTime.UtcNow.Subtract(TimeSpan.FromDays(8)).ToString(); - Pool.set_gui_config(_session, connection.Cache.Pools[0].opaque_ref, config); + Pool.set_health_check_config(_session, connection.Cache.Pools[0].opaque_ref, config); Assert.IsTrue(RequestUploadTask.Request(connection, _session)); //8 For not due uploading, lock should not been set config = cleanStack(); config[CallHomeSettings.LAST_SUCCESSFUL_UPLOAD] = DateTime.UtcNow.Subtract(TimeSpan.FromDays(6)).ToString(); - Pool.set_gui_config(_session, connection.Cache.Pools[0].opaque_ref, config); + Pool.set_health_check_config(_session, connection.Cache.Pools[0].opaque_ref, config); Assert.IsFalse(RequestUploadTask.Request(connection, _session)); //9 For failed upload, retry was needed but not meet RetryIntervalInDays, lock should not been set config = cleanStack(); config[CallHomeSettings.LAST_SUCCESSFUL_UPLOAD] = DateTime.UtcNow.Subtract(TimeSpan.FromDays(14)).ToString(); config[CallHomeSettings.LAST_FAILED_UPLOAD] = DateTime.UtcNow.Subtract(TimeSpan.FromDays(5)).ToString(); - Pool.set_gui_config(_session, connection.Cache.Pools[0].opaque_ref, config); + Pool.set_health_check_config(_session, connection.Cache.Pools[0].opaque_ref, config); Assert.IsFalse(RequestUploadTask.Request(connection, _session)); //10 For failed upload, retry was needed and meet RetryIntervalInDays, lock should be set config = cleanStack(); config[CallHomeSettings.LAST_FAILED_UPLOAD] = DateTime.UtcNow.Subtract(TimeSpan.FromDays(7)).ToString(); - Pool.set_gui_config(_session, connection.Cache.Pools[0].opaque_ref, config); + Pool.set_health_check_config(_session, connection.Cache.Pools[0].opaque_ref, config); Assert.IsTrue(RequestUploadTask.Request(connection, _session)); @@ -114,14 +114,14 @@ namespace XenServerHealthCheckTests config = cleanStack(); config[CallHomeSettings.LAST_SUCCESSFUL_UPLOAD] = ""; config[CallHomeSettings.LAST_FAILED_UPLOAD] = DateTime.UtcNow.Subtract(TimeSpan.FromDays(8)).ToString(); - Pool.set_gui_config(_session, connection.Cache.Pools[0].opaque_ref, config); + Pool.set_health_check_config(_session, connection.Cache.Pools[0].opaque_ref, config); Assert.IsTrue(RequestUploadTask.Request(connection, _session)); //12 For no LAST_FAILED_UPLOAD or invalid LAST_FAILED_UPLOAD, lock should not be set if not due config = cleanStack(); config[CallHomeSettings.LAST_SUCCESSFUL_UPLOAD] = DateTime.UtcNow.Subtract(TimeSpan.FromDays(13)).ToString(); config[CallHomeSettings.LAST_FAILED_UPLOAD] = "asd"; - Pool.set_gui_config(_session, connection.Cache.Pools[0].opaque_ref, config); + Pool.set_health_check_config(_session, connection.Cache.Pools[0].opaque_ref, config); Assert.IsFalse (RequestUploadTask.Request(connection, _session)); } catch (Exception) @@ -142,28 +142,28 @@ namespace XenServerHealthCheckTests config = cleanStack(); config[CallHomeSettings.UPLOAD_LOCK] = UUID + "|" + DateTime.UtcNow.ToString(); config[CallHomeSettings.NEW_UPLOAD_REQUEST] = DateTime.UtcNow.ToString(); - Pool.set_gui_config(_session, connection.Cache.Pools[0].opaque_ref, config); + Pool.set_health_check_config(_session, connection.Cache.Pools[0].opaque_ref, config); Assert.IsFalse(RequestUploadTask.OnDemandRequest(connection, _session)); //2 Uploading is inprocess by other service, demand will be ignore config = cleanStack(); config[CallHomeSettings.UPLOAD_LOCK] = "test2-test2" + "|" + DateTime.UtcNow.ToString(); config[CallHomeSettings.NEW_UPLOAD_REQUEST] = DateTime.UtcNow.ToString(); - Pool.set_gui_config(_session, connection.Cache.Pools[0].opaque_ref, config); + Pool.set_health_check_config(_session, connection.Cache.Pools[0].opaque_ref, config); Assert.IsFalse(RequestUploadTask.OnDemandRequest(connection, _session)); //3 Uploading is not due and demand due, demand will be ignore config = cleanStack(); config[CallHomeSettings.UPLOAD_LOCK] = "test2-test2" + "|" + DateTime.UtcNow.Subtract(TimeSpan.FromDays(14)).ToString(); config[CallHomeSettings.NEW_UPLOAD_REQUEST] = DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(31)).ToString(); - Pool.set_gui_config(_session, connection.Cache.Pools[0].opaque_ref, config); + Pool.set_health_check_config(_session, connection.Cache.Pools[0].opaque_ref, config); Assert.IsFalse(RequestUploadTask.OnDemandRequest(connection, _session)); //4 Uploading is due and demand not due, lock will be set config = cleanStack(); config[CallHomeSettings.UPLOAD_LOCK] = "test2-test2" + "|" + DateTime.UtcNow.Subtract(TimeSpan.FromDays(14)).ToString(); config[CallHomeSettings.NEW_UPLOAD_REQUEST] = DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(28)).ToString(); - Pool.set_gui_config(_session, connection.Cache.Pools[0].opaque_ref, config); + Pool.set_health_check_config(_session, connection.Cache.Pools[0].opaque_ref, config); Assert.IsTrue(RequestUploadTask.OnDemandRequest(connection, _session)); } catch (Exception)