com.vmware.vim25.mo.ManagedEntity Java Examples
The following examples show how to use
com.vmware.vim25.mo.ManagedEntity.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VmwareNetworkProcess.java From primecloud-controller with GNU General Public License v2.0 | 6 votes |
/** * TODO: メソッドコメントを記述 * * @param vmwareProcessClient * @param networkNo * @param instanceNo */ public void removeNetwork(VmwareProcessClient vmwareProcessClient, Long networkNo, Long instanceNo) { VmwareNetwork vmwareNetwork = vmwareNetworkDao.read(networkNo); // HostSystemを取得 VmwareClient vmwareClient = vmwareProcessClient.getVmwareClient(); ManagedEntity[] hostSystems; if (instanceNo == null) { hostSystems = vmwareClient.searchByType(HostSystem.class); } else { VmwareInstance vmwareInstance = vmwareInstanceDao.read(instanceNo); ComputeResource computeResource = vmwareClient.search(ComputeResource.class, vmwareInstance.getComputeResource()); hostSystems = vmwareClient.searchByType(computeResource, HostSystem.class); } // ネットワークを除去 for (ManagedEntity entity : hostSystems) { HostSystem hostSystem = HostSystem.class.cast(entity); vmwareProcessClient.removeNetwork(hostSystem.getName(), vmwareNetwork.getNetworkName()); } }
Example #2
Source File: VmwareNetworkProcess.java From primecloud-controller with GNU General Public License v2.0 | 6 votes |
/** * TODO: メソッドコメントを記述 * * @param vmwareProcessClient * @param networkNo * @param instanceNo */ public void addNetwork(VmwareProcessClient vmwareProcessClient, Long networkNo, Long instanceNo) { VmwareNetwork vmwareNetwork = vmwareNetworkDao.read(networkNo); // HostSystemを取得 VmwareClient vmwareClient = vmwareProcessClient.getVmwareClient(); ManagedEntity[] hostSystems; if (instanceNo == null) { hostSystems = vmwareClient.searchByType(HostSystem.class); } else { VmwareInstance vmwareInstance = vmwareInstanceDao.read(instanceNo); ComputeResource computeResource = vmwareClient.search(ComputeResource.class, vmwareInstance.getComputeResource()); hostSystems = vmwareClient.searchByType(computeResource, HostSystem.class); } // ネットワークを追加 for (ManagedEntity entity : hostSystems) { HostSystem hostSystem = HostSystem.class.cast(entity); vmwareProcessClient.addNetwork(hostSystem.getName(), vmwareNetwork.getNetworkName(), vmwareNetwork.getVlanId(), vmwareNetwork.getVswitchName()); } }
Example #3
Source File: VmwareDescribeServiceImpl.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public List<ComputeResource> getComputeResources(Long platformNo) { PlatformVmware platformVmware = platformVmwareDao.read(platformNo); VmwareClientFactory factory = new VmwareClientFactory(); factory.setUrl(platformVmware.getUrl()); factory.setUsername(platformVmware.getUsername()); factory.setPassword(platformVmware.getPassword()); factory.setDatacenterName(platformVmware.getDatacenter()); factory.setIgnoreCert(true); VmwareClient vmwareClient = factory.createVmwareClient(); List<ComputeResource> computeResources = new ArrayList<ComputeResource>(); ManagedEntity[] entities = vmwareClient.searchByType(ComputeResource.class); for (ManagedEntity entity : entities) { ComputeResource computeResource = ComputeResource.class.cast(entity); if (StringUtils.isNotEmpty(platformVmware.getComputeResource()) && !StringUtils.equals(computeResource.getName(), platformVmware.getComputeResource())) { continue; } computeResources.add(computeResource); } // ソート Collections.sort(computeResources, Comparators.COMPARATOR_COMPUTE_RESOURCE); return computeResources; }
Example #4
Source File: VmwareMachineProcess.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
protected String selectDatastore(VmwareProcessClient vmwareProcessClient, VmwareInstance vmwareInstance) { // データストアフォルダ内のデータストアのうち、アクセス可能で空き容量が最も大きいものを用いる Datastore datastore = null; long freeSpace = 0L; // ComputeResourceごとのフォルダがあれば、その中のデータストアを用いる String datastoreFolderName = vmwareInstance.getComputeResource() + "-storage"; Folder datastoreFolder = vmwareProcessClient.getVmwareClient().search(Folder.class, datastoreFolderName); if (datastoreFolder == null) { // ComputeResourceごとのフォルダがなければ、"storage"フォルダの中のデータストアを用いる datastoreFolder = vmwareProcessClient.getVmwareClient().search(Folder.class, "storage"); } if (datastoreFolder != null) { ManagedEntity[] entities = vmwareProcessClient.getVmwareClient().searchByType(datastoreFolder, Datastore.class); for (ManagedEntity entity : entities) { Datastore datastore2 = Datastore.class.cast(entity); DatastoreSummary summary2 = datastore2.getSummary(); if (summary2.isAccessible() && freeSpace < summary2.getFreeSpace()) { datastore = datastore2; freeSpace = summary2.getFreeSpace(); } } } if (datastore == null) { // 利用可能なデータストアがない場合 throw new AutoException("EPROCESS-000528", vmwareInstance.getComputeResource()); } return datastore.getName(); }
Example #5
Source File: VmwareProcessClient.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
public void deleteDisk(String datastoreName, String fileName) { // Datacenter ManagedEntity datacenter = vmwareClient.getRootEntity(); // Datastore Datastore datastore = vmwareClient.search(Datastore.class, datastoreName); if (datastore == null) { // データストアが見つからない場合 throw new AutoException("EPROCESS-000505", datastoreName); } // ディスクの削除 FileManager fileManager = vmwareClient.getServiceInstance().getFileManager(); if (fileManager == null) { // fileManagerが利用できない場合 throw new AutoException("EPROCESS-000533"); } try { // ディスク削除 fileManager.deleteDatastoreFile_Task(fileName, (Datacenter) datacenter); // ディスク削除後にごみができ、再度アタッチするとエラーになるので削除 String flatname; flatname = fileName.substring(0, fileName.length() - 5) + "-flat.vmdk"; fileManager.deleteDatastoreFile_Task(flatname, (Datacenter) datacenter); } catch (RemoteException e) { throw new AutoException("EPROCESS-000522", e, fileName); } if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-100455", fileName)); } }
Example #6
Source File: VmwareClient.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
/** * TODO: メソッドコメントを記述 * * @param rootEntity * @return */ public ManagedEntity[] searchAll(ManagedEntity rootEntity) { InventoryNavigator navigator = new InventoryNavigator(rootEntity); ManagedEntity[] entities; try { entities = navigator.searchManagedEntities(true); } catch (RemoteException e) { throw new RuntimeException(e); } return entities; }
Example #7
Source File: VmwareClient.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
/** * TODO: メソッドコメントを記述 * * @param <T> * @param rootEntity * @param type * @return */ public <T extends ManagedEntity> ManagedEntity[] searchByType(ManagedEntity rootEntity, Class<T> type) { InventoryNavigator navigator = new InventoryNavigator(rootEntity); ManagedEntity[] entities; try { entities = navigator.searchManagedEntities(type.getSimpleName()); } catch (RemoteException e) { throw new RuntimeException(e); } return entities; }
Example #8
Source File: VmwareClient.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
/** * TODO: メソッドコメントを記述 * * @param rootEntity * @param name * @return */ public ManagedEntity searchByName(ManagedEntity rootEntity, String name) { InventoryNavigator navigator = new InventoryNavigator(rootEntity); ManagedEntity entity; try { entity = navigator.searchManagedEntity("ManagedEntity", name); } catch (RemoteException e) { throw new RuntimeException(e); } return entity; }
Example #9
Source File: VmwareClient.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
/** * TODO: メソッドコメントを記述 * * @param <T> * @param rootEntity * @param type * @param name * @return */ public <T extends ManagedEntity> T search(ManagedEntity rootEntity, Class<T> type, String name) { InventoryNavigator navigator = new InventoryNavigator(rootEntity); ManagedEntity entity; try { entity = navigator.searchManagedEntity(type.getSimpleName(), name); } catch (RemoteException e) { throw new RuntimeException(e); } return type.cast(entity); }
Example #10
Source File: VmwareClient.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
/** * TODO: メソッドコメントを記述 * * @return */ public ManagedEntity getRootEntity() { if (serviceInstance == null) { initialize(); } if (datacenter != null) { return datacenter; } else { return serviceInstance.getRootFolder(); } }
Example #11
Source File: statsGrabber.java From vmstats with Apache License 2.0 | 5 votes |
private static PerfQuerySpec createPerfQuerySpec(ManagedEntity me, PerfMetricId[] metricIds, int maxSample, int interval) { PerfQuerySpec qSpec = new PerfQuerySpec(); qSpec.setEntity(me.getMOR()); // set the maximum of metrics to be return // only appropriate in real-time performance collecting qSpec.setMaxSample(new Integer(maxSample)); // qSpec.setMetricId(metricIds); // optionally you can set format as "normal" qSpec.setFormat("normal"); // set the interval to the refresh rate for the entity qSpec.setIntervalId(new Integer(interval)); return qSpec; }
Example #12
Source File: VmwareApiConnectorTest.java From teamcity-vmware-plugin with Apache License 2.0 | 5 votes |
private <T extends ManagedEntity> T createEntity(Class<T> type, @Nullable ManagedEntity parent, String val, String name){ final ManagedObjectReference mor = new ManagedObjectReference(); mor.setType(type.getSimpleName()); mor.setVal(val); if (type==Folder.class){ return (T)new Folder(null, mor){ @Override public ManagedEntity getParent() { return parent; } @Override public String getName() { return name; } }; } if (type==ResourcePool.class){ return (T)new ResourcePool(null, mor){ @Override public ManagedEntity getParent() { return parent; } @Override public String getName() { return name; } }; } throw new IllegalArgumentException("can't create instance of type " + type.getSimpleName()); }
Example #13
Source File: VmwareCloudIntegrationTest.java From teamcity-vmware-plugin with Apache License 2.0 | 5 votes |
public void handle_instances_deleted_in_the_middle_of_check() throws MalformedURLException, VmwareCheckedCloudException { if (true) throw new SkipException("Not relevant, because we now retrieve all data at once, without additional calls"); final Set<String> instances2RemoveAfterGet = new HashSet<>(); myFakeApi = new FakeApiConnector(TEST_SERVER_UUID, PROFILE_ID){ @NotNull @Override protected <T extends ManagedEntity> Map<String, T> findAllEntitiesAsMapOld(final Class<T> instanceType) throws VmwareCheckedCloudException { final Map<String, T> entities = super.findAllEntitiesAsMapOld(instanceType); final Map<String, T> result = new HashMap<String, T>(); for (Map.Entry<String, T> entry : entities.entrySet()) { if (instances2RemoveAfterGet.contains(entry.getKey()) && entry.getValue() instanceof FakeVirtualMachine){ final FakeVirtualMachine fvm = (FakeVirtualMachine) entry.getValue(); fvm.setGone(true); } result.put(entry.getKey(), entry.getValue()); } return result; } }; final VmwareCloudInstance i1 = startNewInstanceAndWait("image2"); final VmwareCloudInstance i2 = startNewInstanceAndWait("image2"); final VmwareCloudInstance i3 = startNewInstanceAndWait("image2"); instances2RemoveAfterGet.add(i1.getInstanceId()); instances2RemoveAfterGet.add(i2.getInstanceId()); final Map<String, AbstractInstance> image2Instances = myFakeApi.fetchInstances(getImageByName("image2")); assertEquals(1, image2Instances.size()); }
Example #14
Source File: FakeFolder.java From teamcity-vmware-plugin with Apache License 2.0 | 5 votes |
public <T extends ManagedEntity> void setParent(final String parentName, Class<T> parentType) { if (parentType.isAssignableFrom(FakeDatacenter.class)){ setParent(FakeModel.instance().getDatacenter(parentName)); } else if (parentType.isAssignableFrom(Folder.class)){ setParent(FakeModel.instance().getFolder(parentName)); } if (myParent == null) { Assert.fail(String.format("Unable to set parent %s of type %s", parentName, parentType.getSimpleName())); } }
Example #15
Source File: FakeDatacenter.java From teamcity-vmware-plugin with Apache License 2.0 | 4 votes |
@Override public ManagedEntity getParent() { return myParent; }
Example #16
Source File: VmwarePooledUpdateInstanceTaskTest.java From teamcity-vmware-plugin with Apache License 2.0 | 4 votes |
public void check_called_once() throws MalformedURLException { final AtomicBoolean listAllCanBeCalled = new AtomicBoolean(); final AtomicBoolean listAllCalledOnce = new AtomicBoolean(); final AtomicBoolean getByNameCanBeCalled = new AtomicBoolean(); final AtomicBoolean getByNameCalledOnce = new AtomicBoolean(); myFakeApiConnector = new FakeApiConnector(TEST_SERVER_UUID, PROFILE_ID, null) { @Override protected <T extends ManagedEntity> Map<String, T> findAllEntitiesAsMapOld(final Class<T> instanceType) throws VmwareCheckedCloudException { if (!listAllCanBeCalled.get()) { fail("Shouldn't be called"); } assertFalse(listAllCalledOnce.get()); listAllCalledOnce.set(true); return super.findAllEntitiesAsMapOld(instanceType); } @Override protected Map<String, VirtualMachine> searchVMsByNames(@NotNull final Collection<String> names, @Nullable final Datacenter dc) throws VmwareCheckedCloudException { if (!getByNameCanBeCalled.get()) { fail("Shouldn't be called"); } assertFalse(getByNameCalledOnce.get()); getByNameCalledOnce.set(true); return super.searchVMsByNames(names, dc); } }; final CloudClientParameters clientParameters1 = VmwareTestUtils.getClientParameters(PROJECT_ID, "[{sourceVmName:'image1', behaviour:'START_STOP'}]"); final VMWareCloudClient client1 = new MyClient(clientParameters1, null); final CloudClientParameters clientParameters2 = new CloudClientParametersImpl( Collections.emptyMap(), VmwareTestUtils.getImageParameters(PROJECT_ID, "[{sourceVmName:'image2',snapshot:'snap*',folder:'cf',pool:'rp'," + "maxInstances:3,behaviour:'ON_DEMAND_CLONE',customizationSpec:'someCustomization'}]")); final VMWareCloudClient client2 = new MyClient(clientParameters2, null); final CloudClientParameters clientParameters3 = new CloudClientParametersImpl( Collections.emptyMap(), VmwareTestUtils.getImageParameters(PROJECT_ID, "[{'source-id':'image_template',sourceVmName:'image_template', snapshot:'" + VmwareConstants.CURRENT_STATE + "',folder:'cf',pool:'rp',maxInstances:3,behaviour:'FRESH_CLONE', customizationSpec: 'linux'}]")); final VMWareCloudClient client3 = new MyClient(clientParameters3, null); final VmwareUpdateInstanceTask task1 = myTaskManager.createUpdateTask(myFakeApiConnector, client1); final VmwareUpdateInstanceTask task2 = myTaskManager.createUpdateTask(myFakeApiConnector, client2); final VmwareUpdateInstanceTask task3 = myTaskManager.createUpdateTask(myFakeApiConnector, client3); listAllCanBeCalled.set(true); listAllCalledOnce.set(false); getByNameCalledOnce.set(false); getByNameCanBeCalled.set(true); task1.run(); task2.run(); task3.run(); assertTrue(listAllCalledOnce.get()); assertTrue(getByNameCalledOnce.get()); }
Example #17
Source File: VmwarePooledUpdateInstanceTaskTest.java From teamcity-vmware-plugin with Apache License 2.0 | 4 votes |
public void check_cleared_after_dispose_2() throws MalformedURLException { final AtomicBoolean canBeCalled = new AtomicBoolean(); final AtomicInteger callsCount = new AtomicInteger(); myFakeApiConnector = new FakeApiConnector(TEST_SERVER_UUID, PROFILE_ID, null) { @Override protected <T extends ManagedEntity> Map<String, T> findAllEntitiesAsMapOld(final Class<T> instanceType) throws VmwareCheckedCloudException { processChecks(); return Collections.emptyMap(); } private void processChecks() { if (!canBeCalled.get()) { fail("Shouldn't be called"); } assertTrue(callsCount.get() < 2); callsCount.incrementAndGet(); } @Override protected Map<String, VirtualMachine> searchVMsByNames(@NotNull final Collection<String> names, @Nullable final Datacenter dc) throws VmwareCheckedCloudException { processChecks(); return Collections.emptyMap(); } }; final CloudClientParameters clientParameters1 = new CloudClientParametersImpl( Collections.emptyMap(), VmwareTestUtils.getImageParameters(PROJECT_ID,"[{sourceVmName:'image1', behaviour:'START_STOP'}]")); final VMWareCloudClient client1 = new MyClient(clientParameters1, null); final CloudClientParameters clientParameters2 = new CloudClientParametersImpl( Collections.emptyMap(), VmwareTestUtils.getImageParameters(PROJECT_ID, "[{sourceVmName:'image2',snapshot:'snap*',folder:'cf',pool:'rp'," + "maxInstances:3,behaviour:'ON_DEMAND_CLONE',customizationSpec:'someCustomization'}]")); final VMWareCloudClient client2 = new MyClient(clientParameters2, null); final VmwareUpdateInstanceTask task1 = myTaskManager.createUpdateTask(myFakeApiConnector, client1); canBeCalled.set(true); callsCount.set(0); task1.run(); assertTrue(callsCount.get() > 0); client1.dispose(); final VmwareUpdateInstanceTask task2 = myTaskManager.createUpdateTask(myFakeApiConnector, client2); canBeCalled.set(true); callsCount.set(0); task2.run(); assertTrue(callsCount.get() > 0); }
Example #18
Source File: FakeFolder.java From teamcity-vmware-plugin with Apache License 2.0 | 4 votes |
@Override public ManagedEntity getParent() { return myParent; }
Example #19
Source File: FakeFolder.java From teamcity-vmware-plugin with Apache License 2.0 | 4 votes |
public void setParent(final ManagedEntity parent) { myParent = parent; }
Example #20
Source File: VmwareCloudIntegrationTest.java From teamcity-vmware-plugin with Apache License 2.0 | 4 votes |
public void start_instance_should_not_block_ui() throws MalformedURLException, InterruptedException, CheckedCloudException { final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); final Lock lock = new ReentrantLock(); final AtomicBoolean shouldLock = new AtomicBoolean(false); try { myFakeApi = new FakeApiConnector(TEST_SERVER_UUID, PROFILE_ID) { @Override protected <T extends ManagedEntity> T findEntityByIdNameNullableOld(final String name, final Class<T> instanceType, final Datacenter dc) throws VmwareCheckedCloudException { try { if (shouldLock.get()) { lock.lock(); // will stuck here } return super.findEntityByIdNameNullableOld(name, instanceType, dc); } finally { if (shouldLock.get()) lock.unlock(); } } @Override protected <T extends ManagedEntity> Collection<T> findAllEntitiesOld(final Class<T> instanceType) throws VmwareCheckedCloudException { try { if (shouldLock.get()) { lock.lock(); // will stuck here } return super.findAllEntitiesOld(instanceType); } finally { if (shouldLock.get()) lock.unlock(); } } @Override protected <T extends ManagedEntity> Map<String, T> findAllEntitiesAsMapOld(final Class<T> instanceType) throws VmwareCheckedCloudException { try { if (shouldLock.get()) { lock.lock(); // will stuck here } return super.findAllEntitiesAsMapOld(instanceType); } finally { if (shouldLock.get()) lock.unlock(); } } }; recreateClient(); final VmwareCloudInstance startedInstance = startNewInstanceAndWait("image2"); terminateAndDeleteIfNecessary(false, startedInstance); shouldLock.set(true); lock.lock(); executor.execute(new Runnable() { public void run() { // start already existing clone myClient.startNewInstance(getImageByName("image2"), createUserData("image2_agent")); // start-stop instance myClient.startNewInstance(getImageByName("image1"), createUserData("image1_agent")); // clone a new one myClient.startNewInstance(getImageByName("image_template"), createUserData("image_template_agent")); } }); executor.shutdown(); assertTrue("canStart method blocks the thread!", executor.awaitTermination(100000, TimeUnit.MILLISECONDS)); } finally { lock.unlock(); executor.shutdownNow(); } }
Example #21
Source File: FakeResourcePool.java From teamcity-vmware-plugin with Apache License 2.0 | 4 votes |
@Override public ManagedEntity getParent() { return myParent; }
Example #22
Source File: VmwareCloudIntegrationTest.java From teamcity-vmware-plugin with Apache License 2.0 | 4 votes |
public void do_not_clear_image_instances_list_on_error() throws ExecutionException, InterruptedException, MalformedURLException { final AtomicBoolean failure = new AtomicBoolean(false); final AtomicLong lastApiCallTime = new AtomicLong(0); myFakeApi = new FakeApiConnector(TEST_SERVER_UUID, PROFILE_ID){ @Override protected <T extends ManagedEntity> Collection<T> findAllEntitiesOld(final Class<T> instanceType) throws VmwareCheckedCloudException { lastApiCallTime.set(System.currentTimeMillis()); if (failure.get()){ throw new VmwareCheckedCloudException("Cannot connect"); } return super.findAllEntitiesOld(instanceType); } @Override protected <T extends ManagedEntity> Map<String, T> findAllEntitiesAsMapOld(final Class<T> instanceType) throws VmwareCheckedCloudException { lastApiCallTime.set(System.currentTimeMillis()); if (failure.get()){ throw new VmwareCheckedCloudException("Cannot connect"); } return super.findAllEntitiesAsMapOld(instanceType); } @Override protected <T extends ManagedEntity> Pair<T,Datacenter> findEntityByIdNameOld(final String name, final Class<T> instanceType) throws VmwareCheckedCloudException { lastApiCallTime.set(System.currentTimeMillis()); if (failure.get()){ throw new VmwareCheckedCloudException("Cannot connect"); } return super.findEntityByIdNameOld(name, instanceType); } }; recreateClient(250); startNewInstanceAndWait("image2"); startNewInstanceAndWait("image2"); startNewInstanceAndWait("image2"); Thread.sleep(5*1000); failure.set(true); final long problemStart = System.currentTimeMillis(); new WaitFor(5*1000){ @Override protected boolean condition() { return myLastRunTime.get() > problemStart; } }.assertCompleted("Should have been checked at least once - delay set to 2 sec"); assertEquals(3, getImageByName("image2").getInstances().size()); }
Example #23
Source File: VMWareApiConnector.java From teamcity-vmware-plugin with Apache License 2.0 | 4 votes |
<T extends ManagedEntity> boolean hasPrivilegeOnResource(@NotNull final String entityId, @NotNull final Class<T> instanceType, @NotNull final String permission) throws VmwareCheckedCloudException;
Example #24
Source File: VmwareCloudIntegrationTest.java From teamcity-vmware-plugin with Apache License 2.0 | 4 votes |
@TestFor(issues = "TW-61456") public void recover_if_cant_connect_on_start() throws MalformedURLException { final AtomicBoolean failure = new AtomicBoolean(false); final AtomicLong lastApiCallTime = new AtomicLong(0); myFakeApi = new FakeApiConnector(TEST_SERVER_UUID, PROFILE_ID){ @Override protected <T extends ManagedEntity> Collection<T> findAllEntitiesOld(final Class<T> instanceType) throws VmwareCheckedCloudException { lastApiCallTime.set(System.currentTimeMillis()); if (failure.get()){ throw new VmwareCheckedCloudException("Cannot connect"); } return super.findAllEntitiesOld(instanceType); } @Override protected <T extends ManagedEntity> Map<String, T> findAllEntitiesAsMapOld(final Class<T> instanceType) throws VmwareCheckedCloudException { lastApiCallTime.set(System.currentTimeMillis()); if (failure.get()){ throw new VmwareCheckedCloudException("Cannot connect"); } return super.findAllEntitiesAsMapOld(instanceType); } @Override protected <T extends ManagedEntity> Pair<T,Datacenter> findEntityByIdNameOld(final String name, final Class<T> instanceType) throws VmwareCheckedCloudException { lastApiCallTime.set(System.currentTimeMillis()); if (failure.get()){ throw new VmwareCheckedCloudException("Cannot connect"); } return super.findEntityByIdNameOld(name, instanceType); } @Override protected Map<String, VirtualMachine> searchVMsByNames(@NotNull Collection<String> names, @Nullable Datacenter dc) throws VmwareCheckedCloudException { lastApiCallTime.set(System.currentTimeMillis()); if (failure.get()){ throw new VmwareCheckedCloudException("Cannot connect"); } return super.searchVMsByNames(names, dc); } }; failure.set(true); recreateClient(250); new WaitFor(1000){ @Override protected boolean condition() { return myClient.isInitialized(); } }; myClient.getImages().forEach(img-> assertNotNull(img.getErrorInfo())); failure.set(false); new WaitFor(1000){ @Override protected boolean condition() { AtomicBoolean result = new AtomicBoolean(true); myClient.getImages().forEach(img-> result.compareAndSet(true, img.getErrorInfo()==null)); return result.get(); } }; myClient.getImages().forEach(img-> assertNull(img.getErrorInfo())); }
Example #25
Source File: VmwareClient.java From primecloud-controller with GNU General Public License v2.0 | 2 votes |
/** * TODO: メソッドコメントを記述 * * @param <T> * @param type * @return */ public <T extends ManagedEntity> ManagedEntity[] searchByType(Class<T> type) { return searchByType(getRootEntity(), type); }
Example #26
Source File: VmwareClient.java From primecloud-controller with GNU General Public License v2.0 | 2 votes |
/** * TODO: メソッドコメントを記述 * * @param name * @return */ public ManagedEntity searchByName(String name) { return searchByName(getRootEntity(), name); }
Example #27
Source File: VmwareClient.java From primecloud-controller with GNU General Public License v2.0 | 2 votes |
/** * TODO: メソッドコメントを記述 * * @return */ public ManagedEntity[] searchAll() { return searchAll(getRootEntity()); }
Example #28
Source File: VmwareClient.java From primecloud-controller with GNU General Public License v2.0 | 2 votes |
/** * TODO: メソッドコメントを記述 * * @param <T> * @param type * @param name * @return */ public <T extends ManagedEntity> T search(Class<T> type, String name) { return search(getRootEntity(), type, name); }