@@ -0,0 +1,2980 @@
+package org.zstack.core.ansible;%0A%0Aimport org.apache.logging.log4j.util.Strings;%0Aimport org.zstack.utils.Utils;%0Aimport org.zstack.utils.logging.CLogger;%0Aimport org.zstack.utils.ssh.Ssh;%0Aimport org.zstack.utils.ssh.SshResult;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0Aimport java.util.stream.Collectors;%0A%0A/**%0A * Created by MaJin on 2019/12/14.%0A */%0Apublic class SshYamlChecker implements AnsibleChecker %7B%0A    private static final CLogger logger = Utils.getLogger(SshYamlChecker.class);%0A%0A    private String yamlFilePath;%0A    private String username;%0A    private String password;%0A    private String privateKey;%0A    private String targetIp;%0A    private int sshPort = 22;%0A    private Map%3CString, String%3E expectConfigs = new HashMap%3C%3E();%0A%0A    @Override%0A    public boolean needDeploy() %7B%0A        if (Strings.isEmpty(yamlFilePath) %7C%7C expectConfigs.isEmpty()) %7B%0A            return false;%0A        %7D%0A%0A        Ssh ssh = new Ssh();%0A        ssh.setUsername(username).setPrivateKey(privateKey)%0A                .setPassword(password).setPort(sshPort)%0A                .setHostname(targetIp);%0A        try %7B%0A%0A            ssh.command(String.format(%22grep -o '%25s' %25s %7C uniq %7C wc -l%22, getGrepArgs(), yamlFilePath));%0A            SshResult ret = ssh.run();%0A            if (ret.getReturnCode() != 0) %7B%0A                return true;%0A            %7D%0A%0A            String out = ret.getStdout();%0A            if (Strings.isEmpty(out) %7C%7C !out.trim().equals(String.valueOf(expectConfigs.size()))) %7B%0A                return true;%0A            %7D%0A%0A            ssh.reset();%0A        %7D finally %7B%0A            ssh.close();%0A        %7D%0A%0A        return false;%0A    %7D%0A%0A    @Override%0A    public void deleteDestFile() %7B%0A        // do nothing.%0A    %7D%0A%0A    public SshYamlChecker expectConfig(String key, String value) %7B%0A        expectConfigs.put(key, value);%0A        return this;%0A    %7D%0A%0A    private String getGrepArgs() %7B%0A        return expectConfigs.entrySet().stream().map(it -%3E it.getKey() + %22%5C%5Cs*:%5C%5Cs*%22 + it.getValue())%0A                .collect(Collectors.joining(%22%5C%5C%7C%22));%0A    %7D%0A%0A    public String getUsername() %7B%0A        return username;%0A    %7D%0A%0A    public void setUsername(String username) %7B%0A        this.username = username;%0A    %7D%0A%0A    public String getPassword() %7B%0A        return password;%0A    %7D%0A%0A    public void setPassword(String password) %7B%0A        this.password = password;%0A    %7D%0A%0A    public String getPrivateKey() %7B%0A        return privateKey;%0A    %7D%0A%0A    public void setPrivateKey(String privateKey) %7B%0A        this.privateKey = privateKey;%0A    %7D%0A%0A    public int getSshPort() %7B%0A        return sshPort;%0A    %7D%0A%0A    public void setSshPort(int sshPort) %7B%0A        this.sshPort = sshPort;%0A    %7D%0A%0A    public String getTargetIp() %7B%0A        return targetIp;%0A    %7D%0A%0A    public void setTargetIp(String targetIp) %7B%0A        this.targetIp = targetIp;%0A    %7D%0A%0A    public String getYamlFilePath() %7B%0A        return yamlFilePath;%0A    %7D%0A%0A    public void setYamlFilePath(String yamlFilePath) %7B%0A        this.yamlFilePath = yamlFilePath;%0A    %7D%0A%7D%0A

support update image store quota by global config mini upgrade set image store qupta config Resolves MINI-1564