public void Test_RubyHash() { bool test = true; try { Dictionary <string, object> ctorTestO = new Dictionary <string, object>(); ctorTestO.Add("testkey", new List <int>() { 1, 2, 3, 4 }); Dictionary <string, string> ctorTest = new Dictionary <string, string>(); ctorTest.Add("test", "testValue"); RubyHash hash = new RubyHash(ctorTestO); RubyHash hash2 = new RubyHash(ctorTest); RubyHash mergedHash = hash.Merge(hash2); mergedHash = hash.Merge(ctorTest); mergedHash = hash2.Merge(ctorTestO); } catch { test = false; } Assert.AreEqual(true, test); }
public void Test_RubyHash() { bool test = true; try { Dictionary<string, object> ctorTestO = new Dictionary<string, object>(); ctorTestO.Add("testkey", new List<int>() { 1, 2, 3, 4 }); Dictionary<string, string> ctorTest = new Dictionary<string, string>(); ctorTest.Add("test", "testValue"); RubyHash hash = new RubyHash(ctorTestO); RubyHash hash2 = new RubyHash(ctorTest); RubyHash mergedHash = hash.Merge(hash2); mergedHash = hash.Merge(ctorTest); mergedHash = hash2.Merge(ctorTestO); } catch { test = false; } Assert.AreEqual(true, test); }
public static void WriteFactsFile(string file) { try { RubyHash common = Facter.GetFacterFacts(); RubyHash nodeSpecific = Facter.GetOpenshiftFacts(); dynamic desc = common.Merge(nodeSpecific); using (StringWriter sw = new StringWriter()) { Serializer serializer = new Serializer(); serializer.Serialize(new Emitter(sw, 2, int.MaxValue, true), desc); File.WriteAllText(file, sw.ToString()); } } catch (Exception ex) { Logger.Error("Error while generating facts file: {0} - {1}", ex.Message, ex.StackTrace); throw; } }
public RubyHash RotateAndYield(object targetGear, Dictionary <string, string> localGearEnv, RubyHash options, GearRotationCallback action) { RubyHash result = new RubyHash() { { "status", RESULT_FAILURE }, { "messages", new List <string>() }, { "errors", new List <string>() } }; string proxyCart = options["proxy_cart"]; string targetGearUuid = targetGear is string?(string)targetGear : ((GearRegistry.Entry)targetGear).Uuid; // TODO: vladi: check if this condition also needs boolean verification on the value in the hash if (options["init"] == null && options["rotate"] != null && options["rotate"] && options["hot_deploy"] != null && options["hot_deploy"]) { result["messages"].Add("Rotating out gear in proxies"); RubyHash rotateOutResults = this.UpdateProxyStatus(new RubyHash() { { "action", "disable" }, { "gear_uuid", targetGearUuid }, { "cartridge", proxyCart } }); result["rotate_out_results"] = rotateOutResults; if (rotateOutResults["status"] != RESULT_SUCCESS) { result["errors"].Add("Rotating out gear in proxies failed."); return(result); } } RubyHash yieldResult = action(targetGear, localGearEnv, options); dynamic yieldStatus = yieldResult.Delete("status"); dynamic yieldMessages = yieldResult.Delete("messages"); dynamic yieldErrors = yieldResult.Delete("errors"); result["messages"].AddRange(yieldMessages); result["errors"].AddRange(yieldErrors); result = result.Merge(yieldResult); if (yieldStatus != RESULT_SUCCESS) { return(result); } if (options["init"] == null && options["rotate"] != null && options["rotate"] && options["hot_deploy"] != null && options["hot_deploy"]) { result["messages"].Add("Rotating in gear in proxies"); RubyHash rotateInResults = this.UpdateProxyStatus(new RubyHash() { { "action", "enable" }, { "gear_uuid", targetGearUuid }, { "cartridge", proxyCart } }); result["rotate_in_results"] = rotateInResults; if (rotateInResults["status"] != RESULT_SUCCESS) { result["errors"].Add("Rotating in gear in proxies failed"); return(result); } } result["status"] = RESULT_SUCCESS; return(result); }
public RubyHash RotateAndYield(object targetGear, Dictionary<string, string> localGearEnv, RubyHash options, GearRotationCallback action) { RubyHash result = new RubyHash() { { "status", RESULT_FAILURE }, { "messages", new List<string>() }, { "errors", new List<string>() } }; string proxyCart = options["proxy_cart"]; string targetGearUuid = targetGear is string ? (string)targetGear : ((GearRegistry.Entry)targetGear).Uuid; // TODO: vladi: check if this condition also needs boolean verification on the value in the hash if (options["init"] == null && options["rotate"] != null && options["rotate"] && options["hot_deploy"] != null && options["hot_deploy"]) { result["messages"].Add("Rotating out gear in proxies"); RubyHash rotateOutResults = this.UpdateProxyStatus(new RubyHash() { { "action", "disable" }, { "gear_uuid", targetGearUuid }, { "cartridge", proxyCart } }); result["rotate_out_results"] = rotateOutResults; if (rotateOutResults["status"] != RESULT_SUCCESS) { result["errors"].Add("Rotating out gear in proxies failed."); return result; } } RubyHash yieldResult = action(targetGear, localGearEnv, options); dynamic yieldStatus = yieldResult.Delete("status"); dynamic yieldMessages = yieldResult.Delete("messages"); dynamic yieldErrors = yieldResult.Delete("errors"); result["messages"].AddRange(yieldMessages); result["errors"].AddRange(yieldErrors); result = result.Merge(yieldResult); if (yieldStatus != RESULT_SUCCESS) { return result; } if (options["init"] == null && options["rotate"] != null && options["rotate"] && options["hot_deploy"] != null && options["hot_deploy"]) { result["messages"].Add("Rotating in gear in proxies"); RubyHash rotateInResults = this.UpdateProxyStatus(new RubyHash() { { "action", "enable" }, { "gear_uuid", targetGearUuid }, { "cartridge", proxyCart } }); result["rotate_in_results"] = rotateInResults; if (rotateInResults["status"] != RESULT_SUCCESS) { result["errors"].Add("Rotating in gear in proxies failed"); return result; } } result["status"] = RESULT_SUCCESS; return result; }