Search in sources :

Example 1 with MaintenanceModeException

use of alien4cloud.paas.exception.MaintenanceModeException in project yorc-a4c-plugin by ystia.

the class YorcPaaSProvider method switchMaintenanceMode.

/**
 * Switch the maintenance mode for this deployed topology.
 *
 * @param  ctx the deployment context
 * @param  maintenanceModeOn
 * @throws MaintenanceModeException
 */
@Override
public void switchMaintenanceMode(PaaSDeploymentContext ctx, boolean maintenanceModeOn) throws MaintenanceModeException {
    String paasId = ctx.getDeploymentPaaSId();
    YorcRuntimeDeploymentInfo jrdi = runtimeDeploymentInfos.get(paasId);
    log.debug(paasId + " switchMaintenanceMode");
    if (jrdi == null) {
        log.error(paasId + " switchMaintenanceMode: No Deployment Information");
        throw new MaintenanceModeException("No Deployment Information");
    }
    Topology topology = jrdi.getDeploymentContext().getDeploymentTopology();
    Map<String, Map<String, InstanceInformation>> nodes = jrdi.getInstanceInformations();
    if (nodes == null || nodes.isEmpty()) {
        log.error(paasId + " switchMaintenanceMode: No Node found");
        throw new MaintenanceModeException("No Node found");
    }
    for (Entry<String, Map<String, InstanceInformation>> nodeEntry : nodes.entrySet()) {
        String node = nodeEntry.getKey();
        Map<String, InstanceInformation> nodeInstances = nodeEntry.getValue();
        if (nodeInstances != null && !nodeInstances.isEmpty()) {
            NodeTemplate nodeTemplate = topology.getNodeTemplates().get(node);
            NodeType nodeType = toscaTypeSearchService.getRequiredElementInDependencies(NodeType.class, nodeTemplate.getType(), topology.getDependencies());
        // ALIEN 2.0.0 Update
        /*
                if (isFromType(NormativeComputeConstants.COMPUTE_TYPE, nodeType)) {
                    for (Entry<String, InstanceInformation> nodeInstanceEntry : nodeInstances.entrySet()) {
                        String instance = nodeInstanceEntry.getKey();
                        InstanceInformation iinfo = nodeInstanceEntry.getValue();
                        if (iinfo != null) {
                            doSwitchInstanceMaintenanceMode(paasId, node, instance, iinfo, maintenanceModeOn);
                        }
                    }
                }*/
        }
    }
}
Also used : MaintenanceModeException(alien4cloud.paas.exception.MaintenanceModeException) NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) NodeType(org.alien4cloud.tosca.model.types.NodeType) InstanceInformation(alien4cloud.paas.model.InstanceInformation) Topology(org.alien4cloud.tosca.model.templates.Topology) Map(java.util.Map)

Example 2 with MaintenanceModeException

use of alien4cloud.paas.exception.MaintenanceModeException in project yorc-a4c-plugin by ystia.

the class YorcPaaSProvider method switchInstanceMaintenanceMode.

/**
 * Switch the maintenance mode for a given node instance of this deployed topology.
 *
 * @param ctx the deployment context
 * @param node
 * @param instance
 * @param mode
 * @throws MaintenanceModeException
 */
@Override
public void switchInstanceMaintenanceMode(PaaSDeploymentContext ctx, String node, String instance, boolean mode) throws MaintenanceModeException {
    String paasId = ctx.getDeploymentPaaSId();
    YorcRuntimeDeploymentInfo jrdi = runtimeDeploymentInfos.get(paasId);
    log.debug(paasId + " switchInstanceMaintenanceMode");
    if (jrdi == null) {
        log.error(paasId + " switchInstanceMaintenanceMode: No Deployment Information");
        throw new MaintenanceModeException("No Deployment Information");
    }
    final Map<String, Map<String, InstanceInformation>> existingInformations = jrdi.getInstanceInformations();
    if (existingInformations != null && existingInformations.containsKey(node) && existingInformations.get(node).containsKey(instance)) {
        InstanceInformation iinfo = existingInformations.get(node).get(instance);
        doSwitchInstanceMaintenanceMode(paasId, node, instance, iinfo, mode);
    }
}
Also used : MaintenanceModeException(alien4cloud.paas.exception.MaintenanceModeException) InstanceInformation(alien4cloud.paas.model.InstanceInformation) Map(java.util.Map)

Aggregations

MaintenanceModeException (alien4cloud.paas.exception.MaintenanceModeException)2 InstanceInformation (alien4cloud.paas.model.InstanceInformation)2 Map (java.util.Map)2 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)1 Topology (org.alien4cloud.tosca.model.templates.Topology)1 NodeType (org.alien4cloud.tosca.model.types.NodeType)1