Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.storage.volume.datastore.PrimaryDataStoreHelper;
import org.apache.log4j.Logger;

import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Answer;
Expand All @@ -39,9 +38,12 @@
import com.cloud.storage.StoragePoolHostVO;
import com.cloud.storage.dao.StoragePoolHostDao;
import com.cloud.utils.Pair;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class BasePrimaryDataStoreLifeCycleImpl {
private static final Logger s_logger = Logger.getLogger(BasePrimaryDataStoreLifeCycleImpl.class);
private static final Logger logger = LogManager.getLogger(BasePrimaryDataStoreLifeCycleImpl.class);
Comment thread
vishesh92 marked this conversation as resolved.
Outdated

@Inject
AgentManager agentMgr;
@Inject
Expand Down Expand Up @@ -70,13 +72,13 @@ private List<HostVO> getPoolHostsList(ClusterScope clusterScope, HypervisorType

public void changeStoragePoolScopeToZone(DataStore store, ClusterScope clusterScope, HypervisorType hypervisorType) {
List<HostVO> hosts = getPoolHostsList(clusterScope, hypervisorType);
s_logger.debug("Changing scope of the storage pool to Zone");
logger.debug("Changing scope of the storage pool to Zone");
if (hosts != null) {
for (HostVO host : hosts) {
try {
storageMgr.connectHostToSharedPool(host.getId(), store.getId());
} catch (Exception e) {
s_logger.warn("Unable to establish a connection between " + host + " and " + store, e);
logger.warn("Unable to establish a connection between " + host + " and " + store, e);
}
}
}
Expand All @@ -85,7 +87,7 @@ public void changeStoragePoolScopeToZone(DataStore store, ClusterScope clusterSc

public void changeStoragePoolScopeToCluster(DataStore store, ClusterScope clusterScope, HypervisorType hypervisorType) {
Pair<List<StoragePoolHostVO>, Integer> hostPoolRecords = storagePoolHostDao.listByPoolIdNotInCluster(clusterScope.getScopeId(), store.getId());
s_logger.debug("Changing scope of the storage pool to Cluster");
logger.debug("Changing scope of the storage pool to Cluster");
if (hostPoolRecords.second() > 0) {
StoragePool pool = (StoragePool) store;
for (StoragePoolHostVO host : hostPoolRecords.first()) {
Expand All @@ -94,7 +96,7 @@ public void changeStoragePoolScopeToCluster(DataStore store, ClusterScope cluste

if (answer != null) {
if (!answer.getResult()) {
s_logger.debug("Failed to delete storage pool: " + answer.getResult());
logger.debug("Failed to delete storage pool: " + answer.getResult());
} else if (HypervisorType.KVM != hypervisorType) {
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
//
package com.cloud.hypervisor.kvm.resource.wrapper;

import org.apache.log4j.Logger;

import com.cloud.agent.api.Answer;
import com.cloud.agent.api.CheckConvertInstanceAnswer;
import com.cloud.agent.api.CheckConvertInstanceCommand;
Expand All @@ -30,21 +28,19 @@
@ResourceWrapper(handles = CheckConvertInstanceCommand.class)
public class LibvirtCheckConvertInstanceCommandWrapper extends CommandWrapper<CheckConvertInstanceCommand, Answer, LibvirtComputingResource> {

private static final Logger s_logger = Logger.getLogger(LibvirtCheckConvertInstanceCommandWrapper.class);

@Override
public Answer execute(CheckConvertInstanceCommand cmd, LibvirtComputingResource serverResource) {
if (!serverResource.hostSupportsInstanceConversion()) {
String msg = String.format("Cannot convert the instance from VMware as the virt-v2v binary is not found on host %s. " +
"Please install virt-v2v%s on the host before attempting the instance conversion.", serverResource.getPrivateIp(), serverResource.isUbuntuHost()? ", nbdkit" : "");
s_logger.info(msg);
logger.info(msg);
return new CheckConvertInstanceAnswer(cmd, false, msg);
}

if (cmd.getCheckWindowsGuestConversionSupport() && !serverResource.hostSupportsWindowsGuestConversion()) {
String msg = String.format("Cannot convert the instance from VMware as the virtio-win package is not found on host %s. " +
"Please install virtio-win package on the host before attempting the windows guest instance conversion.", serverResource.getPrivateIp());
s_logger.info(msg);
logger.info(msg);
return new CheckConvertInstanceAnswer(cmd, false, msg);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

import java.util.Map;

import org.apache.log4j.Logger;

import com.cloud.agent.api.Answer;
import com.cloud.agent.api.PrepareStorageClientAnswer;
import com.cloud.agent.api.PrepareStorageClientCommand;
Expand All @@ -35,15 +33,13 @@
@ResourceWrapper(handles = PrepareStorageClientCommand.class)
public class LibvirtPrepareStorageClientCommandWrapper extends CommandWrapper<PrepareStorageClientCommand, Answer, LibvirtComputingResource> {

private static final Logger s_logger = Logger.getLogger(LibvirtPrepareStorageClientCommandWrapper.class);

@Override
public Answer execute(PrepareStorageClientCommand cmd, LibvirtComputingResource libvirtComputingResource) {
final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr();
Ternary<Boolean, Map<String, String>, String> prepareStorageClientResult = storagePoolMgr.prepareStorageClient(cmd.getPoolType(), cmd.getPoolUuid(), cmd.getDetails());
if (!prepareStorageClientResult.first()) {
String msg = prepareStorageClientResult.third();
s_logger.debug("Unable to prepare storage client, due to: " + msg);
logger.debug("Unable to prepare storage client, due to: " + msg);
return new PrepareStorageClientAnswer(cmd, false, msg);
}
Map<String, String> details = prepareStorageClientResult.second();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

package com.cloud.hypervisor.kvm.resource.wrapper;

import org.apache.log4j.Logger;

import com.cloud.agent.api.Answer;
import com.cloud.agent.api.UnprepareStorageClientAnswer;
import com.cloud.agent.api.UnprepareStorageClientCommand;
Expand All @@ -33,15 +31,13 @@
@ResourceWrapper(handles = UnprepareStorageClientCommand.class)
public class LibvirtUnprepareStorageClientCommandWrapper extends CommandWrapper<UnprepareStorageClientCommand, Answer, LibvirtComputingResource> {

private static final Logger s_logger = Logger.getLogger(LibvirtUnprepareStorageClientCommandWrapper.class);

@Override
public Answer execute(UnprepareStorageClientCommand cmd, LibvirtComputingResource libvirtComputingResource) {
final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr();
Pair<Boolean, String> unprepareStorageClientResult = storagePoolMgr.unprepareStorageClient(cmd.getPoolType(), cmd.getPoolUuid());
if (!unprepareStorageClientResult.first()) {
String msg = unprepareStorageClientResult.second();
s_logger.debug("Couldn't unprepare storage client, due to: " + msg);
logger.debug("Couldn't unprepare storage client, due to: " + msg);
return new UnprepareStorageClientAnswer(cmd, false, msg);
}
return new UnprepareStorageClientAnswer(cmd, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Component;

import com.cloud.agent.AgentManager;
Expand All @@ -51,7 +52,7 @@

@Component
public class ScaleIOSDCManagerImpl implements ScaleIOSDCManager {
private static final Logger LOGGER = Logger.getLogger(ScaleIOSDCManagerImpl.class);
private static final Logger logger = LogManager.getLogger(ScaleIOSDCManagerImpl.class);
Comment thread
vishesh92 marked this conversation as resolved.
Outdated

@Inject
AgentManager agentManager;
Expand Down Expand Up @@ -79,14 +80,14 @@ public boolean areSDCConnectionsWithinLimit(Long storagePoolId) {

int connectedSdcsCount = getScaleIOClient(storagePoolId).getConnectedSdcsCount();
if (connectedSdcsCount < connectedClientsLimit) {
LOGGER.debug(String.format("Current connected SDCs count: %d - SDC connections are within the limit (%d) on PowerFlex Storage with pool id: %d", connectedSdcsCount, connectedClientsLimit, storagePoolId));
logger.debug(String.format("Current connected SDCs count: %d - SDC connections are within the limit (%d) on PowerFlex Storage with pool id: %d", connectedSdcsCount, connectedClientsLimit, storagePoolId));
return true;
}
LOGGER.debug(String.format("Current connected SDCs count: %d - SDC connections limit (%d) reached on PowerFlex Storage with pool id: %d", connectedSdcsCount, connectedClientsLimit, storagePoolId));
logger.debug(String.format("Current connected SDCs count: %d - SDC connections limit (%d) reached on PowerFlex Storage with pool id: %d", connectedSdcsCount, connectedClientsLimit, storagePoolId));
return false;
} catch (Exception e) {
String errMsg = "Unable to check SDC connections for the PowerFlex storage pool with id: " + storagePoolId + " due to " + e.getMessage();
LOGGER.warn(errMsg, e);
logger.warn(errMsg, e);
return false;
}
}
Expand All @@ -109,33 +110,33 @@ public String prepareSDC(Host host, DataStore dataStore) {

int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600);
if (!hostIdStorageSystemIdLock.lock(storagePoolMaxWaitSeconds)) {
LOGGER.debug("Unable to prepare SDC, couldn't lock on " + hostIdStorageSystemIdLockString);
logger.debug("Unable to prepare SDC, couldn't lock on " + hostIdStorageSystemIdLockString);
throw new CloudRuntimeException("Unable to prepare SDC, couldn't lock on " + hostIdStorageSystemIdLockString);
}

long poolId = dataStore.getId();
long hostId = host.getId();
String sdcId = getConnectedSdc(poolId, hostId);
if (StringUtils.isNotBlank(sdcId)) {
LOGGER.debug(String.format("SDC %s already connected for the pool: %d on host: %d, no need to prepare/start it", sdcId, poolId, hostId));
logger.debug(String.format("SDC %s already connected for the pool: %d on host: %d, no need to prepare/start it", sdcId, poolId, hostId));
return sdcId;
}

String storageSystemIdLockString = String.format(POWERFLEX_SDC_SYSTEMID_LOCK_FORMAT, systemId);
storageSystemIdLock = GlobalLock.getInternLock(storageSystemIdLockString);
if (storageSystemIdLock == null) {
LOGGER.error("Unable to prepare SDC, couldn't get global lock on: " + storageSystemIdLockString);
logger.error("Unable to prepare SDC, couldn't get global lock on: " + storageSystemIdLockString);
throw new CloudRuntimeException("Unable to prepare SDC, couldn't get global lock on " + storageSystemIdLockString);
}

if (!storageSystemIdLock.lock(storagePoolMaxWaitSeconds)) {
LOGGER.error("Unable to prepare SDC, couldn't lock on " + storageSystemIdLockString);
logger.error("Unable to prepare SDC, couldn't lock on " + storageSystemIdLockString);
throw new CloudRuntimeException("Unable to prepare SDC, couldn't lock on " + storageSystemIdLockString);
}

if (!areSDCConnectionsWithinLimit(poolId)) {
String errorMsg = String.format("Unable to check SDC connections or the connections limit reached for Powerflex storage (System ID: %s)", systemId);
LOGGER.error(errorMsg);
logger.error(errorMsg);
throw new CloudRuntimeException(errorMsg);
}

Expand Down Expand Up @@ -174,7 +175,7 @@ public String prepareSDC(Host host, DataStore dataStore) {
}

private String prepareSDCOnHost(Host host, DataStore dataStore, String systemId) {
LOGGER.debug(String.format("Preparing SDC on the host %s (%s)", host.getId(), host.getName()));
logger.debug(String.format("Preparing SDC on the host %s (%s)", host.getId(), host.getName()));
Map<String,String> details = new HashMap<>();
details.put(ScaleIOGatewayClient.STORAGE_POOL_SYSTEM_ID, systemId);
PrepareStorageClientCommand cmd = new PrepareStorageClientCommand(((PrimaryDataStore) dataStore).getPoolType(), dataStore.getUuid(), details);
Expand All @@ -186,25 +187,25 @@ private String prepareSDCOnHost(Host host, DataStore dataStore, String systemId)
prepareStorageClientAnswer = (PrepareStorageClientAnswer) agentManager.send(host.getId(), cmd);
} catch (AgentUnavailableException | OperationTimedoutException e) {
String err = String.format("Failed to prepare SDC on the host %s, due to: %s", host.getName(), e.getMessage());
LOGGER.error(err);
logger.error(err);
throw new CloudRuntimeException(err);
}

if (prepareStorageClientAnswer == null) {
String err = String.format("Unable to prepare SDC on the host %s", host.getName());
LOGGER.error(err);
logger.error(err);
throw new CloudRuntimeException(err);
}

if (!prepareStorageClientAnswer.getResult()) {
String err = String.format("Unable to prepare SDC on the host %s, due to: %s", host.getName(), prepareStorageClientAnswer.getDetails());
LOGGER.error(err);
logger.error(err);
throw new CloudRuntimeException(err);
}

Map<String,String> poolDetails = prepareStorageClientAnswer.getDetailsMap();
if (MapUtils.isEmpty(poolDetails)) {
LOGGER.warn(String.format("PowerFlex storage SDC details not found on the host: %s, try (re)install SDC and restart agent", host.getId()));
logger.warn(String.format("PowerFlex storage SDC details not found on the host: %s, try (re)install SDC and restart agent", host.getId()));
return null;
}

Expand All @@ -217,7 +218,7 @@ private String prepareSDCOnHost(Host host, DataStore dataStore, String systemId)
}

if (StringUtils.isBlank(sdcId)) {
LOGGER.warn(String.format("Couldn't retrieve PowerFlex storage SDC details from the host: %s, try (re)install SDC and restart agent", host.getId()));
logger.warn(String.format("Couldn't retrieve PowerFlex storage SDC details from the host: %s, try (re)install SDC and restart agent", host.getId()));
return null;
}

Expand All @@ -241,15 +242,15 @@ public boolean stopSDC(Host host, DataStore dataStore) {

int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600);
if (!lock.lock(storagePoolMaxWaitSeconds)) {
LOGGER.debug("Unable to unprepare SDC, couldn't lock on " + hostIdStorageSystemIdLockString);
logger.debug("Unable to unprepare SDC, couldn't lock on " + hostIdStorageSystemIdLockString);
throw new CloudRuntimeException("Unable to unprepare SDC, couldn't lock on " + hostIdStorageSystemIdLockString);
}

long poolId = dataStore.getId();
long hostId = host.getId();
String sdcId = getConnectedSdc(poolId, hostId);
if (StringUtils.isBlank(sdcId)) {
LOGGER.debug("SDC not connected, no need to unprepare it");
logger.debug("SDC not connected, no need to unprepare it");
return true;
}

Expand All @@ -263,7 +264,7 @@ public boolean stopSDC(Host host, DataStore dataStore) {
}

private boolean unprepareSDCOnHost(Host host, DataStore dataStore) {
LOGGER.debug(String.format("Unpreparing SDC on the host %s (%s)", host.getId(), host.getName()));
logger.debug(String.format("Unpreparing SDC on the host %s (%s)", host.getId(), host.getName()));
UnprepareStorageClientCommand cmd = new UnprepareStorageClientCommand(((PrimaryDataStore) dataStore).getPoolType(), dataStore.getUuid());
int timeoutSeconds = 60;
cmd.setWait(timeoutSeconds);
Expand All @@ -273,25 +274,25 @@ private boolean unprepareSDCOnHost(Host host, DataStore dataStore) {
unprepareStorageClientAnswer = agentManager.send(host.getId(), cmd);
} catch (AgentUnavailableException | OperationTimedoutException e) {
String err = String.format("Failed to unprepare SDC on the host %s due to: %s", host.getName(), e.getMessage());
LOGGER.error(err);
logger.error(err);
return false;
}

if (!unprepareStorageClientAnswer.getResult()) {
String err = String.format("Unable to unprepare SDC on the the host %s due to: %s", host.getName(), unprepareStorageClientAnswer.getDetails());
LOGGER.error(err);
logger.error(err);
return false;
}
return true;
}

private String getHostSdcId(String sdcGuid, long poolId) {
try {
LOGGER.debug(String.format("Try to get host SDC Id for pool: %s, with SDC guid %s", poolId, sdcGuid));
logger.debug(String.format("Try to get host SDC Id for pool: %s, with SDC guid %s", poolId, sdcGuid));
ScaleIOGatewayClient client = getScaleIOClient(poolId);
return client.getSdcIdByGuid(sdcGuid);
} catch (Exception e) {
LOGGER.error(String.format("Failed to get host SDC Id for pool: %s", poolId), e);
logger.error(String.format("Failed to get host SDC Id for pool: %s", poolId), e);
throw new CloudRuntimeException(String.format("Failed to establish connection with PowerFlex Gateway to get host SDC Id for pool: %s", poolId));
}
}
Expand All @@ -308,14 +309,14 @@ private String getConnectedSdc(long poolId, long hostId) {
return poolHostVO.getLocalPath();
}
} catch (Exception e) {
LOGGER.warn("Unable to get connected SDC for the host: " + hostId + " and storage pool: " + poolId + " due to " + e.getMessage(), e);
logger.warn("Unable to get connected SDC for the host: " + hostId + " and storage pool: " + poolId + " due to " + e.getMessage(), e);
}

return null;
}

private boolean hostSdcConnected(String sdcId, long poolId, int waitTimeInSecs) {
LOGGER.debug(String.format("Waiting (for %d secs) for the SDC %s of the pool id: %d to connect", waitTimeInSecs, sdcId, poolId));
logger.debug(String.format("Waiting (for %d secs) for the SDC %s of the pool id: %d to connect", waitTimeInSecs, sdcId, poolId));
int timeBetweenTries = 1000; // Try more frequently (every sec) and return early if connected
while (waitTimeInSecs > 0) {
if (isHostSdcConnected(sdcId, poolId)) {
Expand All @@ -335,7 +336,7 @@ private boolean isHostSdcConnected(String sdcId, long poolId) {
final ScaleIOGatewayClient client = getScaleIOClient(poolId);
return client.isSdcConnected(sdcId);
} catch (Exception e) {
LOGGER.error("Failed to check host SDC connection", e);
logger.error("Failed to check host SDC connection", e);
throw new CloudRuntimeException("Failed to establish connection with PowerFlex Gateway to check host SDC connection");
}
}
Expand Down