Examples of HypervisorCheckInResult


Examples of org.candlepin.resource.dto.HypervisorCheckInResult

        when(consumerTypeCurator.lookupByLabel(
            eq(ConsumerTypeEnum.HYPERVISOR.getLabel()))).thenReturn(hypervisorType);
        when(idCertService.generateIdentityCert(any(Consumer.class)))
            .thenReturn(new IdentityCertificate());

        HypervisorCheckInResult result = hypervisorResource.hypervisorCheckIn(hostGuestMap,
            principal, owner.getKey(), true);

        Set<Consumer> created = result.getCreated();
        assertEquals(1, created.size());

        Consumer c1 = created.iterator().next();
        assertEquals("test-host", c1.getHypervisorId().getHypervisorId());
        assertEquals(2, c1.getGuestIds().size());
View Full Code Here

Examples of org.candlepin.resource.dto.HypervisorCheckInResult

        when(ownerCurator.lookupByKey(eq(owner.getKey()))).thenReturn(owner);
        // Force update
        when(consumerCurator.getHypervisor(eq("test-host"),
            eq(owner))).thenReturn(existing);

        HypervisorCheckInResult result = hypervisorResource.hypervisorCheckIn(hostGuestMap,
            principal, owner.getKey(), true);
        Set<Consumer> updated = result.getUpdated();
        assertEquals(1, updated.size());

        Consumer c1 = updated.iterator().next();
        assertEquals("test-host", c1.getUuid());
        assertEquals(1, c1.getGuestIds().size());
View Full Code Here

Examples of org.candlepin.resource.dto.HypervisorCheckInResult

        // Simulate failure  when checking the owner
        when(ownerCurator.lookupByKey(eq(owner.getKey()))).thenReturn(owner);
        when(consumerCurator.getHypervisor(eq(expectedHostVirtId),
            eq(owner))).thenThrow(exception);

        HypervisorCheckInResult result = hypervisorResource.hypervisorCheckIn(hostGuestMap,
            principal, owner.getKey(), true);

        Set<String> failures = result.getFailedUpdate();
        assertEquals(1, failures.size());
        assertEquals(expectedHostVirtId + ": " + expectedMessage,
            failures.iterator().next());
    }
View Full Code Here

Examples of org.candlepin.resource.dto.HypervisorCheckInResult

        RuntimeException exception = new RuntimeException(expectedMessage);
        // Simulate failure  when checking the owner
        when(consumerCurator.getHost(any(String.class),
            any(Owner.class))).thenThrow(exception);

        HypervisorCheckInResult result = hypervisorResource.hypervisorCheckIn(hostGuestMap,
            principal, owner.getKey(), true);

        Set<String> failures = result.getFailedUpdate();
        assertEquals(1, failures.size());
        assertEquals(expectedHostVirtId + ": " + expectedMessage,
            failures.iterator().next());
    }
View Full Code Here

Examples of org.candlepin.resource.dto.HypervisorCheckInResult

        when(consumerTypeCurator.lookupByLabel(
            eq(ConsumerTypeEnum.HYPERVISOR.getLabel()))).thenReturn(hypervisorType);
        when(idCertService.generateIdentityCert(any(Consumer.class)))
            .thenReturn(new IdentityCertificate());

        HypervisorCheckInResult result = hypervisorResource.hypervisorCheckIn(hostGuestMap,
            principal, owner.getKey(), false);

        assertEquals(0, result.getCreated().size());
        assertEquals(1, result.getFailedUpdate().size());

        String failed = result.getFailedUpdate().iterator().next();
        String expected = "test-host: Unable to find hypervisor in org 'admin'";
        assertEquals(expected, failed);
    }
View Full Code Here

Examples of org.candlepin.resource.dto.HypervisorCheckInResult

        @QueryParam("create_missing") @DefaultValue("true") boolean createMissing) {
        log.info("Hypervisor check-in by principal: " + principal);

        Owner owner = this.getOwner(ownerKey);

        HypervisorCheckInResult result = new HypervisorCheckInResult();
        for (Entry<String, List<GuestId>> hostEntry : hostGuestMap.entrySet()) {
            try {
                log.info("Checking virt host: " + hostEntry.getKey());

                boolean hostConsumerCreated = false;
                // Attempt to find a consumer for the given hypervisorId
                Consumer consumer =
                    consumerCurator.getHypervisor(hostEntry.getKey(), owner);
                if (consumer == null) {
                    if (!createMissing) {
                        log.info("Unable to find hypervisor with id " +
                            hostEntry.getKey() + " in org " + ownerKey);
                        result.failed(hostEntry.getKey(), i18n.tr(
                            "Unable to find hypervisor in org ''{0}''", ownerKey));
                        continue;
                    }
                    log.info("Registering new host consumer");
                    // Create new consumer
                    consumer = createConsumerForHypervisorId(
                        hostEntry.getKey(), owner, principal);
                    hostConsumerCreated = true;
                }

                boolean guestIdsUpdated = addGuestIds(consumer, hostEntry.getValue());

                // Populate the result with the processed consumer.
                if (hostConsumerCreated) {
                    result.created(consumer);
                }
                else if (guestIdsUpdated) {
                    result.updated(consumer);
                }
                else {
                    result.unchanged(consumer);
                }
            }
            catch (Exception e) {
                log.error("Hypervisor checkin failed", e);
                result.failed(hostEntry.getKey(), e.getMessage());
            }
        }
        return result;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.