|
16 | 16 | // under the License. |
17 | 17 | package com.cloud.hypervisor.kvm.storage; |
18 | 18 |
|
19 | | -import java.io.BufferedReader; |
20 | | -import java.io.IOException; |
21 | | -import java.io.InputStreamReader; |
22 | 19 | import java.util.Collections; |
23 | 20 | import java.util.HashMap; |
24 | 21 | import java.util.List; |
25 | 22 | import java.util.Map; |
26 | 23 | import java.util.Optional; |
27 | | -import java.util.StringJoiner; |
28 | 24 |
|
29 | 25 | import javax.annotation.Nonnull; |
30 | 26 |
|
| 27 | +import com.cloud.storage.Storage; |
| 28 | +import com.cloud.utils.exception.CloudRuntimeException; |
31 | 29 | import org.apache.cloudstack.storage.datastore.util.LinstorUtil; |
32 | 30 | import org.apache.cloudstack.utils.qemu.QemuImg; |
33 | 31 | import org.apache.cloudstack.utils.qemu.QemuImgException; |
34 | 32 | import org.apache.cloudstack.utils.qemu.QemuImgFile; |
35 | 33 | import org.apache.log4j.Logger; |
36 | 34 | import org.libvirt.LibvirtException; |
37 | 35 |
|
38 | | -import com.cloud.storage.Storage; |
39 | | -import com.cloud.utils.exception.CloudRuntimeException; |
40 | 36 | import com.linbit.linstor.api.ApiClient; |
41 | 37 | import com.linbit.linstor.api.ApiException; |
42 | 38 | import com.linbit.linstor.api.Configuration; |
@@ -69,28 +65,6 @@ private static String getLinstorRscName(String name) { |
69 | 65 | return LinstorUtil.RSC_PREFIX + name; |
70 | 66 | } |
71 | 67 |
|
72 | | - private String getHostname() { |
73 | | - // either there is already some function for that in the agent or a better way. |
74 | | - ProcessBuilder pb = new ProcessBuilder("/usr/bin/hostname"); |
75 | | - try |
76 | | - { |
77 | | - String result; |
78 | | - Process p = pb.start(); |
79 | | - final BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); |
80 | | - |
81 | | - StringJoiner sj = new StringJoiner(System.getProperty("line.separator")); |
82 | | - reader.lines().iterator().forEachRemaining(sj::add); |
83 | | - result = sj.toString(); |
84 | | - |
85 | | - p.waitFor(); |
86 | | - p.destroy(); |
87 | | - return result.trim(); |
88 | | - } catch (IOException | InterruptedException exc) { |
89 | | - Thread.currentThread().interrupt(); |
90 | | - throw new CloudRuntimeException("Unable to run '/usr/bin/hostname' command."); |
91 | | - } |
92 | | - } |
93 | | - |
94 | 68 | private void logLinstorAnswer(@Nonnull ApiCallRc answer) { |
95 | 69 | if (answer.isError()) { |
96 | 70 | s_logger.error(answer.getMessage()); |
@@ -121,7 +95,7 @@ private void handleLinstorApiAnswers(ApiCallRcList answers, String excMessage) { |
121 | 95 | } |
122 | 96 |
|
123 | 97 | public LinstorStorageAdaptor() { |
124 | | - localNodeName = getHostname(); |
| 98 | + localNodeName = LinstorStoragePool.getHostname(); |
125 | 99 | } |
126 | 100 |
|
127 | 101 | @Override |
|
0 commit comments