Пример #1
0
// Create a connection to the host. defined by the
// argument host.  If the argument is empty, do a
// connect local
Boolean connectToHost(CIMClient& client, const String& inputName)
{
    // Try to connect.  If there is an optional argument use it as the
    // hostname, optional(port) to connect.
    try
    {
        if (inputName != "")
        {
            Uint32 port;
            String hostName;
            if (!parseHostName(inputName, hostName, port))
            {
                cerr << "Invalid hostName input " << inputName
                     << "format is hostname[:port]" << endl;
                return 1;
            }

            VCOUT << "Connect hostName = " << hostName << " port = "
                  << port << endl;
            client.connect(hostName, port, "", "");
        }
        else
        {
            VCOUT << "connectLocal" << endl;
            client.connectLocal();
        }
        return true;
    }

    catch (CIMException& e)
    {
            cerr << "CIMException Error: in connect: CIMException "
                 << e.getMessage() << endl;
    }
    catch (Exception& e)
    {
        cerr << "Error: in connect: Exception " << e.getMessage() << endl;
    }
    return false;
}
Пример #2
0
bool connectToHost(CIMClient& client, String host_opt = "")
{
    try
    {
        if (host_opt == "")
        {
            VCOUT << "connectLocal" << endl;
            client.connectLocal();
        }
        else
        {
            String hostName;
            Uint32 port;
            if (parseHostName(host_opt, hostName, port))
            {
                VCOUT << " Connect to host "
                       << hostName << ":" << port << endl;
                client.connect(hostName, port, user_opt, password_opt);
            }
            else
            {
                cerr << "Host name parameter error " << hostName << endl;
                PEGASUS_TEST_ASSERT(false);
            }
        }
    }

    catch (CIMException& e)
    {
        cerr << "CIMException Error: in connect " << e.getMessage() << endl;
        PEGASUS_TEST_ASSERT(false);
    }
    catch (Exception& e)
    {
        cerr << "Error: in connect " << e.getMessage() << endl;
        PEGASUS_TEST_ASSERT(false);
    }
    return true;
}
Пример #3
0
bool
LocalConfig::parseString(const char * connectString, BaseString &err){
  char * for_strtok;
  char * copy = strdup(connectString);
  NdbAutoPtr<char> tmp_aptr(copy);

  for (char *tok = strtok_r(copy,";,",&for_strtok); tok != 0;
       tok = strtok_r(NULL, ";,", &for_strtok)) {
    if (tok[0] == '#') continue;

    if (!_ownNodeId) // only one nodeid definition allowed
      if (parseNodeId(tok))
	continue;
    if (parseHostName(tok))
      continue;
    if (parseFileName(tok))
      continue;
    
    err.assfmt("Unexpected entry: \"%s\"", tok);
    return false;
  }

  return true;
}