-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #124 from sumitAgrawal007/master
Updating Bindings, Samples, POM and ReadMe for 7.0U2 Release
- Loading branch information
Showing
11 changed files
with
361 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ JDK 1.8. | |
|
||
## Supported OnPrem vCenter Releases: | ||
|
||
vCenter 6.0, 6.5, 6.7, 6.7U1, 6.7U2, 6.7U3, 7.0, 7.0U1 | ||
vCenter 6.0, 6.5, 6.7, 6.7U1, 6.7U2, 6.7U3, 7.0, 7.0U1, 7.0U2 | ||
|
||
Please refer to the notes in each sample for detailed compatibility information. | ||
|
||
|
@@ -88,9 +88,9 @@ When running the samples, parameters can be provided either on the command line, | |
|
||
Use a command like the following to display usage information for a particular sample. | ||
```` bash | ||
$java -ea -cp target/vsphere-samples-7.0.1.0.jar vmware.samples.vcenter.vm.list.ListVMs | ||
$java -ea -cp target/vsphere-samples-7.0.2.0.jar vmware.samples.vcenter.vm.list.ListVMs | ||
|
||
java -cp target/vsphere-samples-7.0.1.0.jar vmware.samples.vcenter.vm.list.ListVMs [--config-file <CONFIGURATION FILE>] | ||
java -cp target/vsphere-samples-7.0.2.0.jar vmware.samples.vcenter.vm.list.ListVMs [--config-file <CONFIGURATION FILE>] | ||
--server <SERVER> --username <USERNAME> --password <PASSWORD> --cluster <CLUSTER> [--truststorepath <ABSOLUTE PATH OF JAVA TRUSTSTORE FILE>] | ||
[--truststorepassword <JAVA TRUSTSTORE PASSWORD>] [--cleardata] [--skip-server-verification] | ||
|
||
|
@@ -114,17 +114,17 @@ Sample Options: | |
|
||
Use a command like the following to run a sample using only command line parameters: | ||
```` bash | ||
$java -ea -cp target/vsphere-samples-7.0.1.0.jar vmware.samples.vcenter.vm.list.ListVMs --server servername --username [email protected] --password password --skip-server-verification | ||
$java -ea -cp target/vsphere-samples-7.0.2.0.jar vmware.samples.vcenter.vm.list.ListVMs --server servername --username [email protected] --password password --skip-server-verification | ||
```` | ||
|
||
Use a command like the following to run a sample using only a configuration file: | ||
```` bash | ||
$java -ea -cp target/vsphere-samples-7.0.1.0.jar vmware.samples.vcenter.vm.list.ListVMs --config-file sample.properties | ||
$java -ea -cp target/vsphere-samples-7.0.2.0.jar vmware.samples.vcenter.vm.list.ListVMs --config-file sample.properties | ||
```` | ||
|
||
Use the following command to run the sample using a combination of configuration file and command line parameters: | ||
```` bash | ||
$java -ea -cp target/vsphere-samples-7.0.1.0.jar vmware.samples.vcenter.vm.list.ListVMs --config-file sample.properties --server servername | ||
$java -ea -cp target/vsphere-samples-7.0.2.0.jar vmware.samples.vcenter.vm.list.ListVMs --config-file sample.properties --server servername | ||
```` | ||
|
||
### Importing the samples to eclipse | ||
|
@@ -152,20 +152,21 @@ This will import a basic sample class to your package, which you can then custom | |
### vSphere API Documentation | ||
* [VMware vSphere REST API Reference documentation](https://developer.vmware.com/docs/vsphere-automation/latest/). | ||
|
||
* [VMware vSphere APIs 7.0.1.0 (latest version)](https://vmware.github.io/vsphere-automation-sdk-java/vsphere/7.0.1.0/vsphereautomation-client-sdk/index.html). | ||
* [VMware vSphere JAVA APIs 7.0.2.0 (latest version)](https://vmware.github.io/vsphere-automation-sdk-java/vsphere/7.0.2.0/vsphereautomation-client-sdk/index.html). | ||
|
||
* [VMware Cloud on AWS vSphere (latest version)](https://vmware.github.io/vsphere-automation-sdk-java/vsphere/cloud/vsphereautomation-client-sdk/index.html). | ||
|
||
* Previous releases: [7.0.0.1](https://vmware.github.io/vsphere-automation-sdk-java/vsphere/7.0.0.1/vsphereautomation-client-sdk/index.html), | ||
[6.7.3](https://vmware.github.io/vsphere-automation-sdk-java/vsphere/6.7.3/vsphereautomation-client-sdk/index.html) | ||
* Previous releases: [7.0.1.0](https://vmware.github.io/vsphere-automation-sdk-java/vsphere/7.0.1.0/vsphereautomation-client-sdk/index.html), | ||
[7.0.0.1](https://vmware.github.io/vsphere-automation-sdk-java/vsphere/7.0.0.1/vsphereautomation-client-sdk/index.html) | ||
|
||
### VMware Cloud on AWS API Documentation | ||
|
||
* [VMware Cloud on AWS Console APIs](https://vmware.github.io/vsphere-automation-sdk-java/vmc/index.html). | ||
* [VMware Cloud on AWS REST APIs](http://developers.eng.vmware.com/docs/vmc/latest/). | ||
|
||
* [VMware Cloud on AWS JAVA APIs](https://vmware.github.io/vsphere-automation-sdk-java/vmc/index.html). | ||
|
||
* [VMware Cloud on AWS Disaster Recovery as a Service (DRaaS) APIs](https://vmware.github.io/vsphere-automation-sdk-java/vmc-draas/index.html). | ||
* [VMware Cloud on AWS Disaster Recovery as a Service (DRaaS) JAVA APIs](https://vmware.github.io/vsphere-automation-sdk-java/vmc-draas/index.html). | ||
|
||
### NSX API Documentation | ||
* [VMware NSX-T Data Center REST API](https://code.vmware.com/apis/976) | ||
|
||
* [VMware NSX-T Manager APIs (for on-prem customers)](https://vmware.github.io/vsphere-automation-sdk-java/nsx/nsx/index.html). | ||
|
||
|
@@ -238,10 +239,10 @@ Members: | |
Items added to the repository, including items from the Board members, require 2 votes from the board members before being added to the repository. The approving members will have ideally downloaded and tested the item. When two “Approved for Merge” comments are added from board members, the pull can then be committed to the repository. | ||
## VMware Resources | ||
* [vSphere Automation SDK Overview](http://pubs.vmware.com/vsphere-65/index.jsp#com.vmware.vapi.progguide.doc/GUID-AF73991C-FC1C-47DF-8362-184B6544CFDE.html) | ||
* [VMware Developers Site](http://developers.eng.vmware.com/) | ||
* [vSphere Automation SDK Overview](https://code.vmware.com/web/sdk/7.0/vsphere-automation-java) | ||
* [VMware Code](https://code.vmware.com/home) | ||
* [VMware Developer Community](https://communities.vmware.com/community/vmtn/developer) | ||
* VMware vSphere [Java API Reference documentation](https://vmware.github.io/vsphere-automation-sdk-java/vsphere/7.0.1.0/vsphereautomation-client-sdk/index.html). | ||
* VMware vSphere [Java API Reference documentation](https://vmware.github.io/vsphere-automation-sdk-java/vsphere/7.0.2.0/vsphereautomation-client-sdk/index.html). | ||
* [VMware Java forum](https://code.vmware.com/forums/7508/vsphere-automation-sdk-for-java) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
src/main/java/vmware/samples/vcenter/vm/guest/GuestInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* | ||
* ******************************************************* | ||
* Copyright VMware, Inc. 2021. All Rights Reserved. | ||
* SPDX-License-Identifier: MIT | ||
* ******************************************************* | ||
* | ||
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN, | ||
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED | ||
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, | ||
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. | ||
*/ | ||
package vmware.samples.vcenter.vm.guest; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.apache.commons.cli.Option; | ||
|
||
import com.vmware.vcenter.vm.Power; | ||
import com.vmware.vcenter.vm.PowerTypes; | ||
import com.vmware.vcenter.vm.guest.Identity; | ||
import com.vmware.vcenter.vm.guest.IdentityTypes; | ||
import com.vmware.vcenter.vm.guest.LocalFilesystem; | ||
import com.vmware.vcenter.vm.guest.LocalFilesystemTypes; | ||
|
||
import vmware.samples.common.SamplesAbstractBase; | ||
import vmware.samples.vcenter.helpers.VmHelper; | ||
|
||
/** | ||
Demonstrates the virtual machine guest information. | ||
Sample Prerequisites: | ||
The sample needs an existing VM with VMware Tools. | ||
**/ | ||
public class GuestInfo extends SamplesAbstractBase{ | ||
|
||
private String vmName; | ||
private String vmId; | ||
private Power vmPowerService; | ||
private Identity identityService; | ||
private LocalFilesystem filesystemService; | ||
@Override | ||
protected void parseArgs(String[] args) { | ||
// Parse the command line options or use config file | ||
Option vmNameOption = Option.builder() | ||
.longOpt("vmname") | ||
.desc("Name of the VM on which the power operations" | ||
+ " would be performed") | ||
.required(true) | ||
.hasArg() | ||
.argName("VM NAME") | ||
.build(); | ||
List<Option> optionList = Collections.singletonList(vmNameOption); | ||
super.parseArgs(optionList, args); | ||
this.vmName = (String) parsedOptions.get("vmname"); | ||
} | ||
|
||
@Override | ||
protected void setup() throws Exception { | ||
this.vmPowerService = this.vapiAuthHelper.getStubFactory().createStub( | ||
Power.class, this.sessionStubConfig); | ||
identityService=this.vapiAuthHelper.getStubFactory().createStub(Identity.class, sessionStubConfig); | ||
filesystemService=this.vapiAuthHelper.getStubFactory().createStub(LocalFilesystem.class, sessionStubConfig); | ||
} | ||
@Override | ||
protected void run() throws Exception { | ||
this.vmId = VmHelper.getVM(vapiAuthHelper.getStubFactory(), | ||
sessionStubConfig, | ||
vmName); | ||
if(vmId == null) { | ||
throw new Exception("Sample requires an existing vm with name "+this.vmName+"Please create the vm first"); | ||
} | ||
else { | ||
System.out.println("Using VM "+this.vmName+" "+this.vmId+" for Guest Info Sample"); | ||
} | ||
|
||
System.out.println("# Example: Get current vm power state"); | ||
PowerTypes.Info powerInfo = this.vmPowerService.get(vmId); | ||
if (!(PowerTypes.State.POWERED_ON.equals(powerInfo.getState()))) | ||
{ | ||
System.out.println("Powering on VM."); | ||
this.vmPowerService.start(vmId); | ||
} | ||
VmHelper.waitForGuestInfoReady(identityService, vmId, 600); | ||
IdentityTypes.Info info=identityService.get(vmId); | ||
System.out.println("vm.guest.Identity.get({"+vmName+"})"); | ||
System.out.println("Identity: {"+info.toString()+"}"); | ||
|
||
Map<String, LocalFilesystemTypes.Info> filesystemInfo=filesystemService.get(vmId); | ||
System.out.println("vm.guest.Identity.get({"+vmName+"})"); | ||
System.out.println("LocalFilesystem: {"+filesystemInfo.toString()+"}"); | ||
} | ||
|
||
@Override | ||
protected void cleanup() throws Exception { | ||
|
||
this.vmPowerService.stop(vmId); | ||
System.out.println("vm.power->stop()"); | ||
PowerTypes.Info powerInfo = this.vmPowerService.get(vmId); | ||
|
||
//Power off the vm if it is on | ||
if (PowerTypes.State.POWERED_OFF.equals(powerInfo.getState())) | ||
{ | ||
System.out.println("VM is powered off" ); | ||
} | ||
else { | ||
System.out.println("vm.Power Warning: Could not power off vm" ); | ||
} | ||
} | ||
|
||
public static void main(String[] args) throws Exception { | ||
/* | ||
* Execute the sample using the command line arguments or parameters | ||
* from the configuration file. This executes the following steps: | ||
* 1. Parse the arguments required by the sample | ||
* 2. Login to the server | ||
* 3. Setup any resources required by the sample run | ||
* 4. Run the sample | ||
* 5. Cleanup any data created by the sample run, if cleanup=true | ||
* 6. Logout of the server | ||
*/ | ||
new GuestInfo().execute(args); | ||
} | ||
|
||
} |
Oops, something went wrong.