use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class StackUpscaleService method finishExtendMetadata.
@Transactional
public Set<String> finishExtendMetadata(Stack stack, String instanceGroupName, CollectMetadataResult payload) {
List<CloudVmMetaDataStatus> coreInstanceMetaData = payload.getResults();
int newinstances = metadataSetupService.saveInstanceMetaData(stack, coreInstanceMetaData, CREATED);
Set<String> upscaleCandidateAddresses = new HashSet<>();
for (CloudVmMetaDataStatus cloudVmMetaDataStatus : coreInstanceMetaData) {
upscaleCandidateAddresses.add(cloudVmMetaDataStatus.getMetaData().getPrivateIp());
}
InstanceGroup instanceGroup = instanceGroupRepository.findOneByGroupNameInStack(stack.getId(), instanceGroupName);
int nodeCount = instanceGroup.getNodeCount() + newinstances;
if (newinstances != 0) {
instanceGroup.setNodeCount(nodeCount);
instanceGroupRepository.save(instanceGroup);
}
clusterService.updateClusterStatusByStackIdOutOfTransaction(stack.getId(), AVAILABLE);
eventService.fireCloudbreakEvent(stack.getId(), BillingStatus.BILLING_CHANGED.name(), messagesService.getMessage("stack.metadata.setup.billing.changed"));
flowMessageService.fireEventAndLog(stack.getId(), Msg.STACK_METADATA_EXTEND, AVAILABLE.name());
usageService.scaleUsagesForStack(stack.getId(), instanceGroupName, nodeCount);
return upscaleCandidateAddresses;
}
use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class StackUpscaleActions method addInstances.
@Bean(name = "ADD_INSTANCES_STATE")
public Action<?, ?> addInstances() {
return new AbstractStackUpscaleAction<StackScaleTriggerEvent>(StackScaleTriggerEvent.class) {
@Override
protected void prepareExecution(StackScaleTriggerEvent payload, Map<Object, Object> variables) {
variables.put(INSTANCEGROUPNAME, payload.getInstanceGroup());
variables.put(ADJUSTMENT, payload.getAdjustment());
variables.put(HOSTNAMES, payload.getHostNames());
}
@Override
protected void doExecute(StackScalingFlowContext context, StackScaleTriggerEvent payload, Map<Object, Object> variables) {
stackUpscaleService.startAddInstances(context.getStack(), payload.getAdjustment());
sendEvent(context);
}
@Override
protected Selectable createRequest(StackScalingFlowContext context) {
LOGGER.debug("Assembling upscale stack event for stack: {}", context.getStack());
InstanceGroup group = context.getStack().getInstanceGroupByInstanceGroupName(context.getInstanceGroupName());
group.setNodeCount(group.getNodeCount() + context.getAdjustment());
CloudStack cloudStack = cloudStackConverter.convert(context.getStack());
instanceMetadataService.saveInstanceRequests(context.getStack(), cloudStack.getGroups());
List<CloudResource> resources = cloudResourceConverter.convert(context.getStack().getResources());
return new UpscaleStackRequest<UpscaleStackResult>(context.getCloudContext(), context.getCloudCredential(), cloudStack, resources);
}
};
}
use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class StackUpscaleActions method finishExtendMetadata.
@Bean(name = "EXTEND_METADATA_FINISHED_STATE")
public Action<?, ?> finishExtendMetadata() {
return new AbstractStackUpscaleAction<CollectMetadataResult>(CollectMetadataResult.class) {
@Override
protected void doExecute(StackScalingFlowContext context, CollectMetadataResult payload, Map<Object, Object> variables) {
Set<String> upscaleCandidateAddresses = stackUpscaleService.finishExtendMetadata(context.getStack(), context.getInstanceGroupName(), payload);
variables.put(UPSCALE_CANDIDATE_ADDRESSES, upscaleCandidateAddresses);
InstanceGroup ig = instanceGroupRepository.findOneByGroupNameInStack(payload.getStackId(), context.getInstanceGroupName());
if (InstanceGroupType.GATEWAY == ig.getInstanceGroupType()) {
InstanceMetaData gatewayMetaData = context.getStack().getPrimaryGatewayInstance();
CloudInstance gatewayInstance = metadataConverter.convert(gatewayMetaData);
Selectable sshFingerPrintReq = new GetSSHFingerprintsRequest<GetSSHFingerprintsResult>(context.getCloudContext(), context.getCloudCredential(), gatewayInstance);
sendEvent(context.getFlowId(), sshFingerPrintReq);
} else {
BootstrapNewNodesEvent bootstrapPayload = new BootstrapNewNodesEvent(context.getStack().getId(), upscaleCandidateAddresses);
sendEvent(context.getFlowId(), StackUpscaleEvent.BOOTSTRAP_NEW_NODES_EVENT.event(), bootstrapPayload);
}
}
};
}
use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class DependecyDeletionService method deleteDependencies.
public void deleteDependencies(Stack stack) {
deleteNetwork(stack.getNetwork());
deleteCredential(stack.getCredential());
for (InstanceGroup instanceGroup : stack.getInstanceGroups()) {
deleteSecurityGroup(instanceGroup.getSecurityGroup());
deleteTemplate(instanceGroup.getTemplate());
}
if (stack.getCluster() != null) {
Cluster cluster = stack.getCluster();
deleteBlueprint(cluster.getBlueprint());
Set<HostGroup> hostGroupsInCluster = hostGroupRepository.findHostGroupsInCluster(cluster.getId());
for (HostGroup hostGroup : hostGroupsInCluster) {
hostGroup.getRecipes().forEach(this::deleteRecipe);
}
}
}
use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class TestUtil method generateGcpInstanceGroups.
public static Set<InstanceGroup> generateGcpInstanceGroups(int count) {
Set<InstanceGroup> instanceGroups = new HashSet<>();
instanceGroups.add(instanceGroup(1L, InstanceGroupType.GATEWAY, openstackTemplate(1L)));
for (int i = 2; i < count + 1; i++) {
instanceGroups.add(instanceGroup(Integer.toUnsignedLong(i), InstanceGroupType.CORE, openstackTemplate(1L)));
}
return instanceGroups;
}
Aggregations