コード例 #1
0
 public void Test_GearRegistry_Entry()
 {
    bool testresult=false;
    Dictionary<string, object> entryops = new Dictionary<string, object>();                
    entryops["uuid"] = "test";
    entryops["namespace"] = "testnamespace";
    entryops["dns"] = "127.0.0.1";
    entryops["proxy_hostname"] = "broker.test.com";
    entryops["proxy_port"] = "65555";
    GearRegistry.Entry entry = new GearRegistry.Entry(entryops);
    string jsonEntry=entry.ToJson();
    string SshUrlEntry = entry.ToSshUrl();
    if (jsonEntry != string.Empty && SshUrlEntry != string.Empty)
    {
        testresult = true;
    }
    Assert.AreEqual(true, testresult);
 }
コード例 #2
0
        public RubyHash RestartGear(object targetGear, Dictionary<string, string> localGearEnv, string cartName, dynamic options)
        {
            string targetGearUuid = targetGear is string ? (string)targetGear : ((GearRegistry.Entry)targetGear).Uuid;
            RubyHash result = new RubyHash()
            {
                { "status", RESULT_SUCCESS },
                { "messages", new List<string>() },
                { "errors", new List<string>() },
                { "target_gear_uuid", targetGearUuid }
            };

            try
            {
                if (targetGearUuid == this.Uuid)
                {
                    result["messages"].Add(this.Cartridge.StartCartridge("restart", cartName, options));
                }
                else
                {

                    string ooSSH = @"/cygpath/c/openshift/oo-bin/oo-ssh";
                    string bashBinary = Path.Combine(NodeConfig.Values["SSHD_BASE_DIR"], "bin\bash.exe");

                    if (targetGear is string)
                    {
                        targetGear = new GearRegistry.Entry(options);
                    }
                    string sshCommand = string.Format("{0} {1} gear restart --cart {2} --as-json",
                        ooSSH, ((GearRegistry.Entry)targetGear).ToSshUrl(), cartName);
                    string bashArgs = string.Format("--norc --login -c '{0}'", sshCommand);
                    string command = string.Format("{0} {1}", bashBinary, bashArgs);

                    RunProcessInContainerContext(this.ContainerDir, command);

                }
            }
            catch(Exception ex)
            {
                result["errors"].Add(ex.ToString());
                result["status"] = RESULT_FAILURE;
                Logger.Error(ex.ToString());
            }

            return result;
        }