Skip to content

Commit

Permalink
Add new methods to the VirtualMachine MO for 6.0
Browse files Browse the repository at this point in the history
Added CreateSecondaryVMEx_Task, QueryFaultToleranceCompatibilityEx,
SendNMI
More work on yavijava#29
  • Loading branch information
Michael Rice committed May 23, 2015
1 parent 3d7cf0b commit 96ab890
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 0 deletions.
99 changes: 99 additions & 0 deletions src/main/java/com/vmware/vim25/mo/VirtualMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,70 @@ public Task createSnapshot_Task(String name, String description, boolean memory,

/**
* @since SDK4.0
* @deprecated
* As of vSphere API 6.0, use {@link #createSecondaryVMEx_Task createSecondaryVMEx_Task} instead.
*/
public Task createSecondaryVM_Task(HostSystem host) throws TaskInProgress, InvalidState, InsufficientResourcesFault, VmFaultToleranceIssue, FileFault, VmConfigFault, RuntimeFault, RemoteException {
ManagedObjectReference mor = getVimService().createSecondaryVM_Task(getMOR(), host == null ? null : host.getMOR());
return new Task(getServerConnection(), mor);
}

/**
* Creates a secondary virtual machine to be part of this fault tolerant group.
*
* If a host is specified, the secondary virtual machine will be created on it. Otherwise, a host will be selected
* by the system.
*
* If a FaultToleranceConfigSpec is specified, the virtual machine's configuration files and disks will be created
* in the specified datastores.
*
* If the primary virtual machine (i.e., this virtual machine) is powered on when the secondary is created, an
* attempt will be made to power on the secondary on a system selected host. If the cluster is a DRS cluster, DRS
* will be invoked to obtain a placement for the new secondary virtual machine. If the DRS recommendation
* (see {@link com.vmware.vim25.ClusterRecommendation ClusterRecommendation}) is automatic, it will be automatically
* executed. Otherwise, the recommendation will be returned to the caller of this method and the secondary will
* remain powered off until the recommendation is approved using
* {@link com.vmware.vim25.mo.ClusterComputeResource#applyRecommendation applyRecommendation}. Failure to power on the
* secondary virtual machine will not fail the creation of the secondary. This method creates a Record-Replay FT VM
* for single vCPU VMs only when vm.useLegacyFt is set to true in vm.config.extraConfig.
*
* @param host -
* The host where the secondary virtual machine is to be created and powered on. If no host is specified,
* a compatible host will be selected by the system. If a host cannot be found for the secondary or the
* specified host is not suitable, the secondary will not be created and a fault will be returned.
* @param spec contains information about the metadata file and vmdk files for a fault tolerant VM pair.
* @return This method returns a Task object with which to monitor the operation. The info.result property in the Task returns an instance of the FaultToleranceSecondaryOpResult data object, which contains a reference to the created VirtualMachine and the status of powering it on, if attempted.
* @throws FileFault
* @throws InsufficientResourcesFault
* @throws InvalidState
* @throws ManagedObjectNotFound
* @throws NotSupported
* @throws RuntimeFault
* @throws TaskInProgress
* @throws VmConfigFault
* @throws VmFaultToleranceIssue
* @throws RemoteException
* @since 6.0
*/
public Task createSecondaryVMEx_Task(HostSystem host, FaultToleranceConfigSpec spec) throws FileFault, InsufficientResourcesFault, InvalidState, ManagedObjectNotFound, NotSupported, RuntimeFault, TaskInProgress, VmConfigFault, VmFaultToleranceIssue, RemoteException {
ManagedObjectReference taskMor = getVimService().createSecondaryVMEx_Task(getMOR(), host == null ? null : host.getMOR(), spec);
return new Task(getServerConnection(), taskMor);
}

/**
* @since 6.0
*/
public Task createSecondaryVMEx_Task(HostSystem host) throws FileFault, InsufficientResourcesFault, InvalidState, ManagedObjectNotFound, NotSupported, RuntimeFault, TaskInProgress, VmConfigFault, VmFaultToleranceIssue, RemoteException {
return createSecondaryVMEx_Task(host, null);
}

/**
* @since 6.0
*/
public Task createSecondaryVMEx_Task(FaultToleranceConfigSpec spec) throws FileFault, InsufficientResourcesFault, InvalidState, ManagedObjectNotFound, NotSupported, RuntimeFault, TaskInProgress, VmConfigFault, VmFaultToleranceIssue, RemoteException {
return createSecondaryVMEx_Task(null, spec);
}

/**
* @since SDK4.0
*/
Expand Down Expand Up @@ -303,11 +361,39 @@ public DiskChangeInfo queryChangedDiskAreas(VirtualMachineSnapshot snapshot, int

/**
* @since SDK4.1
* @deprecated
* As of 6.0 use {@link #queryFaultToleranceCompatibilityEx}
*/
public LocalizedMethodFault[] queryFaultToleranceCompatibility() throws InvalidState, VmConfigFault, RuntimeFault, RemoteException {
return getVimService().queryFaultToleranceCompatibility(getMOR());
}

/**
* This API can be invoked to determine whether a virtual machine is compatible for Fault Tolerance. The API only
* checks for VM-specific factors that impact compatibility for Fault Tolerance. Other requirements for Fault
* Tolerance such as host processor compatibility, logging nic configuration and licensing are not covered by this
* API. The query returns a list of faults, each fault corresponding to a specific incompatibility. If a given
* virtual machine is compatible for Fault Tolerance, then the fault list returned will be empty.
*
* @param forLegacyFt checks for legacy record-replay FT compatibility only if this is set to true.
* @return Localized Method Fault
* @throws InvalidState
* @throws VmConfigFault
* @throws RuntimeFault
* @throws RemoteException
* @since 6.0
*/
public LocalizedMethodFault[] queryFaultToleranceCompatibilityEx(Boolean forLegacyFt) throws InvalidState, VmConfigFault, RuntimeFault, RemoteException {
return getVimService().queryFaultToleranceCompatibilityEx(getMOR(), forLegacyFt);
}

/**
* @since 6.0
*/
public LocalizedMethodFault[] queryFaultToleranceCompatibilityEx() throws InvalidState, VmConfigFault, RuntimeFault, RemoteException {
return queryFaultToleranceCompatibilityEx(null);
}

/**
* @since SDK4.0
*/
Expand Down Expand Up @@ -471,4 +557,17 @@ public Task upgradeVM_Task(String version) throws TaskInProgress, InvalidState,
ManagedObjectReference mor = getVimService().upgradeVM_Task(getMOR(), version);
return new Task(getServerConnection(), mor);
}

/**
* Send a non-maskable interrupt (NMI). Currently, there is no way to verify if the NMI was actually received by
* the guest OS.
*
* @throws InvalidState
* @throws RuntimeFault
* @throws RemoteException
* @since 6.0
*/
public void sendNMI() throws InvalidState, RuntimeFault, RemoteException {
getVimService().sendNMI(getMOR());
}
}
21 changes: 21 additions & 0 deletions src/main/java/com/vmware/vim25/ws/VimStub.java
Original file line number Diff line number Diff line change
Expand Up @@ -2382,6 +2382,14 @@ public ManagedObjectReference createSecondaryVM_Task(ManagedObjectReference _thi
return (ManagedObjectReference) getWsc().invoke("CreateSecondaryVM_Task", paras, "ManagedObjectReference");
}

