Search in sources :

Example 1 with ModelDatabase

use of org.apache.cloudstack.network.contrail.management.ModelDatabase in project cloudstack by apache.

the class VirtualMachineModelTest method testVirtualMachineDBLookup.

@Test
public void testVirtualMachineDBLookup() {
    ModelDatabase db = new ModelDatabase();
    VMInstanceVO vm = mock(VMInstanceVO.class);
    // Create 3 dummy Virtual Machine model objects
    // Add these models to database.
    // Each VM is identified by unique UUId.
    VirtualMachineModel vm0 = new VirtualMachineModel(vm, "fbc1f8fa-4b78-45ee-bba0-b551dbf72353");
    db.getVirtualMachines().add(vm0);
    VirtualMachineModel vm1 = new VirtualMachineModel(vm, "fbc1f8fa-4b78-45ee-bba0-b551dbf83464");
    db.getVirtualMachines().add(vm1);
    VirtualMachineModel vm2 = new VirtualMachineModel(vm, "fbc1f8fa-4b78-45ee-bba0-b551dbf94575");
    db.getVirtualMachines().add(vm2);
    s_logger.debug("No of Vitual Machines added to database : " + db.getVirtualMachines().size());
    assertEquals(3, db.getVirtualMachines().size());
    assertSame(vm0, db.lookupVirtualMachine("fbc1f8fa-4b78-45ee-bba0-b551dbf72353"));
    assertSame(vm1, db.lookupVirtualMachine("fbc1f8fa-4b78-45ee-bba0-b551dbf83464"));
    assertSame(vm2, db.lookupVirtualMachine("fbc1f8fa-4b78-45ee-bba0-b551dbf94575"));
}
Also used : ModelDatabase(org.apache.cloudstack.network.contrail.management.ModelDatabase) VMInstanceVO(com.cloud.vm.VMInstanceVO) Test(org.junit.Test)

Example 2 with ModelDatabase

use of org.apache.cloudstack.network.contrail.management.ModelDatabase in project cloudstack by apache.

the class VirtualNetworkModelTest method testDBLookup.

@Test
public void testDBLookup() {
    ModelDatabase db = new ModelDatabase();
    NetworkVO network = mock(NetworkVO.class);
    VirtualNetworkModel storageModel = new VirtualNetworkModel(network, null, ContrailManager.managementNetworkName, TrafficType.Storage);
    db.getVirtualNetworks().add(storageModel);
    VirtualNetworkModel mgmtModel = new VirtualNetworkModel(network, null, ContrailManager.managementNetworkName, TrafficType.Management);
    db.getVirtualNetworks().add(mgmtModel);
    VirtualNetworkModel guestModel1 = new VirtualNetworkModel(network, UUID.randomUUID().toString(), "test", TrafficType.Guest);
    db.getVirtualNetworks().add(guestModel1);
    VirtualNetworkModel guestModel2 = new VirtualNetworkModel(network, UUID.randomUUID().toString(), "test", TrafficType.Guest);
    db.getVirtualNetworks().add(guestModel2);
    s_logger.debug("networks: " + db.getVirtualNetworks().size());
    s_logger.debug("No of Vitual Networks added to database : " + db.getVirtualNetworks().size());
    assertEquals(4, db.getVirtualNetworks().size());
    assertSame(storageModel, db.lookupVirtualNetwork(null, storageModel.getName(), TrafficType.Storage));
    assertSame(mgmtModel, db.lookupVirtualNetwork(null, mgmtModel.getName(), TrafficType.Management));
    assertSame(guestModel1, db.lookupVirtualNetwork(guestModel1.getUuid(), null, TrafficType.Guest));
    assertSame(guestModel2, db.lookupVirtualNetwork(guestModel2.getUuid(), null, TrafficType.Guest));
}
Also used : NetworkVO(com.cloud.network.dao.NetworkVO) ModelDatabase(org.apache.cloudstack.network.contrail.management.ModelDatabase) Test(org.junit.Test)

Aggregations

ModelDatabase (org.apache.cloudstack.network.contrail.management.ModelDatabase)2 Test (org.junit.Test)2 NetworkVO (com.cloud.network.dao.NetworkVO)1 VMInstanceVO (com.cloud.vm.VMInstanceVO)1