Package org.candlepin.model

Examples of org.candlepin.model.HypervisorId


    @Test
    public void testGetHypervisor() {
        String hypervisorid = "hypervisor";
        Consumer consumer = new Consumer("testConsumer", "testUser", owner, ct);
        consumer.setHypervisorId(new HypervisorId(hypervisorid));
        consumer = consumerCurator.create(consumer);
        Consumer result = consumerCurator.getHypervisor(hypervisorid, owner);
        assertEquals(consumer, result);
    }
View Full Code Here


    public void testGetHypervisorWrongOwner() {
        Owner otherOwner = new Owner("test-owner-other", "Test Other Owner");
        otherOwner = ownerCurator.create(otherOwner);
        String hypervisorid = "hypervisor";
        Consumer consumer = new Consumer("testConsumer", "testUser", owner, ct);
        consumer.setHypervisorId(new HypervisorId(hypervisorid));
        consumer = consumerCurator.create(consumer);
        Consumer result = consumerCurator.getHypervisor(hypervisorid, otherOwner);
        assertNull(result);
    }
View Full Code Here

    @Test
    public void testGetHypervisorsBulk() {
        String hypervisorid = "hypervisor";
        Consumer consumer = new Consumer("testConsumer", "testUser", owner, ct);
        consumer.setHypervisorId(new HypervisorId(hypervisorid));
        consumer = consumerCurator.create(consumer);
        List<String> hypervisorIds = new LinkedList<String>();
        hypervisorIds.add(hypervisorid);
        hypervisorIds.add("not really a hypervisor");
        List<Consumer> results = consumerCurator.getHypervisorsBulk(
View Full Code Here

    @Test
    public void testGetHypervisorsBulkEmpty() {
        String hypervisorid = "hypervisor";
        Consumer consumer = new Consumer("testConsumer", "testUser", owner, ct);
        consumer.setHypervisorId(new HypervisorId(hypervisorid));
        consumer = consumerCurator.create(consumer);
        List<Consumer> results = consumerCurator.getHypervisorsBulk(
            new LinkedList<String>(), owner.getKey());
        assertEquals(0, results.size());
    }
View Full Code Here

    }

    @Test
    public void testGetHypervisorsByOwner() {
        Consumer consumer = new Consumer("testConsumer", "testUser", owner, ct);
        consumer.setHypervisorId(new HypervisorId("hypervisor"));
        consumer = consumerCurator.create(consumer);
        Owner otherOwner = ownerCurator.create(new Owner("other owner"));
        Consumer consumer2 = new Consumer("testConsumer2", "testUser2", otherOwner, ct);
        consumer2.setHypervisorId(new HypervisorId("hypervisortwo"));
        consumer2 = consumerCurator.create(consumer2);
        Consumer nonHypervisor = new Consumer("testConsumer3", "testUser3", owner, ct);
        nonHypervisor = consumerCurator.create(nonHypervisor);
        List<Consumer> results = consumerCurator.getHypervisorsForOwner(owner.getKey());
        assertEquals(1, results.size());
View Full Code Here

        if (consumer.getGuestIds() != null) {
            for (GuestId g : consumer.getGuestIds()) {
                g.setConsumer(consumer);
            }
        }
        HypervisorId hvsrId = consumer.getHypervisorId();
        if (hvsrId != null && hvsrId.getHypervisorId() != null && !hvsrId.getHypervisorId().isEmpty()) {
            // If a hypervisorId is supplied, make sure the consumer and owner are correct
            hvsrId.setConsumer(consumer);
        }

        consumerBindUtil.validateServiceLevel(owner, consumer.getServiceLevel());

        try {
View Full Code Here

        }
        return changesMade;
    }

    private boolean checkForHypervisorIdUpdate(Consumer existing, Consumer incoming) {
        HypervisorId incomingId = incoming.getHypervisorId();
        if (incomingId != null) {
            HypervisorId existingId = existing.getHypervisorId();
            if (incomingId.getHypervisorId() == null ||
                    incomingId.getHypervisorId().isEmpty()) {
                // Allow hypervisorId to be removed
                existing.setHypervisorId(null);
            }
            else {
                if (existingId != null) {
                    existingId.setHypervisorId(incomingId.getHypervisorId());
                }
                else {
                    // Safer to build a new clean HypervisorId object
                    existing.setHypervisorId(
                        new HypervisorId(incomingId.getHypervisorId()));
                }
            }
            return true;
        }
        return false;
View Full Code Here

        consumer.setType(new ConsumerType(ConsumerTypeEnum.HYPERVISOR));
        consumer.setFact("uname.machine", "x86_64");
        consumer.setGuestIds(new ArrayList<GuestId>());
        consumer.setOwner(owner);
        // Create HypervisorId
        HypervisorId hypervisorId =
            new HypervisorId(consumer, incHypervisorId);
        consumer.setHypervisorId(hypervisorId);
        // Create Consumer
        return consumerResource.create(consumer,
            principal, null, owner.getKey(), null);
    }
View Full Code Here

TOP

Related Classes of org.candlepin.model.HypervisorId

Copyright © 2018 www.massapicom. 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.