/** * Tests logout and then auto login into server * * @throws Exception */ @Test public void testLogout() throws Exception { AuAssert.check(vcService.isConnected()); vcService.logout(); AuAssert.check(!vcService.isConnected()); Datacenter dc = getDatacenter(vcService); System.out.println("datacenter: " + dc); AuAssert.check(vcService.isConnected()); }
/* * @return the VcSnapshot object. */ protected static VcSnapshotImpl loadSnapshotFromMoRef( ManagedObjectReference moRef, VcVirtualMachineImpl parent, String name) throws Exception { AuAssert.check(VcContext.isInSession()); VcSnapshotImpl obj = null; ManagedObject mo = MoUtil.getManagedObject(moRef); AuAssert.check(mo instanceof Snapshot); obj = new VcSnapshotImpl((Snapshot) mo, parent, name); Profiler.inc(StatsType.VC_LOAD_MO, obj); return obj; }
/** * Tests login into vc server * * @throws Exception */ @Test public void testLoginVc() throws Exception { System.out.println("Service url is: " + vcService.getServiceUrl()); Datacenter dc = getDatacenter(vcService); AuAssert.check(vcService.isConnected()); System.out.println("VC server guid is: " + VcContext.getServerGuid()); System.out.println("datacenter: " + dc); }
/** @return the VcObject from ManagedObjectReference */ public static VcObjectImpl loadFromMoRef(ManagedObjectReference moRef) throws Exception { AuAssert.check(VcContext.isInSession()); VcObjectImpl obj = null; ManagedObject mo = MoUtil.getManagedObject(moRef); if (mo instanceof Datacenter) { obj = new VcDatacenterImpl((Datacenter) mo); } else if (mo instanceof ClusterComputeResource) { obj = new VcClusterImpl((ClusterComputeResource) mo); } else if (mo instanceof Network) { obj = new VcNetworkImpl((Network) mo); } else if (mo instanceof Datastore) { obj = new VcDatastoreImpl((Datastore) mo); } else if (mo instanceof ResourcePool) { obj = new VcResourcePoolImpl((ResourcePool) mo); } else if (mo instanceof VirtualMachine) { obj = new VcVirtualMachineImpl((VirtualMachine) mo); } else if (mo instanceof Snapshot) { AuAssert.unreachable(); } else if (mo instanceof HostSystem) { obj = new VcHostImpl((HostSystem) mo); } Profiler.inc(StatsType.VC_LOAD_MO, obj); return obj; }