|
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; |
@@ -73,28 +69,6 @@ private static String getLinstorRscName(String name) { |
73 | 69 | return LinstorUtil.RSC_PREFIX + name; |
74 | 70 | } |
75 | 71 |
|
76 | | - private String getHostname() { |
77 | | - // either there is already some function for that in the agent or a better way. |
78 | | - ProcessBuilder pb = new ProcessBuilder("/usr/bin/hostname"); |
79 | | - try |
80 | | - { |
81 | | - String result; |
82 | | - Process p = pb.start(); |
83 | | - final BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); |
84 | | - |
85 | | - StringJoiner sj = new StringJoiner(System.getProperty("line.separator")); |
86 | | - reader.lines().iterator().forEachRemaining(sj::add); |
87 | | - result = sj.toString(); |
88 | | - |
89 | | - p.waitFor(); |
90 | | - p.destroy(); |
91 | | - return result.trim(); |
92 | | - } catch (IOException | InterruptedException exc) { |
93 | | - Thread.currentThread().interrupt(); |
94 | | - throw new CloudRuntimeException("Unable to run '/usr/bin/hostname' command."); |
95 | | - } |
96 | | - } |
97 | | - |
98 | 72 | private void logLinstorAnswer(@Nonnull ApiCallRc answer) { |
99 | 73 | if (answer.isError()) { |
100 | 74 | s_logger.error(answer.getMessage()); |
@@ -125,7 +99,7 @@ private void handleLinstorApiAnswers(ApiCallRcList answers, String excMessage) { |
125 | 99 | } |
126 | 100 |
|
127 | 101 | public LinstorStorageAdaptor() { |
128 | | - localNodeName = getHostname(); |
| 102 | + localNodeName = LinstorStoragePool.getHostname(); |
129 | 103 | } |
130 | 104 |
|
131 | 105 | @Override |
|
0 commit comments