cloudstack-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CLOUDSTACK-9299) Out-of-band Management for CloudStack
Date Mon, 02 May 2016 20:29:12 GMT

    [ https://issues.apache.org/jira/browse/CLOUDSTACK-9299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15267440#comment-15267440
] 

ASF GitHub Bot commented on CLOUDSTACK-9299:
--------------------------------------------

Github user jburwell commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1502#discussion_r61798443
  
    --- Diff: server/src/org/apache/cloudstack/outofbandmanagement/OutOfBandManagementServiceImpl.java
---
    @@ -0,0 +1,532 @@
    +// Licensed to the Apache Software Foundation (ASF) under one
    +// or more contributor license agreements.  See the NOTICE file
    +// distributed with this work for additional information
    +// regarding copyright ownership.  The ASF licenses this file
    +// to you under the Apache License, Version 2.0 (the
    +// "License"); you may not use this file except in compliance
    +// with the License.  You may obtain a copy of the License at
    +//
    +//   http://www.apache.org/licenses/LICENSE-2.0
    +//
    +// Unless required by applicable law or agreed to in writing,
    +// software distributed under the License is distributed on an
    +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +// KIND, either express or implied.  See the License for the
    +// specific language governing permissions and limitations
    +// under the License.
    +package org.apache.cloudstack.outofbandmanagement;
    +
    +import com.cloud.alert.AlertManager;
    +import com.cloud.dc.ClusterDetailsDao;
    +import com.cloud.dc.ClusterDetailsVO;
    +import com.cloud.dc.DataCenter;
    +import com.cloud.dc.DataCenterDetailVO;
    +import com.cloud.dc.dao.DataCenterDetailsDao;
    +import com.cloud.domain.Domain;
    +import com.cloud.event.ActionEvent;
    +import com.cloud.event.ActionEventUtils;
    +import com.cloud.event.EventTypes;
    +import com.cloud.host.Host;
    +import com.cloud.host.dao.HostDao;
    +import com.cloud.org.Cluster;
    +import com.cloud.utils.component.Manager;
    +import com.cloud.utils.component.ManagerBase;
    +import com.cloud.utils.db.GlobalLock;
    +import com.cloud.utils.db.Transaction;
    +import com.cloud.utils.db.TransactionCallback;
    +import com.cloud.utils.db.TransactionStatus;
    +import com.cloud.utils.exception.CloudRuntimeException;
    +import com.cloud.utils.fsm.NoTransitionException;
    +import com.google.common.base.Strings;
    +import com.google.common.cache.Cache;
    +import com.google.common.cache.CacheBuilder;
    +import com.google.common.collect.ImmutableMap;
    +import org.apache.cloudstack.api.response.OutOfBandManagementResponse;
    +import org.apache.cloudstack.context.CallContext;
    +import org.apache.cloudstack.framework.config.ConfigKey;
    +import org.apache.cloudstack.framework.config.Configurable;
    +import org.apache.cloudstack.outofbandmanagement.dao.OutOfBandManagementDao;
    +import org.apache.cloudstack.outofbandmanagement.driver.OutOfBandManagementDriverChangePasswordCommand;
    +import org.apache.cloudstack.outofbandmanagement.driver.OutOfBandManagementDriverPowerCommand;
    +import org.apache.cloudstack.outofbandmanagement.driver.OutOfBandManagementDriverResponse;
    +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;
    +import java.util.Collections;
    +import java.util.HashMap;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.concurrent.ArrayBlockingQueue;
    +import java.util.concurrent.ExecutorService;
    +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);
    +
    +    @Inject
    +    private ClusterDetailsDao clusterDetailsDao;
    +    @Inject
    +    private DataCenterDetailsDao dataCenterDetailsDao;
    +    @Inject
    +    private OutOfBandManagementDao outOfBandManagementDao;
    +    @Inject
    +    private HostDao hostDao;
    +    @Inject
    +    private AlertManager alertMgr;
    +
    +    private String name;
    +    private long serviceId;
    +
    +    private List<OutOfBandManagementDriver> outOfBandManagementDrivers = new ArrayList<>();
    +    private 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 String getOutOfBandManagementHostLock(long id) {
    +        return "oobm.host." + id;
    +    }
    +
    +    private void initializeDriversMap() {
    +        if (outOfBandManagementDriversMap.isEmpty() && outOfBandManagementDrivers
!= null && outOfBandManagementDrivers.size() > 0) {
    +            for (final OutOfBandManagementDriver driver : outOfBandManagementDrivers)
{
    +                outOfBandManagementDriversMap.put(driver.getName().toLowerCase(), driver);
    +            }
    +            LOG.debug("Discovered out-of-band management drivers configured in the OutOfBandManagementService");
    +        }
    +    }
    +
    +    private OutOfBandManagementDriver getDriver(final OutOfBandManagement outOfBandManagementConfig)
{
    +        if (!Strings.isNullOrEmpty(outOfBandManagementConfig.getDriver())) {
    +            final OutOfBandManagementDriver driver = outOfBandManagementDriversMap.get(outOfBandManagementConfig.getDriver());
    +            if (driver != null) {
    +                return driver;
    +            }
    +        }
    +        throw new CloudRuntimeException("Configured out-of-band management driver is
not available. Aborting any out-of-band management action.");
    +    }
    +
    +    protected OutOfBandManagement updateConfig(final OutOfBandManagement outOfBandManagementConfig,
final ImmutableMap<OutOfBandManagement.Option, String> options) {
    +        if (outOfBandManagementConfig == null) {
    +            throw new CloudRuntimeException("Out-of-band management is not configured
for the host. Aborting.");
    +        }
    +        if (options == null) {
    +            return outOfBandManagementConfig;
    +        }
    +        for (OutOfBandManagement.Option option: options.keySet()) {
    +            final String value = options.get(option);
    +            if (Strings.isNullOrEmpty(value)) {
    +                continue;
    +            }
    +            switch (option) {
    +                case DRIVER:
    +                    outOfBandManagementConfig.setDriver(value);
    +                    break;
    +                case ADDRESS:
    +                    outOfBandManagementConfig.setAddress(value);
    +                    break;
    +                case PORT:
    +                    outOfBandManagementConfig.setPort(Integer.parseInt(value));
    +                    break;
    +                case USERNAME:
    +                    outOfBandManagementConfig.setUsername(value);
    +                    break;
    +                case PASSWORD:
    +                    outOfBandManagementConfig.setPassword(value);
    +                    break;
    +            }
    +        }
    +        return outOfBandManagementConfig;
    +    }
    +
    +    protected ImmutableMap<OutOfBandManagement.Option, String> getOptions(final
OutOfBandManagement outOfBandManagementConfig) {
    +        final ImmutableMap.Builder<OutOfBandManagement.Option, String> optionsBuilder
= ImmutableMap.builder();
    +        if (outOfBandManagementConfig == null) {
    +            throw new CloudRuntimeException("Out-of-band management is not configured
for the host. Aborting.");
    +        }
    +        for (OutOfBandManagement.Option option: OutOfBandManagement.Option.values())
{
    +            String value = null;
    +            switch (option) {
    +                case DRIVER:
    +                    value = outOfBandManagementConfig.getDriver();
    +                    break;
    +                case ADDRESS:
    +                    value = outOfBandManagementConfig.getAddress();
    +                    break;
    +                case PORT:
    +                    if (outOfBandManagementConfig.getPort() != null) {
    +                        value = String.valueOf(outOfBandManagementConfig.getPort());
    +                    }
    +                    break;
    +                case USERNAME:
    +                    value = outOfBandManagementConfig.getUsername();
    +                    break;
    +                case PASSWORD:
    +                    value = outOfBandManagementConfig.getPassword();
    +                    break;
    +            }
    +            if (value != null) {
    +                optionsBuilder.put(option, value);
    +            }
    +        }
    +        return optionsBuilder.build();
    +    }
    +
    +    private void sendAuthError(final Host host, final String message) {
    +        try {
    +            hostAlertCache.asMap().putIfAbsent(host.getId(), 0L);
    +            Long sentCount = hostAlertCache.asMap().get(host.getId());
    +            if (sentCount != null && sentCount <= 0) {
    +                boolean concurrentUpdateResult = hostAlertCache.asMap().replace(host.getId(),
sentCount, sentCount+1L);
    +                if (concurrentUpdateResult) {
    +                    final String subject = String.format("Out-of-band management auth-error
detected for host:%d in cluster:%d, zone:%d", host.getId(), host.getClusterId(), host.getDataCenterId());
    +                    LOG.error(subject + ": " + message);
    +                    alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_OOBM_AUTH_ERROR,
host.getDataCenterId(), host.getPodId(), subject, message);
    +                }
    +            }
    +        } catch (Exception ignored) {
    +        }
    +    }
    +
    +    private boolean transitionPowerState(OutOfBandManagement.PowerState.Event event,
OutOfBandManagement outOfBandManagementHost) {
    +        if (outOfBandManagementHost == null) {
    +            return false;
    +        }
    +        OutOfBandManagement.PowerState currentPowerState = outOfBandManagementHost.getPowerState();
    +        try {
    +            OutOfBandManagement.PowerState newPowerState = OutOfBandManagement.PowerState.getStateMachine().getNextState(currentPowerState,
event);
    +            boolean result = outOfBandManagementDao.updateState(currentPowerState, event,
newPowerState, outOfBandManagementHost, null);
    +            if (result) {
    +                final String message = String.format("Transitioned out-of-band management
power state from:%s to:%s due to event:%s for the host id:%d", currentPowerState, newPowerState,
event, outOfBandManagementHost.getHostId());
    +                LOG.debug(message);
    +                ActionEventUtils.onActionEvent(CallContext.current().getCallingUserId(),
CallContext.current().getCallingAccountId(), Domain.ROOT_DOMAIN,
    +                        EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_POWERSTATE_TRANSITION,
message);
    +            }
    +            return result;
    +        } catch (NoTransitionException ignored) {
    +            LOG.trace(String.format("Unable to transition out-of-band management power
state for host id=%s for the event=%s and current power state=%s", outOfBandManagementHost.getHostId(),
event, currentPowerState));
    --- End diff --
    
    Consider logging to ``ERROR`` as the system is not behaving as specified and in a completely
unexpected manner.  Also, please include the stack trace in the log message to assist with
debugging.


> Out-of-band Management for CloudStack
> -------------------------------------
>
>                 Key: CLOUDSTACK-9299
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9299
>             Project: CloudStack
>          Issue Type: New Feature
>      Security Level: Public(Anyone can view this level - this is the default.) 
>            Reporter: Rohit Yadav
>            Assignee: Rohit Yadav
>             Fix For: 4.9.0, Future
>
>
> Support access to a host’s out-of-band management interface (e.g. IPMI, iLO, DRAC,
etc.) to manage host power operations (on/off etc.) and querying current power state.
> FS: https://cwiki.apache.org/confluence/display/CLOUDSTACK/Out-of-band+Management+for+CloudStack



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message