void Server::setDefaults(Host const host, Type const type) { switch (host) { case Local: setLocalDefaults(); break; case Remote: setRemoteDefaults(); break; case Web: setWebDefaults(); break; } switch (type) { case Basic: setBasicDefaults(host); break; case PBS: setPBSDefaults(host); break; case SGE: setSGEDefaults(host); break; case HTTP: /* nowt to do */ break; } }
void Server::setDefaults(Host const host, Type const type) { if (host == Local) { setLocalDefaults(); } else if (host == Remote) { setRemoteDefaults(); } if (type == Basic) { setBasicDefaults(host); } else if (type == PBS) { setPBSDefaults(host); } else { setCustomDefaults(host); } }
void Server::fromQVariant(QVariant const& qvar) { QVariantMap map(qvar.toMap()); setDefaults(Local, Basic); bool ok; // Name if (map.contains("Name") && !map.value("Name").toString().isEmpty()) { m_name = map.value("Name").toString(); } else { throw Server::Exception("???", "Server name not set"); } // Host if (map.contains("Host")) { int host(map.value("Host").toInt(&ok)); if (ok && (host == Remote)) setRemoteDefaults(); } else { throw Server::Exception(m_name, "Remote/Local type not set"); } // Type if (map.contains("Type")) { int type(map.value("Type").toInt(&ok)); if (ok) { switch (type) { case 1: m_type = PBS; break; case 2: m_type = Custom; break; default: m_type = Basic; break; } } } else { throw Server::Exception(m_name, "Server type not set"); } // Job Limit if (map.contains("JobLimit")) { int limit(map.value("JobLimit").toInt(&ok)); if (ok) m_delegateDefaults.insert("JobLimit", limit); } // $QC if (map.contains("QChemEnvironment")) { m_qchemEnvironment = map.value("QChemEnvironment").toString(); } // Host Address if (map.contains("HostAddress")) { m_hostAddress = map.value("HostAddress").toString(); } // User if (map.contains("UserName")) { m_userName = map.value("UserName").toString(); } // Authentication if (map.contains("Authentication")) { int auth(map.value("Authentication").toInt(&ok)); if (ok) { switch (auth) { case 0: m_authentication = None; break; case 1: m_authentication = Agent; break; case 2: m_authentication = PublicKey; break; case 3: m_authentication = HostBased; break; case 4: m_authentication = KeyboardInteractive; break; case 5: m_authentication = Vault; break; case 6: m_authentication = Prompt; break; } } } // Port if (map.contains("Port")) { int port(map.value("Port").toInt(&ok)); if (ok) m_port = port; } // Working Directory if (map.contains("WorkingDirectory")) { m_workingDirectory = map.value("WorkingDirectory").toString(); } // $EXE_NAME if (map.contains("ExecutableName")) { m_executableName = map.value("ExecutableName").toString(); } // $SUBMIT_CMD if (map.contains("SubmitCommand")) { m_submitCommand = map.value("SubmitCommand").toString(); } // $QUERY_CMD if (map.contains("QueryCommand")) { m_queryCommand = map.value("QueryCommand").toString(); } // $KILL_CMD if (map.contains("KillCommand")) { m_killCommand = map.value("KillCommand").toString(); } // Run File Template if (map.contains("RunFileTemplate")) { m_runFileTemplate = map.value("RunFileTemplate").toString(); } // UpdateInterval if (map.contains("UpdateInterval")) { int interval(map.value("UpdateInterval").toInt(&ok)); if (ok) m_updateInterval = interval; } if (map.contains("DelegateDefaults")) { m_delegateDefaults = map.value("DelegateDefaults").toMap(); } }