Closed GVLLIFESTYLE closed 1 year ago
Please include more details about the issue. Environment details, error stack-trace and steps to reproduce.
well it is not even possible to execute the example, as most of the classes simply don't exist anymore. References from the example cannot be loaded from the sdk, methods don't exist anymore or have different parameters,... Moreover if I build the SDK and add it as external jar to maven, I have no sources from most of the classes. Is there a way to get the sources for debugging?
For example these can't be resolved:
import com.vmware.vim25.mo.InventoryNavigator; import com.vmware.vim25.mo.ServiceInstance; import com.vmware.vim25.mo.VirtualMachine;
Hi @MrLoverLoverMMMM Looks like you have used a sample which is dependent on third party libraries that are not supported by VMware. https://mvnrepository.com/artifact/com.vmware/vijava/5.1 https://vijava.sourceforge.net/
The packages mentioned in https://github.com/vmware/vsphere-automation-sdk-java/issues/185#issuecomment-1530917891 are not part of our official vim25 jar.
OK, could you then please point me to a version of the example which is working officially with the vmware sdk? We bought vmware and we would like to switch from RHV to vmware. Therefore we need that example. As the sources of the SDK are not shipped I have no idea how to proceed.
Can you please help with following details
Please note that vsphere-automation-sdk-java is part of our automation suite of SDKs. The sources for vim25.jar (which is part of our management SDK are not published here). You can refer to our management SDK here
For vsphere-automation-sdk-java, please refer to: samples sources Docs quick start guide
OK Other question. Which SDKs and Examples fit best for my usecases:
We are using the on-prem solution of vmware. The latest version.
I tried and it failed: the classes used in the example are also not in the built of vim25 of the current version of the management sdk
The references from the example you are referring to are not part of the vim25. @aagrawal3 updated earlier that these packages, "com.vmware.vim25.mo.*" are part of 3rd party library and not managed by VMware.
Is there some kind of maven repository for all of your sdks, that would make everything much more easy?
No, at this point SDKs are not present in public repositories. We will have this concern addressed soon.
How can I build the management sdk for java ?
Kindly download the management SDK from https://developer.vmware.com/web/sdk/8.0/vsphere-management and follow the developer setup and programming guide to get started with your use case. The SDK also contains samples/examples to showcase VM operations like Clone, Create, Power, Reconfigure etc.
Let us know if you face issues working with management SDK samples.
Is it possible to get the sources for eclipse for auto completion somewhere? (if I build the sdk according to the manual, they aren't included)
The vim25 source code in not included with the SDK. Since, the vim25 source and jar are built using tools shipped with the SDK. You can chose to retain the java source when you build the management SDK. However, If auto completion is your only concern then check the eclipse build class path for vim25.jar it should address the autocompletion issues related to vim25 APIs.
Thanks Kunal
Thank you very much for the detailed answer. Now I've got only 1 questions left. If that example I found in within your example search is not supported. Do you guys have somewhere an example for getting network info and status of an running vm and could you point me to it?
Which SDKs and Examples fit best for my usecases.
Our vSphere Management SDK covers the legacy VIM APIs which are exposed over SOAP such as VM, Host while our vSphere Automation SDK covers the APIs which are relatively new and are exposed over REST protocol. Ex: Content Library, Tagging Features. There are some APIs which are available in both the SDKs. For the APIs you mentioned, you may use either one of our SDKs.
Do you guys have somewhere an example for getting network info and status of an running vm and could you point me to it?
We do not have samples covering all our APIs. Please refer to our existing samples in SDKs to draw out a coding pattern and utilise the API docs, programming guide to write code for your use cases. We highly appreciate and request sample contributions from community.
For this particular use case, if you are using automation SDK, you can try guest networking API -> https://developer.vmware.com/apis/vsphere-automation/v8.0.0/vcenter/api/vcenter/vm/vm/guest/networking/get/ To get the ID of VM, you may use list VM sample These VM related samples for Automation SDK may be of help to you.
Is there a java SDK for the guest networking api? I think its not best practrise if all is coded beautifully with the SDK and for the network I need the rest interface...
I want to do something like this. Is this not possible??
ManagedObjectReference vmRef= vmWareConnection.findObject("VirtualMachine", vmName); vmWareConnection= getConnectionToVMware(); ManagedObjectReference loadTask= vmWareConnection.getVimPort().getNetworkDetails(vmRef); .... Or how can I get the IP from a virtual machien by a managedobjectreference?
@kunal-pmj from which external library are thos?
import com.vmware.vim25.mo.InventoryNavigator; import com.vmware.vim25.mo.ServiceInstance; import com.vmware.vim25.mo.VirtualMachine;
??
I tried . It was not sufficient.
I was able to implement nearly all usecases.
Now I hava only this 1 usecase left.
Get the ip of an running vm by the vmname. That should be as easy as possible. Can anyone please advice?
@aagrawal3 : Your example (listVMs) does not work. It uses a vapiAuthHelper which comes from somewhere? No initialization, nothing... Where can I find out from where it comes from?
I need at least any kind of example which is working or a list of all example i need to get 1 example to work...
Hi @MrLoverLoverMMMM It looks like you wish to use vim25 jar from our Management SDK for your use case. -> https://developer.vmware.com/web/sdk/8.0/vsphere-management As mentioned earlier, the examples I shared work with Automation SDK. -> https://github.com/vmware/vsphere-automation-sdk-java Please open a service request (SR). It will be convenient for both sides to discuss things over call.
I have those 3 jars refered at my project. Your example still does not work. Neither the one about network nor the one from list vms.
vsphere-management-sdk vim25 vmGuestSDK
It seems the examples are not complete or use imports which are not avialable anymore.
I highlighted the things not clear and add comments
` /*
import java.util.Arrays; import java.util.Collections; import java.util.List;
import org.apache.commons.cli.Option;
import com.vmware.vcenter.VM; import com.vmware.vcenter.VMTypes.Summary; import com.vmware.vcenter.VMTypes.FilterSpec.Builder; import vmware.samples.common.SamplesAbstractBase; import vmware.samples.vcenter.helpers.ClusterHelper; import vmware.samples.vcenter.helpers.DatacenterHelper; import vmware.samples.vcenter.helpers.FolderHelper;
/**
Sample Prerequisites: vCenter 6.5+ */ public class ListVMs extends SamplesAbstractBase { private VM vmService; private String vmFolderName; private String datacenterName; private String clusterName;
/**
@param args command line arguments passed to the sample */ protected void parseArgs(String[] args) { Option datacenterOption = Option.builder() .longOpt("datacenter") .desc("OPTIONAL: Specify the name of the Datacenter"
super.parseArgs(optionList, args); this.vmFolderName = (String) parsedOptions.get("vmfolder"); this.datacenterName = (String) parsedOptions.get("datacenter"); this.clusterName = (String) parsedOptions.get("cluster"); }
protected void setup() throws Exception { this.vmService = vapiAuthHelper.getStubFactory() .createStub(VM.class, sessionStubConfig); //where is this vapiAuthHelper comming from?, How to initialize the connetion? //What is the sessionStubConfig, how to create it? }
protected void run() throws Exception {
Builder bldr = new Builder();
if(null != this.datacenterName && !this.datacenterName.isEmpty()){
bldr.setDatacenters(Collections.singleton(DatacenterHelper.
getDatacenter(this.vapiAuthHelper.getStubFactory(),
this.sessionStubConfig, this.datacenterName)));
}
if(null != this.clusterName && !this.clusterName.isEmpty()) {
bldr.setClusters(Collections.singleton(ClusterHelper.getCluster(
this.vapiAuthHelper.getStubFactory(), sessionStubConfig,
this.clusterName)));
}
if(null != this.vmFolderName && !this.vmFolderName.isEmpty())
{
bldr.setFolders(Collections.singleton(FolderHelper.getFolder(
this.vapiAuthHelper.getStubFactory(), sessionStubConfig,
this.vmFolderName)));
}
List
public static void main(String[] args) throws Exception { /*
//where is this vapiAuthHelper comming from?, How to initialize the connetion? //What is the sessionStubConfig, how to create it?
vapiAuthHelper is a utility class available with this SDK.
Kindly follow the README to build and run the sample
$java -ea -cp target/vsphere-samples-8.0.0.1.jar vmware.samples.vcenter.vm.list.ListVMs --server
I was already building the sdk obviously... Which one of the two I should use in my java and do i have to add the lib-jars from the folder lib additionally? I would like to have an entire bundle of everything as 1 jar.
How can I build 1 jar containing all inclusive sources to add as external repo to maven?
I have those currently Which one contains all, or can i simply bundle all them up into 1 jar?
vsphere-samples-8.0.0.1.jar has all the samples, utilities and dependencies. Include it
OK, I will try.
Where can I open a service request (SR) for assistence to receive the exact quote for what we need?
I added the jar combining all, but source / autocompletion in my ide is for most classes not avialable. I would just like to get the list of ips of a running vm by vmname. Can that be that dificult? Is there somewhere an working example for loading network ips of an running vm? I already where able to load the id of the vm by name.
Where can I open a service request (SR) for assistence to receive the exact quote for what we need?
https://www.vmware.com/web/vmware/login
To get the VM Identity use this API https://vmware.github.io/vsphere-automation-sdk-java/vsphere/8.0.1.0/vcenter-bindings/index.html Here is the REST API Reference for the API https://developer.vmware.com/apis/vsphere-automation/latest/vcenter/api/vcenter/vm/vm/guest/identity/get/
@kunal-pmj : I already have the vms id with the list example you shared beforehand. How do I get the network-ip of the vm? is appliance used synonym to vm in your documentation?
@MrLoverLoverMMMM did you look at the API?
It returns the Guest Identity which includes IP, hostname etc.
You need to pass the VM ids to this API to get guest Info
So from where can I get then, which endpoint do I need to use?
Updated the right API bindings Link
@MrLoverLoverMMMM did you look at the API?
It returns the Guest Identity which includes IP, hostname etc.
You need to pass the VM ids to this API to get guest Info
I use the java-sdk, not the api directly
I need the ip-address of the running vm. This seems to also not be possible with the identiy endpoint. Which one should I use?
This conversation is going all over the place. Kindly share you official email address to discuss further
OK. You should have received an e-mail from our side.
I have sent it to singhk@vmware.com
You can refer to this SDK sample which uses the VM Guest Identity API(https://vmware.github.io/vsphere-automation-sdk-java/vsphere/8.0.1.0/vcenter-bindings/com/vmware/vcenter/vm/Identity.html)
But there is also no method to get the interfaces / ip of the vm.
I seem have shared a wrong link earlier
thanks, what actually if there is multiple ips / nics on 1 vm? This method returns only 1 string.
The REST API does not have the capability to return multiple VM IPs. You can use the SOAP SDK to get multiple nics/IPs
2 things: Could you add the support for multiple ips as feature request? 2nd: How does the api currently handly 2 ips? Will there be both in 1 string or just nothing returned or how does it work?
Could you add the support for multiple ips as feature request?
Yes, an enhancement request can be taken up
2nd: How does the api currently handly 2 ips? Will there be both in 1 string or just nothing returned or how does it work?
The first IP from NIC0 will be returned by the API
perfect, thanks :) Please add me to the list of notifications about this feature request. We do need this function.
APIs to expose full guest networking have existed for a while (7.0.x I think?)
Look under https://vmware.github.io/vsphere-automation-sdk-java/vsphere/8.0.1.0/vcenter-bindings/com/vmware/vcenter/vm/guest/networking/package-tree.html for them.
for full guest NIC info.
Thanks @lemke1458
@MrLoverLoverMMMM here is the for REST API reference https://developer.vmware.com/apis/vsphere-automation/v8.0.0/vcenter/api/vcenter/vm/vm/guest/networking/interfaces/get/ I am closing the Issue.
I need the java sdk. You got a bundle where this is fixed? I dont wanna use the api directly!
Am 19. Mai 2023, 08:32, um 08:32, Kunal Singh @.***> schrieb:
Thanks @lemke1458
@MrLoverLoverMMMM here is the for REST API reference https://developer.vmware.com/apis/vsphere-automation/v8.0.0/vcenter/api/vcenter/vm/vm/guest/networking/interfaces/get/ I am closing the Issue.
-- Reply to this email directly or view it on GitHub: https://github.com/vmware/vsphere-automation-sdk-java/issues/185#issuecomment-1554075214 You are receiving this because you were mentioned.
Message ID: @.***>
The API bindings are present in the SDK.
Kindly refer to @lemke1458 's update
com.vmware.vcenter.vm.guest.networking.Interfaces.list(java.lang.String vm)
Returns information about the networking interfaces in the guest operating system.
Thanks, I'll try that. I have 1 question. If the current interface is only ipv6 what does getIpv4().getAddress() return in this case?
OK, I tried but it won't work I get unauthorized for the following code:
Interfaces interfacesService = vmwareConnection.getVapiAuthHelper().getStubFactory().createStub(
Interfaces.class,
vmwareConnection.getSessionStubConfig());
List<InterfaceInfo> interfaceInfo = interfacesService.list();
Other code such as the following works without issues
Power vmPowerService = vmwareConnection.getVapiAuthHelper().getStubFactory().createStub(Power.class, vmwareConnection.getSessionStubConfig());
Identity identityService=vmwareConnection.getVapiAuthHelper().getStubFactory().createStub(Identity.class, vmwareConnection.getSessionStubConfig());
Can you help me out why?
can you share your snippet and console log
This documentation does not work anymore, could you provide an valid example for the latest api?
https://developer.vmware.com/samples/7909/print-vm-network-details?h=network
if possible please incluse connecting, ....