public ManagedObjectReference createSecondaryVMEx_Task(ManagedObjectReference _this, ManagedObjectReference host, FaultToleranceConfigSpec spec) throws FileFault, InsufficientResourcesFault, InvalidState, ManagedObjectNotFound, NotSupported, RuntimeFault, TaskInProgress, VmConfigFault, VmFaultToleranceIssue, RemoteException {
Argument[] params = new Argument[3];
params[0] = new Argument("_this", "ManagedObjectReference", _this);
params[1] = new Argument("host", "ManagedObjectReference", host);
params[2] = new Argument("spec", "FaultToleranceConfigSpec", host);
return (ManagedObjectReference) getWsc().invoke("CreateSecondaryVMEx_Task", params, "ManagedObjectReference");
}

public ManagedObjectReference turnOffFaultToleranceForVM_Task(ManagedObjectReference _this) throws java.rmi.RemoteException, TaskInProgress, VmFaultToleranceIssue, InvalidState, RuntimeFault {
Argument[] paras = new Argument[1];
paras[0] = new Argument("_this", "ManagedObjectReference", _this);
Expand Down Expand Up @@ -2494,6 +2502,13 @@ public LocalizedMethodFault[] queryFaultToleranceCompatibility(ManagedObjectRefe
return (LocalizedMethodFault[]) getWsc().invoke("QueryFaultToleranceCompatibility", paras, "LocalizedMethodFault[]");
}

public LocalizedMethodFault[] queryFaultToleranceCompatibilityEx(ManagedObjectReference _this, Boolean forLegacyFt) throws java.rmi.RemoteException, InvalidState, VmConfigFault, RuntimeFault {
Argument[] params = new Argument[2];
params[0] = new Argument("_this", "ManagedObjectReference", _this);
params[1] = new Argument("forLegacyFt", "Boolean", forLegacyFt);
return (LocalizedMethodFault[]) getWsc().invoke("QueryFaultToleranceCompatibilityEx", params, "LocalizedMethodFault[]");
}

public void terminateVM(ManagedObjectReference _this) throws java.rmi.RemoteException, InvalidState, TaskInProgress, RuntimeFault {
Argument[] paras = new Argument[1];
paras[0] = new Argument("_this", "ManagedObjectReference", _this);
Expand Down Expand Up @@ -5242,4 +5257,10 @@ public ManagedObjectReference removeDatastoreEx_Task(ManagedObjectReference _thi
params[1] = new Argument("datastore", "ManagedObjectReference[]", datastore);
return (ManagedObjectReference) getWsc().invoke("RemoveDatastoreEx_Task", params, "ManagedObjectReference");
}

public void sendNMI(ManagedObjectReference _this) throws InvalidState, RuntimeFault, RemoteException {
Argument[] params = new Argument[1];
params[0] = new Argument("_this", "ManagedObjectReference", _this);
getWsc().invoke("SendNMI", params, null);
}
}

0 comments on commit 96ab890

Please sign in to comment.