Search in sources :

Example 1 with CleanupEvent

use of com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent in project cloudbreak by hortonworks.

the class FreeIpaDownscaleActions method updateDnsSoaRecordsAction.

@Bean(name = "DOWNSCALE_UPDATE_DNS_SOA_RECORDS_STATE")
public Action<?, ?> updateDnsSoaRecordsAction() {
    return new AbstractDownscaleAction<>(RemoveDnsResponse.class) {

        @Override
        protected void doExecute(StackContext context, RemoveDnsResponse payload, Map<Object, Object> variables) {
            stackUpdater.updateStackStatus(context.getStack().getId(), getInProgressStatus(variables), "Update DNS SOA records");
            CleanupEvent cleanupEvent = buildCleanupEvent(context, getDownscaleHosts(variables));
            UpdateDnsSoaRecordsRequest request = new UpdateDnsSoaRecordsRequest(cleanupEvent);
            sendEvent(context, request);
        }
    };
}
Also used : RemoveDnsResponse(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsResponse) StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) CleanupEvent(com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent) UpdateDnsSoaRecordsRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsRequest) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 2 with CleanupEvent

use of com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent in project cloudbreak by hortonworks.

the class FreeIpaDownscaleActions method revokeCertsAction.

@Bean(name = "DOWNSCALE_REVOKE_CERTS_STATE")
public Action<?, ?> revokeCertsAction() {
    return new AbstractDownscaleAction<>(StackEvent.class) {

        @Override
        protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) {
            stackUpdater.updateStackStatus(context.getStack().getId(), getInProgressStatus(variables), "Revoking certificates");
            CleanupEvent cleanupEvent = buildCleanupEvent(context, getDownscaleHosts(variables));
            RevokeCertsRequest request = new RevokeCertsRequest(cleanupEvent, context.getStack());
            sendEvent(context, request);
        }
    };
}
Also used : StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) RevokeCertsRequest(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.cert.RevokeCertsRequest) CleanupEvent(com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 3 with CleanupEvent

use of com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent in project cloudbreak by hortonworks.

the class FreeIpaDownscaleActions method removeDnsEntriesAction.

@Bean(name = "DOWNSCALE_REMOVE_DNS_ENTRIES_STATE")
public Action<?, ?> removeDnsEntriesAction() {
    return new AbstractDownscaleAction<>(RevokeCertsResponse.class) {

        @Override
        protected void doExecute(StackContext context, RevokeCertsResponse payload, Map<Object, Object> variables) {
            stackUpdater.updateStackStatus(context.getStack().getId(), getInProgressStatus(variables), "Remove DNS entries");
            CleanupEvent cleanupEvent = buildCleanupEvent(context, getDownscaleHosts(variables));
            RemoveDnsRequest request = new RemoveDnsRequest(cleanupEvent);
            sendEvent(context, request);
        }
    };
}
Also used : StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) RemoveDnsRequest(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsRequest) RevokeCertsResponse(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.cert.RevokeCertsResponse) CleanupEvent(com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 4 with CleanupEvent

use of com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent in project cloudbreak by hortonworks.

the class RemoveHostsHandlerTest method testSendsSuccessMessageWhenRemovingHostAndIPAddressIsReusedAfterRepair.

@Test
void testSendsSuccessMessageWhenRemovingHostAndIPAddressIsReusedAfterRepair() throws Exception {
    CleanupEvent cleanupEvent = new CleanupEvent(STACK_ID, USERS, Set.of("example1.com"), ROLES, IPS, STATES_TO_SKIP, ACCOUNT_ID, OPERATION_ID, CLUSTER_NAME, ENVIRONMENT_CRN);
    RemoveHostsFromOrchestrationRequest request = new RemoveHostsFromOrchestrationRequest(cleanupEvent);
    Stack stack = new Stack();
    when(stackService.getByIdWithListsInTransaction(any())).thenReturn(stack);
    InstanceGroup ig = new InstanceGroup();
    ig.setGroupName("group");
    Template t = new Template();
    t.setInstanceType("GATEWAY");
    ig.setTemplate(t);
    InstanceMetaData im1 = new InstanceMetaData();
    im1.setDiscoveryFQDN("example1.com");
    im1.setPrivateIp("192.168.0.1");
    im1.setInstanceId("i-1");
    im1.setInstanceGroup(ig);
    InstanceMetaData im2 = new InstanceMetaData();
    im2.setDiscoveryFQDN("example2.com");
    im2.setPrivateIp("192.168.0.2");
    im2.setInstanceId("i-2");
    im2.setInstanceGroup(ig);
    InstanceMetaData im3 = new InstanceMetaData();
    im3.setDiscoveryFQDN("example3.com");
    im3.setPrivateIp("192.168.0.1");
    im3.setInstanceId("i-3");
    im3.setInstanceGroup(ig);
    ig.setInstanceMetaData(Set.of(im1, im2, im3));
    stack.setInstanceGroups(Set.of(ig));
    underTest.accept(new Event<>(request));
    verify(eventBus, times(1)).notify(eq("REMOVEHOSTSFROMORCHESTRATIONSUCCESS"), ArgumentMatchers.<Event>any());
    verify(bootstrapService).bootstrap(any(), any());
    verify(hostOrchestrator).tearDown(any(), any(), eq(Map.of("example1.com", "192.168.0.1")), any(), any());
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) CleanupEvent(com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent) RemoveHostsFromOrchestrationRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removehosts.RemoveHostsFromOrchestrationRequest) Stack(com.sequenceiq.freeipa.entity.Stack) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Template(com.sequenceiq.freeipa.entity.Template) Test(org.junit.jupiter.api.Test)

