mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-9299: Incorporate out-of-band management PR changes
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
0f8d63989f
commit
bb0282dfa1
|
|
@ -311,7 +311,8 @@ public class EventTypes {
|
|||
public static final String EVENT_HOST_RECONNECT = "HOST.RECONNECT";
|
||||
|
||||
// Host Out-of-band management
|
||||
public static final String EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLEDISABLE = "HOST.OOBM.ENABLEDISABLE";
|
||||
public static final String EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLE = "HOST.OOBM.ENABLE";
|
||||
public static final String EVENT_HOST_OUTOFBAND_MANAGEMENT_DISABLE = "HOST.OOBM.DISABLE";
|
||||
public static final String EVENT_HOST_OUTOFBAND_MANAGEMENT_CONFIGURE = "HOST.OOBM.CONFIGURE";
|
||||
public static final String EVENT_HOST_OUTOFBAND_MANAGEMENT_ACTION = "HOST.OOBM.ACTION";
|
||||
public static final String EVENT_HOST_OUTOFBAND_MANAGEMENT_CHANGE_PASSWORD = "HOST.OOBM.CHANGEPASSWORD";
|
||||
|
|
@ -746,7 +747,8 @@ public class EventTypes {
|
|||
entityEventDetails.put(EVENT_HOST_RECONNECT, Host.class);
|
||||
|
||||
// Host Out-of-band management
|
||||
entityEventDetails.put(EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLEDISABLE, Host.class);
|
||||
entityEventDetails.put(EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLE, Host.class);
|
||||
entityEventDetails.put(EVENT_HOST_OUTOFBAND_MANAGEMENT_DISABLE, Host.class);
|
||||
entityEventDetails.put(EVENT_HOST_OUTOFBAND_MANAGEMENT_CONFIGURE, Host.class);
|
||||
entityEventDetails.put(EVENT_HOST_OUTOFBAND_MANAGEMENT_ACTION, Host.class);
|
||||
entityEventDetails.put(EVENT_HOST_OUTOFBAND_MANAGEMENT_CHANGE_PASSWORD, Host.class);
|
||||
|
|
|
|||
|
|
@ -68,10 +68,11 @@ public class DisableOutOfBandManagementForClusterCmd extends BaseAsyncCmd {
|
|||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find cluster by ID: " + getClusterId());
|
||||
}
|
||||
|
||||
OutOfBandManagementResponse response = outOfBandManagementService.disableOutOfBandManagement(cluster);
|
||||
|
||||
CallContext.current().setEventDetails("Cluster Id:" + cluster.getId() + " out-of-band management enabled: false");
|
||||
CallContext.current().putContextParameter(Cluster.class, cluster.getUuid());
|
||||
|
||||
final OutOfBandManagementResponse response = outOfBandManagementService.enableDisableOutOfBandManagement(cluster, false);
|
||||
response.setResponseName(getCommandName());
|
||||
setResponseObject(response);
|
||||
}
|
||||
|
|
@ -92,7 +93,7 @@ public class DisableOutOfBandManagementForClusterCmd extends BaseAsyncCmd {
|
|||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLEDISABLE;
|
||||
return EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_DISABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -68,10 +68,11 @@ public class DisableOutOfBandManagementForHostCmd extends BaseAsyncCmd {
|
|||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find host by ID: " + getHostId());
|
||||
}
|
||||
|
||||
OutOfBandManagementResponse response = outOfBandManagementService.disableOutOfBandManagement(host);
|
||||
|
||||
CallContext.current().setEventDetails("Host Id:" + host.getId() + " out-of-band management enabled: false");
|
||||
CallContext.current().putContextParameter(Host.class, host.getUuid());
|
||||
|
||||
final OutOfBandManagementResponse response = outOfBandManagementService.enableDisableOutOfBandManagement(host, false);
|
||||
response.setId(host.getUuid());
|
||||
response.setResponseName(getCommandName());
|
||||
setResponseObject(response);
|
||||
|
|
@ -93,7 +94,7 @@ public class DisableOutOfBandManagementForHostCmd extends BaseAsyncCmd {
|
|||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLEDISABLE;
|
||||
return EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_DISABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -68,10 +68,11 @@ public class DisableOutOfBandManagementForZoneCmd extends BaseAsyncCmd {
|
|||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find zone by ID: " + getZoneId());
|
||||
}
|
||||
|
||||
OutOfBandManagementResponse response = outOfBandManagementService.disableOutOfBandManagement(zone);
|
||||
|
||||
CallContext.current().setEventDetails("Zone Id:" + zone.getId() + " out-of-band management enabled: false");
|
||||
CallContext.current().putContextParameter(DataCenter.class, zone.getUuid());
|
||||
|
||||
final OutOfBandManagementResponse response = outOfBandManagementService.enableDisableOutOfBandManagement(zone, false);
|
||||
response.setResponseName(getCommandName());
|
||||
setResponseObject(response);
|
||||
}
|
||||
|
|
@ -92,7 +93,7 @@ public class DisableOutOfBandManagementForZoneCmd extends BaseAsyncCmd {
|
|||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLEDISABLE;
|
||||
return EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_DISABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -68,10 +68,11 @@ public class EnableOutOfBandManagementForClusterCmd extends BaseAsyncCmd {
|
|||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find cluster by ID: " + getClusterId());
|
||||
}
|
||||
|
||||
OutOfBandManagementResponse response = outOfBandManagementService.enableOutOfBandManagement(cluster);
|
||||
|
||||
CallContext.current().setEventDetails("Cluster Id:" + cluster.getId() + " out-of-band management enabled: true");
|
||||
CallContext.current().putContextParameter(Cluster.class, cluster.getUuid());
|
||||
|
||||
final OutOfBandManagementResponse response = outOfBandManagementService.enableDisableOutOfBandManagement(cluster, true);
|
||||
response.setResponseName(getCommandName());
|
||||
setResponseObject(response);
|
||||
}
|
||||
|
|
@ -92,7 +93,7 @@ public class EnableOutOfBandManagementForClusterCmd extends BaseAsyncCmd {
|
|||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLEDISABLE;
|
||||
return EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -68,10 +68,11 @@ public class EnableOutOfBandManagementForHostCmd extends BaseAsyncCmd {
|
|||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find host by ID: " + getHostId());
|
||||
}
|
||||
|
||||
OutOfBandManagementResponse response = outOfBandManagementService.enableOutOfBandManagement(host);
|
||||
|
||||
CallContext.current().setEventDetails("Host Id:" + host.getId() + " out-of-band management enabled: true");
|
||||
CallContext.current().putContextParameter(Host.class, host.getUuid());
|
||||
|
||||
final OutOfBandManagementResponse response = outOfBandManagementService.enableDisableOutOfBandManagement(host, true);
|
||||
response.setId(host.getUuid());
|
||||
response.setResponseName(getCommandName());
|
||||
setResponseObject(response);
|
||||
|
|
@ -93,7 +94,7 @@ public class EnableOutOfBandManagementForHostCmd extends BaseAsyncCmd {
|
|||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLEDISABLE;
|
||||
return EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -68,10 +68,11 @@ public class EnableOutOfBandManagementForZoneCmd extends BaseAsyncCmd {
|
|||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find zone by ID: " + getZoneId());
|
||||
}
|
||||
|
||||
OutOfBandManagementResponse response = outOfBandManagementService.enableOutOfBandManagement(zone);
|
||||
|
||||
CallContext.current().setEventDetails("Zone Id:" + zone.getId() + " out-of-band management enabled: true");
|
||||
CallContext.current().putContextParameter(DataCenter.class, zone.getUuid());
|
||||
|
||||
final OutOfBandManagementResponse response = outOfBandManagementService.enableDisableOutOfBandManagement(zone, true);
|
||||
response.setResponseName(getCommandName());
|
||||
setResponseObject(response);
|
||||
}
|
||||
|
|
@ -92,7 +93,7 @@ public class EnableOutOfBandManagementForZoneCmd extends BaseAsyncCmd {
|
|||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLEDISABLE;
|
||||
return EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@ import java.util.List;
|
|||
|
||||
public interface OutOfBandManagementService {
|
||||
|
||||
ConfigKey<Long> OutOfBandManagementActionTimeout = new ConfigKey<Long>("Advanced", Long.class, "outofbandmanagement.action.timeout", "60",
|
||||
ConfigKey<Long> ActionTimeout = new ConfigKey<Long>("Advanced", Long.class, "outofbandmanagement.action.timeout", "60",
|
||||
"The out of band management action timeout in seconds, configurable by cluster", true, ConfigKey.Scope.Cluster);
|
||||
|
||||
ConfigKey<Long> OutOfBandManagementSyncThreadInterval = new ConfigKey<Long>("Advanced", Long.class, "outofbandmanagement.sync.interval", "300000",
|
||||
ConfigKey<Long> SyncThreadInterval = new ConfigKey<Long>("Advanced", Long.class, "outofbandmanagement.sync.interval", "300000",
|
||||
"The interval (in milliseconds) when the out-of-band management background sync are retrieved", true, ConfigKey.Scope.Global);
|
||||
|
||||
ConfigKey<Integer> OutOfBandManagementSyncThreadPoolSize = new ConfigKey<Integer>("Advanced", Integer.class, "outofbandmanagement.sync.poolsize", "50",
|
||||
ConfigKey<Integer> SyncThreadPoolSize = new ConfigKey<Integer>("Advanced", Integer.class, "outofbandmanagement.sync.poolsize", "50",
|
||||
"The out of band management background sync thread pool size", true, ConfigKey.Scope.Global);
|
||||
|
||||
long getId();
|
||||
|
|
@ -41,11 +41,15 @@ public interface OutOfBandManagementService {
|
|||
void submitBackgroundPowerSyncTask(Host host);
|
||||
boolean transitionPowerStateToDisabled(List<? extends Host> hosts);
|
||||
|
||||
OutOfBandManagementResponse enableDisableOutOfBandManagement(DataCenter zone, boolean enabled);
|
||||
OutOfBandManagementResponse enableDisableOutOfBandManagement(Cluster cluster, boolean enabled);
|
||||
OutOfBandManagementResponse enableDisableOutOfBandManagement(Host host, boolean enabled);
|
||||
OutOfBandManagementResponse enableOutOfBandManagement(DataCenter zone);
|
||||
OutOfBandManagementResponse enableOutOfBandManagement(Cluster cluster);
|
||||
OutOfBandManagementResponse enableOutOfBandManagement(Host host);
|
||||
|
||||
OutOfBandManagementResponse disableOutOfBandManagement(DataCenter zone);
|
||||
OutOfBandManagementResponse disableOutOfBandManagement(Cluster cluster);
|
||||
OutOfBandManagementResponse disableOutOfBandManagement(Host host);
|
||||
|
||||
OutOfBandManagementResponse configureOutOfBandManagement(Host host, ImmutableMap<OutOfBandManagement.Option, String> options);
|
||||
OutOfBandManagementResponse changeOutOfBandManagementPassword(Host host, String password);
|
||||
OutOfBandManagementResponse executeOutOfBandManagementPowerOperation(Host host, OutOfBandManagement.PowerOperation operation, Long timeout);
|
||||
OutOfBandManagementResponse changeOutOfBandManagementPassword(Host host, String password);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,5 @@ import java.util.List;
|
|||
public interface OutOfBandManagementDao extends GenericDao<OutOfBandManagementVO, Long>, StateDao<OutOfBandManagement.PowerState, OutOfBandManagement.PowerState.Event, OutOfBandManagement> {
|
||||
OutOfBandManagement findByHost(long hostId);
|
||||
List<OutOfBandManagementVO> findAllByManagementServer(long serverId);
|
||||
void expireOutOfBandManagementOwnershipByHours(long hours);
|
||||
void expireOutOfBandManagementOwnershipByServer(long serverId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,22 +24,22 @@ import com.cloud.utils.db.Filter;
|
|||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionCallbackNoReturn;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
import com.cloud.utils.db.TransactionStatus;
|
||||
import com.cloud.utils.db.UpdateBuilder;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import org.apache.cloudstack.outofbandmanagement.OutOfBandManagement;
|
||||
import org.apache.cloudstack.outofbandmanagement.OutOfBandManagementVO;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
@DB
|
||||
@Component
|
||||
@Local(value = {OutOfBandManagementDao.class})
|
||||
public class OutOfBandManagementDaoImpl extends GenericDaoBase<OutOfBandManagementVO, Long> implements OutOfBandManagementDao {
|
||||
private static final Logger LOG = Logger.getLogger(OutOfBandManagementDaoImpl.class);
|
||||
|
||||
|
|
@ -93,24 +93,20 @@ public class OutOfBandManagementDaoImpl extends GenericDaoBase<OutOfBandManageme
|
|||
return listBy(sc, new Filter(OutOfBandManagementVO.class, "updateTime", true, null, null));
|
||||
}
|
||||
|
||||
private void executeExpireOwnershipSql(final String sql, long resource) {
|
||||
TransactionLegacy txn = TransactionLegacy.currentTxn();
|
||||
try {
|
||||
txn.start();
|
||||
PreparedStatement pstmt = txn.prepareAutoCloseStatement(sql);
|
||||
pstmt.setLong(1, resource);
|
||||
pstmt.executeUpdate();
|
||||
txn.commit();
|
||||
} catch (SQLException e) {
|
||||
txn.rollback();
|
||||
throw new CloudRuntimeException("Unable to reset out-of-band management ownership based on resource:" + resource);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expireOutOfBandManagementOwnershipByHours(long hours) {
|
||||
final String resetOwnerSql = "UPDATE oobm set mgmt_server_id=NULL where update_time<= (NOW() - INTERVAL ? HOUR)";
|
||||
executeExpireOwnershipSql(resetOwnerSql, hours);
|
||||
private void executeExpireOwnershipSql(final String sql, final long resource) {
|
||||
Transaction.execute(new TransactionCallbackNoReturn() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
TransactionLegacy txn = TransactionLegacy.currentTxn();
|
||||
try (final PreparedStatement pstmt = txn.prepareAutoCloseStatement(sql);) {
|
||||
pstmt.setLong(1, resource);
|
||||
pstmt.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
txn.rollback();
|
||||
LOG.warn("Failed to expire ownership for out-of-band management server id: " + resource);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -31,11 +31,9 @@ import org.apache.cloudstack.outofbandmanagement.driver.OutOfBandManagementDrive
|
|||
import org.apache.log4j.Logger;
|
||||
import org.joda.time.Duration;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Local(value = {OutOfBandManagementDriver.class})
|
||||
public class IpmitoolOutOfBandManagementDriver extends AdapterBase implements OutOfBandManagementDriver, Configurable {
|
||||
public static final Logger LOG = Logger.getLogger(IpmitoolOutOfBandManagementDriver.class);
|
||||
|
||||
|
|
|
|||
|
|
@ -104,9 +104,11 @@ public class IpmitoolWrapper {
|
|||
}
|
||||
|
||||
public static String findIpmiUser(final String usersList, final String username) {
|
||||
// Expected usersList string contains legends on first line and users on rest
|
||||
// ID Name Callin Link Auth IPMI Msg Channel Priv Limit
|
||||
// 1 admin true true true ADMINISTRATOR
|
||||
/**
|
||||
* Expected usersList string contains legends on first line and users on rest
|
||||
* ID Name Callin Link Auth IPMI Msg Channel Priv Limit
|
||||
* 1 admin true true true ADMINISTRATOR
|
||||
*/
|
||||
|
||||
// Assuming user 'ID' index on 1st position
|
||||
int idIndex = 0;
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
|
|||
private void init(Map<String, String> configs) {
|
||||
_executor = Executors.newScheduledThreadPool(6, new NamedThreadFactory("StatsCollector"));
|
||||
|
||||
hostOutOfBandManagementStatsInterval = OutOfBandManagementService.OutOfBandManagementSyncThreadInterval.value();
|
||||
hostOutOfBandManagementStatsInterval = OutOfBandManagementService.SyncThreadInterval.value();
|
||||
hostStatsInterval = NumbersUtil.parseLong(configs.get("host.stats.interval"), 60000L);
|
||||
hostAndVmStatsInterval = NumbersUtil.parseLong(configs.get("vm.stats.interval"), 60000L);
|
||||
storageStatsInterval = NumbersUtil.parseLong(configs.get("storage.stats.interval"), 60000L);
|
||||
|
|
|
|||
|
|
@ -18,8 +18,11 @@
|
|||
package org.apache.cloudstack.outofbandmanagement;
|
||||
|
||||
import com.cloud.host.Host;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class OutOfBandManagementBackgroundTask implements Runnable {
|
||||
public static final Logger LOG = Logger.getLogger(OutOfBandManagementBackgroundTask.class);
|
||||
|
||||
final private OutOfBandManagementService service;
|
||||
final private Host host;
|
||||
final private OutOfBandManagement.PowerOperation powerOperation;
|
||||
|
|
@ -39,7 +42,9 @@ public class OutOfBandManagementBackgroundTask implements Runnable {
|
|||
public void run() {
|
||||
try {
|
||||
service.executeOutOfBandManagementPowerOperation(host, powerOperation, null);
|
||||
} catch (Exception ignored) {
|
||||
} catch (Exception e) {
|
||||
LOG.warn(String.format("Out-of-band management background task operation=%s for host id=%d failed with: %s",
|
||||
powerOperation.name(), host.getId(), e.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ import org.apache.cloudstack.utils.identity.ManagementServerNode;
|
|||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -67,7 +66,6 @@ import java.util.concurrent.ThreadPoolExecutor;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Component
|
||||
@Local(value = {OutOfBandManagementService.class})
|
||||
public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOfBandManagementService, Manager, Configurable {
|
||||
public static final Logger LOG = Logger.getLogger(OutOfBandManagementServiceImpl.class);
|
||||
|
||||
|
|
@ -86,13 +84,13 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
private long serviceId;
|
||||
|
||||
private List<OutOfBandManagementDriver> outOfBandManagementDrivers = new ArrayList<>();
|
||||
private Map<String, OutOfBandManagementDriver> outOfBandManagementDriversMap = new HashMap<String, OutOfBandManagementDriver>();
|
||||
private final Map<String, OutOfBandManagementDriver> outOfBandManagementDriversMap = new HashMap<String, OutOfBandManagementDriver>();
|
||||
|
||||
private static final String OOBM_ENABLED_DETAIL = "outOfBandManagementEnabled";
|
||||
private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_HOST = 120;
|
||||
|
||||
private Cache<Long, Long> hostAlertCache;
|
||||
private static ExecutorService backgroundSyncExecutor;
|
||||
private static Cache<Long, Long> hostAlertCache;
|
||||
private static ExecutorService backgroundSyncBlockingExecutor;
|
||||
|
||||
private String getOutOfBandManagementHostLock(long id) {
|
||||
return "oobm.host." + id;
|
||||
|
|
@ -282,8 +280,7 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
|
||||
public void submitBackgroundPowerSyncTask(final Host host) {
|
||||
if (host != null) {
|
||||
// Note: This is a blocking queue based executor
|
||||
backgroundSyncExecutor.submit(new OutOfBandManagementBackgroundTask(this, host, OutOfBandManagement.PowerOperation.STATUS));
|
||||
backgroundSyncBlockingExecutor.submit(new OutOfBandManagementBackgroundTask(this, host, OutOfBandManagement.PowerOperation.STATUS));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -295,42 +292,68 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
}
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLEDISABLE, eventDescription = "enabling/disabling out-of-band management on a zone")
|
||||
public OutOfBandManagementResponse enableDisableOutOfBandManagement(final DataCenter zone, final boolean enabled) {
|
||||
dataCenterDetailsDao.persist(zone.getId(), OOBM_ENABLED_DETAIL, String.valueOf(enabled));
|
||||
if (!enabled) {
|
||||
transitionPowerStateToDisabled(hostDao.findByDataCenterId(zone.getId()));
|
||||
}
|
||||
return buildEnableDisableResponse(enabled);
|
||||
@ActionEvent(eventType = EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLE, eventDescription = "enabling out-of-band management on a zone")
|
||||
public OutOfBandManagementResponse enableOutOfBandManagement(final DataCenter zone) {
|
||||
dataCenterDetailsDao.persist(zone.getId(), OOBM_ENABLED_DETAIL, String.valueOf(true));
|
||||
return buildEnableDisableResponse(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLEDISABLE, eventDescription = "enabling/disabling out-of-band management on a cluster")
|
||||
public OutOfBandManagementResponse enableDisableOutOfBandManagement(final Cluster cluster, final boolean enabled) {
|
||||
clusterDetailsDao.persist(cluster.getId(), OOBM_ENABLED_DETAIL, String.valueOf(enabled));
|
||||
if (!enabled) {
|
||||
transitionPowerStateToDisabled(hostDao.findByClusterId(cluster.getId()));
|
||||
}
|
||||
return buildEnableDisableResponse(enabled);
|
||||
@ActionEvent(eventType = EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_DISABLE, eventDescription = "disabling out-of-band management on a zone")
|
||||
public OutOfBandManagementResponse disableOutOfBandManagement(final DataCenter zone) {
|
||||
dataCenterDetailsDao.persist(zone.getId(), OOBM_ENABLED_DETAIL, String.valueOf(false));
|
||||
transitionPowerStateToDisabled(hostDao.findByDataCenterId(zone.getId()));
|
||||
|
||||
return buildEnableDisableResponse(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLEDISABLE, eventDescription = "enabling/disabling out-of-band management on a host")
|
||||
public OutOfBandManagementResponse enableDisableOutOfBandManagement(final Host host, final boolean enabled) {
|
||||
@ActionEvent(eventType = EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLE, eventDescription = "enabling out-of-band management on a cluster")
|
||||
public OutOfBandManagementResponse enableOutOfBandManagement(final Cluster cluster) {
|
||||
clusterDetailsDao.persist(cluster.getId(), OOBM_ENABLED_DETAIL, String.valueOf(true));
|
||||
return buildEnableDisableResponse(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_DISABLE, eventDescription = "disabling out-of-band management on a cluster")
|
||||
public OutOfBandManagementResponse disableOutOfBandManagement(final Cluster cluster) {
|
||||
clusterDetailsDao.persist(cluster.getId(), OOBM_ENABLED_DETAIL, String.valueOf(false));
|
||||
transitionPowerStateToDisabled(hostDao.findByClusterId(cluster.getId()));
|
||||
return buildEnableDisableResponse(false);
|
||||
}
|
||||
|
||||
private OutOfBandManagement getConfigForHost(final Host host) {
|
||||
final OutOfBandManagement outOfBandManagementConfig = outOfBandManagementDao.findByHost(host.getId());
|
||||
if (outOfBandManagementConfig == null) {
|
||||
final OutOfBandManagementResponse response = new OutOfBandManagementResponse(null);
|
||||
response.setSuccess(false);
|
||||
response.setResultDescription("Out-of-band management is not configured for the host. Please configure the host before enabling/disabling it.");
|
||||
return response;
|
||||
throw new CloudRuntimeException("Out-of-band management is not configured for the host. Please configure the host before enabling/disabling it.");
|
||||
}
|
||||
return outOfBandManagementConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLE, eventDescription = "enabling out-of-band management on a host")
|
||||
public OutOfBandManagementResponse enableOutOfBandManagement(final Host host) {
|
||||
final OutOfBandManagement outOfBandManagementConfig = getConfigForHost(host);
|
||||
hostAlertCache.invalidate(host.getId());
|
||||
outOfBandManagementConfig.setEnabled(enabled);
|
||||
outOfBandManagementConfig.setEnabled(true);
|
||||
boolean updateResult = outOfBandManagementDao.update(outOfBandManagementConfig.getId(), (OutOfBandManagementVO) outOfBandManagementConfig);
|
||||
if (updateResult && !enabled) {
|
||||
if (updateResult) {
|
||||
transitionPowerStateToDisabled(Collections.singletonList(host));
|
||||
}
|
||||
return buildEnableDisableResponse(enabled && updateResult);
|
||||
return buildEnableDisableResponse(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_DISABLE, eventDescription = "disabling out-of-band management on a host")
|
||||
public OutOfBandManagementResponse disableOutOfBandManagement(final Host host) {
|
||||
final OutOfBandManagement outOfBandManagementConfig = getConfigForHost(host);
|
||||
hostAlertCache.invalidate(host.getId());
|
||||
outOfBandManagementConfig.setEnabled(false);
|
||||
boolean updateResult = outOfBandManagementDao.update(outOfBandManagementConfig.getId(), (OutOfBandManagementVO) outOfBandManagementConfig);
|
||||
if (updateResult) {
|
||||
transitionPowerStateToDisabled(Collections.singletonList(host));
|
||||
}
|
||||
return buildEnableDisableResponse(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -362,16 +385,16 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
}
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ACTION, eventDescription = "issuing Host out-of-band management action", async = true)
|
||||
@ActionEvent(eventType = EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ACTION, eventDescription = "issuing host out-of-band management action", async = true)
|
||||
public OutOfBandManagementResponse executeOutOfBandManagementPowerOperation(final Host host, final OutOfBandManagement.PowerOperation powerOperation, final Long timeout) {
|
||||
checkOutOfBandManagementEnabledByZoneClusterHost(host);
|
||||
final OutOfBandManagement outOfBandManagementConfig = outOfBandManagementDao.findByHost(host.getId());
|
||||
final OutOfBandManagement outOfBandManagementConfig = getConfigForHost(host);
|
||||
final ImmutableMap<OutOfBandManagement.Option, String> options = getOptions(outOfBandManagementConfig);
|
||||
final OutOfBandManagementDriver driver = getDriver(outOfBandManagementConfig);
|
||||
|
||||
Long actionTimeOut = timeout;
|
||||
if (actionTimeOut == null) {
|
||||
actionTimeOut = OutOfBandManagementActionTimeout.valueIn(host.getClusterId());
|
||||
actionTimeOut = ActionTimeout.valueIn(host.getClusterId());
|
||||
}
|
||||
|
||||
final OutOfBandManagementDriverPowerCommand cmd = new OutOfBandManagementDriverPowerCommand(options, actionTimeOut, powerOperation);
|
||||
|
|
@ -424,7 +447,7 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
}
|
||||
final OutOfBandManagementDriver driver = getDriver(outOfBandManagementConfig);
|
||||
|
||||
final OutOfBandManagementDriverChangePasswordCommand cmd = new OutOfBandManagementDriverChangePasswordCommand(options, OutOfBandManagementActionTimeout.valueIn(host.getClusterId()), newPassword);
|
||||
final OutOfBandManagementDriverChangePasswordCommand cmd = new OutOfBandManagementDriverChangePasswordCommand(options, ActionTimeout.valueIn(host.getClusterId()), newPassword);
|
||||
final OutOfBandManagementDriverResponse driverResponse;
|
||||
try {
|
||||
driverResponse = driver.execute(cmd);
|
||||
|
|
@ -482,7 +505,7 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
this.name = name;
|
||||
this.serviceId = ManagementServerNode.getManagementServerId();
|
||||
|
||||
final int poolSize = OutOfBandManagementSyncThreadPoolSize.value();
|
||||
final int poolSize = SyncThreadPoolSize.value();
|
||||
|
||||
hostAlertCache = CacheBuilder.newBuilder()
|
||||
.concurrencyLevel(4)
|
||||
|
|
@ -491,11 +514,11 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
.expireAfterWrite(1, TimeUnit.DAYS)
|
||||
.build();
|
||||
|
||||
backgroundSyncExecutor = new ThreadPoolExecutor(poolSize, poolSize,
|
||||
backgroundSyncBlockingExecutor = new ThreadPoolExecutor(poolSize, poolSize,
|
||||
0L, TimeUnit.MILLISECONDS,
|
||||
new ArrayBlockingQueue<Runnable>(10 * poolSize, true), new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
|
||||
LOG.info("Starting out-of-band management background sync executor with thread pool-size=" + poolSize + " and background sync thread interval=" + OutOfBandManagementSyncThreadInterval.value() + "s");
|
||||
LOG.info("Starting out-of-band management background sync executor with thread pool-size=" + poolSize + " and background sync thread interval=" + SyncThreadInterval.value() + "s");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -507,7 +530,7 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
backgroundSyncExecutor.shutdown();
|
||||
backgroundSyncBlockingExecutor.shutdown();
|
||||
outOfBandManagementDao.expireOutOfBandManagementOwnershipByServer(getId());
|
||||
return true;
|
||||
}
|
||||
|
|
@ -519,7 +542,7 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
|
||||
@Override
|
||||
public ConfigKey<?>[] getConfigKeys() {
|
||||
return new ConfigKey<?>[] {OutOfBandManagementActionTimeout, OutOfBandManagementSyncThreadInterval, OutOfBandManagementSyncThreadPoolSize};
|
||||
return new ConfigKey<?>[] {ActionTimeout, SyncThreadInterval, SyncThreadPoolSize};
|
||||
}
|
||||
|
||||
public List<OutOfBandManagementDriver> getOutOfBandManagementDrivers() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue