/** * @since SDK5.0 */ public Task checkAnswerFileStatus_Task(HostSystem[] hosts) throws RuntimeFault, RemoteException { ManagedObjectReference[] hostMors = MorUtil.createMORs(hosts); ManagedObjectReference taskMor = getVimService().checkAnswerFileStatus_Task(getMOR(), hostMors); return new Task(getServerConnection(), taskMor); }
public ManagedEntity[] closeInventoryViewFolder(ManagedEntity[] entities) throws RuntimeFault, RemoteException { if(entities==null) { throw new IllegalArgumentException("entities must not be null."); } ManagedObjectReference[] mors = getVimService().closeInventoryViewFolder(getMOR(), MorUtil.createMORs(entities)); return MorUtil.createManagedEntities(getServerConnection(), mors); }
public ManagedEntity[] openInventoryViewFolder(ManagedEntity[] entities) throws RuntimeFault, RemoteException { if(entities==null) { throw new IllegalArgumentException("entities must not be null."); } ManagedObjectReference[] mors = getVimService().openInventoryViewFolder(getMOR(), MorUtil.createMORs(entities)); return MorUtil.createManagedEntities(getServerConnection(), mors); }
/** * @since SDK5.0 */ public Task rectifyDvsOnHost_Task(HostSystem[] hosts) throws DvsFault, RuntimeFault, RemoteException { ManagedObjectReference[] hostMors = MorUtil.createMORs(hosts); ManagedObjectReference taskMor = getVimService().rectifyDvsOnHost_Task(getMOR(), hostMors); return new Task(getServerConnection(), taskMor); }
/** @since SDK4.0 */ public ManagedEntity[] findAllByDnsName(Datacenter datacenter, String dnsName, boolean vmSearch) throws RuntimeFault, RemoteException { ManagedObjectReference[] mors = getVimService().findAllByDnsName(getMOR(), datacenter==null? null : datacenter.getMOR(), dnsName, vmSearch); return MorUtil.createManagedEntities(getServerConnection(), mors); }
/** @since SDK4.0 */ public ManagedEntity[] findAllByIp(Datacenter datacenter, String ip, boolean vmSearch) throws RuntimeFault, RemoteException { ManagedObjectReference[] mors = getVimService().findAllByIp(getMOR(), datacenter==null? null : datacenter.getMOR(), ip, vmSearch); return MorUtil.createManagedEntities(getServerConnection(), mors); }
/** @since SDK4.0 */ public ManagedEntity[] findAllByUuid(Datacenter datacenter, String uuid, boolean vmSearch, boolean instanceUuid) throws RuntimeFault, RemoteException { ManagedObjectReference[] mors = getVimService().findAllByUuid(getMOR(), datacenter==null? null : datacenter.getMOR(), uuid, vmSearch, instanceUuid); return MorUtil.createManagedEntities(getServerConnection(), mors); }
/** * Find a VM by its location on a datastore * @param datacenter The datacenter within which it searches. * @param dPath The datastore path, for example, "[storage1] WinXP/WinXP.vmx". * @return A VirtualMachine that pointed by the dPath * @throws RemoteException * @throws RuntimeFault * @throws InvalidDatastore */ public VirtualMachine findByDatastorePath(Datacenter datacenter, String dPath) throws InvalidDatastore, RuntimeFault, RemoteException { if(datacenter==null) { throw new IllegalArgumentException("datacenter must not be null."); } ManagedObjectReference mor = getVimService().findByDatastorePath(getMOR(), datacenter.getMOR(), dPath); return (VirtualMachine) MorUtil.createExactManagedEntity(getServerConnection(), mor); }
/** * Find a child entity under a ManagedObjectReference in the inventory. * @param parent The parent managed entity. * @param name The name of the child to search. * @return A child entity. * @throws RemoteException * @throws RuntimeFault */ public ManagedEntity findChild(ManagedEntity parent, String name) throws RuntimeFault, RemoteException { if(parent == null) { throw new IllegalArgumentException("parent entity must not be null."); } ManagedObjectReference mor = getVimService().findChild(getMOR(), parent.getMOR(), name); return MorUtil.createExactManagedEntity(getServerConnection(), mor); }
protected void service( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); String morStr = request.getParameter(MOREF); String type = morStr.substring(0, morStr.indexOf(":")); String value = morStr.substring(morStr.indexOf(":")+1); ManagedObjectReference mor = new ManagedObjectReference(); mor.setType(type); mor.set_value(value); String sessionStr = "vmware_soap_session=\"" + request.getParameter(SESSION_ID) + "\""; System.out.println("morStr:" + morStr); System.out.println("serviceUrl" + request.getParameter(SERVICE_URL) ); System.out.println("session:" + sessionStr); ServiceInstance si = new ServiceInstance(new URL( request.getParameter(SERVICE_URL)),sessionStr, true); ManagedEntity me = MorUtil.createExactManagedEntity( si.getServerConnection(), mor); String name = me.getName(); out.println("name:" + name); out.println(DateFormat.getDateTimeInstance().format( new Date())); }
protected ManagedObjectReference[] convertMors(ManagedObject[] mos) { ManagedObjectReference[] mors = null; if(mos!=null) { mors = MorUtil.createMORs(mos); } return mors; }
/** * Returns a managed entitiy for a given managed object Id. * * @param managedObjectId the managed object Id * @return the managed entity */ public ManagedEntity getManagedEntityByManagedObjectId(String managedObjectId) { ManagedObjectReference managedObjectReference = new ManagedObjectReference(); managedObjectReference.setType("ManagedEntity"); managedObjectReference.setVal(managedObjectId); ManagedEntity managedEntity = MorUtil.createExactManagedEntity(m_serviceInstance.getServerConnection(), managedObjectReference); return managedEntity; }
/** * Returns a virtual machine by a given managed object Id. * * @param managedObjectId the managed object Id * @return the virtual machine object */ public VirtualMachine getVirtualMachineByManagedObjectId(String managedObjectId) { ManagedObjectReference managedObjectReference = new ManagedObjectReference(); managedObjectReference.setType("VirtualMachine"); managedObjectReference.setVal(managedObjectId); VirtualMachine virtualMachine = (VirtualMachine) MorUtil.createExactManagedEntity(m_serviceInstance.getServerConnection(), managedObjectReference); return virtualMachine; }
/** * Returns a host system by a given managed object Id. * * @param managedObjectId the managed object Id * @return the host system object */ public HostSystem getHostSystemByManagedObjectId(String managedObjectId) { ManagedObjectReference managedObjectReference = new ManagedObjectReference(); managedObjectReference.setType("HostSystem"); managedObjectReference.setVal(managedObjectId); HostSystem hostSystem = (HostSystem) MorUtil.createExactManagedEntity(m_serviceInstance.getServerConnection(), managedObjectReference); return hostSystem; }
protected <T extends ManagedEntity> T createExactManagedEntity(final ManagedObjectReference mor) { return (T)MorUtil.createExactManagedEntity(myServiceInstance.getServerConnection(), mor); }
public void update(Observable obj, Object arg) { if (arg instanceof PropertyFilterUpdate[]) { PropertyFilterUpdate[] pfus = (PropertyFilterUpdate[]) arg; for(int i=0; pfus!=null && i< pfus.length; i++) { ObjectUpdate[] ous = pfus[i].getObjectSet(); for(int j=0; ous!=null && j < ous.length; j++) { ManagedObjectReference mor = ous[j].getObj(); if(! items.containsKey(mor)) { items.put(mor, new ConcurrentHashMap<String, Object>()); } Map<String, Object> moMap = items.get(mor); PropertyChange[] pcs = ous[j].getChangeSet(); if(pcs==null) { continue; } for(int k=0; k < pcs.length; k++) { Object value = pcs[k].getVal(); value = value == null ? NULL : value; //null is not allowed as value in CHM String propName = pcs[k].getName(); if(moMap.containsKey(propName)) { moMap.put(propName, value); } else { String parentPropName = getExistingParentPropName(moMap, propName); if(parentPropName != null) { ManagedObject mo = MorUtil.createExactManagedObject(si.getServerConnection(), mor); moMap.put(parentPropName, mo.getPropertyByPath(parentPropName)); } else { //almost impossible to be here. moMap.put(propName, value); } } } } } } isReady = true; }
/** * @since SDK5.0 */ public AnswerFileStatusResult[] queryAnswerFileStatus(HostSystem[] hosts) throws RuntimeFault, RemoteException { ManagedObjectReference[] hostMors = MorUtil.createMORs(hosts); return getVimService().queryAnswerFileStatus(getMOR(), hostMors); }
public void associateProfile(ManagedEntity[] mes) throws RuntimeFault, RemoteException { ManagedObjectReference[] mors = MorUtil.createMORs(mes); getVimService().associateProfile(getMOR(), mors); }
public Task checkProfileCompliance_Task(ManagedEntity[] mes) throws RuntimeFault, RemoteException { ManagedObjectReference[] mors = MorUtil.createMORs(mes); ManagedObjectReference taskMor = getVimService().checkProfileCompliance_Task(getMOR(), mors); return new Task(getServerConnection(), taskMor); }
public void dissociateProfile(ManagedEntity[] mes) throws RuntimeFault, RemoteException { ManagedObjectReference[] mors = MorUtil.createMORs(mes); getVimService().dissociateProfile(getMOR(), mors); }
/** * @since SDK5.0 */ public ManagedEntity[] queryManagedBy(String extensionKey) throws RuntimeFault, RemoteException { ManagedObjectReference[] mors = getVimService().queryManagedBy(getMOR(), extensionKey); return MorUtil.createManagedEntities(getServerConnection(), mors); }
public Task rectifyDvsHost_Task(HostSystem[] hosts) throws DvsFault, NotFound, RuntimeFault, RemoteException { ManagedObjectReference[] mors = MorUtil.createMORs(hosts); ManagedObjectReference mor = getVimService().rectifyDvsHost_Task(getMOR(), mors); return new Task(getServerConnection(), mor); }
public Task generateLogBundles_Task(boolean includeDefault, HostSystem[] hosts) throws LogBundlingFailed, RuntimeFault, RemoteException { ManagedObjectReference mor = getVimService().generateLogBundles_Task(getMOR(), includeDefault, hosts==null? null : MorUtil.createMORs(hosts)); return new Task(getServerConnection(), mor); }
public ManagedEntity findByUuid(Datacenter datacenter, String uuid, boolean vmOnly, Boolean instanceUuid) throws RuntimeFault, RemoteException { ManagedObjectReference mor = getVimService().findByUuid(getMOR(), datacenter==null? null : datacenter.getMOR(), uuid, vmOnly, instanceUuid); return MorUtil.createExactManagedEntity(getServerConnection(), mor); }
public static void main(String[] args) throws Exception { if(args.length!=3) { System.out.println("Usage: DrsAffRule url username password"); System.exit(-1); } URL url = null; try { url = new URL(args[0]); } catch ( MalformedURLException urlE) { System.out.println("The URL provided is NOT valid. Please check it."); System.exit(-1); } String username = args[1]; String password = args[2]; String drs_obj_id = "domain-c5"; // The reference ID for cluster String vm1_oid = "vm-26"; // The reference ID for VM 1 String vm2_oid = "vm-28"; // The reference ID for VM 2 // initialize the system, set up web services ServiceInstance si = new ServiceInstance(url, username, password, true); //create the MOR object for DRS cluster ManagedObjectReference mref_drs = createMOR("ClusterComputeResource", drs_obj_id); ClusterComputeResource ccr = (ClusterComputeResource ) MorUtil.createExactManagedEntity(si.getServerConnection(), mref_drs); // create a new ClusterConfigSpec and populate it with related data for affinity rule ClusterConfigSpec ccs = new ClusterConfigSpec(); ClusterAffinityRuleSpec cars = new ClusterAffinityRuleSpec(); cars.setName("App and DB Appliance Bundle"); cars.setEnabled(Boolean.TRUE); ManagedObjectReference vm1 = createMOR("VirtualMachine", vm1_oid); ManagedObjectReference vm2 = createMOR("VirtualMachine", vm2_oid); cars.setVm(new ManagedObjectReference[] {vm1, vm2}); ClusterRuleSpec crs = new ClusterRuleSpec(); //*NOTE*: the following setOperation has to be called since operation must be set. crs.setOperation(ArrayUpdateOperation.add); crs.setInfo(cars); ccs.setRulesSpec(new ClusterRuleSpec[] {crs}); // make a call to set the configuration. ccr.reconfigureCluster_Task(ccs, true); si.getServerConnection().logout(); System.out.println("Done with setting affinity rule for DRS cluster."); }
protected ManagedObject getManagedObject(String propName) { ManagedObjectReference mor = (ManagedObjectReference) getCurrentProperty(propName); return MorUtil.createExactManagedObject(getServerConnection(), mor); }
/** * @since SDK5.5 */ public EntityPrivilege[] hasPrivilegeOnEntities(ManagedEntity[] entity, String sessionId, String[] privId) throws RuntimeFault, RemoteException { ManagedObjectReference[] mors = MorUtil.createMORs(entity); return getVimService().hasPrivilegeOnEntities(getMOR(), mors, sessionId, privId); }
private void lookupMetrics(String collectionName, String managedObjectId) throws Exception { ManagedObjectReference managedObjectReference = new ManagedObjectReference(); managedObjectReference.setType("ManagedEntity"); managedObjectReference.setVal(managedObjectId); ManagedEntity managedEntity = MorUtil.createExactManagedEntity(serviceInstance.getServerConnection(), managedObjectReference); int refreshRate = performanceManager.queryPerfProviderSummary(managedEntity).getRefreshRate(); PerfQuerySpec perfQuerySpec = new PerfQuerySpec(); perfQuerySpec.setEntity(managedEntity.getMOR()); perfQuerySpec.setMaxSample(Integer.valueOf(1)); perfQuerySpec.setIntervalId(refreshRate); PerfEntityMetricBase[] perfEntityMetricBases = performanceManager.queryPerf(new PerfQuerySpec[]{perfQuerySpec}); HashMap<String, TreeSet<VMwareConfigMetric>> groupMap = new HashMap<String, TreeSet<VMwareConfigMetric>>(); HashMap<String, Boolean> multiInstance = new HashMap<String, Boolean>(); if (perfEntityMetricBases != null) { for (int i = 0; i < perfEntityMetricBases.length; i++) { PerfMetricSeries[] perfMetricSeries = ((PerfEntityMetric) perfEntityMetricBases[i]).getValue(); for (int j = 0; perfMetricSeries != null && j < perfMetricSeries.length; j++) { if (perfMetricSeries[j] instanceof PerfMetricIntSeries) { long[] longs = ((PerfMetricIntSeries) perfMetricSeries[j]).getValue(); if (longs.length == 1) { PerfCounterInfo perfCounterInfo = perfCounterInfoMap.get(perfMetricSeries[j].getId().getCounterId()); String instanceName = perfMetricSeries[j].getId().getInstance(); String humanReadableName = getHumanReadableName(perfCounterInfo); String aliasName = getAliasName(perfCounterInfo); String groupName = perfCounterInfo.getGroupInfo().getKey(); String normalizedGroupName = normalizeGroupName(groupName); Boolean b = multiInstance.get(getHumanReadableName(perfCounterInfo)); if (b == null) { b = Boolean.valueOf(instanceName != null && !"".equals(instanceName)); } else { b = Boolean.valueOf(b.booleanValue() || (instanceName != null && !"".equals(instanceName))); } if (!b) { groupName = "Node"; normalizedGroupName = "Node"; } if (!groupMap.containsKey(normalizedGroupName)) { groupMap.put(normalizedGroupName, new TreeSet<VMwareConfigMetric>()); } TreeSet<VMwareConfigMetric> counterSet = groupMap.get(normalizedGroupName); multiInstance.put(getHumanReadableName(perfCounterInfo), b); counterSet.add(new VMwareConfigMetric(perfCounterInfo, humanReadableName, aliasName, b, normalizedGroupName)); } } } } } collections.put(collectionName, groupMap); }
/** * Find a VM or Host by its DNS name * @param datacenter The datacenter within which it searches. If null is passed, all inventory is searched. * @param dnsName DNS name like "dev.eng.vmware.com" * @param vmOnly When set true only searches for VM; otherwise only for Host. * @return A ManagedEntity to either HostSystem or VirtualMachine having the DNS name. * @throws RemoteException * @throws RuntimeFault */ public ManagedEntity findByDnsName(Datacenter datacenter, String dnsName, boolean vmOnly) throws RuntimeFault, RemoteException { ManagedObjectReference mor = getVimService().findByDnsName(getMOR(), datacenter==null? null : datacenter.getMOR(), dnsName, vmOnly); return MorUtil.createExactManagedEntity(getServerConnection(), mor); }
/** * find a managed object in the inventory tree. * @param inventoryPath The inventory path to the managed object searched. * @return ManagedEntity object. * @throws RemoteException * @throws RuntimeFault */ public ManagedEntity findByInventoryPath(String inventoryPath) throws RuntimeFault, RemoteException { ManagedObjectReference mor = getVimService().findByInventoryPath(getMOR(), inventoryPath); return MorUtil.createExactManagedEntity(getServerConnection(), mor); }
/** * Find a Virtual Machine or Host System by its IP address. * @param datacenter The datacenter within which it searches. If null is passed, all inventory is searched. * @param ip The IP address of the VM or Host. * @param vmOnly When set true only searches for VM; otherwise only for Host. * @return A ManagedEntity to either HostSystem or VirtualMachine having the IP address. * @throws RuntimeFault * @throws RemoteException */ public ManagedEntity findByIp(Datacenter datacenter, String ip, boolean vmOnly) throws RuntimeFault, RemoteException { ManagedObjectReference mor = getVimService().findByIp(getMOR(), datacenter==null? null : datacenter.getMOR(), ip, vmOnly); return MorUtil.createExactManagedEntity(getServerConnection(), mor); }