Example 5 with CleanupEvent

use of com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent in project cloudbreak by hortonworks.

the class RemoveHostsHandlerTest method testSendsSuccessMessageWhenNoHostnamesAreProvided.

@Test
void testSendsSuccessMessageWhenNoHostnamesAreProvided() throws Exception {
    CleanupEvent cleanupEvent = new CleanupEvent(STACK_ID, USERS, Set.of(), ROLES, IPS, STATES_TO_SKIP, ACCOUNT_ID, OPERATION_ID, CLUSTER_NAME, ENVIRONMENT_CRN);
    RemoveHostsFromOrchestrationRequest request = new RemoveHostsFromOrchestrationRequest(cleanupEvent);
    underTest.accept(new Event<>(request));
    verify(eventBus, times(1)).notify(eq("REMOVEHOSTSFROMORCHESTRATIONSUCCESS"), ArgumentMatchers.<Event>any());
}
Also used : CleanupEvent(com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent) RemoveHostsFromOrchestrationRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removehosts.RemoveHostsFromOrchestrationRequest) Test(org.junit.jupiter.api.Test)

Aggregations

CleanupEvent (com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent)18 Test (org.junit.jupiter.api.Test)10 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)6 Map (java.util.Map)6 Bean (org.springframework.context.annotation.Bean)6 Stack (com.sequenceiq.freeipa.entity.Stack)5 RemoveHostsFromOrchestrationRequest (com.sequenceiq.freeipa.flow.freeipa.downscale.event.removehosts.RemoveHostsFromOrchestrationRequest)5 RemoveServersRequest (com.sequenceiq.freeipa.flow.freeipa.downscale.event.removeserver.RemoveServersRequest)4 RemoveReplicationAgreementsRequest (com.sequenceiq.freeipa.flow.freeipa.downscale.event.removereplication.RemoveReplicationAgreementsRequest)3 UpdateDnsSoaRecordsRequest (com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsRequest)2 DownscaleStackResult (com.sequenceiq.cloudbreak.cloud.event.resource.DownscaleStackResult)1 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)1 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)1 DnsZone (com.sequenceiq.freeipa.client.model.DnsZone)1 IpaServer (com.sequenceiq.freeipa.client.model.IpaServer)1 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)1 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)1 Operation (com.sequenceiq.freeipa.entity.Operation)1 Template (com.sequenceiq.freeipa.entity.Template)1 FreeIpaCleanupEvent (com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupEvent)1