Search in sources :

Example 1 with InventoryNavigator

use of com.vmware.vim25.mo.InventoryNavigator in project SimianArmy by Netflix.

the class VSphereServiceConnection method getVirtualMachineById.

/**
     * Gets the named VirtualMachine.
     */
public VirtualMachine getVirtualMachineById(String instanceId) throws RemoteException {
    InventoryNavigator inventoryNavigator = getInventoryNavigator();
    VirtualMachine virtualMachine = (VirtualMachine) inventoryNavigator.searchManagedEntity(VIRTUAL_MACHINE_TYPE_NAME, instanceId);
    return virtualMachine;
}
Also used : InventoryNavigator(com.vmware.vim25.mo.InventoryNavigator) VirtualMachine(com.vmware.vim25.mo.VirtualMachine)

Example 2 with InventoryNavigator

use of com.vmware.vim25.mo.InventoryNavigator in project SimianArmy by Netflix.

the class VSphereServiceConnectionWithMockedInventoryNavigator method shouldCallSearchManagedEntitiesOnDescribeWhenAtLeastOneVMIsReturned.

@Test
public void shouldCallSearchManagedEntitiesOnDescribeWhenAtLeastOneVMIsReturned() throws RemoteException {
    VSphereServiceConnectionWithMockedInventoryNavigator service = new VSphereServiceConnectionWithMockedInventoryNavigator();
    InventoryNavigator inventoryNavigatorMock = service.getInventoryNavigatorMock();
    ManagedEntity[] meMocks = new ManagedEntity[] { mock(VirtualMachine.class) };
    when(inventoryNavigatorMock.searchManagedEntities(VIRTUAL_MACHINE_TYPE_NAME)).thenReturn(meMocks);
    VirtualMachine[] actualVMs = service.describeVirtualMachines();
    verify(inventoryNavigatorMock).searchManagedEntities(VIRTUAL_MACHINE_TYPE_NAME);
    assertSame(meMocks[0], actualVMs[0]);
}
Also used : ManagedEntity(com.vmware.vim25.mo.ManagedEntity) InventoryNavigator(com.vmware.vim25.mo.InventoryNavigator) VirtualMachine(com.vmware.vim25.mo.VirtualMachine) Test(org.testng.annotations.Test)

Example 3 with InventoryNavigator

use of com.vmware.vim25.mo.InventoryNavigator in project SimianArmy by Netflix.

the class VSphereServiceConnectionWithMockedInventoryNavigator method shouldEncapsulateInvalidPropertyException.

@Test(expectedExceptions = AmazonServiceException.class)
public void shouldEncapsulateInvalidPropertyException() throws RemoteException {
    VSphereServiceConnectionWithMockedInventoryNavigator service = new VSphereServiceConnectionWithMockedInventoryNavigator();
    InventoryNavigator inventoryNavigatorMock = service.getInventoryNavigatorMock();
    when(inventoryNavigatorMock.searchManagedEntities(VIRTUAL_MACHINE_TYPE_NAME)).thenThrow(new InvalidProperty());
    service.describeVirtualMachines();
}
Also used : InvalidProperty(com.vmware.vim25.InvalidProperty) InventoryNavigator(com.vmware.vim25.mo.InventoryNavigator) Test(org.testng.annotations.Test)

Example 4 with InventoryNavigator

use of com.vmware.vim25.mo.InventoryNavigator in project SimianArmy by Netflix.

the class VSphereServiceConnectionWithMockedInventoryNavigator method shouldEncapsulateRemoteExceptionException.

@Test(expectedExceptions = AmazonServiceException.class)
public void shouldEncapsulateRemoteExceptionException() throws RemoteException {
    VSphereServiceConnectionWithMockedInventoryNavigator service = new VSphereServiceConnectionWithMockedInventoryNavigator();
    InventoryNavigator inventoryNavigatorMock = service.getInventoryNavigatorMock();
    when(inventoryNavigatorMock.searchManagedEntities(VIRTUAL_MACHINE_TYPE_NAME)).thenThrow(new RemoteException());
    service.describeVirtualMachines();
}
Also used : RemoteException(java.rmi.RemoteException) InventoryNavigator(com.vmware.vim25.mo.InventoryNavigator) Test(org.testng.annotations.Test)

Example 5 with InventoryNavigator

use of com.vmware.vim25.mo.InventoryNavigator in project SimianArmy by Netflix.

the class VSphereServiceConnectionWithMockedInventoryNavigator method shouldEncapsulateRuntimeFaultException.

@Test(expectedExceptions = AmazonServiceException.class)
public void shouldEncapsulateRuntimeFaultException() throws RemoteException {
    VSphereServiceConnectionWithMockedInventoryNavigator service = new VSphereServiceConnectionWithMockedInventoryNavigator();
    InventoryNavigator inventoryNavigatorMock = service.getInventoryNavigatorMock();
    when(inventoryNavigatorMock.searchManagedEntities(VIRTUAL_MACHINE_TYPE_NAME)).thenThrow(new RuntimeFault());
    service.describeVirtualMachines();
}
Also used : RuntimeFault(com.vmware.vim25.RuntimeFault) InventoryNavigator(com.vmware.vim25.mo.InventoryNavigator) Test(org.testng.annotations.Test)

Aggregations

InventoryNavigator (com.vmware.vim25.mo.InventoryNavigator)7 Test (org.testng.annotations.Test)5 VirtualMachine (com.vmware.vim25.mo.VirtualMachine)3 ManagedEntity (com.vmware.vim25.mo.ManagedEntity)2 InvalidProperty (com.vmware.vim25.InvalidProperty)1 PerfCounterInfo (com.vmware.vim25.PerfCounterInfo)1 RuntimeFault (com.vmware.vim25.RuntimeFault)1 ServiceInstance (com.vmware.vim25.mo.ServiceInstance)1 URL (java.net.URL)1 RemoteException (java.rmi.RemoteException)1