Eli Mesika has posted comments on this change.

Change subject: Add VdsPowerDown command and use it in Power saving policy
......................................................................


Patch Set 1:

(6 comments)

....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsPowerDownCommand.java
Line 34:     protected void executeCommand() {
Line 35:         setVds(null);
Line 36:         if (getVds() == null) {
Line 37:             setCommandShouldBeLogged(false);
Line 38:             log.infoFormat("SSH powerdown will not be executed on host 
{0}({1}) since it doesn't exist anymore.",
power down
Line 39:                     getVdsName(),
Line 40:                     getVdsId());
Line 41:             getReturnValue().setSucceeded(false);
Line 42:             return;


Line 44: 
Line 45:         /* Try this only when the Host is in maintenance state */
Line 46:         if (getVds().getStatus() != VDSStatus.Maintenance) {
Line 47:             setCommandShouldBeLogged(false);
Line 48:             log.infoFormat("SSH powerdown will not be executed on host 
{0}({1}) since it is not in Maintenance.",
same
Line 49:                     getVdsName(),
Line 50:                     getVdsId());
Line 51:             getReturnValue().setSucceeded(false);
Line 52:             return;


Line 47:             setCommandShouldBeLogged(false);
Line 48:             log.infoFormat("SSH powerdown will not be executed on host 
{0}({1}) since it is not in Maintenance.",
Line 49:                     getVdsName(),
Line 50:                     getVdsId());
Line 51:             getReturnValue().setSucceeded(false);
This can be re-factored as a function that get the message as an argument and 
then you can call it instead of repeating the code block

private void handleError(String msg) {
    setCommandShouldBeLogged(false);
    log.infoFormat(msg,getVdsName(),getVdsId());
    getReturnValue().setSucceeded(false);
}
Line 52:             return;
Line 53:         }
Line 54: 
Line 55:         boolean result = 
executeSshPowerdown(getVds().getVdsGroupCompatibilityVersion().toString());


Line 86:                 final ByteArrayOutputStream cmdOut = new 
ByteArrayOutputStream();
Line 87:                 final ByteArrayOutputStream cmdErr = new 
ByteArrayOutputStream();
Line 88:         ) {
Line 89:             try {
Line 90:                 log.infoFormat("Opening SSH powerdown session on host 
{0}", getVds().getHostName());
power down
Line 91:                 sshClient.setVds(getVds());
Line 92:                 sshClient.useDefaultKeyPair();
Line 93:                 sshClient.connect();
Line 94:                 sshClient.authenticate();


Line 92:                 sshClient.useDefaultKeyPair();
Line 93:                 sshClient.connect();
Line 94:                 sshClient.authenticate();
Line 95: 
Line 96:                 log.infoFormat("Executing SSH powerdown command on 
host {0}", getVds().getHostName());
same
Line 97:                 sshClient.executeCommand(
Line 98:                         Config.<String> 
getValue(ConfigValues.SshVdsPowerdownCommand, version),
Line 99:                         null,
Line 100:                         cmdOut,


Line 101:                         cmdErr
Line 102:                 );
Line 103:                 ret = true;
Line 104:             } catch (Exception ex) {
Line 105:                 log.errorFormat("SSH powerdown command failed on host 
{0}: {1}\nStdout: {2}\nStderr: {3}\nStacktrace: {4}",
same
Line 106:                         getVds().getHostName(), ex.getMessage(), 
cmdOut.toString(), cmdErr.toString(), ex);
Line 107:             }
Line 108:         }
Line 109:         catch(IOException e) {


-- 
To view, visit http://gerrit.ovirt.org/22520
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Iccb9064dcfc9c20901d32a550354d66bbb0cc863
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Martin Sivák <[email protected]>
Gerrit-Reviewer: Doron Fediuck <[email protected]>
Gerrit-Reviewer: Eli Mesika <[email protected]>
Gerrit-Reviewer: Gilad Chaplik <[email protected]>
Gerrit-Reviewer: Martin Sivák <[email protected]>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to