void SyntiParameterData::print() const { SParmId spid(_id); if (_type == P_FLOAT) { printf("<id=(%d,%d,%d) name=%s val=%f>", spid.syntiId, spid.subsystemId, spid.paramId, qPrintable(_name), _fval); } else if (_type == P_STRING) { printf("<id=(%d,%d,%d) name=%s val=%s>", spid.syntiId, spid.subsystemId, spid.paramId, qPrintable(_name), qPrintable(_sval)); } }
QString QueryCommand(bool const local) { QString cmd("/bin/ps xc -S -o command=,pid=,time= ${JOB_ID}"); if (local) { // The command only changes for Windows boxes #ifdef Q_OS_WIN32 QFileInfo tasklist("/Windows/System32/tasklist.exe"); if (tasklist.exists()) { QString spid("\"PID eq ${JOB_ID}\""); QStringList args; args << "/v" << "/fo list" << "/fi " + spid; cmd = tasklist.filePath() + " " + args.join(" "); }else { return QString("Error: tasklist.exe not found"); } #endif } return cmd; }
void Sinful::regenerateV1String() { if(! m_valid) { // The empty list. m_v1String = "{}"; return; } std::vector< SourceRoute > v; std::vector< SourceRoute > publics; // // We need to preserve the primary address to permit round-trips from // original serialization to v1 serialization and back again. If we're // clever, we can also use the special primary-address entry to handle // some troublesome backwards-compability concerns: original Sinful // did no input validation, and an empty original Sinful is considered // valid. We should also be able to maintain the invariant that all // addresses are protocol literals (and therefore require no lookup). // SourceRoute sr( CP_PRIMARY, m_host, getPortNum(), PUBLIC_NETWORK_NAME ); v.push_back( sr ); // // Presently, // each element of the list must be of one of the following forms: // // a = primary, port = port, p = IPv4, n = "internet" // a = primary, port = port, p = IPv6, n = "internet" // a = addrs[], port = port, p = IPv4, n = "internet" // a = addrs[], port = port, p = IPv6, n = "internet" // // a = primary, port = port, p = IPv4, n = "private" // a = primary, port = port, p = IPv6, n = "private" // a = private, port = privport, p = IPv4, n = "private" // a = private, port = privport, p = IPv6, n = "private" // // a = CCB[], port = ccbport, p = IPv4, n = "internet" // a = CCB[], port = ccbport, p = IPv6, n = "internet" // a = CCB[], port = ccbport, p = IPv4, n = "internet", ccbsharedport // a = CCB[], port = ccbport, p = IPv6, n = "internet", ccbsharedport // // Additionally, each of the above may also include sp; if any // address includes sp, all must include (the same) sp. // // Start by generating our list of public addresses. if( numParams() == 0 ) { condor_sockaddr sa; if( sa.from_ip_string( m_host ) ) { SourceRoute * sr = simpleRouteFromSinful( * this ); if( sr != NULL ) { publics.push_back( * sr ); delete sr; } } } else if( hasAddrs() ) { for( unsigned i = 0; i < addrs.size(); ++i ) { condor_sockaddr sa = addrs[i]; SourceRoute sr( sa, PUBLIC_NETWORK_NAME ); publics.push_back( sr ); } } // If we have a private network, either: // * add its private network address, if it exists // or // * add each of its public addresses. // In both cases, the network name for the routes being added is the // private network name. if( getPrivateNetworkName() != NULL ) { if( getPrivateAddr() == NULL ) { for( unsigned i = 0; i < publics.size(); ++i ) { SourceRoute sr( publics[i], getPrivateNetworkName() ); v.push_back( sr ); } } else { // The private address is defined to be a simple original Sinful, // just and ip-and-port string surrounded by brackets. This is // overkill, but it's less ugly than stripping the brackets. Sinful s( getPrivateAddr() ); if(! s.valid()) { m_valid = false; return; } SourceRoute * sr = simpleRouteFromSinful( s, getPrivateNetworkName() ); if( sr == NULL ) { m_valid = false; return; } v.push_back( * sr ); free( sr ); } } // If we have a CCB address, add all CCB addresses. Otherwise, add all // of our public addresses. if( getCCBContact() != NULL ) { unsigned brokerIndex = 0; StringList brokers( getCCBContact(), " " ); brokers.rewind(); char * contact = NULL; while( (contact = brokers.next()) != NULL ) { MyString ccbAddr, ccbID; MyString peer( "er, constructing v1 Sinful string" ); bool contactOK = CCBClient::SplitCCBContact( contact, ccbAddr, ccbID, peer, NULL ); if(! contactOK ) { m_valid = false; return; } // // A ccbAddr is an original Sinful without the <brackets>. It // may have "PrivNet", "sock", "noUDP", and "alias" set. What // we want to do is add copy ccbAddr's source routes to this // Sinful, adding the ccbID and setting the brokerIndex, so // that we know how to merge them back together when regenerating // this Sinful's original Sinful string. // std::string ccbSinfulString; formatstr( ccbSinfulString, "<%s>", ccbAddr.c_str() ); Sinful s( ccbSinfulString.c_str() ); if(! s.valid()) { m_valid = false; return; } std::vector< SourceRoute > w; if(! s.getSourceRoutes( w )) { m_valid = false; return; } for( unsigned j = 0; j < w.size(); ++j ) { SourceRoute sr = w[j]; sr.setBrokerIndex( brokerIndex ); sr.setCCBID( ccbID.c_str() ); sr.setSharedPortID( "" ); if( s.getSharedPortID() != NULL ) { sr.setCCBSharedPortID( s.getSharedPortID() ); } v.push_back( sr ); } ++brokerIndex; } } // We'll never use these addresses -- the CCB address will supersede // them -- but we need to record them to properly recreate addrs. for( unsigned i = 0; i < publics.size(); ++i ) { v.push_back( publics[i] ); } // Set the host alias, if present, on all addresses. if( getAlias() != NULL ) { std::string alias( getAlias() ); for( unsigned i = 0; i < v.size(); ++i ) { v[i].setAlias( alias ); } } // Set the shared port ID, if present, on all addresses. if( getSharedPortID() != NULL ) { std::string spid( getSharedPortID() ); for( unsigned i = 0; i < v.size(); ++i ) { v[i].setSharedPortID( spid ); } } // Set noUDP, if true, on all addresses. (We don't have to set // noUDP on public non-CCB addresses, or on the private address, // unless WANT_UDP_COMMAND_SOCKET is false. However, we can't // distinguish that case from the former two unless both CCB and // SP are disabled.) if( noUDP() ) { for( unsigned i = 0; i < v.size(); ++i ) { v[i].setNoUDP( true ); } } // // Now that we've generated a list of source routes, convert it into // a nested ClassAd list. The correct way to do this is to faff // about with ClassAds, but they make it uneccessarily hard; for now, // I'll just generated the appropriate string directly. // m_v1String.erase(); m_v1String += "{"; m_v1String += v[0].serialize(); for( unsigned i = 1; i < v.size(); ++i ) { m_v1String += ", "; m_v1String += v[i].serialize(); } m_v1String += "}"; }