You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by no...@apache.org on 2013/02/28 15:56:03 UTC
[11/20] git commit: refs/heads/noa/packaging_rpm_fixes -
CLOUDSTACK-1252: Fix the issue of locating systemvm patch ISO under VMware
environment
CLOUDSTACK-1252: Fix the issue of locating systemvm patch ISO under VMware environment
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/ccc51147
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/ccc51147
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/ccc51147
Branch: refs/heads/noa/packaging_rpm_fixes
Commit: ccc51147a54ff3d0362b233914c1580de52696c1
Parents: 336d133
Author: Kelven Yang <ke...@gmail.com>
Authored: Wed Feb 27 21:56:10 2013 -0500
Committer: Kelven Yang <ke...@gmail.com>
Committed: Wed Feb 27 22:05:23 2013 -0500
----------------------------------------------------------------------
.../vmware/manager/VmwareManagerImpl.java | 71 +++++++++++----
1 files changed, 54 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ccc51147/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
index 88e03f5..0b020bb 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
@@ -514,7 +514,6 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
return _storageMgr;
}
-
@Override
public void gcLeftOverVMs(VmwareContext context) {
VmwareCleanupMaid.gcLeftOverVMs(context);
@@ -534,6 +533,19 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
String msg = "Unable to create systemvm folder on secondary storage. location: " + patchFolder.toString();
s_logger.error(msg);
throw new CloudRuntimeException(msg);
+ } else {
+ s_logger.info("Creating systemvm folder " + patchFolder.getAbsolutePath() + " failed. try with sudo privilege");
+
+ String result = null;
+ Script command = new Script(true, "mkdir", _timeout, s_logger);
+ command.add("-p");
+ command.add(patchFolder.getAbsolutePath());
+ result = command.execute();
+ if (result != null) {
+ String msg = "Unable to create systemvm folder on secondary storage. location: " + patchFolder.toString();
+ s_logger.error(msg);
+ throw new CloudRuntimeException(msg);
+ }
}
}
@@ -547,10 +559,18 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
FileUtil.copyfile(srcIso, destIso);
} catch(IOException e) {
s_logger.error("Unexpected exception ", e);
-
- String msg = "Unable to copy systemvm ISO on secondary storage. src location: " + srcIso.toString() + ", dest location: " + destIso;
- s_logger.error(msg);
- throw new CloudRuntimeException(msg);
+
+ String result = null;
+ Script command = new Script(true, "cp", _timeout, s_logger);
+ command.add(srcIso.getAbsolutePath());
+ command.add(destIso.getAbsolutePath());
+ result = command.execute();
+
+ if (result != null) {
+ String msg = "Unable to copy systemvm ISO on secondary storage. src location: " + srcIso.toString() + ", dest location: " + destIso;
+ s_logger.error(msg);
+ throw new CloudRuntimeException(msg);
+ }
}
} else {
if(s_logger.isTraceEnabled())
@@ -576,13 +596,15 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
public String getSystemVMDefaultNicAdapterType() {
return this._defaultSystemVmNicAdapterType;
}
-
+
private File getSystemVMPatchIsoFile() {
// locate systemvm.iso
- URL url = this.getClass().getProtectionDomain().getCodeSource().getLocation();
- File file = new File(url.getFile());
- File isoFile = new File(file.getParent() + "/vms/systemvm.iso");
- if (!isoFile.exists()) {
+ URL url = this.getClass().getClassLoader().getResource("vms/systemvm.iso");
+ File isoFile = null;
+ if (url != null) {
+ isoFile = new File(url.getPath());
+ }
+ if (isoFile == null || !isoFile.exists()) {
isoFile = new File("/usr/lib64/cloud/common/" + "/vms/systemvm.iso");
if (!isoFile.exists()) {
isoFile = new File("/usr/lib/cloud/common/" + "/vms/systemvm.iso");
@@ -593,18 +615,19 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
@Override
public File getSystemVMKeyFile() {
- URL url = this.getClass().getProtectionDomain().getCodeSource().getLocation();
- File file = new File(url.getFile());
-
- File keyFile = new File(file.getParent(), "/scripts/vm/systemvm/id_rsa.cloud");
- if (!keyFile.exists()) {
+ URL url = this.getClass().getClassLoader().getResource("scripts/vm/systemvm/id_rsa.cloud");
+ File keyFile = null;
+ if ( url != null ){
+ keyFile = new File(url.getPath());
+ }
+ if (keyFile == null || !keyFile.exists()) {
keyFile = new File("/usr/lib64/cloud/common" + "/scripts/vm/systemvm/id_rsa.cloud");
if (!keyFile.exists()) {
keyFile = new File("/usr/lib/cloud/common" + "/scripts/vm/systemvm/id_rsa.cloud");
}
}
return keyFile;
- }
+ }
private Runnable getHostScanTask() {
return new Runnable() {
@@ -656,6 +679,20 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
if (_storage.mkdir(mntPt)) {
mountPoint = mntPt;
break;
+ } else {
+ s_logger.info("Prepare mount point " + mntPt + " failed. try with sudo privilege");
+
+ String result = null;
+ Script command = new Script(true, "mkdir", _timeout, s_logger);
+ command.add("-p");
+ command.add(mntPt);
+ result = command.execute();
+ if (result != null) {
+ s_logger.warn("Unable to umount " + mountPoint + " due to " + result);
+ } else {
+ mountPoint = mntPt;
+ break;
+ }
}
}
s_logger.error("Unable to create mount: " + mntPt);
@@ -741,7 +778,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
script = new Script(true, "chmod", _timeout, s_logger);
script.add("777", mountPoint);
result = script.execute();
- if (result != null) {
+ if (result != null) {
s_logger.warn("Unable to set permissions for " + mountPoint + " due to " + result);
return null;
}