Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 18 additions & 33 deletions api/src/main/java/com/cloud/agent/api/storage/OVFHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ protected OVFPropertyTO createOVFPropertyFromNode(Node node, int index, String c
boolean password = StringUtils.isNotBlank(passStr) && passStr.equalsIgnoreCase("true");
String label = ovfParser.getChildNodeValue(node, "Label");
String description = ovfParser.getChildNodeValue(node, "Description");
logger.debug("Creating OVF property index " + index + (category == null ? "" : " for category " + category)
+ " with key = " + key);
logger.debug("Creating OVF property index {} {} with key = {}", index, (category == null ? "" : " for category " + category), key);
return new OVFPropertyTO(key, type, value, qualifiers, userConfigurable,
label, description, password, index, category);
}
Expand Down Expand Up @@ -152,7 +151,7 @@ public List<OVFPropertyTO> getConfigurableOVFPropertiesFromDocument(Document doc
if (child.getNodeName().equalsIgnoreCase("Category") ||
child.getNodeName().endsWith(":Category")) {
lastCategoryFound = child.getTextContent();
logger.info("Category found " + lastCategoryFound);
logger.info("Category found {}", lastCategoryFound);
} else if (child.getNodeName().equalsIgnoreCase("Property") ||
child.getNodeName().endsWith(":Property")) {
OVFPropertyTO prop = createOVFPropertyFromNode(child, propertyIndex, lastCategoryFound);
Expand Down Expand Up @@ -250,13 +249,13 @@ private List<DatadiskTO> matchHardwareItemsToDiskAndFilesInformation(List<OVFVir
int diskNumber = 0;
for (OVFVirtualHardwareItemTO diskItem : diskHardwareItems) {
if (StringUtils.isBlank(diskItem.getHostResource())) {
logger.error("Missing disk information for hardware item " + diskItem.getElementName() + " " + diskItem.getInstanceId());
logger.error("Missing disk information for hardware item {} {}", diskItem.getElementName(), diskItem.getInstanceId());
continue;
}
String diskId = extractDiskIdFromDiskHostResource(diskItem.getHostResource());
OVFDisk diskDefinition = getDiskDefinitionFromDiskId(diskId, disks);
if (diskDefinition == null) {
logger.error("Missing disk definition for disk ID " + diskId);
logger.error("Missing disk definition for disk ID {}", diskId);
}
OVFFile fileDefinition = getFileDefinitionFromDiskDefinition(diskDefinition._fileRef, files);
DatadiskTO datadiskTO = generateDiskTO(fileDefinition, diskDefinition, ovfParentPath, diskNumber, diskItem);
Expand All @@ -278,7 +277,7 @@ private DatadiskTO generateDiskTO(OVFFile file, OVFDisk disk, String ovfParentPa
if (StringUtils.isNotBlank(path)) {
File f = new File(path);
if (!f.exists() || f.isDirectory()) {
logger.error("One of the attached disk or iso does not exists " + path);
logger.error("One of the attached disk or iso does not exists {}", path);
throw new InternalErrorException("One of the attached disk or iso as stated on OVF does not exists " + path);
}
}
Expand Down Expand Up @@ -334,9 +333,7 @@ protected List<OVFDisk> extractDisksFromOvfDocumentTree(Document doc) {
od._controller = getControllerType(items, od._diskId);
vd.add(od);
}
if (logger.isTraceEnabled()) {
logger.trace(String.format("found %d disk definitions",vd.size()));
}
logger.trace("Found {} disk definitions", vd.size());
return vd;
}

Expand Down Expand Up @@ -366,9 +363,7 @@ protected List<OVFFile> extractFilesFromOvfDocumentTree(File ovfFile, Document d
vf.add(of);
}
}
if (logger.isTraceEnabled()) {
logger.trace(String.format("found %d file definitions in %s",vf.size(), ovfFile.getPath()));
}
logger.trace("Found {} file definitions in {}", vf.size(), ovfFile.getPath());
return vf;
}

Expand Down Expand Up @@ -506,7 +501,7 @@ private void writeDocumentToFile(String newOvfFilePath, Document doc) {
outfile.write(writer.toString());
outfile.close();
} catch (IOException | TransformerException e) {
logger.info("Unexpected exception caught while rewriting OVF:" + e.getMessage(), e);
logger.info("Unexpected exception caught while rewriting OVF: {}", e.getMessage(), e);
throw new CloudRuntimeException(e);
}
}
Expand All @@ -522,9 +517,7 @@ OVFFile getFileDefinitionFromDiskDefinition(String fileRef, List<OVFFile> files)

public List<OVFNetworkTO> getNetPrerequisitesFromDocument(Document doc) throws InternalErrorException {
if (doc == null) {
if (logger.isTraceEnabled()) {
logger.trace("no document to parse; returning no prerequisite networks");
}
logger.trace("No document to parse; returning no prerequisite networks");
return Collections.emptyList();
}

Expand All @@ -540,19 +533,15 @@ public List<OVFNetworkTO> getNetPrerequisitesFromDocument(Document doc) throws I
private void matchNicsToNets(Map<String, OVFNetworkTO> nets, Node systemElement) {
final DocumentTraversal traversal = (DocumentTraversal) systemElement;
final NodeIterator iterator = traversal.createNodeIterator(systemElement, NodeFilter.SHOW_ELEMENT, null, true);
if (logger.isTraceEnabled()) {
logger.trace(String.format("starting out with %d network-prerequisites, parsing hardware",nets.size()));
}
logger.trace("Starting out with {} network-prerequisites, parsing hardware", nets.size());
int nicCount = 0;
for (Node n = iterator.nextNode(); n != null; n = iterator.nextNode()) {
final Element e = (Element) n;
if ("rasd:Connection".equals(e.getTagName())) {
nicCount++;
String name = e.getTextContent(); // should be in our nets
if(nets.get(name) == null) {
if(logger.isInfoEnabled()) {
logger.info(String.format("found a nic definition without a network definition byname %s, adding it to the list.", name));
}
logger.info("Found a nic definition without a network definition by name {}, adding it to the list.", name);
nets.put(name, new OVFNetworkTO());
}
OVFNetworkTO thisNet = nets.get(name);
Expand All @@ -561,9 +550,7 @@ private void matchNicsToNets(Map<String, OVFNetworkTO> nets, Node systemElement)
}
}
}
if (logger.isTraceEnabled()) {
logger.trace(String.format("ending up with %d network-prerequisites, parsed %d nics", nets.size(), nicCount));
}
logger.trace("Ending up with {} network-prerequisites, parsed {} nics", nets.size(), nicCount);
}

/**
Expand All @@ -585,7 +572,7 @@ private void fillNicPrerequisites(OVFNetworkTO nic, Node parentNode) {
int addressOnParent = Integer.parseInt(addressOnParentStr);
nic.setAddressOnParent(addressOnParent);
} catch (NumberFormatException e) {
logger.warn("Encountered element of type \"AddressOnParent\", that could not be parse to an integer number: " + addressOnParentStr);
logger.warn("Encountered element of type \"AddressOnParent\", that could not be parse to an integer number: {}", addressOnParentStr);
}

boolean automaticAllocation = StringUtils.isNotBlank(automaticAllocationStr) && Boolean.parseBoolean(automaticAllocationStr);
Expand All @@ -597,7 +584,7 @@ private void fillNicPrerequisites(OVFNetworkTO nic, Node parentNode) {
int instanceId = Integer.parseInt(instanceIdStr);
nic.setInstanceID(instanceId);
} catch (NumberFormatException e) {
logger.warn("Encountered element of type \"InstanceID\", that could not be parse to an integer number: " + instanceIdStr);
logger.warn("Encountered element of type \"InstanceID\", that could not be parse to an integer number: {}", instanceIdStr);
}

nic.setResourceSubType(resourceSubType);
Expand Down Expand Up @@ -630,9 +617,7 @@ private Map<String, OVFNetworkTO> getNetworksFromDocumentTree(Document doc) {

nets.put(networkName,network);
}
if (logger.isTraceEnabled()) {
logger.trace(String.format("found %d networks in template", nets.size()));
}
logger.trace("Found {} networks in template", nets.size());
return nets;
}

Expand Down Expand Up @@ -771,7 +756,7 @@ private Long getLongValueFromString(String value) {
try {
return Long.parseLong(value);
} catch (NumberFormatException e) {
logger.debug("Could not parse the value: " + value + ", ignoring it");
logger.debug("Could not parse the value: {}, ignoring it", value);
}
}
return null;
Expand All @@ -782,7 +767,7 @@ private Integer getIntValueFromString(String value) {
try {
return Integer.parseInt(value);
} catch (NumberFormatException e) {
logger.debug("Could not parse the value: " + value + ", ignoring it");
logger.debug("Could not parse the value: {}, ignoring it", value);
}
}
return null;
Expand Down Expand Up @@ -820,7 +805,7 @@ public List<OVFEulaSectionTO> getEulaSectionsFromDocument(Document doc) {
try {
compressedLicense = compressOVFEula(eulaLicense);
} catch (IOException e) {
logger.error("Could not compress the license for info " + eulaInfo);
logger.error("Could not compress the license for info {}", eulaInfo);
continue;
}
OVFEulaSectionTO eula = new OVFEulaSectionTO(eulaInfo, compressedLicense, eulaIndex);
Expand Down
4 changes: 2 additions & 2 deletions api/src/main/java/com/cloud/agent/api/storage/OVFParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public OVFParser() {
documentBuilderFactory.setNamespaceAware(true);
documentBuilder = documentBuilderFactory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
logger.error("Cannot start the OVF parser: " + e.getMessage(), e);
logger.error("Cannot start the OVF parser: {}", e.getMessage(), e);
}
}

Expand All @@ -70,7 +70,7 @@ public Document parseOVFFile(String ovfFilePath) {
try {
return documentBuilder.parse(new File(ovfFilePath));
} catch (SAXException | IOException e) {
logger.error("Error parsing " + ovfFilePath + " " + e.getMessage(), e);
logger.error("Error parsing {} {}", ovfFilePath, e.getMessage(), e);
return null;
}
}
Expand Down
4 changes: 2 additions & 2 deletions api/src/main/java/org/apache/cloudstack/acl/RoleType.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ public static Set<RoleType> fromCombinedMask(int combinedMask) {
* */
public static Account.Type getAccountTypeByRole(final Role role, final Account.Type defautAccountType) {
if (role != null) {
LOGGER.debug(String.format("Role [%s] is not null; therefore, we use its account type [%s].", role, defautAccountType));
LOGGER.debug("Role [{}] is not null; therefore, we use its account type [{}].", role, defautAccountType);
return role.getRoleType().getAccountType();
}
LOGGER.debug(String.format("Role is null; therefore, we use the default account type [%s] value.", defautAccountType));
LOGGER.debug("Role is null; therefore, we use the default account type [{}] value.", defautAccountType);
return defautAccountType;
}
}
2 changes: 1 addition & 1 deletion api/src/main/java/org/apache/cloudstack/api/BaseCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ public List<Field> getParamFields() {
if (roleIsAllowed) {
validFields.add(field);
} else {
logger.debug("Ignoring parameter " + parameterAnnotation.name() + " as the caller is not authorized to pass it in");
logger.debug("Ignoring parameter {} as the caller is not authorized to pass it in", parameterAnnotation.name());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void execute() {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
logger.warn("Failed to delete counter with Id: " + getId());
logger.warn("Failed to delete counter with Id: {}", getId());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete counter.");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void execute() {
this.setResponseObject(response);
} catch (CloudRuntimeException e) {
ApiErrorCode paramError = e instanceof InvalidParameterValueException ? ApiErrorCode.PARAM_ERROR : ApiErrorCode.INTERNAL_ERROR;
logger.error(String.format("Failed to update Backup Offering [id: %s] due to: [%s].", id, e.getMessage()), e);
logger.error("Failed to update Backup Offering [id: {}] due to: [{}].", id, e.getMessage(), e);
throw new ServerApiException(paramError, e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void execute() {
}

try {
logger.debug("Uploading certificate " + name + " to agents for Direct Download");
logger.debug("Uploading certificate {} to agents for Direct Download", name);
Pair<DirectDownloadCertificate, List<HostCertificateStatus>> uploadStatus =
directDownloadManager.uploadCertificateToHosts(certificate, name, hypervisor, zoneId, hostId);
DirectDownloadCertificate certificate = uploadStatus.first();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void execute() {
this.setResponseObject(hostResponse);
} catch (Exception e) {
Host host = _entityMgr.findById(Host.class, getId());
logger.debug("Failed to update host: {} with id {}", host, getId(), e);
logger.error("Failed to update {}", host, e);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, String.format("Failed to update host: %s with id %d, %s", host, getId(), e.getMessage()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void execute() {
logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
} catch (Exception e) {
logger.warn("Failed to delete management ip range from " + getStartIp() + " to " + getEndIp() + " of Pod: " + getPodId(), e);
logger.warn("Failed to delete management ip range from {} to {} of Pod: {}", getStartIp(), getEndIp(), getPodId(), e);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} catch (Exception e) {
logger.warn("Failed to delete storage network ip range " + getId(), e);
logger.warn("Failed to delete storage network ip range {}", getId(), e);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE
response.setResponseName(getCommandName());
this.setResponseObject(response);
} catch (Exception e) {
logger.warn("Failed to list storage network ip range for rangeId=" + getRangeId() + " podId=" + getPodId() + " zoneId=" + getZoneId());
logger.warn("Failed to list storage network ip range for rangeId={} podId={} zoneId={}", getRangeId(), getPodId(), getZoneId());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void execute() {
logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
} catch (Exception e) {
logger.warn("Failed to update pod management IP range " + getNewStartIP() + "-" + getNewEndIP() + " of Pod: " + getPodId(), e);
logger.warn("Failed to update pod management IP range {}-{} of Pod: {}", getNewStartIP(), getNewEndIP(), getPodId(), e);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public void execute() throws ResourceUnavailableException, ResourceAllocationExc
logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
} catch (InsufficientCapacityException ex) {
logger.info(ex);
logger.error(ex);
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,7 @@ public Map<String, Long> getNicNetworkList() {
for (Map<String, String> entry : (Collection<Map<String, String>>)nicNetworkList.values()) {
String nic = entry.get(VmDetailConstants.NIC);
String networkUuid = entry.get(VmDetailConstants.NETWORK);
if (logger.isDebugEnabled()) {
logger.debug(String.format("nic, '%s', goes on net, '%s'", nic, networkUuid));
}
logger.debug("Checking if NIC '{}' can be mapped on network '{}'", nic, networkUuid);
if (StringUtils.isAnyEmpty(nic, networkUuid) || _entityMgr.findByUuid(Network.class, networkUuid) == null) {
throw new InvalidParameterValueException(String.format("Network ID: %s for NIC ID: %s is invalid", networkUuid, nic));
}
Expand All @@ -219,9 +217,7 @@ public Map<String, Network.IpAddresses> getNicIpAddressList() {
for (Map<String, String> entry : (Collection<Map<String, String>>)nicIpAddressList.values()) {
String nic = entry.get(VmDetailConstants.NIC);
String ipAddress = StringUtils.defaultIfEmpty(entry.get(VmDetailConstants.IP4_ADDRESS), null);
if (logger.isDebugEnabled()) {
logger.debug(String.format("nic, '%s', gets ip, '%s'", nic, ipAddress));
}
logger.debug("Checking if IP address '{}' can be mapped to NIC '{}'", ipAddress, nic);
if (StringUtils.isEmpty(nic)) {
throw new InvalidParameterValueException(String.format("NIC ID: '%s' is invalid for IP address mapping", nic));
}
Expand All @@ -244,9 +240,7 @@ public Map<String, Long> getDataDiskToDiskOfferingList() {
for (Map<String, String> entry : (Collection<Map<String, String>>)dataDiskToDiskOfferingList.values()) {
String disk = entry.get(VmDetailConstants.DISK);
String offeringUuid = entry.get(VmDetailConstants.DISK_OFFERING);
if (logger.isTraceEnabled()) {
logger.trace(String.format("disk, '%s', gets offering, '%s'", disk, offeringUuid));
}
logger.trace("Checking if offering '{}' can be used on disk '{}'", offeringUuid, disk);
if (StringUtils.isAnyEmpty(disk, offeringUuid) || _entityMgr.findByUuid(DiskOffering.class, offeringUuid) == null) {
throw new InvalidParameterValueException(String.format("Disk offering ID: %s for disk ID: %s is invalid", offeringUuid, disk));
}
Expand Down
Loading
Loading