Skip to content

Commit 8a83968

Browse files
Jira ticket CLOUDSTACK-8750
Re-pushing the PR 714, we had forgotten a class behind and it had to be reverted.
1 parent dd9ba48 commit 8a83968

File tree

380 files changed

+5978
-6712
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

380 files changed

+5978
-6712
lines changed

core/src/com/cloud/storage/template/IsoProcessor.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,27 @@
2525
import javax.ejb.Local;
2626
import javax.naming.ConfigurationException;
2727

28-
import org.apache.log4j.Logger;
2928

3029
import com.cloud.storage.Storage.ImageFormat;
3130
import com.cloud.storage.StorageLayer;
3231
import com.cloud.utils.component.AdapterBase;
3332

3433
@Local(value = Processor.class)
3534
public class IsoProcessor extends AdapterBase implements Processor {
36-
private static final Logger s_logger = Logger.getLogger(IsoProcessor.class);
3735

3836
StorageLayer _storage;
3937

4038
@Override
4139
public FormatInfo process(String templatePath, ImageFormat format, String templateName) {
4240
if (format != null) {
43-
s_logger.debug("We don't handle conversion from " + format + " to ISO.");
41+
logger.debug("We don't handle conversion from " + format + " to ISO.");
4442
return null;
4543
}
4644

4745
String isoPath = templatePath + File.separator + templateName + "." + ImageFormat.ISO.getFileExtension();
4846

4947
if (!_storage.exists(isoPath)) {
50-
s_logger.debug("Unable to find the iso file: " + isoPath);
48+
logger.debug("Unable to find the iso file: " + isoPath);
5149
return null;
5250
}
5351

core/src/com/cloud/storage/template/OVAProcessor.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import javax.naming.ConfigurationException;
2727
import javax.xml.parsers.DocumentBuilderFactory;
2828

29-
import org.apache.log4j.Logger;
3029
import org.w3c.dom.Document;
3130
import org.w3c.dom.Element;
3231

@@ -38,39 +37,38 @@
3837

3938
@Local(value = Processor.class)
4039
public class OVAProcessor extends AdapterBase implements Processor {
41-
private static final Logger s_logger = Logger.getLogger(OVAProcessor.class);
4240

4341
StorageLayer _storage;
4442

4543
@Override
4644
public FormatInfo process(String templatePath, ImageFormat format, String templateName) throws InternalErrorException {
4745
if (format != null) {
48-
if (s_logger.isInfoEnabled()) {
49-
s_logger.info("We currently don't handle conversion from " + format + " to OVA.");
46+
if (logger.isInfoEnabled()) {
47+
logger.info("We currently don't handle conversion from " + format + " to OVA.");
5048
}
5149
return null;
5250
}
5351

54-
s_logger.info("Template processing. templatePath: " + templatePath + ", templateName: " + templateName);
52+
logger.info("Template processing. templatePath: " + templatePath + ", templateName: " + templateName);
5553
String templateFilePath = templatePath + File.separator + templateName + "." + ImageFormat.OVA.getFileExtension();
5654
if (!_storage.exists(templateFilePath)) {
57-
if (s_logger.isInfoEnabled()) {
58-
s_logger.info("Unable to find the vmware template file: " + templateFilePath);
55+
if (logger.isInfoEnabled()) {
56+
logger.info("Unable to find the vmware template file: " + templateFilePath);
5957
}
6058
return null;
6159
}
6260

63-
s_logger.info("Template processing - untar OVA package. templatePath: " + templatePath + ", templateName: " + templateName);
61+
logger.info("Template processing - untar OVA package. templatePath: " + templatePath + ", templateName: " + templateName);
6462
String templateFileFullPath = templatePath + File.separator + templateName + "." + ImageFormat.OVA.getFileExtension();
6563
File templateFile = new File(templateFileFullPath);
6664

67-
Script command = new Script("tar", 0, s_logger);
65+
Script command = new Script("tar", 0, logger);
6866
command.add("--no-same-owner");
6967
command.add("-xf", templateFileFullPath);
7068
command.setWorkDir(templateFile.getParent());
7169
String result = command.execute();
7270
if (result != null) {
73-
s_logger.info("failed to untar OVA package due to " + result + ". templatePath: " + templatePath + ", templateName: " + templateName);
71+
logger.info("failed to untar OVA package due to " + result + ". templatePath: " + templatePath + ", templateName: " + templateName);
7472
return null;
7573
}
7674

@@ -91,7 +89,7 @@ public long getVirtualSize(File file) {
9189
long size = getTemplateVirtualSize(file.getParent(), file.getName());
9290
return size;
9391
} catch (Exception e) {
94-
s_logger.info("[ignored]"
92+
logger.info("[ignored]"
9593
+ "failed to get virtual template size for ova: " + e.getLocalizedMessage());
9694
}
9795
return file.length();
@@ -105,7 +103,7 @@ public long getTemplateVirtualSize(String templatePath, String templateName) thr
105103
String ovfFileName = getOVFFilePath(templateFileFullPath);
106104
if (ovfFileName == null) {
107105
String msg = "Unable to locate OVF file in template package directory: " + templatePath;
108-
s_logger.error(msg);
106+
logger.error(msg);
109107
throw new InternalErrorException(msg);
110108
}
111109
try {
@@ -130,7 +128,7 @@ public long getTemplateVirtualSize(String templatePath, String templateName) thr
130128
return virtualSize;
131129
} catch (Exception e) {
132130
String msg = "Unable to parse OVF XML document to get the virtual disk size due to" + e;
133-
s_logger.error(msg);
131+
logger.error(msg);
134132
throw new InternalErrorException(msg);
135133
}
136134
}

core/src/com/cloud/storage/template/QCOW2Processor.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import javax.ejb.Local;
2828
import javax.naming.ConfigurationException;
2929

30-
import org.apache.log4j.Logger;
3130

3231
import com.cloud.storage.Storage.ImageFormat;
3332
import com.cloud.storage.StorageLayer;
@@ -36,22 +35,21 @@
3635

3736
@Local(value = Processor.class)
3837
public class QCOW2Processor extends AdapterBase implements Processor {
39-
private static final Logger s_logger = Logger.getLogger(QCOW2Processor.class);
4038
private static final int VIRTUALSIZE_HEADER_LOCATION = 24;
4139

4240
private StorageLayer _storage;
4341

4442
@Override
4543
public FormatInfo process(String templatePath, ImageFormat format, String templateName) {
4644
if (format != null) {
47-
s_logger.debug("We currently don't handle conversion from " + format + " to QCOW2.");
45+
logger.debug("We currently don't handle conversion from " + format + " to QCOW2.");
4846
return null;
4947
}
5048

5149
String qcow2Path = templatePath + File.separator + templateName + "." + ImageFormat.QCOW2.getFileExtension();
5250

5351
if (!_storage.exists(qcow2Path)) {
54-
s_logger.debug("Unable to find the qcow2 file: " + qcow2Path);
52+
logger.debug("Unable to find the qcow2 file: " + qcow2Path);
5553
return null;
5654
}
5755

@@ -66,7 +64,7 @@ public FormatInfo process(String templatePath, ImageFormat format, String templa
6664
try {
6765
info.virtualSize = getVirtualSize(qcow2File);
6866
} catch (IOException e) {
69-
s_logger.error("Unable to get virtual size from " + qcow2File.getName());
67+
logger.error("Unable to get virtual size from " + qcow2File.getName());
7068
return null;
7169
}
7270

core/src/com/cloud/storage/template/RawImageProcessor.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import javax.ejb.Local;
2626
import javax.naming.ConfigurationException;
2727

28-
import org.apache.log4j.Logger;
2928

3029
import com.cloud.exception.InternalErrorException;
3130
import com.cloud.storage.Storage.ImageFormat;
@@ -34,7 +33,6 @@
3433

3534
@Local(value = Processor.class)
3635
public class RawImageProcessor extends AdapterBase implements Processor {
37-
private static final Logger s_logger = Logger.getLogger(RawImageProcessor.class);
3836
StorageLayer _storage;
3937

4038
@Override
@@ -50,21 +48,21 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
5048
@Override
5149
public FormatInfo process(String templatePath, ImageFormat format, String templateName) throws InternalErrorException {
5250
if (format != null) {
53-
s_logger.debug("We currently don't handle conversion from " + format + " to raw image.");
51+
logger.debug("We currently don't handle conversion from " + format + " to raw image.");
5452
return null;
5553
}
5654

5755
String imgPath = templatePath + File.separator + templateName + "." + ImageFormat.RAW.getFileExtension();
5856
if (!_storage.exists(imgPath)) {
59-
s_logger.debug("Unable to find raw image:" + imgPath);
57+
logger.debug("Unable to find raw image:" + imgPath);
6058
return null;
6159
}
6260
FormatInfo info = new FormatInfo();
6361
info.format = ImageFormat.RAW;
6462
info.filename = templateName + "." + ImageFormat.RAW.getFileExtension();
6563
info.size = _storage.getSize(imgPath);
6664
info.virtualSize = info.size;
67-
s_logger.debug("Process raw image " + info.filename + " successfully");
65+
logger.debug("Process raw image " + info.filename + " successfully");
6866
return info;
6967
}
7068

core/src/com/cloud/storage/template/TARProcessor.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import com.cloud.storage.Storage.ImageFormat;
2323
import com.cloud.storage.StorageLayer;
2424
import com.cloud.utils.component.AdapterBase;
25-
import org.apache.log4j.Logger;
2625

2726
import javax.ejb.Local;
2827
import javax.naming.ConfigurationException;
@@ -31,21 +30,20 @@
3130

3231
@Local(value = Processor.class)
3332
public class TARProcessor extends AdapterBase implements Processor {
34-
private static final Logger s_logger = Logger.getLogger(TARProcessor.class);
3533

3634
private StorageLayer _storage;
3735

3836
@Override
3937
public FormatInfo process(String templatePath, ImageFormat format, String templateName) {
4038
if (format != null) {
41-
s_logger.debug("We currently don't handle conversion from " + format + " to TAR.");
39+
logger.debug("We currently don't handle conversion from " + format + " to TAR.");
4240
return null;
4341
}
4442

4543
String tarPath = templatePath + File.separator + templateName + "." + ImageFormat.TAR.getFileExtension();
4644

4745
if (!_storage.exists(tarPath)) {
48-
s_logger.debug("Unable to find the tar file: " + tarPath);
46+
logger.debug("Unable to find the tar file: " + tarPath);
4947
return null;
5048
}
5149

core/src/com/cloud/storage/template/VhdProcessor.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import javax.ejb.Local;
2828
import javax.naming.ConfigurationException;
2929

30-
import org.apache.log4j.Logger;
3130

3231
import com.cloud.storage.Storage.ImageFormat;
3332
import com.cloud.storage.StorageLayer;
@@ -43,7 +42,6 @@
4342
@Local(value = Processor.class)
4443
public class VhdProcessor extends AdapterBase implements Processor {
4544

46-
private static final Logger s_logger = Logger.getLogger(VhdProcessor.class);
4745
StorageLayer _storage;
4846
private int vhdFooterSize = 512;
4947
private int vhdFooterCreatorAppOffset = 28;
@@ -54,13 +52,13 @@ public class VhdProcessor extends AdapterBase implements Processor {
5452
@Override
5553
public FormatInfo process(String templatePath, ImageFormat format, String templateName) {
5654
if (format != null) {
57-
s_logger.debug("We currently don't handle conversion from " + format + " to VHD.");
55+
logger.debug("We currently don't handle conversion from " + format + " to VHD.");
5856
return null;
5957
}
6058

6159
String vhdPath = templatePath + File.separator + templateName + "." + ImageFormat.VHD.getFileExtension();
6260
if (!_storage.exists(vhdPath)) {
63-
s_logger.debug("Unable to find the vhd file: " + vhdPath);
61+
logger.debug("Unable to find the vhd file: " + vhdPath);
6462
return null;
6563
}
6664

@@ -74,7 +72,7 @@ public FormatInfo process(String templatePath, ImageFormat format, String templa
7472
try {
7573
info.virtualSize = getVirtualSize(vhdFile);
7674
} catch (IOException e) {
77-
s_logger.error("Unable to get the virtual size for " + vhdPath);
75+
logger.error("Unable to get the virtual size for " + vhdPath);
7876
return null;
7977
}
8078

core/src/com/cloud/storage/template/VmdkProcessor.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import javax.ejb.Local;
3232
import javax.naming.ConfigurationException;
3333

34-
import org.apache.log4j.Logger;
3534

3635
import com.cloud.exception.InternalErrorException;
3736
import com.cloud.storage.Storage.ImageFormat;
@@ -40,24 +39,23 @@
4039

4140
@Local(value = Processor.class)
4241
public class VmdkProcessor extends AdapterBase implements Processor {
43-
private static final Logger s_logger = Logger.getLogger(VmdkProcessor.class);
4442

4543
StorageLayer _storage;
4644

4745
@Override
4846
public FormatInfo process(String templatePath, ImageFormat format, String templateName) throws InternalErrorException {
4947
if (format != null) {
50-
if (s_logger.isInfoEnabled()) {
51-
s_logger.info("We currently don't handle conversion from " + format + " to VMDK.");
48+
if (logger.isInfoEnabled()) {
49+
logger.info("We currently don't handle conversion from " + format + " to VMDK.");
5250
}
5351
return null;
5452
}
5553

56-
s_logger.info("Template processing. templatePath: " + templatePath + ", templateName: " + templateName);
54+
logger.info("Template processing. templatePath: " + templatePath + ", templateName: " + templateName);
5755
String templateFilePath = templatePath + File.separator + templateName + "." + ImageFormat.VMDK.getFileExtension();
5856
if (!_storage.exists(templateFilePath)) {
59-
if (s_logger.isInfoEnabled()) {
60-
s_logger.info("Unable to find the vmware template file: " + templateFilePath);
57+
if (logger.isInfoEnabled()) {
58+
logger.info("Unable to find the vmware template file: " + templateFilePath);
6159
}
6260
return null;
6361
}
@@ -77,7 +75,7 @@ public long getVirtualSize(File file) {
7775
long size = getTemplateVirtualSize(file.getParent(), file.getName());
7876
return size;
7977
} catch (Exception e) {
80-
s_logger.info("[ignored]"
78+
logger.info("[ignored]"
8179
+ "failed to get template virtual size for vmdk: " + e.getLocalizedMessage());
8280
}
8381
return file.length();
@@ -103,15 +101,15 @@ public long getTemplateVirtualSize(String templatePath, String templateName) thr
103101
}
104102
} catch(FileNotFoundException ex) {
105103
String msg = "Unable to open file '" + templateFileFullPath + "' " + ex.toString();
106-
s_logger.error(msg);
104+
logger.error(msg);
107105
throw new InternalErrorException(msg);
108106
} catch(IOException ex) {
109107
String msg = "Unable read open file '" + templateFileFullPath + "' " + ex.toString();
110-
s_logger.error(msg);
108+
logger.error(msg);
111109
throw new InternalErrorException(msg);
112110
}
113111

114-
s_logger.debug("vmdk file had size="+virtualSize);
112+
logger.debug("vmdk file had size="+virtualSize);
115113
return virtualSize;
116114
}
117115

0 commit comments

Comments
 (0)