Java Code Examples for com.vmware.vim25.ManagedObjectReference#getValue()
The following examples show how to use
com.vmware.vim25.ManagedObjectReference#getValue() .
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: DistributedVirtualSwitchMO.java From cloudstack with Apache License 2.0 | 5 votes |
public void updateDvPortGroup(ManagedObjectReference dvPortGroupMor, DVPortgroupConfigSpec dvPortGroupSpec) throws Exception { synchronized (dvPortGroupMor.getValue().intern()) { ManagedObjectReference task = _context.getService().reconfigureDVPortgroupTask(dvPortGroupMor, dvPortGroupSpec); if (!_context.getVimClient().waitForTask(task)) { throw new Exception("Failed to update dvPortGroup " + dvPortGroupMor.getValue()); } } }
Example 2
Source File: VMwareDatacenterInventory.java From development with Apache License 2.0 | 4 votes |
/** * Adds a VM instance to the inventory based on given properties. * * @return the created VM instance */ public VMwareVirtualMachine addVirtualMachine( List<DynamicProperty> properties, ManagedObjectAccessor serviceUtil) throws Exception { if (properties == null || properties.size() == 0) { return null; } VMwareVirtualMachine result = new VMwareVirtualMachine(); for (DynamicProperty dp : properties) { String key = dp.getName(); if ("name".equals(key) && dp.getVal() != null) { result.setName(dp.getVal().toString()); } else if ("summary.config.memorySizeMB".equals(key) && dp.getVal() != null) { result.setMemorySizeMB( Integer.parseInt(dp.getVal().toString())); } else if ("summary.config.numCpu".equals(key) && dp.getVal() != null) { result.setNumCpu(Integer.parseInt(dp.getVal().toString())); } else if ("runtime.host".equals(key)) { ManagedObjectReference mor = (ManagedObjectReference) dp .getVal(); Object cacheKey = mor == null ? null : mor.getValue(); if (!hostCache.containsKey(cacheKey)) { Object name = serviceUtil.getDynamicProperty(mor, "name"); if (name != null) { hostCache.put(cacheKey, name.toString()); } } result.setHostName(hostCache.get(cacheKey)); } } if (result.getHostName() != null) { vms.add(result); } else { logger.warn("Cannot determine host system for VM '" + result.getName() + "'. Check whether configured VMware API user host rights to access the host system."); } return result; }