use of com.vmware.vim25.mo.VirtualMachine in project SimianArmy by Netflix.
the class VSphereClient method describeAutoScalingGroups.
@Override
public List<AutoScalingGroup> describeAutoScalingGroups(String... names) {
final VSphereGroups groups = new VSphereGroups();
try {
connection.connect();
for (VirtualMachine virtualMachine : connection.describeVirtualMachines()) {
String instanceId = virtualMachine.getName();
String groupName = virtualMachine.getParent().getName();
boolean shouldAddNamedGroup = true;
if (names != null) {
// TODO need to implement this feature!!!
throw new RuntimeException("This feature (selecting groups by name) is not implemented yet");
}
if (shouldAddNamedGroup) {
groups.addInstance(instanceId, groupName);
}
}
} finally {
connection.disconnect();
}
return groups.asList();
}
use of com.vmware.vim25.mo.VirtualMachine in project SimianArmy by Netflix.
the class VSphereClient method terminateInstance.
@Override
public /**
* reinstall the given instance. If it is powered down this will be ignored and the
* reinstall occurs the next time the machine is powered up.
*/
void terminateInstance(String instanceId) {
try {
connection.connect();
VirtualMachine virtualMachine = connection.getVirtualMachineById(instanceId);
this.terminationStrategy.terminate(virtualMachine);
} catch (RemoteException e) {
throw new AmazonServiceException("cannot destroy & recreate " + instanceId, e);
} finally {
connection.disconnect();
}
}
use of com.vmware.vim25.mo.VirtualMachine in project SimianArmy by Netflix.
the class VSphereServiceConnectionWithMockedInventoryNavigator method shouldCallSearchManagedEntityAndReturnVMForDoItGetVirtualMachineById.
@Test
public void shouldCallSearchManagedEntityAndReturnVMForDoItGetVirtualMachineById() throws RemoteException {
VSphereServiceConnectionWithMockedInventoryNavigator service = new VSphereServiceConnectionWithMockedInventoryNavigator();
InventoryNavigator inventoryNavigatorMock = service.getInventoryNavigatorMock();
VirtualMachine vmMock = mock(VirtualMachine.class);
when(inventoryNavigatorMock.searchManagedEntity(VIRTUAL_MACHINE_TYPE_NAME, "instanceId")).thenReturn(vmMock);
VirtualMachine actualVM = service.getVirtualMachineById("instanceId");
verify(inventoryNavigatorMock).searchManagedEntity(VIRTUAL_MACHINE_TYPE_NAME, "instanceId");
assertSame(vmMock, actualVM);
}
use of com.vmware.vim25.mo.VirtualMachine in project opennms by OpenNMS.
the class VmwareViJavaAccessTest method testGetVirtualMachineByManagedObjectId.
@Test
public void testGetVirtualMachineByManagedObjectId() throws Exception {
replay(mockServiceInstance, MorUtil.class, ServiceInstance.class);
try {
vmwareViJavaAccess.connect();
} catch (MalformedURLException e) {
Assert.fail(e.getMessage());
} catch (RemoteException e) {
Assert.fail(e.getMessage());
}
VirtualMachine returnedVirtualMachine = vmwareViJavaAccess.getVirtualMachineByManagedObjectId("moIdVm");
Assert.assertNotNull(returnedVirtualMachine);
Assert.assertEquals(virtualMachine.getMOR().getVal(), returnedVirtualMachine.getMOR().getVal());
verify(mockServiceInstance, MorUtil.class, ServiceInstance.class);
}
use of com.vmware.vim25.mo.VirtualMachine in project cloudstack by apache.
the class ClusterMO method getVmPropertiesOnHyperHost.
@Override
public ObjectContent[] getVmPropertiesOnHyperHost(String[] propertyPaths) throws Exception {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - retrieveProperties() for VM properties. target MOR: " + _mor.getValue() + ", properties: " + new Gson().toJson(propertyPaths));
PropertySpec pSpec = new PropertySpec();
pSpec.setType("VirtualMachine");
pSpec.getPathSet().addAll(Arrays.asList(propertyPaths));
TraversalSpec host2VmFolderTraversal = new TraversalSpec();
host2VmFolderTraversal.setType("HostSystem");
host2VmFolderTraversal.setPath("vm");
host2VmFolderTraversal.setName("host2VmFolderTraversal");
TraversalSpec cluster2HostFolderTraversal = new TraversalSpec();
cluster2HostFolderTraversal.setType("ClusterComputeResource");
cluster2HostFolderTraversal.setPath("host");
cluster2HostFolderTraversal.setName("cluster2HostFolderTraversal");
cluster2HostFolderTraversal.getSelectSet().add(host2VmFolderTraversal);
ObjectSpec oSpec = new ObjectSpec();
oSpec.setObj(getMor());
oSpec.setSkip(Boolean.TRUE);
oSpec.getSelectSet().add(cluster2HostFolderTraversal);
PropertyFilterSpec pfSpec = new PropertyFilterSpec();
pfSpec.getPropSet().add(pSpec);
pfSpec.getObjectSet().add(oSpec);
List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
pfSpecArr.add(pfSpec);
List<ObjectContent> properties = _context.getService().retrieveProperties(_context.getPropertyCollector(), pfSpecArr);
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - retrieveProperties() done");
return properties.toArray(new ObjectContent[properties.size()]);
}
Aggregations