public String instantiateTag(Map tokens) { return s(tagFormat).formatByMap(tokens); }
public Ssh checkTool(String...toolNames) { String tool = StringUtils.join(Arrays.asList(toolNames), " "); String cmdstr = s("EXIT (){ echo \"$1\"; exit 1;}; cmds=\"{0}\"; for cmd in $cmds; do which $cmd >/dev/null 2>&1 || EXIT \"Not find command: $cmd\"; done").format(tool); return command(cmdstr); }
public SshResult runScriptWithToken(String scriptName, Map token) { String scriptPath = PathUtil.findFileOnClassPath(scriptName, true).getAbsolutePath(); if (token == null) { token = new HashMap(); } String contents = null; try { contents = FileUtils.readFileToString(new File(scriptPath)); } catch (IOException e) { throw new RuntimeException(e); } String script = s(contents).formatByMap(token); return runScript(script); }
String srcScript = String.format("zstack-script-%s", UUID.randomUUID().toString()); scriptFile = new File(PathUtil.join(PathUtil.getFolderUnderZStackHomeFolder("temp-scripts"), srcScript)); scriptContent = s(contents).formatByMap(token);
var.put("foreignVO", foreignVOClass.getSimpleName()); if (where.isEmpty()) { return s("{entity}.{primaryKey} in (select {subEntity}.{foreignKey} from {foreignVO} {subEntity})").formatByMap(var); } else { var.put("condition", StringUtils.join(where, " and ").trim()); return s("{entity}.{primaryKey} in (select {subEntity}.{foreignKey} from {foreignVO} {subEntity} where {condition})").formatByMap(var); return s("{entity}.{foreignKey} in (select {expandedEntity}.{expandedKey} from {expandedVO} {expandedEntity})").formatByMap(var); } else { var.put("condition", StringUtils.join(where, " and ").trim()); return s("{entity}.{foreignKey} in (select {expandedEntity}.{expandedKey} from {expandedVO} {expandedEntity} where {condition})").formatByMap(var);
return s("{entity}.{primaryKey} not in (select {subEntity}.{foreignKey} from {foreignVO} {subEntity} where {condition})").formatByMap(var); } else { var.put("condition", formatSql(foreignVOClass.getSimpleName().toLowerCase(), refName, op)); return s("{entity}.{primaryKey} in (select {subEntity}.{foreignKey} from {foreignVO} {subEntity} where {condition})").formatByMap(var);
String info = s( "\nssh execution[host: {0}, port:{1}]\n", "command: {2}\n",
private String makeUpdateEventPath() { return s(GlobalConfigCanonicalEvents.UPDATE_EVENT_PATH).formatByMap(map( e("nodeUuid", Platform.getManagementServerId()), e("category", category), e("name", name) )); }
void init() { evtf.on(s(GlobalConfigCanonicalEvents.UPDATE_EVENT_PATH).formatByMap(map( e("category", category), e("name", name) )), new EventCallback() { @Override public void run(Map tokens, Object data) { String nodeUuid = (String) tokens.get("nodeUuid"); if (Platform.getManagementServerId().equals(nodeUuid)) { return; } UpdateEvent evt = (UpdateEvent)data; update(evt.getNewValue(), false); logger.info(String.format("GlobalConfig[category: %s, name: %s] was updated in other management node[uuid:%s]," + "in line with that change, updated ours. %s --> %s", category, name, nodeUuid, evt.getOldValue(), value)); } }); }