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);
}
}
}*/
}
}
}
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);
}
}
Aggregations