Skip to content

Commit

Permalink
Fix merge errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoJandre committed Oct 11, 2024
1 parent dbfc7f2 commit 554ea22
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2171,11 +2171,11 @@ private MigrationOptions.Type decideMigrationTypeAndCopyTemplateIfNeeded(Host de
srcVolumeInfo.getTemplateId() != null &&
Objects.nonNull(vmTemplate) &&
!Arrays.asList(KVM_VM_IMPORT_DEFAULT_TEMPLATE_NAME, VM_IMPORT_DEFAULT_TEMPLATE_NAME).contains(vmTemplate.getName())) {
LOGGER.debug(String.format("Copying template [%s] of volume [%s] from source storage pool [%s] to target storage pool [%s].", srcVolumeInfo.getTemplateId(), srcVolumeInfo.getId(), sourceStoragePool.getId(), destStoragePool.getId()));
logger.debug(String.format("Copying template [%s] of volume [%s] from source storage pool [%s] to target storage pool [%s].", srcVolumeInfo.getTemplateId(), srcVolumeInfo.getId(), sourceStoragePool.getId(), destStoragePool.getId()));
copyTemplateToTargetFilesystemStorageIfNeeded(srcVolumeInfo, sourceStoragePool, destDataStore, destStoragePool, destHost);
return MigrationOptions.Type.LinkedClone;
}
LOGGER.debug(String.format("Skipping copy template from source storage pool [%s] to target storage pool [%s] before migration due to volume [%s] does not have a " +
logger.debug(String.format("Skipping copy template from source storage pool [%s] to target storage pool [%s] before migration due to volume [%s] does not have a " +
"template or we are doing full clone migration.", sourceStoragePool.getId(), destStoragePool.getId(), srcVolumeInfo.getId()));
return MigrationOptions.Type.FullClone;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
import org.apache.cloudstack.storage.datastore.db.ObjectStoreVO;
import org.apache.cloudstack.storage.object.BaseObjectStoreDriverImpl;
import org.apache.cloudstack.storage.object.BucketObject;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.twonote.rgwadmin4j.RgwAdmin;
import org.twonote.rgwadmin4j.RgwAdminBuilder;
import org.twonote.rgwadmin4j.model.BucketInfo;
Expand All @@ -62,7 +60,6 @@
import java.util.HashMap;

public class CephObjectStoreDriverImpl extends BaseObjectStoreDriverImpl {
private static final Logger s_logger = LogManager.getLogger(CephObjectStoreDriverImpl.class);

@Inject
AccountDao _accountDao;
Expand Down Expand Up @@ -168,7 +165,7 @@ public void setBucketPolicy(BucketTO bucket, String policy, long storeId) {
String policyConfig;

if (policy.equalsIgnoreCase("public")) {
s_logger.debug("Setting public policy on bucket " + bucket.getName());
logger.debug("Setting public policy on bucket " + bucket.getName());
StringBuilder builder = new StringBuilder();
builder.append("{\n");
builder.append(" \"Statement\": [\n");
Expand All @@ -192,7 +189,7 @@ public void setBucketPolicy(BucketTO bucket, String policy, long storeId) {
builder.append("}\n");
policyConfig = builder.toString();
} else {
s_logger.debug("Setting private policy on bucket " + bucket.getName());
logger.debug("Setting private policy on bucket " + bucket.getName());
policyConfig = "{\"Version\":\"2012-10-17\",\"Statement\":[]}";
}

Expand All @@ -218,15 +215,15 @@ public boolean createUser(long accountId, long storeId) {
RgwAdmin rgwAdmin = getRgwAdminClient(storeId);
String username = account.getUuid();

s_logger.debug("Attempting to create Ceph RGW user for account " + account.getAccountName() + " with UUID " + username);
logger.debug("Attempting to create Ceph RGW user for account " + account.getAccountName() + " with UUID " + username);
try {
Optional<User> user = rgwAdmin.getUserInfo(username);
if (user.isPresent()) {
s_logger.info("User already exists in Ceph RGW: " + username);
logger.info("User already exists in Ceph RGW: " + username);
return true;
}
} catch (Exception e) {
s_logger.debug("User does not exist. Creating user in Ceph RGW: " + username);
logger.debug("User does not exist. Creating user in Ceph RGW: " + username);
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

public class CephObjectStoreLifeCycleImpl implements ObjectStoreLifeCycle {

private static final Logger s_logger = LogManager.getLogger(CephObjectStoreLifeCycleImpl.class);
private Logger logger = LogManager.getLogger(CephObjectStoreLifeCycleImpl.class);

@Inject
ObjectStoreHelper objectStoreHelper;
Expand Down Expand Up @@ -72,7 +72,7 @@ public DataStore initialize(Map<String, Object> dsInfos) {
objectStoreParameters.put("accesskey", accessKey);
objectStoreParameters.put("secretkey", secretKey);

s_logger.info("Attempting to connect to Ceph RGW at " + url + " with access key " + accessKey);
logger.info("Attempting to connect to Ceph RGW at " + url + " with access key " + accessKey);

RgwAdmin rgwAdmin = new RgwAdminBuilder()
.accessKey(accessKey)
Expand All @@ -81,10 +81,10 @@ public DataStore initialize(Map<String, Object> dsInfos) {
.build();
try {
List<String> buckets = rgwAdmin.listBucket();
s_logger.debug("Found " + buckets + " buckets at Ceph RGW: " + url);
s_logger.info("Successfully connected to Ceph RGW: " + url);
logger.debug("Found " + buckets + " buckets at Ceph RGW: " + url);
logger.info("Successfully connected to Ceph RGW: " + url);
} catch (Exception e) {
s_logger.debug("Error while initializing Ceph RGW Object Store: " + e.getMessage());
logger.debug("Error while initializing Ceph RGW Object Store: " + e.getMessage());
throw new RuntimeException("Error while initializing Ceph RGW Object Store. Invalid credentials or URL");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public static void setupSamlUserCookies(final LoginCmdResponse loginResponse, fi
}
String sameSite = ApiServlet.getApiSessionKeySameSite();
String sessionKeyCookie = String.format("%s=%s;Domain=%s;Path=%s;%s", ApiConstants.SESSIONKEY, loginResponse.getSessionKey(), domain, path, sameSite);
s_logger.debug("Adding sessionkey cookie to response: " + sessionKeyCookie);
LOGGER.debug("Adding sessionkey cookie to response: " + sessionKeyCookie);
resp.addHeader("SET-COOKIE", sessionKeyCookie);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public void processParameters(final BaseCmd cmd, final Map params) {
doAccessChecks(cmd, entitiesToAccess);
}

private void doAccessChecks(BaseCmd cmd, Map<Object, AccessType> entitiesToAccess) {
protected void doAccessChecks(BaseCmd cmd, Map<Object, AccessType> entitiesToAccess) {
Account caller = CallContext.current().getCallingAccount();
List<Long> entityOwners = cmd.getEntityOwnerIds();
Account[] owners = null;
Expand Down
4 changes: 2 additions & 2 deletions server/src/main/java/com/cloud/user/AccountManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -749,9 +749,9 @@ public void validateAccountHasAccessToResource(Account account, AccessType acces
} else if (Domain.class.isAssignableFrom(resourceClass)) {
checkAccess(account, (Domain) resource);
} else if (InfrastructureEntity.class.isAssignableFrom(resourceClass)) {
s_logger.trace("Validation of access to infrastructure entity has been disabled in CloudStack version 4.4.");
logger.trace("Validation of access to infrastructure entity has been disabled in CloudStack version 4.4.");
}
s_logger.debug(String.format("Account [%s] has access to resource.", account.getUuid()));
logger.debug(String.format("Account [%s] has access to resource.", account.getUuid()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public void processVmHostNameParameter_NotMoreThan63Chars() {

@Test
public void doAccessChecksTestChecksCallerAccessToOwnerWhenCmdExtendsBaseAsyncCreateCmd() {
Mockito.doReturn(owners).when(paramProcessWorkerSpy).getEntityOwners(Mockito.any());
Mockito.lenient().doReturn(owners).when(paramProcessWorkerSpy).getEntityOwners(Mockito.any());
Mockito.doNothing().when(paramProcessWorkerSpy).checkCallerAccessToEntities(Mockito.any(), Mockito.any(), Mockito.any());

paramProcessWorkerSpy.doAccessChecks(new AssociateIPAddrCmd(), entities);
Expand All @@ -184,7 +184,7 @@ public void doAccessChecksTestChecksCallerAccessToOwnerWhenCmdExtendsBaseAsyncCr

@Test
public void doAccessChecksTestChecksCallerAccessToEntities() {
Mockito.doReturn(owners).when(paramProcessWorkerSpy).getEntityOwners(Mockito.any());
Mockito.lenient().doReturn(owners).when(paramProcessWorkerSpy).getEntityOwners(Mockito.any());
Mockito.doNothing().when(paramProcessWorkerSpy).checkCallerAccessToEntities(Mockito.any(), Mockito.any(), Mockito.any());

paramProcessWorkerSpy.doAccessChecks(new AssociateIPAddrCmd(), entities);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

import com.cloud.utils.NumbersUtil;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.FileInputStream;
import java.io.IOException;
Expand All @@ -42,7 +43,7 @@
* and on the <a href="https://review.opendev.org/c/openstack/cinder/+/923247/2/cinder/image/format_inspector.py">OpenStack's Cinder implementation for Python</a>.
*/
public class Qcow2Inspector {
protected static Logger LOGGER = Logger.getLogger(Qcow2Inspector.class);
protected static Logger LOGGER = LogManager.getLogger(Qcow2Inspector.class);

private static final byte[] QCOW_MAGIC_STRING = ArrayUtils.add("QFI".getBytes(), (byte) 0xfb);
private static final int INCOMPATIBLE_FEATURES_MAX_KNOWN_BIT = 4;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3489,7 +3489,7 @@ public String postUpload(String uuid, String filename, long processTimeout) {
try {
Qcow2Inspector.validateQcow2File(finalFilename);
} catch (RuntimeException e) {
s_logger.error(String.format("Uploaded file [%s] is not a valid QCOW2.", finalFilename), e);
logger.error(String.format("Uploaded file [%s] is not a valid QCOW2.", finalFilename), e);
return "The uploaded file is not a valid QCOW2. Ask the administrator to check the logs for more details.";
}
}
Expand Down
4 changes: 2 additions & 2 deletions utils/src/main/java/com/cloud/utils/HttpUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ public static boolean validateSessionKey(final HttpSession session, final Map<St
final String jsessionidFromCookie = HttpUtils.findCookie(cookies, "JSESSIONID");
if (jsessionidFromCookie == null
|| !(jsessionidFromCookie.startsWith(session.getId() + '.'))) {
s_logger.error("JSESSIONID from cookie is invalid.");
LOGGER.error("JSESSIONID from cookie is invalid.");
return false;
}
final String sessionKey = (String) session.getAttribute(sessionKeyString);
if (sessionKey == null) {
s_logger.error("sessionkey attribute of the session is null.");
LOGGER.error("sessionkey attribute of the session is null.");
return false;
}
final String sessionKeyFromCookie = HttpUtils.findCookie(cookies, sessionKeyString);
Expand Down

0 comments on commit 554ea22

Please sign in to comment.