[GitHub] cloudstack pull request #1660: CLOUDSTACK-9470: [BLOCKER] Bug in SshHelper a...

2016-09-10 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/cloudstack/pull/1660


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1660: CLOUDSTACK-9470: [BLOCKER] Bug in SshHelper a...

2016-09-02 Thread nvazquez
Github user nvazquez commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1660#discussion_r77363519
  
--- Diff: utils/src/main/java/com/cloud/utils/ssh/SshHelper.java ---
@@ -196,6 +201,16 @@ public static void scpTo(String host, int port, String 
user, File pemKeyFile, St
 
 String result = sbResult.toString();
 
+if (StringUtils.isBlank(result)) {
+try {
+result = IOUtils.toString(stdout, UTF8);
--- End diff --

Done, thanks @jburwell 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1660: CLOUDSTACK-9470: [BLOCKER] Bug in SshHelper a...

2016-09-01 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1660#discussion_r77285299
  
--- Diff: utils/src/main/java/com/cloud/utils/ssh/SshHelper.java ---
@@ -196,6 +201,16 @@ public static void scpTo(String host, int port, String 
user, File pemKeyFile, St
 
 String result = sbResult.toString();
 
+if (StringUtils.isBlank(result)) {
+try {
+result = IOUtils.toString(stdout, UTF8);
--- End diff --

Rather than use a homegrown string constant, pass 
``StandardCharsets.UTF_8`` instead.  An additional benefit is that it is a 
``Charset`` instance which provides greater type safety.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1660: CLOUDSTACK-9470: [BLOCKER] Bug in SshHelper a...

2016-08-29 Thread rhtyd
Github user rhtyd commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1660#discussion_r76731318
  
--- Diff: utils/src/main/java/com/cloud/utils/ssh/SshHelper.java ---
@@ -196,6 +198,10 @@ public static void scpTo(String host, int port, String 
user, File pemKeyFile, St
 
 String result = sbResult.toString();
 
+if (StringUtils.isBlank(result)) {
+result = IOUtils.toString(stdout);
--- End diff --

Add the default utf8 encoding, what if this throws an exception 
(IOException)?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1660: CLOUDSTACK-9470: [BLOCKER] Bug in SshHelper a...

2016-08-28 Thread nvazquez
Github user nvazquez commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1660#discussion_r76532860
  
--- Diff: utils/src/main/java/com/cloud/utils/ssh/SshHelper.java ---
@@ -196,6 +198,9 @@ public static void scpTo(String host, int port, String 
user, File pemKeyFile, St
 
 String result = sbResult.toString();
 
+if (StringUtils.isBlank(result))
+result = IOUtils.toString(stdout);
--- End diff --

Done, thanks


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1660: CLOUDSTACK-9470: [BLOCKER] Bug in SshHelper a...

2016-08-28 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1660#discussion_r76530524
  
--- Diff: utils/src/main/java/com/cloud/utils/ssh/SshHelper.java ---
@@ -196,6 +198,9 @@ public static void scpTo(String host, int port, String 
user, File pemKeyFile, St
 
 String result = sbResult.toString();
 
+if (StringUtils.isBlank(result))
+result = IOUtils.toString(stdout);
--- End diff --

Per our coding standards, all conditionals must wrapped in curly braces.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1660: CLOUDSTACK-9470: [BLOCKER] Bug in SshHelper a...

2016-08-27 Thread nvazquez
Github user nvazquez commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1660#discussion_r76517786
  
--- Diff: utils/src/main/java/com/cloud/utils/ssh/SshHelper.java ---
@@ -195,6 +195,15 @@ public static void scpTo(String host, int port, String 
user, File pemKeyFile, St
 }
 
 String result = sbResult.toString();
+if (result == null || (result != null && result.isEmpty())){
+int stdOutAvailable = stdout.available();
+while (stdOutAvailable != 0){
+currentReadBytes = stdout.read(buffer);
+sbResult.append(new String(buffer, 0, 
currentReadBytes));
+stdOutAvailable = stdout.available();
+}
+result = sbResult.toString();
--- End diff --

Great, didn't know about those utils, thanks!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1660: CLOUDSTACK-9470: [BLOCKER] Bug in SshHelper a...

2016-08-27 Thread nvazquez
Github user nvazquez commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1660#discussion_r76517779
  
--- Diff: utils/src/main/java/com/cloud/utils/ssh/SshHelper.java ---
@@ -195,6 +195,15 @@ public static void scpTo(String host, int port, String 
user, File pemKeyFile, St
 }
 
 String result = sbResult.toString();
+if (result == null || (result != null && result.isEmpty())){
--- End diff --

Done, thanks


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1660: CLOUDSTACK-9470: [BLOCKER] Bug in SshHelper a...

2016-08-26 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1660#discussion_r76476168
  
--- Diff: utils/src/main/java/com/cloud/utils/ssh/SshHelper.java ---
@@ -195,6 +195,15 @@ public static void scpTo(String host, int port, String 
user, File pemKeyFile, St
 }
 
 String result = sbResult.toString();
+if (result == null || (result != null && result.isEmpty())){
--- End diff --

Consider using ``StringUtils.isBlank`` which will not only make the code 
more expressive, but also covers the case where the string is composed only of 
whitespace.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1660: CLOUDSTACK-9470: [BLOCKER] Bug in SshHelper a...

2016-08-26 Thread jburwell
Github user jburwell commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1660#discussion_r76477326
  
--- Diff: utils/src/main/java/com/cloud/utils/ssh/SshHelper.java ---
@@ -195,6 +195,15 @@ public static void scpTo(String host, int port, String 
user, File pemKeyFile, St
 }
 
 String result = sbResult.toString();
+if (result == null || (result != null && result.isEmpty())){
+int stdOutAvailable = stdout.available();
+while (stdOutAvailable != 0){
+currentReadBytes = stdout.read(buffer);
+sbResult.append(new String(buffer, 0, 
currentReadBytes));
+stdOutAvailable = stdout.available();
+}
+result = sbResult.toString();
--- End diff --

Consider replacing lines 199-205 with the following:
```
 result = IOUtils.toString(buffer, Charset.defaultCharset());
```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---