|
30 | 30 | import java.util.HashMap; |
31 | 31 | import java.util.List; |
32 | 32 | import java.util.Map; |
33 | | -import java.util.Random; |
| 33 | + |
34 | 34 | import java.util.UUID; |
35 | 35 |
|
36 | 36 | import javax.naming.ConfigurationException; |
|
49 | 49 | import com.cloud.agent.api.ReadyAnswer; |
50 | 50 | import com.cloud.agent.api.ReadyCommand; |
51 | 51 | import com.cloud.agent.api.SecStorageFirewallCfgCommand; |
| 52 | +import com.cloud.agent.api.SecStorageSetupAnswer; |
52 | 53 | import com.cloud.agent.api.SecStorageSetupCommand; |
53 | 54 | import com.cloud.agent.api.StartupSecondaryStorageCommand; |
54 | 55 | import com.cloud.agent.api.SecStorageFirewallCfgCommand.PortConfig; |
@@ -95,8 +96,6 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S |
95 | 96 | boolean _inSystemVM = false; |
96 | 97 | boolean _sslCopy = false; |
97 | 98 |
|
98 | | - Random _rand = new Random(System.currentTimeMillis()); |
99 | | - |
100 | 99 | DownloadManager _dlMgr; |
101 | 100 | UploadManager _upldMgr; |
102 | 101 | private String _configSslScr; |
@@ -219,7 +218,11 @@ private Answer execute(SecStorageSetupCommand cmd) { |
219 | 218 | String nfsHostIp = nfsHostAddr.getHostAddress(); |
220 | 219 |
|
221 | 220 | addRouteToInternalIpOrCidr(_localgw, _eth1ip, _eth1mask, nfsHostIp); |
222 | | - return new Answer(cmd, true, "success"); |
| 221 | + String nfsPath = nfsHostIp + ":" + uri.getPath(); |
| 222 | + String dir = UUID.nameUUIDFromBytes(nfsPath.getBytes()).toString(); |
| 223 | + String root = _parent + "/" + dir; |
| 224 | + mount(root, nfsPath); |
| 225 | + return new SecStorageSetupAnswer(dir); |
223 | 226 | } catch (Exception e) { |
224 | 227 | String msg = "GetRootDir for " + secUrl + " failed due to " + e.toString(); |
225 | 228 | s_logger.error(msg); |
@@ -707,6 +710,15 @@ public StartupCommand[] initialize() { |
707 | 710 | fillNetworkInformation(cmd); |
708 | 711 | if(_publicIp != null) |
709 | 712 | cmd.setPublicIpAddress(_publicIp); |
| 713 | + |
| 714 | + Script command = new Script("/bin/bash", s_logger); |
| 715 | + command.add("-c"); |
| 716 | + command.add("ln -sf " + _parent + " /var/www/html/copy"); |
| 717 | + String result = command.execute(); |
| 718 | + if (result != null) { |
| 719 | + s_logger.warn("Error in linking err=" + result); |
| 720 | + return null; |
| 721 | + } |
710 | 722 | return new StartupCommand[] {cmd}; |
711 | 723 | } |
712 | 724 |
|
|
0 commit comments