Alon Bar-Lev has posted comments on this change.
Change subject: Adding query for fetching ssh pubic key
......................................................................
Patch Set 2: (6 inline comments)
....................................................
File
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetServerSSHPublicKeyQuery.java
Line 13: protected EngineSSHDialog getEngineSSHDialog() {
Line 14: return new EngineSSHDialog();
Line 15: }
Line 16:
Line 17: public GetServerSSHPublicKeyQuery(P parameters) {
fingerprint?
Line 18: super(parameters);
Line 19: }
Line 20:
Line 21: public String getServerPublicKey(String serverName) {
Line 18: super(parameters);
Line 19: }
Line 20:
Line 21: public String getServerPublicKey(String serverName) {
Line 22: PublicKey pk = null;
tab
Line 23: EngineSSHDialog dialog = getEngineSSHDialog();
Line 24: try {
Line 25: dialog.setHost(serverName);
Line 26: dialog.connect();
Line 19: }
Line 20:
Line 21: public String getServerPublicKey(String serverName) {
Line 22: PublicKey pk = null;
Line 23: EngineSSHDialog dialog = getEngineSSHDialog();
Please use EngineSSHClient for this.
Line 24: try {
Line 25: dialog.setHost(serverName);
Line 26: dialog.connect();
Line 27: dialog.useDefaultKeyPair();
Line 23: EngineSSHDialog dialog = getEngineSSHDialog();
Line 24: try {
Line 25: dialog.setHost(serverName);
Line 26: dialog.connect();
Line 27: dialog.useDefaultKeyPair();
Why do you need to authenticate?
Line 28: PublicKey pk = dialog.getPublicKey
Line 29: } catch (Throwable e) {
Line 30: log.errorFormat("Could not ssh public key of host {0} with
message: {1}",
Line 31: serverName,
Line 24: try {
Line 25: dialog.setHost(serverName);
Line 26: dialog.connect();
Line 27: dialog.useDefaultKeyPair();
Line 28: PublicKey pk = dialog.getPublicKey
I don't understand this statement.
Line 29: } catch (Throwable e) {
Line 30: log.errorFormat("Could not ssh public key of host {0} with
message: {1}",
Line 31: serverName,
Line 32: ExceptionUtils.getMessage(e)
Line 33: );
Line 34: } finally {
Line 35: dialog.disconnect();
Line 36: }
Line 37: return pk.toString();
I wrote you the complete code... why haven't you used it?
[Monday 17 June 2013] [14:13:24] <alonbl> private String getFingerprint(String
host, int port, timeout) {
[Monday 17 June 2013] [14:13:24] <alonbl> SSHClient client = null;
[Monday 17 June 2013] [14:13:24] <alonbl> try {
[Monday 17 June 2013] [14:13:24] <alonbl> SSHClient client = new SSHClient();
[Monday 17 June 2013] [14:13:24] <alonbl> client.setHardTimeout(timeout);
[Monday 17 June 2013] [14:13:24] <alonbl> client.setSoftTimeout(timeout);
[Monday 17 June 2013] [14:13:24] <alonbl> client.setHost(host, port);
[Monday 17 June 2013] [14:13:24] <alonbl> client.connect();
[Monday 17 June 2013] [14:13:24] <alonbl> return
OpenSSHUtils.getKeyFingerprintString(client.getHostKey());
[Monday 17 June 2013] [14:13:24] <alonbl> } finally {
[Monday 17 June 2013] [14:13:24] <alonbl> if (client != null) {
[Monday 17 June 2013] [14:13:24] <alonbl> client.disconnect();
[Monday 17 June 2013] [14:13:24] <alonbl> }
[Monday 17 June 2013] [14:13:24] <alonbl> }
[Monday 17 June 2013] [14:13:24] <alonbl> }
Line 38: }
Line 39:
Line 40: @Override
Line 41: protected void executeQueryCommand() {
--
To view, visit http://gerrit.ovirt.org/16019
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie508d6f9bdaa482f46a3cf1224b2fd84568299ba
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Yaniv Bronhaim <[email protected]>
Gerrit-Reviewer: Alon Bar-Lev <[email protected]>
Gerrit-Reviewer: Yair Zaslavsky <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches