public Task reconfigureCluster_Task(ClusterConfigSpec spec, boolean modify) throws RuntimeFault, RemoteException { ManagedObjectReference taskMOR = getVimService().reconfigureCluster_Task(getMOR(), spec, modify); return new Task(getServerConnection(), taskMOR); }
public Task addHost_Task(HostConnectSpec spec, boolean asConnected, ResourcePool resourcePool) throws InvalidLogin, HostConnectFault, RuntimeFault, RemoteException { return addHost_Task(spec, asConnected, resourcePool, null); }
/** @since SDK4.1 */ public void cancelRecommendation(String key) throws RuntimeFault, RemoteException { getVimService().cancelRecommendation(getMOR(), key); }
ccs.setDrsConfig(cdci); ccr.reconfigureCluster_Task(ccs, true);
/** * Returns a JSON-formatted array with the clusters list for use with * Zabbix low-level discovery */ private void getClusters(PrintWriter out) throws IOException { try { ManagedEntity[] cl = getManagedEntities("ClusterComputeResource"); JsonArray jArray = new JsonArray(); for (int j = 0; j < cl.length; j++) { ClusterComputeResource c = (ClusterComputeResource) cl[j]; String name = c.getName(); ComputeResourceSummary s = c.getSummary(); JsonObject jObject = new JsonObject(); jObject.addProperty("{#CLUSTER}", name); jArray.add(jObject); } JsonObject jOutput = new JsonObject(); jOutput.add("data", jArray); out.print(jOutput); out.flush(); } catch (Exception ex) { LOG.error("An error occurred : " + ex.toString()); } }
public void scanAllClusters() { VMWareQueryTemplate t = new VMWareQueryTemplate(getServiceInstance()); for (ClusterComputeResource ccr : t.findAllClusters()) { try { scanCluster(ccr); } catch (RuntimeException e) { logger.warn("scan cluster failed: " + ccr.getName(), e); } } }
public static void main(String[] args) throws Exception { ServiceInstance si = new ServiceInstance(new URL("https://10.20.143.209/sdk"), "Administrator", "password", true); ClusterComputeResource drsCluster = (ClusterComputeResource) new InventoryNavigator( si.getRootFolder()).searchManagedEntity("ClusterComputeResource", "myDrs"); if(drsCluster==null) { System.out.println("There is no cluster called myDrs. Exiting..."); } ClusterDrsMigration[] histories = drsCluster.getMigrationHistory(); if(histories==null) { System.out.println("There is no migration history set. Please check whether it's running in automatic mode!\nExiting..."); } System.out.println("There were totally " + histories.length + " migration(s)."); for(int i=0; i < histories.length; i++) { ServerConnection sc = si.getServerConnection(); VirtualMachine vm = (VirtualMachine) MorUtil.createExactManagedEntity(sc, histories[i].getVm()); HostSystem srcHost = (HostSystem) MorUtil.createExactManagedEntity(sc, histories[i].getSource()); HostSystem dstHost = (HostSystem) MorUtil.createExactManagedEntity(sc, histories[i].getDestination()); System.out.println("VM: " + vm.getName() + " migrated from " + srcHost.getName() + " to " + dstHost.getName()); } si.getServerConnection().logout(); } }
ClusterRecommendation[] recs = ccr.getRecommendation(); if(recs!=null)
/** * @since 4.0 */ public ClusterDrsFaults[] getDrsFault() { return (ClusterDrsFaults[]) getCurrentProperty("drsFault"); }
String getUniqueId(ClusterComputeResource ccr) { return computeUniqueId(ccr.getMOR()); }
public ClusterComputeResource createClusterEx(String name, ClusterConfigSpecEx spec) throws InvalidName, DuplicateName, RuntimeFault, RemoteException { return new ClusterComputeResource(getServerConnection(), getVimService().createClusterEx(getMOR(), name, spec) ); }
public void listPortGroupForCluster(ServiceInstance si, String clusterName) throws InvalidProperty, RuntimeFault, RemoteException { ClusterComputeResource cluster = (ClusterComputeResource) (new InventoryNavigator(si.getRootFolder())).searchManagedEntity("ClusterComputeResource", clusterName); if (cluster == null) { System.out.println("Not found cluster:" + cluster); return; } System.out.println("List port groups for cluster:" + clusterName); Network[] networks = cluster.getNetworks(); for (int i = 0; i < networks.length; i++) { System.out.println(i + ": " + networks[i].getName()); } }
/** * @since 4.0 */ public ClusterDasAdvancedRuntimeInfo retrieveDasAdvancedRuntimeInfo() throws RuntimeFault, RemoteException { return getVimService().retrieveDasAdvancedRuntimeInfo(getMOR()); } }
ccs.setDrsConfig(cdci); ccr.reconfigureCluster_Task(ccs, true);
protected void updateClusterHostRelationship(ClusterComputeResource cluster, HostSystem host) { logger.debug("updating relationship between cluster={} and host={}", cluster.getName(), host.getName()); String cypher = "match (h {id:{hostId} }), (c:VMWareCluster {id: {clusterId}}) MERGE (c)-[r:CONTAINS]->(h) ON CREATE SET r.updateTs=timestamp(),r.createTs=timestamp() ON MATCH SET r.updateTs=timestamp() return r"; getProjector().getNeoRxClient().execCypher(cypher, "hostId", getUniqueId(host), "clusterId", getUniqueId(cluster)); }
public static void main(String[] args) throws Exception { ServiceInstance si = new ServiceInstance(new URL("https://10.20.143.209/sdk"), "Administrator", "password", true); ClusterComputeResource drsCluster = (ClusterComputeResource) new InventoryNavigator( si.getRootFolder()).searchManagedEntity("ClusterComputeResource", "myDrs"); if(drsCluster==null) { System.out.println("There is no cluster called myDrs. Exiting..."); } ClusterDrsMigration[] histories = drsCluster.getMigrationHistory(); if(histories==null) { System.out.println("There is no migration history set. Please check whether it's running in automatic mode!\nExiting..."); } System.out.println("There were totally " + histories.length + " migration(s)."); for(int i=0; i < histories.length; i++) { ServerConnection sc = si.getServerConnection(); VirtualMachine vm = (VirtualMachine) MorUtil.createExactManagedEntity(sc, histories[i].getVm()); HostSystem srcHost = (HostSystem) MorUtil.createExactManagedEntity(sc, histories[i].getSource()); HostSystem dstHost = (HostSystem) MorUtil.createExactManagedEntity(sc, histories[i].getDestination()); System.out.println("VM: " + vm.getName() + " migrated from " + srcHost.getName() + " to " + dstHost.getName()); } si.getServerConnection().logout(); } }
ClusterRecommendation[] recs = ccr.getRecommendation(); if(recs!=null)
public ClusterRecommendation[] getRecommendation() { return (ClusterRecommendation[]) getCurrentProperty("recommendation"); }